From a3c7d26a7d5fd2505056ddc0aabd97735a462709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 6 Aug 2018 17:05:43 +0200 Subject: [PATCH 1/3] dist/tools/has_minimal_version: add tool to check minimal version usage: has_minimal_version.sh [toolname] Checks that version >= minimal_version Version format MAJOR.MINOR.PATCH ex 3.1.4 --- .../has_minimal_version.sh | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 dist/tools/has_minimal_version/has_minimal_version.sh diff --git a/dist/tools/has_minimal_version/has_minimal_version.sh b/dist/tools/has_minimal_version/has_minimal_version.sh new file mode 100755 index 000000000000..f6afdf3ae9bd --- /dev/null +++ b/dist/tools/has_minimal_version/has_minimal_version.sh @@ -0,0 +1,33 @@ +#! /bin/bash +# +# usage: has_minimal_version.sh [toolname] +# Checks that version >= minimal_version +# Version format MAJOR.MINOR.PATCH ex 3.1.4 + +# Adapted from https://stackoverflow.com/a/24067243 to have >= +# Checking versions with '-rcX' does not work properly due to the usage of +# `sort -V`. + +if [ $# -lt 2 ]; then + echo "usage: ${0} [toolname]" >&2 + echo " Checks that version >= minimal_version" >&2 + echo " Version format MAJOR.MINOR.PATCH ex 3.1.4" >&2 + exit 1 +fi + +readonly TOOLVERSION="${1}" +readonly MINVERSION="${2}" +readonly TOOLNAME="${3}" + +if [ "${TOOLNAME}" != "" ]; then + readonly TOOLSTR="${TOOLNAME} " +else + readonly TOOLSTR="" +fi + + +HIGHEST=$(printf "%s\n%s\n" "${TOOLVERSION}" "${MINVERSION}" | sort -rV | head -n 1) +test "${HIGHEST}" = "${TOOLVERSION}" && exit 0 + +printf "\nInvalid version, found %s%s, minimal required is %s\n\n" "${TOOLSTR}" "${TOOLVERSION}" "${MINVERSION}" >&2 +exit 1 From b0986d91ff1616eb9f76d3797312892a892d1c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 6 Aug 2018 14:56:51 +0200 Subject: [PATCH 2/3] pkg/ccn-lite: check for minimal cmake version ccn-lite does not build with cmake < 3.6.0. This checks for a minimal version instead of failing to compile. cmake version 3.5.2 is not >= to minimal required 3.6.0 Makefile:25: recipe for target '..cmake_version_supported' failed Tested with versions 3.5.2, 3.6.0-rc1, 3.6.0, 3.6.3, 3.7.0-rc1, 3.7.0. Note: the check used does not consider '-rcX' as 'sort -V' does not handle them properly. --- pkg/ccn-lite/Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/ccn-lite/Makefile b/pkg/ccn-lite/Makefile index bc63c1fb9445..58ee622b60ff 100644 --- a/pkg/ccn-lite/Makefile +++ b/pkg/ccn-lite/Makefile @@ -3,7 +3,10 @@ PKG_URL=https://github.com/cn-uofbasel/ccn-lite/ PKG_VERSION=f85a2a055db92b5978f2d4f92b830b5b6b9acb42 PKG_LICENSE=ISC -.PHONY: all +.PHONY: all ..cmake_version_supported + +CMAKE_MINIMAL_VERSION = 3.6.0 + RIOT_CFLAGS = $(INCLUDES) @@ -17,10 +20,18 @@ $(PKG_BUILDDIR)/src/Makefile: $(TOOLCHAIN_FILE) cd $(PKG_BUILDDIR)/src && \ cmake -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) \ -DCCNL_RIOT=1 -DRIOT_CFLAGS="$(RIOT_CFLAGS)" -DBUILD_TESTING=OFF . - $(TOOLCHAIN_FILE): git-download $(RIOTTOOLS)/cmake/generate-xcompile-toolchain.sh > $(TOOLCHAIN_FILE) +git-download: | ..cmake_version_supported + +..cmake_version_supported: + @ # Remove '-rcX' from version as they are not well handled + $(Q)\ + CMAKE_VERSION=$$(cmake --version | sed -n '1 {s/cmake version //;s/-rc.*//;p;}'); \ + $(RIOTTOOLS)/has_minimal_version/has_minimal_version.sh "$${CMAKE_VERSION}" "$(CMAKE_MINIMAL_VERSION)" cmake + + include $(RIOTBASE)/pkg/pkg.mk ifneq (,$(filter -Wformat-nonliteral -Wformat=2, $(CFLAGS))) CFLAGS += -Wno-format-nonliteral From 1aebe28f3833c4a90b8a24a242304f05360eb944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 6 Aug 2018 14:56:51 +0200 Subject: [PATCH 3/3] pkg/relic: check for minimal cmake version relic does not build with cmake < 3.6.0. This checks for a minimal version instead of failing to compile. cmake version 3.5.2 is not >= to minimal required 3.6.0 Makefile:25: recipe for target '..cmake_version_supported' failed --- pkg/relic/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/relic/Makefile b/pkg/relic/Makefile index c9c3296e77fe..7e2466c9dc9d 100644 --- a/pkg/relic/Makefile +++ b/pkg/relic/Makefile @@ -3,7 +3,10 @@ PKG_URL=https://github.com/relic-toolkit/relic.git PKG_VERSION=0b0442a8218df8d309266923f2dd5b9ae3b318ce PKG_LICENSE=LGPL-2.1 -.PHONY: all +.PHONY: all ..cmake_version_supported + +CMAKE_MINIMAL_VERSION = 3.6.0 + CFLAGS += -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-function -Wno-newline-eof @@ -22,6 +25,14 @@ $(PKG_BUILDDIR)/Makefile: $(TOOLCHAIN_FILE) $(TOOLCHAIN_FILE): git-download $(RIOTTOOLS)/cmake/generate-xcompile-toolchain.sh > $(TOOLCHAIN_FILE) +git-download: | ..cmake_version_supported + +..cmake_version_supported: + @ # Remove '-rcX' from version as they are not well handled + $(Q)\ + CMAKE_VERSION=$$(cmake --version | sed -n '1 {s/cmake version //;s/-rc.*//;p;}'); \ + $(RIOTTOOLS)/has_minimal_version/has_minimal_version.sh "$${CMAKE_VERSION}" "$(CMAKE_MINIMAL_VERSION)" cmake + clean:: @rm -rf $(BINDIR)/$(PKG_NAME).a