Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -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:
@:
Expand Down Expand Up @@ -89,14 +89,9 @@ include $(RIOTMAKE)/tools/fixdep.inc.mk
$(BINDIR)/$(MODULE)/:
$(Q)mkdir -p $@

$(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/
$(MODULE).module $(OBJ): | $(BINDIR)/$(MODULE)/

# 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)
Expand Down
4 changes: 3 additions & 1 deletion Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
82 changes: 21 additions & 61 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -452,7 +446,7 @@ endif
APPLICATION_MODULE ?= application_$(APPLICATION)

# the binaries to link
BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a
BASELIBS += $(APPLICATION_MODULE).module
BASELIBS += $(APPDEPS)


Expand Down Expand Up @@ -562,38 +556,48 @@ 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)

# 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)
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)
link: ..compiler-check ..build-message $(BASELIBS) $(ARCHIVES) ..module-check
endif # RIOTNOLINK

$(ELFFILE): $(BASELIBS)
$(ELFFILE): $(BASELIBS) $(ARCHIVES)
$(Q)$(_LINK) -o $@

$(BINDIR)/$(APPLICATION_MODULE).a: pkg-build $(BUILDDEPS)
.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
$(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)
Expand All @@ -607,50 +611,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
Expand Down Expand Up @@ -680,7 +640,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:
Expand Down
2 changes: 0 additions & 2 deletions boards/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,3 @@ eval-gprof:

eval-cachegrind:
$(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)

UNDEF += $(BINDIR)/cpu/startup.o
2 changes: 0 additions & 2 deletions cpu/arm7_common/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions cpu/cc26x0/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
CPU_VARIANT = x0

VECTORS_O = $(BINDIR)/cc26xx_cc13xx/vectors.o

ROM_START_ADDR ?= 0x00000000
RAM_START_ADDR ?= 0x20000000

Expand Down
2 changes: 0 additions & 2 deletions cpu/cc26x2_cc13x2/Makefile.include
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions cpu/efm32/families/efm32gg/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions cpu/efm32/families/efm32lg/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions cpu/efm32/families/efm32pg12b/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions cpu/efm32/families/efm32pg1b/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions cpu/efm32/families/efr32mg12p/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions cpu/efm32/families/efr32mg1p/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cpu/esp8266/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions cpu/esp_common/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions cpu/kinetis/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions cpu/msp430_common/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion cpu/native/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 0 additions & 20 deletions dist/ar-wrapper

This file was deleted.

Loading