mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
Makefiles: (application) support for SRC in subfolders
This commit is contained in:
parent
00e25adfe3
commit
b96536d1ba
@ -104,20 +104,30 @@ ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)/$(MODULE)/%.o)
|
||||
OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ) $(GENOBJC)
|
||||
DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d)
|
||||
|
||||
SRC_ALL := $(SRC) $(SRCXX) $(ASMSRC) $(ASSMSRC)
|
||||
SUBDIRS_IN_DIRS := $(filter $(DIRS), $(abspath $(sort $(dir $(SRC_ALL)))))
|
||||
ifneq (,$(SUBDIRS_IN_DIRS))
|
||||
$(warning Files of the following subdirectories are selected \
|
||||
both as RIOT modules (using DIRS) and directly as sourcefiles (using SRC): \
|
||||
$(patsubst $(CURDIR)/%,./%, $(SUBDIRS_IN_DIRS)). \
|
||||
Please select a single approach for each subfolder to prevent linking errors.)
|
||||
endif
|
||||
SUBDIRS := $(filter-out $(BINDIR)/$(MODULE)/, $(dir $(OBJ)))
|
||||
|
||||
include $(RIOTMAKE)/blob.inc.mk
|
||||
include $(RIOTMAKE)/tools/fixdep.inc.mk
|
||||
|
||||
$(BINDIR)/$(MODULE)/:
|
||||
$(BINDIR)/$(MODULE)/ $(SUBDIRS):
|
||||
$(Q)mkdir -p $@
|
||||
|
||||
OLD_OBJECTS = $(wildcard $(BINDIR)/$(MODULE)/*.o)
|
||||
OLD_OBJECTS = $(wildcard $(BINDIR)/$(MODULE)/*.o $(BINDIR)/$(MODULE)/**/*.o)
|
||||
|
||||
# do not clean objects from bindist modules
|
||||
ifeq (,$(filter $(MODULE),$(BIN_USEMODULE)))
|
||||
OBJECTS_TO_REMOVE = $(filter-out $(OBJ),$(OLD_OBJECTS))
|
||||
endif
|
||||
|
||||
$(MODULE).module compile-commands $(OBJ): | $(BINDIR)/$(MODULE)/
|
||||
$(MODULE).module compile-commands $(OBJ): | $(BINDIR)/$(MODULE)/ $(SUBDIRS)
|
||||
|
||||
$(MODULE).module: $(OBJ) $(if $(OBJECTS_TO_REMOVE),$(MODULE).cleanup) | $(DIRS:%=ALL--%)
|
||||
|
||||
|
||||
@ -720,6 +720,7 @@ COMPILE_COMMANDS_FLAGS ?= --clangd
|
||||
compile-commands: $(COMPILE_COMMANDS_PATH)
|
||||
%/compile_commands.json: $(BUILDDEPS)
|
||||
$(Q)DIRS="$(DIRS)" APPLICATION_BLOBS="$(BLOBS)" \
|
||||
APPLICATION_SRC="$(SRC)" APPLICATION_SRCXX="$(SRCXX)" APPLICATION_ASMSRC="$(ASMSRC)" APPLICATION_ASSMSRC="$(ASSMSRC)" \
|
||||
"$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk compile-commands
|
||||
$(Q)$(RIOTTOOLS)/compile_commands/compile_commands.py $(COMPILE_COMMANDS_FLAGS) $(BINDIR) \
|
||||
> $@
|
||||
@ -744,6 +745,7 @@ $(ELFFILE): $(BASELIBS) $(ARCHIVES) $(LD_SCRIPTS)
|
||||
|
||||
$(APPLICATION_MODULE).module: pkg-build $(BUILDDEPS)
|
||||
$(Q)DIRS="$(DIRS)" APPLICATION_BLOBS="$(BLOBS)" \
|
||||
APPLICATION_SRC="$(SRC)" APPLICATION_SRCXX="$(SRCXX)" APPLICATION_ASMSRC="$(ASMSRC)" APPLICATION_ASSMSRC="$(ASSMSRC)" \
|
||||
"$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk
|
||||
$(APPLICATION_MODULE).module: FORCE
|
||||
|
||||
|
||||
@ -3,17 +3,20 @@ MODULE = $(APPLICATION_MODULE)
|
||||
DIRS += $(RIOTCPU)/$(CPU) $(BOARDDIR)
|
||||
DIRS += $(RIOTBASE)/core $(RIOTBASE)/core/lib $(RIOTBASE)/drivers $(RIOTBASE)/sys
|
||||
|
||||
# For regular modules, adding files to BLOBS to their Makefile is sufficient to
|
||||
# create the corresponding headers.
|
||||
# For regular modules, adding files to BLOBS, SRC, SRCXX, ASMSRC or ASSMSRC
|
||||
# in their Makefile is sufficient to explicitely set the variables.
|
||||
#
|
||||
# Application modules are different, as they use this makefile to build, thus
|
||||
# application level variables are not available unless exported.
|
||||
#
|
||||
# But exporting e.g., BLOBS, would pre-set the variable for all
|
||||
# submakefiles.
|
||||
# But exporting would pre-set the variables for all submakefiles.
|
||||
#
|
||||
# As workaround, $(RIOTBASE)/Makefile.include passes BLOBS to this
|
||||
# Makefile as APPLICATION_BLOBS.
|
||||
BLOBS = $(APPLICATION_BLOBS)
|
||||
# As workaround, $(RIOTBASE)/Makefile.include passes the above-listed variables
|
||||
# to this Makefile as APPLICATION_*.
|
||||
BLOBS = $(APPLICATION_BLOBS)
|
||||
SRC = $(APPLICATION_SRC)
|
||||
SRCXX = $(APPLICATION_SRCXX)
|
||||
ASMSRC = $(APPLICATION_ASMSRC)
|
||||
ASSMSRC = $(APPLICATION_ASSMSRC)
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user