From 0aa4fffe81787fe89e8849414f858215421084cb Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 11 Jun 2020 21:44:33 +0200 Subject: [PATCH 1/8] pkg/relic: separate cmake build dir from source dir --- pkg/relic/Makefile | 17 ++++++++++------- pkg/relic/Makefile.include | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/relic/Makefile b/pkg/relic/Makefile index 088564eb28..85bc8f622c 100644 --- a/pkg/relic/Makefile +++ b/pkg/relic/Makefile @@ -7,26 +7,29 @@ include $(RIOTBASE)/pkg/pkg.mk .PHONY: ..cmake_version_supported +RELIC_BUILD_DIR = $(PKG_BUILDDIR)/build +RELIC_SOURCE_DIR = $(PKG_BUILDDIR) + CMAKE_MINIMAL_VERSION = 3.6.0 CFLAGS += -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-function -Wno-newline-eof -TOOLCHAIN_FILE = $(PKG_BUILDDIR)/xcompile-toolchain.cmake +TOOLCHAIN_FILE = $(RELIC_SOURCE_DIR)/xcompile-toolchain.cmake all: $(BINDIR)/$(PKG_NAME).a -$(BINDIR)/$(PKG_NAME).a: $(PKG_BUILDDIR)/lib/librelic_s.a +$(BINDIR)/$(PKG_NAME).a: $(RELIC_BUILD_DIR)/lib/librelic_s.a cp $< $@ -$(PKG_BUILDDIR)/lib/librelic_s.a: $(PKG_BUILDDIR)/Makefile - $(MAKE) -C $(PKG_BUILDDIR) +$(RELIC_BUILD_DIR)/lib/librelic_s.a: $(RELIC_BUILD_DIR)/Makefile + $(MAKE) -C $(RELIC_BUILD_DIR) # Pass 'COMP' with a target specific export to not have issues with the shell # escaping evaluation. COMP = $(filter-out -Werror -Werror=old-style-definition -Werror=strict-prototypes -std=gnu99,$(CFLAGS)) -$(PKG_BUILDDIR)/Makefile: export COMP ?= -$(PKG_BUILDDIR)/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported - cmake -B$(PKG_BUILDDIR) -H$(PKG_BUILDDIR) \ +$(RELIC_BUILD_DIR)/Makefile: export COMP ?= +$(RELIC_BUILD_DIR)/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported + cmake -B$(RELIC_BUILD_DIR) -H$(RELIC_SOURCE_DIR) \ -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) \ -DCHECK=off -DTESTS=0 -DBENCH=0 -DSHLIB=off -Wno-dev $(RELIC_CONFIG_FLAGS) diff --git a/pkg/relic/Makefile.include b/pkg/relic/Makefile.include index 218bdfd82c..8dd433605c 100644 --- a/pkg/relic/Makefile.include +++ b/pkg/relic/Makefile.include @@ -1,4 +1,5 @@ INCLUDES += -I$(PKGDIRBASE)/relic/include +INCLUDES += -I$(PKGDIRBASE)/relic/build/include ifneq (,$(filter cortex-m%,$(CPU_CORE))) # relic package package is not using system includes right now, so From 82947ec156170834a56e7994e8b98a30e3844cb7 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 11 Jun 2020 20:32:17 +0200 Subject: [PATCH 2/8] pkg/jerryscript: configure out-of-source build with cmake --- pkg/jerryscript/Makefile.jerryscript | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/jerryscript/Makefile.jerryscript b/pkg/jerryscript/Makefile.jerryscript index ba533203db..13c75dae7c 100644 --- a/pkg/jerryscript/Makefile.jerryscript +++ b/pkg/jerryscript/Makefile.jerryscript @@ -1,4 +1,5 @@ -JERRYSCRIPT_BUILD_DIR ?= $(BINDIR)/jerryscript +JERRYSCRIPT_BUILD_DIR ?= $(CURDIR)/build +JERRYSCRIPT_SOURCE_DIR ?= $(CURDIR) JERRYHEAP ?= 16 @@ -29,7 +30,7 @@ endif all: libjerry libjerry: - cmake -B$(JERRYSCRIPT_BUILD_DIR) -H./ \ + cmake -B$(JERRYSCRIPT_BUILD_DIR) -H$(JERRYSCRIPT_SOURCE_DIR) \ -DCMAKE_SYSTEM_NAME=RIOT \ -DCMAKE_SYSTEM_PROCESSOR="$(MCPU)" \ -DCMAKE_C_COMPILER=$(CC) \ From 188ca56e1c3a9f7211132752b7ee7b4c4168c603 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 11 Jun 2020 20:32:47 +0200 Subject: [PATCH 3/8] pkg/jerryscript: remove non existent use of CMake variable --- pkg/jerryscript/Makefile.jerryscript | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/jerryscript/Makefile.jerryscript b/pkg/jerryscript/Makefile.jerryscript index 13c75dae7c..ad681ef38a 100644 --- a/pkg/jerryscript/Makefile.jerryscript +++ b/pkg/jerryscript/Makefile.jerryscript @@ -38,7 +38,6 @@ libjerry: -DENABLE_LTO=OFF \ -DFEATURE_VALGRIND=OFF \ -DENABLE_ALL_IN_ONE=OFF \ - -DJERRY_LIBC=OFF \ -DJERRY_LIBM=OFF \ -DJERRY_CMDLINE=OFF \ -DHAVE_TIME_H=0 \ From b67578899f6364e106015d281109b16a66ba2a10 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 12 Jun 2020 18:18:45 +0200 Subject: [PATCH 4/8] pkg/ccn-lite: improve out-of-source build --- pkg/ccn-lite/Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/ccn-lite/Makefile b/pkg/ccn-lite/Makefile index 7b51fc395b..55c3bf01be 100644 --- a/pkg/ccn-lite/Makefile +++ b/pkg/ccn-lite/Makefile @@ -7,6 +7,9 @@ include $(RIOTBASE)/pkg/pkg.mk .PHONY: ..cmake_version_supported +CCNLITE_SOURCE_DIR = $(PKG_BUILDDIR) +CCNLITE_BUILD_DIR = $(PKG_BUILDDIR)/build + CMAKE_MINIMAL_VERSION = 3.6.0 RIOT_CFLAGS = $(INCLUDES) @@ -15,18 +18,18 @@ ifeq (llvm,$(TOOLCHAIN)) RIOT_CFLAGS += -Wno-char-subscripts endif -TOOLCHAIN_FILE = $(PKG_BUILDDIR)/xcompile-toolchain.cmake +TOOLCHAIN_FILE = $(CCNLITE_SOURCE_DIR)/xcompile-toolchain.cmake all: $(BINDIR)/ccn-lite.a -$(BINDIR)/ccn-lite.a: $(PKG_BUILDDIR)/bin/lib/libccnl-riot.a +$(BINDIR)/ccn-lite.a: $(CCNLITE_BUILD_DIR)/lib/libccnl-riot.a cp $< $@ -$(PKG_BUILDDIR)/bin/lib/libccnl-riot.a: $(PKG_BUILDDIR)/bin/Makefile - $(MAKE) -C $(PKG_BUILDDIR)/bin +$(CCNLITE_BUILD_DIR)/lib/libccnl-riot.a: $(CCNLITE_BUILD_DIR)/Makefile + $(MAKE) -C $(CCNLITE_BUILD_DIR) -$(PKG_BUILDDIR)/bin/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported - cmake -B$(PKG_BUILDDIR)/bin -H$(PKG_BUILDDIR)/src \ +$(CCNLITE_BUILD_DIR)/Makefile: $(PKG_PREPARED) $(TOOLCHAIN_FILE) | ..cmake_version_supported + cmake -B$(CCNLITE_BUILD_DIR) -H$(CCNLITE_SOURCE_DIR)/src \ -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE) \ -DCCNL_RIOT=1 -DRIOT_CFLAGS="$(RIOT_CFLAGS)" -DBUILD_TESTING=OFF From 3332f7d6433c3a88aea331563ff7eeba62b30fc6 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 12 Jun 2020 18:38:03 +0200 Subject: [PATCH 5/8] dist/tools/flatc: configure cmake for out-of-source build --- dist/tools/flatc/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dist/tools/flatc/Makefile b/dist/tools/flatc/Makefile index e8bfaf19f4..24a3dab6d0 100644 --- a/dist/tools/flatc/Makefile +++ b/dist/tools/flatc/Makefile @@ -5,6 +5,9 @@ PKG_LICENSE=Apache2.0 PKG_BUILDDIR=$(CURDIR)/bin +FLATC_SOURCE_DIR = $(PKG_BUILDDIR) +FLATC_BUILD_DIR = $(PKG_BUILDDIR)/build + # manually set some RIOT env vars, so this Makefile can be called stand-alone RIOTBASE ?= $(CURDIR)/../../.. RIOTTOOLS ?= $(CURDIR)/.. @@ -24,9 +27,9 @@ endif include $(RIOTBASE)/pkg/pkg.mk all: - @cd "$(PKG_BUILDDIR)" && env -i PATH="$(PATH)" cmake -G "Unix Makefiles" $(CMAKE_OPTIONS) . - "$(MAKE)" -C "$(PKG_BUILDDIR)" - @mv "$(PKG_BUILDDIR)"/flatc $(CURDIR)/flatc + @env -i PATH="$(PATH)" cmake -G "Unix Makefiles" $(CMAKE_OPTIONS) -H"$(FLATC_SOURCE_DIR)" -B"$(FLATC_BUILD_DIR)" + "$(MAKE)" -C "$(FLATC_BUILD_DIR)" + @mv "$(FLATC_BUILD_DIR)"/flatc $(CURDIR)/flatc distclean:: @rm -f $(CURDIR)/flatc From 0087a2a892995f32d8cea0810392a8685e92460a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 13 Jun 2020 16:09:36 +0200 Subject: [PATCH 6/8] pkg/jerryscript: refactor Makefile --- pkg/jerryscript/Makefile | 53 ++++++++++++++++++++++++++-- pkg/jerryscript/Makefile.jerryscript | 50 -------------------------- 2 files changed, 51 insertions(+), 52 deletions(-) delete mode 100644 pkg/jerryscript/Makefile.jerryscript diff --git a/pkg/jerryscript/Makefile b/pkg/jerryscript/Makefile index 2513ec2004..e5e127f4ef 100644 --- a/pkg/jerryscript/Makefile +++ b/pkg/jerryscript/Makefile @@ -5,12 +5,61 @@ PKG_LICENSE=Apache-2.0 include $(RIOTBASE)/pkg/pkg.mk +JERRYSCRIPT_BUILD_DIR ?= $(PKG_BUILDDIR)/build +JERRYSCRIPT_SOURCE_DIR ?= $(PKG_BUILDDIR) + CFLAGS += -Wno-implicit-fallthrough +JERRYHEAP ?= 16 + +EXT_CFLAGS := -D__TARGET_RIOT + # disable warnings when compiling with LLVM for board native ifeq ($(TOOLCHAIN)_$(BOARD),llvm_native) CFLAGS += -Wno-macro-redefined -Wno-gnu-folding-constant + EXT_CFLAGS += -Wno-conversion +else ifeq ($(OS)_$(BOARD),FreeBSD_native) + EXT_CFLAGS += -Wno-conversion +else ifeq (esp32,$(CPU)) + # The esp32 C newlib version 2.2.0 has errors when compiling with warnings + # that are enabled by jerryscript build system so disable them for this cpu: + # * -Wundef: stdio.h: `__GNU_VISIBLE` and `__BSD_VISIBLE` are not defined + EXT_CFLAGS += -Wno-undef -Wno-error=undef +else ifeq (esp8266,$(CPU)) + # The esp8266 C newlib version 3.0.0 has errors when compiling with warnings + # that are enabled by jerryscript build system so disable them for this cpu: + # * -Wundef + # * -Wconversion + # * -Wsign-conversion + EXT_CFLAGS += -Wno-undef -Wno-error=undef + EXT_CFLAGS += -Wno-conversion -Wno-error=conversion + EXT_CFLAGS += -Wno-sign-conversion -Wno-error=sign-conversion endif -all: - "$(MAKE)" -C $(PKG_BUILDDIR) -f $(CURDIR)/Makefile.jerryscript all +.PHONY: libjerry + +all: libjerry + +libjerry: $(JERRYSCRIPT_BUILD_DIR)/Makefile + "$(MAKE)" -C $(JERRYSCRIPT_BUILD_DIR) jerry-core jerry-ext jerry-port-default-minimal + @cp $(JERRYSCRIPT_BUILD_DIR)/lib/libjerry-core.a $(BINDIR)/jerryscript.a + @cp $(JERRYSCRIPT_BUILD_DIR)/lib/libjerry-ext.a $(BINDIR)/jerryscript-ext.a + @cp $(JERRYSCRIPT_BUILD_DIR)/lib/libjerry-port-default-minimal.a $(BINDIR)/jerryport-minimal.a + +$(JERRYSCRIPT_BUILD_DIR)/Makefile: + cmake -B$(JERRYSCRIPT_BUILD_DIR) -H$(JERRYSCRIPT_SOURCE_DIR) \ + -DCMAKE_SYSTEM_NAME=RIOT \ + -DCMAKE_SYSTEM_PROCESSOR="$(MCPU)" \ + -DCMAKE_C_COMPILER=$(CC) \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DENABLE_LTO=OFF \ + -DFEATURE_VALGRIND=OFF \ + -DENABLE_ALL_IN_ONE=OFF \ + -DJERRY_LIBM=OFF \ + -DJERRY_CMDLINE=OFF \ + -DHAVE_TIME_H=0 \ + -DEXTERNAL_COMPILE_FLAGS="$(INCLUDES) $(EXT_CFLAGS)" \ + -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) + +clean:: + @rm -rf $(JERRYSCRIPT_BUILD_DIR) diff --git a/pkg/jerryscript/Makefile.jerryscript b/pkg/jerryscript/Makefile.jerryscript deleted file mode 100644 index ad681ef38a..0000000000 --- a/pkg/jerryscript/Makefile.jerryscript +++ /dev/null @@ -1,50 +0,0 @@ -JERRYSCRIPT_BUILD_DIR ?= $(CURDIR)/build -JERRYSCRIPT_SOURCE_DIR ?= $(CURDIR) - -JERRYHEAP ?= 16 - -EXT_CFLAGS :=-D__TARGET_RIOT - -ifeq ($(TOOLCHAIN)_$(BOARD),llvm_native) - EXT_CFLAGS :=-D__TARGET_RIOT -Wno-conversion -else ifeq ($(OS)_$(BOARD),FreeBSD_native) - EXT_CFLAGS += -Wno-conversion -else ifeq (esp32,$(CPU)) - # The esp32 C newlib version 2.2.0 has errors when compiling with warnings - # that are enabled by jerryscript build system so disable them for this cpu: - # * -Wundef: stdio.h: `__GNU_VISIBLE` and `__BSD_VISIBLE` are not defined - EXT_CFLAGS += -Wno-undef -Wno-error=undef -else ifeq (esp8266,$(CPU)) - # The esp8266 C newlib version 3.0.0 has errors when compiling with warnings - # that are enabled by jerryscript build system so disable them for this cpu: - # * -Wundef - # * -Wconversion - # * -Wsign-conversion - EXT_CFLAGS += -Wno-undef -Wno-error=undef - EXT_CFLAGS += -Wno-conversion -Wno-error=conversion - EXT_CFLAGS += -Wno-sign-conversion -Wno-error=sign-conversion -endif - -.PHONY: all libjerry - -all: libjerry - -libjerry: - cmake -B$(JERRYSCRIPT_BUILD_DIR) -H$(JERRYSCRIPT_SOURCE_DIR) \ - -DCMAKE_SYSTEM_NAME=RIOT \ - -DCMAKE_SYSTEM_PROCESSOR="$(MCPU)" \ - -DCMAKE_C_COMPILER=$(CC) \ - -DCMAKE_C_COMPILER_WORKS=TRUE \ - -DENABLE_LTO=OFF \ - -DFEATURE_VALGRIND=OFF \ - -DENABLE_ALL_IN_ONE=OFF \ - -DJERRY_LIBM=OFF \ - -DJERRY_CMDLINE=OFF \ - -DHAVE_TIME_H=0 \ - -DEXTERNAL_COMPILE_FLAGS="$(INCLUDES) $(EXT_CFLAGS)" \ - -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) - - "$(MAKE)" -C $(JERRYSCRIPT_BUILD_DIR) jerry-core jerry-ext jerry-port-default-minimal - cp $(JERRYSCRIPT_BUILD_DIR)/lib/libjerry-core.a $(BINDIR)/jerryscript.a - cp $(JERRYSCRIPT_BUILD_DIR)/lib/libjerry-ext.a $(BINDIR)/jerryscript-ext.a - cp $(JERRYSCRIPT_BUILD_DIR)/lib/libjerry-port-default-minimal.a $(BINDIR)/jerryport-minimal.a From 3cdc337c223fe5d469729130d239aa2550dd3f0a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 15 Jun 2020 10:49:51 +0200 Subject: [PATCH 7/8] pkg/pkg.mk: add custom prepared target This target is called by the prepare target and does nothing by default --- pkg/pkg.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/pkg.mk b/pkg/pkg.mk index ee69ba60d2..76bbcc3232 100644 --- a/pkg/pkg.mk +++ b/pkg/pkg.mk @@ -51,6 +51,9 @@ PKG_PREPARED = $(PKG_STATE)-prepared PKG_PATCHED = $(PKG_STATE)-patched PKG_DOWNLOADED = $(PKG_STATE)-downloaded +# Custom prepared target that can be defined in packages Makefile. +PKG_CUSTOM_PREPARED ?= + # Declare 'all' first to have it being the default target all: $(PKG_PREPARED) prepare: $(PKG_PREPARED) @@ -92,7 +95,7 @@ $(PKG_DOWNLOADED): $(MAKEFILE_LIST) | $(PKG_BUILDDIR)/.git $(Q)$(GIT_IN_PKG) fetch $(GIT_QUIET) $(PKG_URL) $(PKG_VERSION) echo $(PKG_VERSION) > $@ -$(PKG_BUILDDIR)/.git: +$(PKG_BUILDDIR)/.git: | $(PKG_CUSTOM_PREPARED) $(info [INFO] cloning $(PKG_NAME)) $(Q)rm -Rf $(PKG_BUILDDIR) $(Q)mkdir -p $(PKG_BUILDDIR) From f869354c763e6770e0cd24f2e64b6ceddb63b18e Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 15 Jun 2020 10:51:19 +0200 Subject: [PATCH 8/8] pkg/relic: add custom prepared target This custom prepared target create an include directory in the build directory which is set globally in the INCLUDES variables. --- pkg/relic/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/relic/Makefile b/pkg/relic/Makefile index 85bc8f622c..fab952b4b6 100644 --- a/pkg/relic/Makefile +++ b/pkg/relic/Makefile @@ -3,6 +3,8 @@ PKG_URL=https://github.com/relic-toolkit/relic.git PKG_VERSION=0b0442a8218df8d309266923f2dd5b9ae3b318ce PKG_LICENSE=LGPL-2.1 +PKG_CUSTOM_PREPARED = $(PKGDIRBASE)/$(PKG_NAME)/build/include + include $(RIOTBASE)/pkg/pkg.mk .PHONY: ..cmake_version_supported @@ -18,6 +20,10 @@ TOOLCHAIN_FILE = $(RELIC_SOURCE_DIR)/xcompile-toolchain.cmake all: $(BINDIR)/$(PKG_NAME).a +$(PKG_CUSTOM_PREPARED): + $(info [INFO] Relic: create include directory in build) + mkdir -p $(PKG_CUSTOM_PREPARED) + $(BINDIR)/$(PKG_NAME).a: $(RELIC_BUILD_DIR)/lib/librelic_s.a cp $< $@