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 0000000000000000000000000000000000000000..f6afdf3ae9bdf852681d187db10ab546ef5e3dc2 --- /dev/null +++ b/dist/tools/has_minimal_version/has_minimal_version.sh @@ -0,0 +1,33 @@ +#! /bin/bash +# +# usage: has_minimal_version.sh <version> <minimal_version> [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} <version> <minimal_version> [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 diff --git a/pkg/ccn-lite/Makefile b/pkg/ccn-lite/Makefile index bc63c1fb94455b83640165cd6467285615480dd4..58ee622b60fff180e4df234603bcfb1c1db8254b 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 diff --git a/pkg/relic/Makefile b/pkg/relic/Makefile index c9c3296e77fe1ddc184c7d91b5d3034a50df293a..7e2466c9dc9de74c196c1e3f9254dd9531419874 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