diff --git a/Makefile.base b/Makefile.base index 5174119c0978..e70ea91852a7 100644 --- a/Makefile.base +++ b/Makefile.base @@ -9,7 +9,13 @@ MODULE ?= $(shell basename $(CURDIR)) .PHONY: all clean $(DIRS:%=ALL--%) $(DIRS:%=CLEAN--%) +# Build a static library if the current module is listed in LIBS +ifneq (,$(filter $(MODULE),$(LIBS))) all: $(BINDIR)/$(MODULE).a ..nothing +else +# .. otherwise, build a monolithic object file +all: $(BINDIR)/$(MODULE).o ..nothing +endif ..nothing: @: @@ -65,6 +71,18 @@ DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d) $(BINDIR)/$(MODULE)/: $(Q)mkdir -p $@ +$(BINDIR)/$(MODULE).o $(OBJ): | $(BINDIR)/$(MODULE)/ + +# An empty object file is included in the link to avoid situations where modules +# do not provide any code (e.g. sys, some boards), causing the build to fail +# with a missing object file. +EMPTYOBJ = $(BINDIR)/$(MODULE)/.empty.o +$(EMPTYOBJ): | $(BINDIR)/$(MODULE)/ + $(Q)$(CC) $(CFLAGS) -Wno-pedantic -xc -o $@ -c - < /dev/null + +$(BINDIR)/$(MODULE).o: $(OBJ) $(EMPTYOBJ) | ${DIRS:%=ALL--%} + $(Q)$(ILINK) $(ILINKFLAGS) -o $@ $^ + $(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/ $(BINDIR)/$(MODULE).a: $(OBJ) | $(DIRS:%=ALL--%) diff --git a/Makefile.dep b/Makefile.dep index f89090bbb578..b916005ff984 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -398,7 +398,14 @@ endif ifneq (,$(filter stdio_uart,$(USEMODULE))) USEMODULE += isrpipe - FEATURES_REQUIRED += periph_uart + ifneq (,$(filter newlib_syscalls_mips_uhi,$(USEMODULE))) + # The periph_uart driver is optional when using MIPS UHI syscalls (debug + # UART is used on PIC32 boards, but not on mips-malta) + FEATURES_OPTIONAL += periph_uart + else + # All other UART implementations require the periph_uart driver. + FEATURES_REQUIRED += periph_uart + endif endif ifneq (,$(filter isrpipe,$(USEMODULE))) @@ -562,6 +569,10 @@ ifneq (,$(filter pthread,$(USEMODULE))) USEMODULE += timex endif +ifneq (,$(filter pthread_tls,$(USEMODULE))) + USEMODULE += pthread +endif + ifneq (,$(filter schedstatistics,$(USEMODULE))) USEMODULE += xtimer endif diff --git a/Makefile.include b/Makefile.include index 9c45a7440fd0..163ad617b287 100644 --- a/Makefile.include +++ b/Makefile.include @@ -348,7 +348,7 @@ endif APPLICATION_MODULE ?= application_$(APPLICATION) # the binaries to link -BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a +BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).o BASELIBS += $(APPDEPS) @@ -437,9 +437,9 @@ _BASELIBS_VALUE_BEFORE_USAGE := $(BASELIBS) # Linker rule $(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) -size +8c) $(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)) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map endif # BUILDOSXNATIVE # include bootloaders support. When trying to overwrite one variable @@ -459,13 +459,13 @@ endif # RIOTNOLINK $(ELFFILE): $(BASELIBS) $(Q)$(_LINK) -o $@ -$(BINDIR)/$(APPLICATION_MODULE).a: pkg-build $(BUILDDEPS) +$(BINDIR)/$(APPLICATION_MODULE).o: pkg-build $(BUILDDEPS) $(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk -$(BINDIR)/$(APPLICATION_MODULE).a: FORCE +$(BINDIR)/$(APPLICATION_MODULE).o: 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 $(BINDIR)/$(APPLICATION_MODULE).o $(APPDEPS), $(BASELIBS)) +$(_SUBMAKE_LIBS): $(BINDIR)/$(APPLICATION_MODULE).o pkg-build # 'print-size' triggers a rebuild. Use 'info-buildsize' if you do not need to rebuild. print-size: $(ELFFILE) @@ -516,7 +516,7 @@ clean: # Remove intermediates, but keep the .elf, .hex and .map etc. clean-intermediates: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done - -@rm -rf $(BINDIR)/*.a $(BINDIR)/*/ + -@rm -rf $(BINDIR)/*.o $(BINDIR)/*.a $(BINDIR)/*/ clean-pkg: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done diff --git a/boards/common/msba2/Makefile.include b/boards/common/msba2/Makefile.include index db624de2b4ed..a3515e739df2 100644 --- a/boards/common/msba2/Makefile.include +++ b/boards/common/msba2/Makefile.include @@ -28,5 +28,3 @@ USEMODULE += newlib_nano FFLAGS = $(PORT) $(HEXFILE) INCLUDES += -I$(RIOTBOARD)/common/msba2/include - -export UNDEF += $(BINDIR)/cpu/startup.o diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 974effb34116..767cd55cb029 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -74,6 +74,7 @@ export CXXEXFLAGS += ifeq ($(shell uname -m),x86_64) export LINKFLAGS += -m32 + export ILINKFLAGS += -r -m elf_i386 --unique endif ifeq ($(shell uname -s),FreeBSD) ifeq ($(shell uname -m),amd64) @@ -187,5 +188,3 @@ eval-gprof: eval-cachegrind: $(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1) - -export UNDEF += $(BINDIR)/cpu/startup.o diff --git a/cpu/atmega1281/Makefile.include b/cpu/atmega1281/Makefile.include index 66add33aaaf2..a945a0f33aae 100644 --- a/cpu/atmega1281/Makefile.include +++ b/cpu/atmega1281/Makefile.include @@ -1,6 +1,9 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common +# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html +export CPU_FAM = avr51 + RAM_LEN = 8K ROM_LEN = 128K diff --git a/cpu/atmega1284p/Makefile.include b/cpu/atmega1284p/Makefile.include index 985d14cf9e42..d7ea3fddcf71 100644 --- a/cpu/atmega1284p/Makefile.include +++ b/cpu/atmega1284p/Makefile.include @@ -1,6 +1,9 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common +# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html +export CPU_FAM = avr51 + RAM_LEN = 16K ROM_LEN = 128K diff --git a/cpu/atmega2560/Makefile.include b/cpu/atmega2560/Makefile.include index 16c500d37cc6..59e62f9214c0 100644 --- a/cpu/atmega2560/Makefile.include +++ b/cpu/atmega2560/Makefile.include @@ -1,6 +1,9 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common +# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html +export CPU_FAM = avr6 + RAM_LEN = 8K ROM_LEN = 256K diff --git a/cpu/atmega256rfr2/Makefile.include b/cpu/atmega256rfr2/Makefile.include index c7e4d680eaeb..376cfac9d403 100644 --- a/cpu/atmega256rfr2/Makefile.include +++ b/cpu/atmega256rfr2/Makefile.include @@ -1,6 +1,9 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common +# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html +export CPU_FAM = avr6 + #include periph module USEMODULE += periph diff --git a/cpu/atmega328p/Makefile.include b/cpu/atmega328p/Makefile.include index 20119203dd60..736b3713de5b 100644 --- a/cpu/atmega328p/Makefile.include +++ b/cpu/atmega328p/Makefile.include @@ -1,6 +1,9 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common +# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html +export CPU_FAM = avr5 + RAM_LEN = 2K ROM_LEN = 32K diff --git a/cpu/efm32/Makefile.include b/cpu/efm32/Makefile.include index de69fa6fb721..1616f6fbd684 100644 --- a/cpu/efm32/Makefile.include +++ b/cpu/efm32/Makefile.include @@ -17,9 +17,6 @@ endif # include CPU family module USEMODULE += cpu_$(EFM32_FAMILY) -# vectors.o is provided by 'cpu_$(EFM32_FAMILY)' and not by 'cpu' -VECTORS_O := $(BINDIR)/cpu_$(EFM32_FAMILY)/vectors.o - # include common periph module USEMODULE += periph_common diff --git a/cpu/kinetis/Makefile.include b/cpu/kinetis/Makefile.include index a5f36b4ed0b3..de390d39e432 100644 --- a/cpu/kinetis/Makefile.include +++ b/cpu/kinetis/Makefile.include @@ -30,9 +30,6 @@ LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_start_addr=$(RAM_START_ADDR) LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_length=$(ROM_LEN) LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_length=$(RAM_LEN) -# add the CPU specific flash configuration field for the linker -export UNDEF += $(BINDIR)/cpu/fcfield.o - # include common periph drivers USEMODULE += periph_common diff --git a/cpu/mips32r2_common/Makefile.include b/cpu/mips32r2_common/Makefile.include index 8924ee503721..25529c6345af 100644 --- a/cpu/mips32r2_common/Makefile.include +++ b/cpu/mips32r2_common/Makefile.include @@ -8,6 +8,9 @@ export USEMODULE += newlib # mips32 needs periph_timer for its gettimeofday() implementation export USEMODULE += periph_timer +# Need to tell the linker about the CPU endianness +export ILINKFLAGS += -r -EL --unique + ifeq ($(USE_UHI_SYSCALLS),1) #Use UHI to handle syscalls export LINKFLAGS += -luhi diff --git a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c index 87efbb0c5750..f21a7e729184 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; +/* MIPS newlib crt implements _init,_fini and _exit and manages the heap */ +#ifndef __mips__ /** * @brief Free resources on NewLib de-initialization, not used for RIOT */ @@ -98,6 +100,8 @@ void *_sbrk_r(struct _reent *r, ptrdiff_t incr) 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 ab6e0cf8c0d3..472b3b41e4b5 100644 --- a/cpu/msp430_common/Makefile.include +++ b/cpu/msp430_common/Makefile.include @@ -4,7 +4,6 @@ INCLUDES += -I$(RIOTCPU)/msp430_common/include/ MODEL = $(shell echo $(CPU_MODEL) | tr 'a-z' 'A-Z') export CFLAGS += -DCPU_MODEL_$(MODEL) -export UNDEF += $(BINDIR)/msp430_common/startup.o export USEMODULE += msp430_common msp430_common_periph periph_common DEFAULT_MODULE += oneway_malloc diff --git a/makefiles/arch/atmega.inc.mk b/makefiles/arch/atmega.inc.mk index b45178e3016b..dea44ad1d348 100644 --- a/makefiles/arch/atmega.inc.mk +++ b/makefiles/arch/atmega.inc.mk @@ -8,6 +8,9 @@ CFLAGS_OPT ?= -Os CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) +# See https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html for information on +# which CPU_FAM corresponds to your CPU +ILINKFLAGS += -r -m $(CPU_FAM) --unique LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections OFLAGS += -j .text -j .data @@ -27,10 +30,6 @@ endif # the atmel port uses stdio_uart USEMODULE += stdio_uart -# 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 0416869b9086..8418844bb0eb 100644 --- a/makefiles/arch/cortexm.inc.mk +++ b/makefiles/arch/cortexm.inc.mk @@ -133,13 +133,6 @@ export CFLAGS += -DARM_MATH_CM23 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),) -export 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/arch/riscv.inc.mk b/makefiles/arch/riscv.inc.mk index 549e3d87f3a0..76b693de283a 100644 --- a/makefiles/arch/riscv.inc.mk +++ b/makefiles/arch/riscv.inc.mk @@ -17,3 +17,5 @@ export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK) export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) # export linker flags export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc +# ld defaults to elf64-littleriscv, tell it to use elf32 in incremental links +ILINKFLAGS += -m elf32lriscv -r --unique diff --git a/makefiles/bindist.inc.mk b/makefiles/bindist.inc.mk index b8b8510e61bf..b695b06e4f45 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". diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index 058e62363286..222684eee398 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -60,7 +60,6 @@ export DOCKER_ENV_VARS = \ SCANBUILD_OUTPUTDIR \ SIZE \ TOOLCHAIN \ - UNDEF \ # # Find which variables were set using the command line or the environment and diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 7dd0575b37ee..ba713f82005b 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -2,9 +2,19 @@ ED = $(addprefix MODULE_,$(sort $(USEMODULE) $(USEPKG))) EXTDEFINES = $(addprefix -D,$(shell echo '$(ED)' | tr 'a-z-' 'A-Z_')) # filter "pseudomodules" from "real modules", but not "no_pseudomodules" -NO_PSEUDOMODULES := $(filter $(NO_PSEUDOMODULES), $(sort $(USEMODULE) $(USEPKG))) -REALMODULES = $(filter-out $(PSEUDOMODULES), $(sort $(USEMODULE) $(USEPKG))) $(NO_PSEUDOMODULES) -export BASELIBS += $(REALMODULES:%=$(BINDIR)/%.a) +# any module listed in LIBS will be used as a .a file instead of .o +REALMODULES = $(filter-out $(LIBS), \ + $(filter-out $(PSEUDOMODULES), $(USEMODULE)) \ + $(filter $(NO_PSEUDOMODULES), $(USEMODULE))) +REALPKGS = $(filter-out $(LIBS), \ + $(filter-out $(PSEUDOMODULES), $(USEPKG)) \ + $(filter $(NO_PSEUDOMODULES), $(USEPKG))) +REALARCHIVES = $(filter $(LIBS),$(USEMODULE) $(USEPKG)) +# filter out any duplicate object file names +BASELIBS += \ + $(shell printf %s '$(REALMODULES:%=$(BINDIR)/%.o) $(REALPKGS:%=$(BINDIR)/%.o)' | \ + tr ' ' '\n' | awk '!a[$$0]++') +BASELIBS += $(REALARCHIVES:%=$(BINDIR)/%.a) CFLAGS += $(EXTDEFINES) diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 6132f5b16d82..98b4d21a601f 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -58,6 +58,7 @@ PSEUDOMODULES += pktqueue PSEUDOMODULES += printf_float PSEUDOMODULES += prng PSEUDOMODULES += prng_% +PSEUDOMODULES += pthread_tls PSEUDOMODULES += riotboot_% PSEUDOMODULES += saul_adc PSEUDOMODULES += saul_default diff --git a/makefiles/scan-build.inc.mk b/makefiles/scan-build.inc.mk index 9fcf881b0d18..2566240b4b9a 100644 --- a/makefiles/scan-build.inc.mk +++ b/makefiles/scan-build.inc.mk @@ -32,7 +32,6 @@ SCANBUILD_ENV_VARS := \ RIOT_CI_BUILD \ SIZE \ TOOLCHAIN \ - UNDEF \ USER \ # diff --git a/makefiles/toolchain/gnu.inc.mk b/makefiles/toolchain/gnu.inc.mk index a65d433c7da7..f2ec89bfa7f5 100644 --- a/makefiles/toolchain/gnu.inc.mk +++ b/makefiles/toolchain/gnu.inc.mk @@ -10,6 +10,9 @@ export RANLIB = $(PREFIX)ranlib endif export AS = $(PREFIX)as export NM = $(PREFIX)nm +export LD = $(PREFIX)ld +export ILINK = $(LD) +export ILINKFLAGS ?= -r --unique export LINK = $(PREFIX)gcc export LINKXX = $(PREFIX)g++ export SIZE = $(PREFIX)size diff --git a/makefiles/toolchain/llvm.inc.mk b/makefiles/toolchain/llvm.inc.mk index f005ca7092ad..b266befe1536 100644 --- a/makefiles/toolchain/llvm.inc.mk +++ b/makefiles/toolchain/llvm.inc.mk @@ -16,6 +16,9 @@ export NM = $(LLVMPREFIX)nm # compatible with GCC. For instance spec files as used in # `makefiles/libc/newlib.mk` are not supported. Therefore # we just use GCC for now. +export LD = $(PREFIX)ld +export ILINK = $(LD) +export ILINKFLAGS ?= -r --unique export LINK = $(PREFIX)gcc export LINKXX = $(PREFIX)g++ # objcopy does not have a clear substitute in LLVM, use GNU binutils diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index bff4d74f52a1..b5f2343d481d 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -16,6 +16,7 @@ export CXXINCLUDES # The extra include paths for c++, set by the vario export USEMODULE # Sys Module dependencies of the application. Set in the application's Makefile. export USEPKG # Pkg dependencies (third party modules) of the application. Set in the application's Makefile. +export LIBS # Build a static archive instead of a single object file for the given modules. Set by the package's Makefile.include when necessary export DISABLE_MODULE # Used in the application's Makefile to suppress DEFAULT_MODULEs. export APPDEPS # Files / Makefile targets that need to be created before the application can be build. Set in the application's Makefile. # BUILDDEPS # Files / Makefile targets that need to be created before starting to build. @@ -55,6 +56,8 @@ 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 ILINK # Command used to perform incremental linking to create intermediate object files. Usually "ld" +export ILINKFLAGS # Incremental link command line options. export LINK # The command used to link the files. Must take the same parameters as GCC, i.e. "ld" won't work. # LINKFLAGS # Flags to supply in the linking step. export LTOFLAGS # extra CFLAGS for compiling with link time optimization @@ -64,7 +67,6 @@ export OBJDUMP # The command used to create the assembly listing. export OBJDUMPFLAGS # The parameter for OBJDUMP. export SIZE # The command to read to size of the ELF sections. export SIZEFLAGS # The optional size flags. -export UNDEF # Object files that the linker must include in the ELFFILE even if no call to the functions or symbols (ex: interrupt vectors). export WERROR # Treat all compiler warnings as errors if set to 1 (see -Werror flag in GCC manual) export GITCACHE # path to git-cache executable diff --git a/pkg/ccn-lite/Makefile.include b/pkg/ccn-lite/Makefile.include index a91eba997aa0..e0ac5b0a8aa4 100644 --- a/pkg/ccn-lite/Makefile.include +++ b/pkg/ccn-lite/Makefile.include @@ -5,3 +5,4 @@ INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-fwd/include INCLUDES += -I$(RIOTBASE)/sys/posix/include CFLAGS += -DCCNL_RIOT +LIBS += ccn-lite diff --git a/pkg/jerryscript/Makefile.include b/pkg/jerryscript/Makefile.include index fdf28101d478..87411b9e9d02 100644 --- a/pkg/jerryscript/Makefile.include +++ b/pkg/jerryscript/Makefile.include @@ -1,2 +1,7 @@ INCLUDES += -I$(PKGDIRBASE)/jerryscript/jerry-core/include INCLUDES += -I$(PKGDIRBASE)/jerryscript/jerry-ext/include + +# the jerryscript build produces static archives +LIBS += jerryscript +LIBS += jerryscript-ext +LIBS += jerryport-minimal diff --git a/pkg/nordic_softdevice_ble/Makefile.include b/pkg/nordic_softdevice_ble/Makefile.include index a06b35192af6..4341b83be56b 100644 --- a/pkg/nordic_softdevice_ble/Makefile.include +++ b/pkg/nordic_softdevice_ble/Makefile.include @@ -26,6 +26,9 @@ CFLAGS += -Wno-pedantic -Wno-unused-parameter -Wno-sign-compare # so set this, otherwise linking fails CFLAGS_FPU := -mfloat-abi=hard -mfpu=fpv4-sp-d16 +# ble_6lowpan.a is provided as a binary-only library within the softdevice package +LIBS += ble_6lowpan + DIRS += \ $(RIOTBASE)/pkg/nordic_softdevice_ble/src \ $(NORDIC_SRCS)/components/softdevice/common/softdevice_handler \ diff --git a/pkg/oonf_api/Makefile b/pkg/oonf_api/Makefile index 09e0bcca5e4c..3d978a055dfa 100644 --- a/pkg/oonf_api/Makefile +++ b/pkg/oonf_api/Makefile @@ -12,10 +12,6 @@ CFLAGS += -Wno-implicit-fallthrough all: git-download "$(MAKE)" -C $(PKG_BUILDDIR) - "$(MAKE)" $(BINDIR)/$(MODULE).a - -$(BINDIR)/$(MODULE).a: $(BINDIR)/oonf_*.a - mkdir -p $(BINDIR)/$(MODULE); cd $(BINDIR)/$(MODULE); for var in $?; do ar -x $$var; done; ar -r -c -s $(BINDIR)/$(MODULE).a *.o include $(RIOTBASE)/pkg/pkg.mk ifneq (,$(filter -Wformat-nonliteral -Wformat=2, $(CFLAGS))) diff --git a/pkg/oonf_api/Makefile.include b/pkg/oonf_api/Makefile.include index ec6be727f0ef..5ee0c0ec0609 100644 --- a/pkg/oonf_api/Makefile.include +++ b/pkg/oonf_api/Makefile.include @@ -3,3 +3,5 @@ INCLUDES += -I$(PKGDIRBASE)/oonf_api/src-api ifeq ($(TOOLCHAIN), llvm) CFLAGS += -Wno-keyword-macro -Wno-parentheses-equality endif + +LIBS += oonf_api diff --git a/pkg/oonf_api/patches/0001-add-RIOT-support.patch b/pkg/oonf_api/patches/0001-add-RIOT-support.patch index e8ec40831b77..91b5597daa2e 100644 --- a/pkg/oonf_api/patches/0001-add-RIOT-support.patch +++ b/pkg/oonf_api/patches/0001-add-RIOT-support.patch @@ -26,7 +26,7 @@ new file mode 100644 index 0000000..1f1cd9c --- /dev/null +++ b/Makefile -@@ -0,0 +1,29 @@ +@@ -0,0 +1,24 @@ +# +# to use oonf_api in your RIOT project, +# add the following to your Makefile: @@ -50,19 +50,14 @@ index 0000000..1f1cd9c +ifneq (,$(filter oonf_regex,$(USEMODULE))) + DIRS += external/regex +endif -+ -+all: -+ mkdir -p $(BINDIR) -+ @for i in $(DIRS) ; do $(MAKE) -C $$i || exit 1; done ; -+ -+clean: ++include $(RIOTBASE)/Makefile.base diff --git a/external/regex/Makefile b/external/regex/Makefile new file mode 100644 index 0000000..3bc1ce1 --- /dev/null +++ b/external/regex/Makefile @@ -0,0 +1,4 @@ -+MODULE:=oonf_$(shell basename $(CURDIR)) ++MODULE:=oonf_$(notdir $(CURDIR)) +INCLUDES += $(CURDIR)/.. + +include $(RIOTBASE)/Makefile.base @@ -72,7 +67,7 @@ index 0000000..5e0046d --- /dev/null +++ b/src-api/common/Makefile @@ -0,0 +1,3 @@ -+MODULE:=oonf_$(shell basename $(CURDIR)) ++MODULE:=oonf_$(notdir $(CURDIR)) + +include $(RIOTBASE)/Makefile.base diff --git a/src-api/common/autobuf.c b/src-api/common/autobuf.c @@ -188,7 +183,7 @@ index 0000000..5e0046d --- /dev/null +++ b/src-api/rfc5444/Makefile @@ -0,0 +1,3 @@ -+MODULE:=oonf_$(shell basename $(CURDIR)) ++MODULE:=oonf_$(notdir $(CURDIR)) + +include $(RIOTBASE)/Makefile.base diff --git a/src-api/rfc5444/rfc5444_api_config.h b/src-api/rfc5444/rfc5444_api_config.h diff --git a/pkg/openthread/Makefile b/pkg/openthread/Makefile index 863c1af35915..aa741a36533d 100644 --- a/pkg/openthread/Makefile +++ b/pkg/openthread/Makefile @@ -22,7 +22,7 @@ OPENTHREAD_COMMON_FLAGS += -Wno-implicit-fallthrough -Wno-unused-parameter all: git-download cd $(PKG_BUILDDIR) && PREFIX="/" ./bootstrap - cd $(PKG_BUILDDIR) && CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)"\ + cd $(PKG_BUILDDIR) && LIBS="" CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)"\ OBJC="" OBJCXX="" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" \ STRIP="$(STRIP)" \ CPPFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -D$(CONFIG_FILE)" \ @@ -31,7 +31,7 @@ all: git-download LDFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -nostartfiles -specs=nano.specs \ -specs=nosys.specs -Wl,--gc-sections -Wl,-Map=map.map " \ ./configure --disable-docs --host=$(TARGET_ARCH) --target=$(TARGET_ARCH) \ - --prefix=/ --enable-default-logging $(OPENTHREAD_ARGS) + --prefix=/ $(OPENTHREAD_ARGS) cd $(PKG_BUILDDIR) && DESTDIR=$(PKG_BUILDDIR)/output PREFIX=/ make -j4 --no-print-directory install cp $(PKG_BUILDDIR)/output/lib/libmbedcrypto.a ${BINDIR}/mbedcrypto.a diff --git a/pkg/openthread/Makefile.include b/pkg/openthread/Makefile.include index d399a8f90253..8cdbc7610078 100644 --- a/pkg/openthread/Makefile.include +++ b/pkg/openthread/Makefile.include @@ -8,6 +8,10 @@ ifneq (,$(filter openthread_contrib,$(USEMODULE))) DIRS += $(OPENTHREAD_DIR)/contrib/netdev endif +LIBS += libmbedcrypto +LIBS += libopenthread +LIBS += libopenthread-cli + ifneq (,$(filter cortex-m0% cortex-m3%,$(CPU_ARCH))) # There are problem with unused `-mcpu...` arguments in clang and with # ranlib + LLVM/clang in this package with Cortex-M0 and M3 diff --git a/pkg/relic/Makefile.include b/pkg/relic/Makefile.include index 5dc828d0ec28..80c149464ef9 100644 --- a/pkg/relic/Makefile.include +++ b/pkg/relic/Makefile.include @@ -1,5 +1,7 @@ INCLUDES += -I$(PKGDIRBASE)/relic/include +LIBS += relic + ifneq (,$(filter cortex-m%,$(CPU_ARCH))) # relic package package is not using system includes right now, so # many newlib headers (not even stdio.h) are not found. diff --git a/sys/Makefile.include b/sys/Makefile.include index b87126c5388f..7f86d90d5311 100644 --- a/sys/Makefile.include +++ b/sys/Makefile.include @@ -37,9 +37,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. - export UNDEF += $(BINDIR)/cpp11-compat/cppsupport.o endif ifneq (,$(filter embunit,$(USEMODULE))) @@ -64,10 +61,6 @@ ifneq (,$(filter newlib,$(USEMODULE))) include $(RIOTMAKE)/libc/newlib.mk endif -ifneq (,$(filter newlib_syscalls_default,$(USEMODULE))) - include $(RIOTBASE)/sys/newlib_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 419a6feddc87..000000000000 --- a/sys/newlib_syscalls_default/Makefile.include +++ /dev/null @@ -1 +0,0 @@ -UNDEF += $(BINDIR)/newlib_syscalls_default/syscalls.o diff --git a/sys/posix/pthread/Makefile b/sys/posix/pthread/Makefile index 48422e909a47..c9aaa08d00fe 100644 --- a/sys/posix/pthread/Makefile +++ b/sys/posix/pthread/Makefile @@ -1 +1,6 @@ +# exclude pthread_tls if not selected explicitly +ifeq (,$(filter pthread_tls,$(USEMODULE))) + SRC := $(filter-out pthread_tls.c,$(wildcard *.c)) +endif + include $(RIOTBASE)/Makefile.base diff --git a/tests/pthread_tls/Makefile b/tests/pthread_tls/Makefile index 728b0c10f015..97e550307314 100644 --- a/tests/pthread_tls/Makefile +++ b/tests/pthread_tls/Makefile @@ -8,6 +8,7 @@ BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove USEMODULE += posix USEMODULE += pthread +USEMODULE += pthread_tls TEST_ON_CI_WHITELIST += all diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index 87ce8102c85d..33fb2c9c3c10 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -249,7 +249,7 @@ DISABLE_MODULE += auto_init -include $(UNIT_TESTS:%=$(RIOTBASE)/tests/unittests/%/Makefile.include) DIRS += $(UNIT_TESTS) -BASELIBS += $(UNIT_TESTS:%=$(BINDIR)/%.a) +BASELIBS += $(UNIT_TESTS:%=$(BINDIR)/%.o) INCLUDES += -I$(RIOTBASE)/tests/unittests/common