Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile.include: fully define BASELIBS before using its value #9451

Merged
Merged
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
61 changes: 38 additions & 23 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,33 @@ APPLICATION_MODULE ?= application_$(APPLICATION)
BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a
BASELIBS += $(APPDEPS)


# add extra include paths for packages in $(USEMODULE)
export USEMODULE_INCLUDES =

include $(RIOTBASE)/sys/Makefile.include
include $(RIOTBASE)/drivers/Makefile.include

# include Makefile.includes for packages in $(USEPKG)
$(RIOTPKG)/%/Makefile.include::
$(Q)"$(MAKE)" -C $(RIOTPKG)/$* Makefile.include

$(info $(USEPKG:%=$(RIOTPKG)/%/Makefile.include))
.PHONY: $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)

USEMODULE_INCLUDES_ = $(shell echo $(USEMODULE_INCLUDES) | tr ' ' '\n' | awk '!a[$$0]++' | tr '\n' ' ')

INCLUDES += $(USEMODULE_INCLUDES_:%=-I%)


# include bindist target
include $(RIOTMAKE)/bindist.inc.mk

# Add all USEMODULE modules to CFLAGS and populate BASELIBS
include $(RIOTMAKE)/modules.inc.mk


.PHONY: all link clean flash flash-only term doc debug debug-server reset objdump help info-modules
.PHONY: print-size elffile binfile hexfile
.PHONY: ..in-docker-container
Expand All @@ -335,6 +362,9 @@ LINKFLAGPREFIX ?= -Wl,

DIRS += $(EXTERNAL_MODULE_DIRS)

# Save value to verify it is not modified later
_BASELIBS_VALUE_BEFORE_USAGE := $(BASELIBS)

# Linker rule
$(ELFFILE): FORCE
ifeq ($(BUILDOSXNATIVE),1)
Expand Down Expand Up @@ -391,28 +421,11 @@ endef
@$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)'
@$(COLOR_ECHO)

# add extra include paths for packages in $(USEMODULE)
export USEMODULE_INCLUDES =

include $(RIOTBASE)/sys/Makefile.include
include $(RIOTBASE)/drivers/Makefile.include

# The `clean` needs to be serialized before everything else.
ifneq (, $(filter clean, $(MAKECMDGOALS)))
all $(BASELIBS) $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) $(RIOTBUILD_CONFIG_HEADER_C) pkg-prepare: clean
endif

# include Makefile.includes for packages in $(USEPKG)
$(RIOTPKG)/%/Makefile.include::
$(Q)"$(MAKE)" -C $(RIOTPKG)/$* Makefile.include

.PHONY: $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)

USEMODULE_INCLUDES_ = $(shell echo $(USEMODULE_INCLUDES) | tr ' ' '\n' | awk '!a[$$0]++' | tr '\n' ' ')

INCLUDES += $(USEMODULE_INCLUDES_:%=-I%)

.PHONY: pkg-prepare $(USEPKG:%=$(BINDIR)/%.a)
pkg-prepare:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done
Expand Down Expand Up @@ -603,12 +616,6 @@ endif
# Include desvirt Makefile
include $(RIOTTOOLS)/desvirt/Makefile.desvirt

# include bindist target
include $(RIOTMAKE)/bindist.inc.mk

# Add all USEMODULE modules to CFLAGS
include $(RIOTMAKE)/modules.inc.mk

# Build a header file with all common macro definitions and undefinitions
# make it phony to force re-run of the script every time even if the file exists
# The script will only touch the file if anything has changed since last time.
Expand Down Expand Up @@ -640,4 +647,12 @@ ifneq (all, $(.DEFAULT_GOAL))
$(error .DEFAULT_GOAL := $(.DEFAULT_GOAL))
endif


# Detect if BASELIBS changed since its first use
ifneq ($(_BASELIBS_VALUE_BEFORE_USAGE),$(BASELIBS))
$(warning $(sort $(filter-out $(_BASELIBS_VALUE_BEFORE_USAGE), $(BASELIBS)) \
$(filter-out $(BASELIBS), $(_BASELIBS_VALUE_BEFORE_USAGE))))
$(error BASELIBS value changed)
endif

endif # BOARD=none