From 81cb769cadd31e4fb30711bf6a3da85fa88b2135 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 10 Aug 2020 14:45:39 +0200 Subject: [PATCH 1/5] makefiles: avoid building archives when compiling --- Makefile.base | 16 ++-- Makefile.include | 75 ++++--------------- boards/native/Makefile.include | 2 - cpu/arm7_common/Makefile.include | 2 - cpu/cc26x0/Makefile.include | 2 - cpu/cc26x2_cc13x2/Makefile.include | 2 - cpu/efm32/families/efm32gg/Makefile.include | 3 - cpu/efm32/families/efm32lg/Makefile.include | 3 - .../families/efm32pg12b/Makefile.include | 3 - cpu/efm32/families/efm32pg1b/Makefile.include | 3 - .../families/efr32mg12p/Makefile.include | 3 - cpu/efm32/families/efr32mg1p/Makefile.include | 3 - cpu/esp32/Makefile.include | 12 +-- cpu/esp8266/Makefile.include | 4 +- cpu/esp_common/Makefile.include | 5 +- cpu/kinetis/Makefile.include | 3 - .../newlib_syscalls_mips_uhi/syscalls.c | 3 + cpu/msp430_common/Makefile.include | 2 - cpu/native/Makefile | 5 +- makefiles/arch/atmega.inc.mk | 4 - makefiles/arch/cortexm.inc.mk | 7 -- makefiles/cflags.inc.mk | 10 +-- makefiles/docker.inc.mk | 2 - makefiles/modules.inc.mk | 2 +- makefiles/scan-build.inc.mk | 1 - makefiles/vars.inc.mk | 3 +- pkg/ccn-lite/Makefile.include | 1 + pkg/cryptoauthlib/Makefile.include | 1 + pkg/jerryscript/Makefile.include | 3 + pkg/micropython/Makefile.include | 3 + pkg/nordic_softdevice_ble/Makefile.include | 1 + pkg/openthread/Makefile.dep | 1 - pkg/openthread/Makefile.include | 3 + pkg/relic/Makefile.include | 1 + pkg/tlsf/Makefile.include | 6 -- sys/Makefile.include | 11 --- sys/newlib_syscalls_default/Makefile.include | 1 - .../Makefile.include | 1 - tests/unittests/Makefile | 2 +- 39 files changed, 58 insertions(+), 157 deletions(-) delete mode 100644 sys/newlib_syscalls_default/Makefile.include delete mode 100644 sys/picolibc_syscalls_default/Makefile.include diff --git a/Makefile.base b/Makefile.base index 57fdc4f7fb..5469d5c117 100644 --- a/Makefile.base +++ b/Makefile.base @@ -17,9 +17,9 @@ DIRS := $(sort $(abspath $(DIRS))) _MOD := $(shell basename $(CURDIR)) MODULE ?= $(_MOD) -.PHONY: all clean $(DIRS:%=ALL--%) $(DIRS:%=CLEAN--%) +.PHONY: all clean $(DIRS:%=ALL--%) $(DIRS:%=CLEAN--%) $(MODULE).module -all: $(BINDIR)/$(MODULE).a ..nothing +all: $(MODULE).module ..nothing ..nothing: @: @@ -89,14 +89,12 @@ include $(RIOTMAKE)/tools/fixdep.inc.mk $(BINDIR)/$(MODULE)/: $(Q)mkdir -p $@ -$(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/ +# only create the module folder when it's going to hold objects +ifneq (,$(strip $(OBJ))) + $(MODULE).module $(OBJ): | $(BINDIR)/$(MODULE)/ +endif -# Build the archive from the output directory to create relative thin archives -# This allows having them valid in and outside of docker -$(BINDIR)/$(MODULE).a: $(OBJ) | $(DIRS:%=ALL--%) - @# Recreate archive to cleanup deleted/non selected source files objects - $(Q)$(RM) $@ - $(Q)cd $(@D) && $(AR) $(ARFLAGS) $(@F) $(subst $(@D)/,,$^) +$(MODULE).module: $(OBJ) | $(DIRS:%=ALL--%) CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS) diff --git a/Makefile.include b/Makefile.include index f15c625371..165b4cf314 100644 --- a/Makefile.include +++ b/Makefile.include @@ -426,12 +426,6 @@ CFLAGS += -DBOARD_$(BOARDDEF)=\"$(BOARD)\" -DRIOT_BOARD=BOARD_$(BOARDDEF) CFLAGS += -DCPU_$(CPUDEF)=\"$(CPU)\" -DRIOT_CPU=CPU_$(CPUDEF) CFLAGS += -DMCU_$(MCUDEF)=\"$(MCU)\" -DRIOT_MCU=MCU_$(MCUDEF) -# OSX fails to create empty archives. Provide a wrapper to catch that error. -ifneq (0, $(shell mkdir -p $(BINDIR); $(AR) rc $(BINDIR)/empty-archive.a 2> /dev/null; \ - echo $$?; rm -f $(BINDIR)/empty-archive.a 2>&1 > /dev/null)) - AR := $(RIOTBASE)/dist/ar-wrapper $(AR) -endif - # Feature test default CFLAGS and LINKFLAGS for the set compiled. include $(RIOTMAKE)/cflags.inc.mk @@ -452,7 +446,7 @@ endif APPLICATION_MODULE ?= application_$(APPLICATION) # the binaries to link -BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a +BASELIBS += $(APPLICATION_MODULE).module BASELIBS += $(APPDEPS) @@ -567,11 +561,14 @@ BUILDDEPS += $(APPDEPS) _BASELIBS_VALUE_BEFORE_USAGE := $(BASELIBS) # Linker rule +# Only use --start-group when archives are defined +ARCHIVES_GROUP = $(if $(ARCHIVES),$(LINKFLAGPREFIX)--start-group $(ARCHIVES) -lm $(LINKFLAGPREFIX)--end-group, -lm) + $(ELFFILE): FORCE ifeq ($(BUILDOSXNATIVE),1) - _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie + _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $$(find $(BASELIBS:%.module=$(BINDIR)/%/*.o) 2> /dev/null) $(ARCHIVES_GROUP) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie else - _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map + _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $$(find $(BASELIBS:%.module=$(BINDIR)/%/*.o) 2> /dev/null) $(ARCHIVES_GROUP) $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map endif # BUILDOSXNATIVE ifeq ($(BUILD_IN_DOCKER),1) @@ -580,20 +577,22 @@ else ifeq (,$(RIOTNOLINK)) link: ..compiler-check ..build-message $(BUILD_FILES) print-size else -link: ..compiler-check ..build-message $(BASELIBS) +link: ..compiler-check ..build-message $(BASELIBS) $(ARCHIVES) endif # RIOTNOLINK -$(ELFFILE): $(BASELIBS) +$(ELFFILE): $(BASELIBS) $(ARCHIVES) $(Q)$(_LINK) -o $@ -$(BINDIR)/$(APPLICATION_MODULE).a: pkg-build $(BUILDDEPS) +.PHONY: $(APPLICATION_MODULE).module + +$(APPLICATION_MODULE).module: pkg-build $(BUILDDEPS) $(Q)DIRS="$(DIRS)" APPLICATION_BLOBS="$(BLOBS)" \ "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk -$(BINDIR)/$(APPLICATION_MODULE).a: FORCE +$(APPLICATION_MODULE).module: FORCE # Other modules are built by application.inc.mk and packages building -_SUBMAKE_LIBS = $(filter-out $(BINDIR)/$(APPLICATION_MODULE).a $(APPDEPS), $(BASELIBS)) -$(_SUBMAKE_LIBS): $(BINDIR)/$(APPLICATION_MODULE).a pkg-build +_SUBMAKE_LIBS = $(filter-out $(APPLICATION_MODULE).module $(APPDEPS), $(BASELIBS) $(ARCHIVES)) +$(_SUBMAKE_LIBS): $(APPLICATION_MODULE).module pkg-build # 'print-size' triggers a rebuild. Use 'info-buildsize' if you do not need to rebuild. print-size: $(ELFFILE) @@ -607,50 +606,6 @@ print-size: $(ELFFILE) endif # BUILD_IN_DOCKER -# Rules to check the correctness of thin archives. - -# OS independant relpath as 'realpath --relative-to' is not supported on OSx -relpath = $(shell python3 -c 'import pathlib; print(pathlib.Path("$1").relative_to("$(CURDIR)"))') - -# Each ARCHECK file contains all the absolute paths found inside the archive. -BASELIB_ARCHECKS = $(patsubst %.a,%.a-check,$(filter %.a,$(BASELIBS))) - -# For each a file, print the absolute paths found inside it -# If "ar t" is called with an absolute path it will print an abs path regardless -# of how the archive is internally -# In case of a malformed archive, ar prints to stderr (and sets an error code). -# Doing `2>&1` is hacky, the correct thing would be to get the exit code. -# The `| %.a` is necessary to be able to check file produced in docker. -%.a-check: %.a - $(Q)$(AR) t $(call relpath,$<) 2>&1 | grep '^/' | '$(LAZYSPONGE)' $(LAZYSPONGE_FLAGS) '$@' - -# There's no point on keeping files whose content is later copied to another file -.INTERMEDIATE: $(BASELIB_ARCHECKS) - -ARCHIVE_CHECK = $(BINDIR)/$(APPLICATION).archive-check - -$(ARCHIVE_CHECK): $(BASELIB_ARCHECKS) - $(Q)cat $^ | '$(LAZYSPONGE)' $(LAZYSPONGE_FLAGS) '$@' - -# Rule to check if thin archives are correctly produced, that is, with a correct -# relative path. -ifeq ($(BUILD_IN_DOCKER),1) -archive-check: ..in-docker-container -else -archive-check: $(ARCHIVE_CHECK) FORCE - @if [ -s '$<' ] ; then \ - $(COLOR_ECHO) '$(COLOR_RED)Found the following absolute paths in archives' ;\ - cat '$<';\ - $(COLOR_ECHO) '$(COLOR_RESET)' ;\ - exit 1;\ - elif [ -f '$<' ] ; then \ - $(COLOR_ECHO) '$(COLOR_GREEN)Archives correctly formed$(COLOR_RESET)' ;\ - else \ - $(COLOR_ECHO) '$(COLOR_RED)Unexpected error (file not found)$(COLOR_RESET)' ;\ - exit 1;\ - fi -endif # BUILD_IN_DOCKER - # Check given command is available in the path # check_cmd 'command' 'description' define check_cmd @@ -680,7 +635,7 @@ endif @$(COLOR_ECHO) # The `clean` needs to be serialized before everything else. -all $(BASELIBS) $(BUILDDEPS) ..in-docker-container: | $(CLEAN) +all $(BASELIBS) $(ARCHIVES) $(BUILDDEPS) ..in-docker-container: | $(CLEAN) .PHONY: pkg-prepare pkg-build pkg-build-% pkg-prepare: diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 944d406533..9a148f3824 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -169,5 +169,3 @@ eval-gprof: eval-cachegrind: $(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1) - -UNDEF += $(BINDIR)/cpu/startup.o diff --git a/cpu/arm7_common/Makefile.include b/cpu/arm7_common/Makefile.include index 1d7edd59b4..38be2da505 100644 --- a/cpu/arm7_common/Makefile.include +++ b/cpu/arm7_common/Makefile.include @@ -17,5 +17,3 @@ ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ldscripts/$(CPU).ld LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -nostartfiles LINKFLAGS += -Wl,--gc-sections - -UNDEF += $(BINDIR)/cpu/startup.o diff --git a/cpu/cc26x0/Makefile.include b/cpu/cc26x0/Makefile.include index 9e7ad2a34a..1782072c50 100644 --- a/cpu/cc26x0/Makefile.include +++ b/cpu/cc26x0/Makefile.include @@ -1,7 +1,5 @@ CPU_VARIANT = x0 -VECTORS_O = $(BINDIR)/cc26xx_cc13xx/vectors.o - ROM_START_ADDR ?= 0x00000000 RAM_START_ADDR ?= 0x20000000 diff --git a/cpu/cc26x2_cc13x2/Makefile.include b/cpu/cc26x2_cc13x2/Makefile.include index cbfec44aa3..7ea2006b3d 100644 --- a/cpu/cc26x2_cc13x2/Makefile.include +++ b/cpu/cc26x2_cc13x2/Makefile.include @@ -1,7 +1,5 @@ CPU_VARIANT = x2 -VECTORS_O = $(BINDIR)/cc26xx_cc13xx/vectors.o - ROM_START_ADDR ?= 0x00000000 RAM_START_ADDR ?= 0x20000000 ROM_LEN ?= 352K diff --git a/cpu/efm32/families/efm32gg/Makefile.include b/cpu/efm32/families/efm32gg/Makefile.include index bf3dceba2b..f9059b378b 100644 --- a/cpu/efm32/families/efm32gg/Makefile.include +++ b/cpu/efm32/families/efm32gg/Makefile.include @@ -3,8 +3,5 @@ # as easy as adding the header file only. EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efm32gg/include/vendor/$(CPU_MODEL).h) -# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu' -VECTORS_O = $(BINDIR)/cpu_efm32gg/vectors.o - # include vendor device headers INCLUDES += -I$(RIOTCPU)/efm32/families/efm32gg/include/vendor diff --git a/cpu/efm32/families/efm32lg/Makefile.include b/cpu/efm32/families/efm32lg/Makefile.include index 736f74d238..01b0a9c1c5 100644 --- a/cpu/efm32/families/efm32lg/Makefile.include +++ b/cpu/efm32/families/efm32lg/Makefile.include @@ -3,8 +3,5 @@ # as easy as adding the header file only. EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efm32lg/include/vendor/$(CPU_MODEL).h) -# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu' -VECTORS_O = $(BINDIR)/cpu_efm32lg/vectors.o - # include vendor device headers INCLUDES += -I$(RIOTCPU)/efm32/families/efm32lg/include/vendor diff --git a/cpu/efm32/families/efm32pg12b/Makefile.include b/cpu/efm32/families/efm32pg12b/Makefile.include index 0fc8605d4b..541a1d3214 100644 --- a/cpu/efm32/families/efm32pg12b/Makefile.include +++ b/cpu/efm32/families/efm32pg12b/Makefile.include @@ -3,8 +3,5 @@ # as easy as adding the header file only. EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efm32pg12b/include/vendor/$(CPU_MODEL).h) -# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu' -VECTORS_O = $(BINDIR)/cpu_efm32pg12b/vectors.o - # include vendor device headers INCLUDES += -I$(RIOTCPU)/efm32/families/efm32pg12b/include/vendor diff --git a/cpu/efm32/families/efm32pg1b/Makefile.include b/cpu/efm32/families/efm32pg1b/Makefile.include index 056dd3c742..6a521017cd 100644 --- a/cpu/efm32/families/efm32pg1b/Makefile.include +++ b/cpu/efm32/families/efm32pg1b/Makefile.include @@ -3,8 +3,5 @@ # as easy as adding the header file only. EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efm32pg1b/include/vendor/$(CPU_MODEL).h) -# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu' -VECTORS_O = $(BINDIR)/cpu_efm32pg1b/vectors.o - # include vendor device headers INCLUDES += -I$(RIOTCPU)/efm32/families/efm32pg1b/include/vendor diff --git a/cpu/efm32/families/efr32mg12p/Makefile.include b/cpu/efm32/families/efr32mg12p/Makefile.include index be38e43843..ada98dbed5 100644 --- a/cpu/efm32/families/efr32mg12p/Makefile.include +++ b/cpu/efm32/families/efr32mg12p/Makefile.include @@ -3,8 +3,5 @@ # as easy as adding the header file only. EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efr32mg12p/include/vendor/$(CPU_MODEL).h) -# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu' -VECTORS_O = $(BINDIR)/cpu_efr32mg12p/vectors.o - # include vendor device headers INCLUDES += -I$(RIOTCPU)/efm32/families/efr32mg12p/include/vendor diff --git a/cpu/efm32/families/efr32mg1p/Makefile.include b/cpu/efm32/families/efr32mg1p/Makefile.include index d6dc5144d8..0902f16be3 100644 --- a/cpu/efm32/families/efr32mg1p/Makefile.include +++ b/cpu/efm32/families/efr32mg1p/Makefile.include @@ -3,8 +3,5 @@ # as easy as adding the header file only. EFM32_HEADER = $(wildcard $(RIOTCPU)/efm32/families/efr32mg1p/include/vendor/$(CPU_MODEL).h) -# vectors.o is provided by 'cpu_$(CPU_FAM)' module and not by 'cpu' -VECTORS_O = $(BINDIR)/cpu_efr32mg1p/vectors.o - # include vendor device headers INCLUDES += -I$(RIOTCPU)/efm32/families/efr32mg1p/include/vendor diff --git a/cpu/esp32/Makefile.include b/cpu/esp32/Makefile.include index 0e6fa68188..68c8c00dd6 100644 --- a/cpu/esp32/Makefile.include +++ b/cpu/esp32/Makefile.include @@ -59,19 +59,19 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.ld LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.nanofmt.ld LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections -# Baselibs needed when using esp_wifi_any pseudomodule +# Libraries needed when using esp_wifi_any pseudomodule ifneq (,$(filter esp_wifi_any,$(USEMODULE))) - BASELIBS += -lcore -lrtc -lnet80211 -lpp -lcoexist -lwps -lwpa -lwpa2 - BASELIBS += -lphy -lstdc++ + ARCHIVES += -lcore -lrtc -lnet80211 -lpp -lcoexist -lwps -lwpa -lwpa2 + ARCHIVES += -lphy -lstdc++ endif -# Baselibs needed when using esp_now module +# Libraries needed when using esp_now module ifneq (,$(filter esp_now,$(USEMODULE))) - BASELIBS += -lespnow -lmesh + ARCHIVES += -lespnow -lmesh endif ifneq (,$(filter cpp,$(FEATURES_USED))) - BASELIBS += -lstdc++ + ARCHIVES += -lstdc++ endif # additional flasher configuration for ESP32 QEMU diff --git a/cpu/esp8266/Makefile.include b/cpu/esp8266/Makefile.include index 09e2fbbf5c..24111c3f6c 100644 --- a/cpu/esp8266/Makefile.include +++ b/cpu/esp8266/Makefile.include @@ -55,10 +55,10 @@ ifneq (,$(filter esp_gdbstub,$(USEMODULE))) endif ifneq (,$(filter esp_now,$(USEMODULE))) - BASELIBS += -lespnow + ARCHIVES += -lespnow endif -BASELIBS += -lgcc -lwpa -lcore -lnet80211 -lphy -lpp -lstdc++ +ARCHIVES += -lgcc -lwpa -lcore -lnet80211 -lphy -lpp -lstdc++ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp8266.rom.ld LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp8266.riot-os.ld diff --git a/cpu/esp_common/Makefile.include b/cpu/esp_common/Makefile.include index cfdcf34125..3e00c42f6c 100644 --- a/cpu/esp_common/Makefile.include +++ b/cpu/esp_common/Makefile.include @@ -36,9 +36,6 @@ OPTIONAL_CFLAGS_BLACKLIST += -gz ASFLAGS += --longcalls --text-section-literals -# thin archives trigger a reboot loop - see #12258, #12035, #12346 -ARFLAGS = rcs - CFLAGS_DBG ?= -ggdb -g3 # override default CFLAGS_OPT in case module esp_gdb is enabled @@ -80,7 +77,7 @@ CFLAGS += $(if $(findstring qio,$(FLASH_MODE)),-DFLASH_MODE_QIO=1) CFLAGS += $(if $(findstring dio,$(FLASH_MODE)),-DFLASH_MODE_DIO=1) CFLAGS += $(if $(findstring dout,$(FLASH_MODE)),-DFLASH_MODE_DOUT=1) -BASELIBS += -lhal -lg -lc +ARCHIVES += -lhal -lg -lc LINKFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG) LINKFLAGS += -L$(ESP_SDK_DIR)/components/$(CPU) diff --git a/cpu/kinetis/Makefile.include b/cpu/kinetis/Makefile.include index ec612774cd..19dce224aa 100644 --- a/cpu/kinetis/Makefile.include +++ b/cpu/kinetis/Makefile.include @@ -37,7 +37,4 @@ CFLAGS += \ -DKINETIS_ROMSIZE=$(KINETIS_ROMSIZE) \ # -# add the CPU specific flash configuration field for the linker -UNDEF += $(BINDIR)/cpu/fcfield.o - include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c index 067b89133e..c764397042 100644 --- a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c +++ b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c @@ -46,6 +46,8 @@ extern char _sheap; /* start of the heap */ extern char _eheap; /* end of the heap */ char *heap_top = &_sheap + 4; +/* Only need to define these when MIPS newlib is not used */ +#ifndef __mips__ /** * @brief Free resources on NewLib de-initialization, not used for RIOT */ @@ -97,6 +99,7 @@ void *_sbrk_r(struct _reent *r, ptrdiff_t incr) irq_restore(state); return res; } +#endif /*__mips__*/ /** * @brief Get the process-ID of the current thread diff --git a/cpu/msp430_common/Makefile.include b/cpu/msp430_common/Makefile.include index e84b10ae72..5776456f0d 100644 --- a/cpu/msp430_common/Makefile.include +++ b/cpu/msp430_common/Makefile.include @@ -2,7 +2,5 @@ INCLUDES += -I$(RIOTCPU)/msp430_common/include/ CFLAGS += -DCPU_MODEL_$(call uppercase_and_underscore,$(CPU_MODEL)) -UNDEF += $(BINDIR)/msp430_common/startup.o - # include the msp430 common Makefile include $(RIOTMAKE)/arch/msp430.inc.mk diff --git a/cpu/native/Makefile b/cpu/native/Makefile index e21039bb76..f5ebcab788 100644 --- a/cpu/native/Makefile +++ b/cpu/native/Makefile @@ -1,7 +1,10 @@ MODULE = cpu DIRS += periph -DIRS += vfs + +ifneq (,$(filter native_vfs,$(USEMODULE))) + DIRS += vfs +endif ifeq ($(OS),Darwin) CFLAGS += -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE diff --git a/makefiles/arch/atmega.inc.mk b/makefiles/arch/atmega.inc.mk index 24e7cb08dd..6ec773e007 100644 --- a/makefiles/arch/atmega.inc.mk +++ b/makefiles/arch/atmega.inc.mk @@ -11,10 +11,6 @@ ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections OFLAGS += -j .text -j .data -# explicitly tell the linker to link the syscalls and startup code. -# without this the interrupt vectors will not be linked correctly! -UNDEF += $(BINDIR)/atmega_common/startup.o - # Use ROM_LEN and RAM_LEN during link $(if $(ROM_LEN),,$(error ROM_LEN is not defined)) $(if $(RAM_LEN),,$(error RAM_LEN is not defined)) diff --git a/makefiles/arch/cortexm.inc.mk b/makefiles/arch/cortexm.inc.mk index 2751389fad..63e40230f8 100644 --- a/makefiles/arch/cortexm.inc.mk +++ b/makefiles/arch/cortexm.inc.mk @@ -102,13 +102,6 @@ ifneq (,$(filter cmsis-dsp,$(USEPKG))) endif endif -# Explicitly tell the linker to link the startup code. -# Without this the interrupt vectors will not be linked correctly! -VECTORS_O ?= $(BINDIR)/cpu/vectors.o -ifeq ($(COMMON_STARTUP),) - UNDEF += $(VECTORS_O) -endif - # CPU depends on the cortex-m common module, so include it: include $(RIOTCPU)/cortexm_common/Makefile.include diff --git a/makefiles/cflags.inc.mk b/makefiles/cflags.inc.mk index c9f21ef4a6..10f3751a68 100644 --- a/makefiles/cflags.inc.mk +++ b/makefiles/cflags.inc.mk @@ -38,6 +38,10 @@ endif # Forbid common symbols to prevent accidental aliasing. CFLAGS += -fno-common +# Place data and functions into their own sections. This helps the linker +# garbage collection to remove unused symbols when linking statically. +CFLAGS += -ffunction-sections -fdata-sections + # Compress debug info. This saves approximately 50% of disk usage. # It has no effect if debugging information is not emitted, so it can be left # on unconditionally. @@ -61,9 +65,3 @@ endif # Add the optional flags that are not architecture/toolchain blacklisted CFLAGS += $(filter-out $(OPTIONAL_CFLAGS_BLACKLIST),$(OPTIONAL_CFLAGS)) - -# Default ARFLAGS for platforms which do not specify it. -# Note: make by default provides ARFLAGS=rv which we want to override -ifeq ($(origin ARFLAGS),default) - ARFLAGS = rcTs -endif diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index 587a3dfa2f..330df6411f 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -8,7 +8,6 @@ export DOCKER_MAKECMDGOALS_POSSIBLE = \ scan-build \ scan-build-analyze \ tests-% \ - archive-check \ # export DOCKER_MAKECMDGOALS = $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS)) @@ -28,7 +27,6 @@ export DOCKER_MAKECMDGOALS ?= all export DOCKER_ENV_VARS += \ APPDIR \ AR \ - ARFLAGS \ AS \ ASFLAGS \ BINDIR \ diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 772b3fa360..55595b5d37 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -11,4 +11,4 @@ EXTDEFINES = $(addprefix -D,$(call uppercase_and_underscore,$(ED))) # filter "pseudomodules" from "real modules", but not "no_pseudomodules" REALMODULES += $(filter-out $(PSEUDOMODULES), $(_ALLMODULES)) REALMODULES += $(filter $(NO_PSEUDOMODULES), $(_ALLMODULES)) -BASELIBS += $(REALMODULES:%=$(BINDIR)/%.a) +BASELIBS += $(REALMODULES:%=%.module) diff --git a/makefiles/scan-build.inc.mk b/makefiles/scan-build.inc.mk index ba7d83a1a9..1c53a4fe00 100644 --- a/makefiles/scan-build.inc.mk +++ b/makefiles/scan-build.inc.mk @@ -1,7 +1,6 @@ SCANBUILD_ENV_VARS := \ APPDIR \ AR \ - ARFLAGS \ AS \ ASFLAGS \ BINDIR \ diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index f7fe9b101e..6e48f53964 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -64,14 +64,13 @@ export CXXUWFLAGS # (Patterns of) flags in CFLAGS that should not be export CXXEXFLAGS # Additional flags that should be passed to CXX. export CCASUWFLAGS # (Patterns of) flags in CFLAGS that should not be passed to CCAS. export CCASEXFLAGS # Additional flags that should be passed to CCAS. -export AR # The command to create the object file archives. -export ARFLAGS # Command-line options to pass to AR, default `rcs`. export AS # The assembler. export ASFLAGS # Flags for the assembler. export LINK # The command used to link the files. Must take the same parameters as GCC, i.e. "ld" won't work. export NM # The command used to list symbols from objet files export RANLIB # The command used to generate an index to the contents of an archive # LINKFLAGS # Flags to supply in the linking step. +export ARCHIVES # List of archives to add in the linking step export LTOFLAGS # extra CFLAGS for compiling with link time optimization export OBJCOPY # The command used to create the HEXFILE and BINFILE. export OFLAGS # The parameter for OBJCOPY, e.g. to strip the debug information. diff --git a/pkg/ccn-lite/Makefile.include b/pkg/ccn-lite/Makefile.include index d7578c81ce..bab9bba358 100644 --- a/pkg/ccn-lite/Makefile.include +++ b/pkg/ccn-lite/Makefile.include @@ -4,3 +4,4 @@ INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-pkt/include INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-fwd/include CFLAGS += -DCCNL_RIOT +ARCHIVES += $(BINDIR)/ccn-lite.a diff --git a/pkg/cryptoauthlib/Makefile.include b/pkg/cryptoauthlib/Makefile.include index 310b391ef2..82cd2a0a39 100644 --- a/pkg/cryptoauthlib/Makefile.include +++ b/pkg/cryptoauthlib/Makefile.include @@ -7,6 +7,7 @@ INCLUDES += -I$(PKG_SOURCE_DIR)/app INCLUDES += -I$(RIOTPKG)/cryptoauthlib/include DIRS += $(RIOTPKG)/cryptoauthlib/contrib +ARCHIVES += $(BINDIR)/cryptoauthlib.a ifneq (,$(filter cryptoauthlib_test,$(USEMODULE))) INCLUDES += -I$(PKG_TESTINCLDIR) diff --git a/pkg/jerryscript/Makefile.include b/pkg/jerryscript/Makefile.include index a2e8279ade..ad2a265f42 100644 --- a/pkg/jerryscript/Makefile.include +++ b/pkg/jerryscript/Makefile.include @@ -1,6 +1,9 @@ INCLUDES += -I$(PKGDIRBASE)/jerryscript/jerry-core/include INCLUDES += -I$(PKGDIRBASE)/jerryscript/jerry-ext/include +ARCHIVES += $(BINDIR)/jerryscript.a $(BINDIR)/jerryscript-ext.a +ARCHIVES += $(BINDIR)/jerryport-minimal.a + # Ensure MCPU is correctly exported to CMake variables when configuring the # Jerrycript build $(call target-export-variables,libjerry,MCPU) diff --git a/pkg/micropython/Makefile.include b/pkg/micropython/Makefile.include index 4b60bb2649..b1aba6239a 100644 --- a/pkg/micropython/Makefile.include +++ b/pkg/micropython/Makefile.include @@ -8,5 +8,8 @@ INCLUDES += -I$(RIOTBASE)/pkg/micropython/include INCLUDES += -I$(BINDIR)/pkg/micropython INCLUDES += -I$(BINDIR)/pkg/micropython/ports/riot +# include archive +ARCHIVES += $(BINDIR)/micropython.a + # The port currently doesn't build with llvm TOOLCHAINS_BLACKLIST += llvm diff --git a/pkg/nordic_softdevice_ble/Makefile.include b/pkg/nordic_softdevice_ble/Makefile.include index 75648c74e5..1426ee11b3 100644 --- a/pkg/nordic_softdevice_ble/Makefile.include +++ b/pkg/nordic_softdevice_ble/Makefile.include @@ -25,6 +25,7 @@ CFLAGS += -Wno-pedantic -Wno-unused-parameter -Wno-sign-compare # Nordic's ble_6lowpan.a is compiled with hard-float # so set this, otherwise linking fails CFLAGS_FPU := -mfloat-abi=hard -mfpu=fpv4-sp-d16 +ARCHIVES += $(BINDIR)/ble_6lowpan.a DIRS += $(RIOTBASE)/pkg/nordic_softdevice_ble/src diff --git a/pkg/openthread/Makefile.dep b/pkg/openthread/Makefile.dep index 404b3c1765..d64cdf9127 100644 --- a/pkg/openthread/Makefile.dep +++ b/pkg/openthread/Makefile.dep @@ -1,5 +1,4 @@ USEMODULE += openthread_contrib -USEMODULE += mbedcrypto USEMODULE += openthread_contrib_netdev USEMODULE += l2util diff --git a/pkg/openthread/Makefile.include b/pkg/openthread/Makefile.include index e8301970a5..5ce14f1b5a 100644 --- a/pkg/openthread/Makefile.include +++ b/pkg/openthread/Makefile.include @@ -13,3 +13,6 @@ ifneq (,$(filter cortex-m0% cortex-m3%,$(CPU_CORE))) # ranlib + LLVM/clang in this package with Cortex-M0 and M3 TOOLCHAINS_BLACKLIST += llvm endif + +ARCHIVES += $(addprefix $(BINDIR)/,$(addsuffix .a,$(filter openthread-%,$(USEMODULE)))) +ARCHIVES += $(BINDIR)/mbedcrypto.a diff --git a/pkg/relic/Makefile.include b/pkg/relic/Makefile.include index c9c78b30d2..bbcfce1ccb 100644 --- a/pkg/relic/Makefile.include +++ b/pkg/relic/Makefile.include @@ -1,5 +1,6 @@ INCLUDES += -I$(PKGDIRBASE)/relic/include INCLUDES += -I$(BINDIR)/pkg-build/relic/include +ARCHIVES += $(BINDIR)/relic.a ifneq (,$(filter cortex-m%,$(CPU_CORE))) # relic package package is not using system includes right now, so diff --git a/pkg/tlsf/Makefile.include b/pkg/tlsf/Makefile.include index f5780a6113..2ed273be51 100644 --- a/pkg/tlsf/Makefile.include +++ b/pkg/tlsf/Makefile.include @@ -7,9 +7,3 @@ endif PSEUDOMODULES += tlsf-malloc_newlib PSEUDOMODULES += tlsf-malloc_native - -ifneq (,$(filter tlsf-malloc_newlib,$(USEMODULE))) - UNDEF += $(BINDIR)/tlsf-malloc/newlib.o -else ifneq (,$(filter tlsf-malloc_native,$(BOARD))) - UNDEF += $(BINDIR)/tlsf-malloc/native.o -endif diff --git a/sys/Makefile.include b/sys/Makefile.include index f14f415815..3067d51c00 100644 --- a/sys/Makefile.include +++ b/sys/Makefile.include @@ -49,9 +49,6 @@ endif ifneq (,$(filter cpp11-compat,$(USEMODULE))) USEMODULE_INCLUDES += $(RIOTBASE)/sys/cpp11-compat/include - # make sure cppsupport.o is linked explicitly because __dso_handle is not - # found if it is hidden away inside a static object. - UNDEF += $(BINDIR)/cpp11-compat/cppsupport.o endif ifneq (,$(filter embunit,$(USEMODULE))) @@ -80,14 +77,6 @@ ifneq (,$(filter picolibc,$(USEMODULE))) include $(RIOTMAKE)/libc/picolibc.mk endif -ifneq (,$(filter newlib_syscalls_default,$(USEMODULE))) - include $(RIOTBASE)/sys/newlib_syscalls_default/Makefile.include -endif - -ifneq (,$(filter picolibc_syscalls_default,$(USEMODULE))) - include $(RIOTBASE)/sys/picolibc_syscalls_default/Makefile.include -endif - ifneq (,$(filter arduino,$(USEMODULE))) include $(RIOTBASE)/sys/arduino/Makefile.include endif diff --git a/sys/newlib_syscalls_default/Makefile.include b/sys/newlib_syscalls_default/Makefile.include deleted file mode 100644 index 419a6feddc..0000000000 --- a/sys/newlib_syscalls_default/Makefile.include +++ /dev/null @@ -1 +0,0 @@ -UNDEF += $(BINDIR)/newlib_syscalls_default/syscalls.o diff --git a/sys/picolibc_syscalls_default/Makefile.include b/sys/picolibc_syscalls_default/Makefile.include deleted file mode 100644 index d14f2c9f79..0000000000 --- a/sys/picolibc_syscalls_default/Makefile.include +++ /dev/null @@ -1 +0,0 @@ -UNDEF += $(BINDIR)/picolibc_syscalls_default/syscalls.o diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index 3a36d50523..cee2d25466 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -24,7 +24,7 @@ FEATURES_BLACKLIST += bootloader_nrfutil -include $(UNIT_TESTS:%=$(RIOTBASE)/tests/unittests/%/Makefile.include) DIRS += $(UNIT_TESTS) -BASELIBS += $(UNIT_TESTS:%=$(BINDIR)/%.a) +BASELIBS += $(UNIT_TESTS:%=%.module) INCLUDES += -I$(RIOTBASE)/tests/unittests/common From 29b81e4b40695157aff78c28cf328214c8296e03 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 12 Aug 2020 15:37:49 +0200 Subject: [PATCH 2/5] makefiles/bindist: copy object files and use .bin to compare --- makefiles/bindist.inc.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/makefiles/bindist.inc.mk b/makefiles/bindist.inc.mk index b8b8510e61..3002e95404 100644 --- a/makefiles/bindist.inc.mk +++ b/makefiles/bindist.inc.mk @@ -1,7 +1,7 @@ # Avoid including APPLICATION_MODULE twice to prevent multiple definition errors USEMODULE += $(filter-out $(APPLICATION_MODULE),$(BIN_USEMODULE)) -DIST_FILES += $(BIN_USEMODULE:%=bin/$(BOARD)/%.a) +DIST_FILES += $(BIN_USEMODULE:%=bin/$(BOARD)/%/*.o) # if the file Makefile.distcheck exists, we're executing from within a folder # generated by "make bindist". @@ -17,7 +17,7 @@ bindist: all echo Copying $$i to bindist. ; \ cp -a --parents $$i bindist ; \ done - @cp -a bin/$(BOARD)/$(APPLICATION).elf bindist + @cp -a bin/$(BOARD)/$(APPLICATION).bin bindist @echo "BINDIST_RIOT_VERSION=$(RIOT_VERSION)" > bindist/Makefile.distcheck @echo "BINDIST_GIT_HEAD=$$(git -C $(RIOTBASE) describe)" >> bindist/Makefile.distcheck @@ -29,7 +29,7 @@ prepare_check_bindist: echo "Warning! git describe doesn't match!" check_bindist: prepare_check_bindist all - @test $(shell md5sum bin/$(BOARD)/$(APPLICATION).elf | cut -f1 -d\ ) \ - = $(shell md5sum $(APPLICATION).elf | cut -f1 -d\ ) \ - && echo "bin/$(BOARD)/$(APPLICATION).elf matches $(APPLICATION).elf." \ - || echo "bin/$(BOARD)/$(APPLICATION).elf and $(APPLICATION).elf don't match!" + @test $(shell md5sum bin/$(BOARD)/$(APPLICATION).bin | cut -f1 -d\ ) \ + = $(shell md5sum $(APPLICATION).bin | cut -f1 -d\ ) \ + && echo "bin/$(BOARD)/$(APPLICATION).bin matches $(APPLICATION).bin." \ + || echo "bin/$(BOARD)/$(APPLICATION).bin and $(APPLICATION).bin don't match!" From 847c2f8b6bfd8e75c99adc6453ef8820181c1c0f Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 12 Aug 2020 17:09:43 +0200 Subject: [PATCH 3/5] dist: remove unused ar-wrapper --- dist/ar-wrapper | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 dist/ar-wrapper diff --git a/dist/ar-wrapper b/dist/ar-wrapper deleted file mode 100755 index a3d17d74c4..0000000000 --- a/dist/ar-wrapper +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# This wrapper takes the arguments: -# can be any ar implementation. -# , and are the normal arguments to . -# -# OS X's ar implementation has the problem, that it refuses to create empty archives. -# This wrapper will copy a provided empty .a file to if it was told to. - -# If contains "r", and there are no given. -if [ "${2#*r}" != "$2" ] && [ "$#" -eq 3 ]; then - # If exists, do nothing, otherwise copy an empty archive. - [ -e "$3" ] || cp "${0%ar-wrapper}/empty.a" "$3" -else - # Otherwise act like this wrapper was not present. - "$@" -fi - -# Return the exit code of the last invocation ("[", "cp", or ). -exit $? From 16b5fd303b546ab091a0b20f003c6457c40d57b6 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 17 Aug 2020 18:30:36 +0200 Subject: [PATCH 4/5] drivers: add usbdev_mock --- Makefile.dep | 4 +++- {tests/usbus => drivers/include}/usbdev_mock.h | 7 +++---- drivers/usbdev_mock/Makefile | 1 + {tests/usbus => drivers/usbdev_mock}/usbdev_mock.c | 1 - tests/usbus/Makefile | 2 +- tests/usbus/Makefile.ci | 2 ++ tests/usbus/main.c | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) rename {tests/usbus => drivers/include}/usbdev_mock.h (97%) create mode 100644 drivers/usbdev_mock/Makefile rename {tests/usbus => drivers/usbdev_mock}/usbdev_mock.c (99%) diff --git a/Makefile.dep b/Makefile.dep index dacaa1b387..91e48962cc 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -977,9 +977,11 @@ endif ifneq (,$(filter usbus,$(USEMODULE))) DEFAULT_MODULE += auto_init_usbus - FEATURES_REQUIRED += periph_usbdev USEMODULE += core_thread_flags USEMODULE += event + ifeq (,$(filter usbdev_mock,$(USEMODULE))) + FEATURES_REQUIRED += periph_usbdev + endif endif ifneq (,$(filter usbus_cdc_acm,$(USEMODULE))) diff --git a/tests/usbus/usbdev_mock.h b/drivers/include/usbdev_mock.h similarity index 97% rename from tests/usbus/usbdev_mock.h rename to drivers/include/usbdev_mock.h index 8bebcaaeb6..30c5c74b4e 100644 --- a/tests/usbus/usbdev_mock.h +++ b/drivers/include/usbdev_mock.h @@ -6,13 +6,11 @@ * directory for more details. */ /** - * @defgroup tests_usbdev_mock USBdev mockup device - * @ingroup tests + * @defgroup drivers_usbdev_mock USBdev mockup device + * @ingroup drivers * @brief USBdev mockup device for testing * @{ * - * @file - * * @author Koen Zandberg */ @@ -115,3 +113,4 @@ void usbdev_mock_setup(usbdev_mock_esr_cb_t esr_cb, #endif /* USBDEV_MOCK_H */ /** @} */ +/** @} */ diff --git a/drivers/usbdev_mock/Makefile b/drivers/usbdev_mock/Makefile new file mode 100644 index 0000000000..48422e909a --- /dev/null +++ b/drivers/usbdev_mock/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/tests/usbus/usbdev_mock.c b/drivers/usbdev_mock/usbdev_mock.c similarity index 99% rename from tests/usbus/usbdev_mock.c rename to drivers/usbdev_mock/usbdev_mock.c index bd96bba83e..abf9515f75 100644 --- a/tests/usbus/usbdev_mock.c +++ b/drivers/usbdev_mock/usbdev_mock.c @@ -17,7 +17,6 @@ #include #include -#include "embUnit.h" #include "periph/usbdev.h" #include "test_utils/expect.h" #include "usbdev_mock.h" diff --git a/tests/usbus/Makefile b/tests/usbus/Makefile index 236d98343c..eada3089ec 100644 --- a/tests/usbus/Makefile +++ b/tests/usbus/Makefile @@ -1,7 +1,7 @@ include ../Makefile.tests_common USEMODULE += embunit USEMODULE += usbus -FEATURES_PROVIDED += periph_usbdev +USEMODULE += usbdev_mock DISABLE_MODULE += auto_init_usbus diff --git a/tests/usbus/Makefile.ci b/tests/usbus/Makefile.ci index 437811ffa9..3585ad2b49 100644 --- a/tests/usbus/Makefile.ci +++ b/tests/usbus/Makefile.ci @@ -1,7 +1,9 @@ BOARD_INSUFFICIENT_MEMORY := \ arduino-duemilanove \ + arduino-leonardo \ arduino-nano \ arduino-uno \ atmega328p \ + nucleo-f031k6 \ stm32f030f4-demo \ # diff --git a/tests/usbus/main.c b/tests/usbus/main.c index 1224b61839..3252ce36de 100644 --- a/tests/usbus/main.c +++ b/tests/usbus/main.c @@ -274,7 +274,7 @@ static void _handle_data(usbdev_mock_t *dev, usbdev_mock_ep_t *ep, size_t len) static void _ep_esr_validation(usbdev_mock_t *dev, usbdev_mock_ep_t *ep) { - DEBUG("[ep esr]: Data available for stack: %u\n", ep->available); + DEBUG("[ep esr]: Data available for stack: %u\n", (unsigned)ep->available); if (req_phase == TEST_REQ_PHASE_IDLE) { DEBUG("[ep esr]: Done with the request\n"); /* signal USBDEV_EVENT_ESR to call _test_sequence */ From e80bb4b3dcc6aef89ca69844b90fefcb64248b96 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 1 Sep 2020 17:09:57 +0200 Subject: [PATCH 5/5] makefile: add a check for real modules --- Makefile.base | 5 +---- Makefile.include | 9 +++++++-- makefiles/modules.inc.mk | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Makefile.base b/Makefile.base index 5469d5c117..53f858e99a 100644 --- a/Makefile.base +++ b/Makefile.base @@ -89,10 +89,7 @@ include $(RIOTMAKE)/tools/fixdep.inc.mk $(BINDIR)/$(MODULE)/: $(Q)mkdir -p $@ -# only create the module folder when it's going to hold objects -ifneq (,$(strip $(OBJ))) - $(MODULE).module $(OBJ): | $(BINDIR)/$(MODULE)/ -endif +$(MODULE).module $(OBJ): | $(BINDIR)/$(MODULE)/ $(MODULE).module: $(OBJ) | $(DIRS:%=ALL--%) diff --git a/Makefile.include b/Makefile.include index 165b4cf314..1ef4458753 100644 --- a/Makefile.include +++ b/Makefile.include @@ -556,6 +556,7 @@ DIRS += $(EXTERNAL_MODULE_DIRS) BUILDDEPS += $(RIOTBUILD_CONFIG_HEADER_C) BUILDDEPS += pkg-prepare BUILDDEPS += $(APPDEPS) +BUILDDEPS += $(MODULE_LIST_DIR) # Save value to verify it is not modified later _BASELIBS_VALUE_BEFORE_USAGE := $(BASELIBS) @@ -575,9 +576,9 @@ ifeq ($(BUILD_IN_DOCKER),1) link: ..in-docker-container else ifeq (,$(RIOTNOLINK)) -link: ..compiler-check ..build-message $(BUILD_FILES) print-size +link: ..compiler-check ..build-message $(BUILD_FILES) print-size ..module-check else -link: ..compiler-check ..build-message $(BASELIBS) $(ARCHIVES) +link: ..compiler-check ..build-message $(BASELIBS) $(ARCHIVES) ..module-check endif # RIOTNOLINK $(ELFFILE): $(BASELIBS) $(ARCHIVES) @@ -585,6 +586,10 @@ $(ELFFILE): $(BASELIBS) $(ARCHIVES) .PHONY: $(APPLICATION_MODULE).module +..module-check: $(BASELIBS) + @[ -z "$(strip $(NON_GENERATED_MODULES))" ] || \ + ($(COLOR_ECHO) "$(COLOR_RED)Error - using unknown modules: $(COLOR_RESET)$(NON_GENERATED_MODULES)" && false) + $(APPLICATION_MODULE).module: pkg-build $(BUILDDEPS) $(Q)DIRS="$(DIRS)" APPLICATION_BLOBS="$(BLOBS)" \ "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 55595b5d37..4595d8d062 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -12,3 +12,8 @@ EXTDEFINES = $(addprefix -D,$(call uppercase_and_underscore,$(ED))) REALMODULES += $(filter-out $(PSEUDOMODULES), $(_ALLMODULES)) REALMODULES += $(filter $(NO_PSEUDOMODULES), $(_ALLMODULES)) BASELIBS += $(REALMODULES:%=%.module) + +# Add modules compiled with Makefile.base and extra archives +GENERATED_MODULES = $(notdir $(shell find $(BINDIR) -type d)) $(basename $(notdir $(ARCHIVES))) + +NON_GENERATED_MODULES = $(filter-out $(GENERATED_MODULES),$(REALMODULES))