Skip to content

Commit

Permalink
Merge pull request #16945 from leandrolanzieri/pr/build_system/delete…
Browse files Browse the repository at this point in the history
…_non_selected_objects

Makefile.base: cleanup non selected source object files
  • Loading branch information
fjmolinas authored Oct 5, 2021
2 parents 93bff48 + 452333c commit 58726bf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _MOD := $(shell basename $(CURDIR))
MODULE ?= $(_MOD)

.PHONY: all clean $(DIRS:%=ALL--%) $(DIRS:%=CLEAN--%) $(MODULE).module \
compile-commands $(DIRS:%=COMPILE-COMMANDS--%)
compile-commands $(DIRS:%=COMPILE-COMMANDS--%) $(MODULE).cleanup

all: $(MODULE).module ..nothing

Expand Down Expand Up @@ -113,9 +113,16 @@ include $(RIOTMAKE)/tools/fixdep.inc.mk
$(BINDIR)/$(MODULE)/:
$(Q)mkdir -p $@

OLD_OBJECTS = $(wildcard $(BINDIR)/$(MODULE)/*.o)
OBJECTS_TO_REMOVE = $(filter-out $(OBJ),$(OLD_OBJECTS))

$(MODULE).module compile-commands $(OBJ): | $(BINDIR)/$(MODULE)/

$(MODULE).module: $(OBJ) | $(DIRS:%=ALL--%)
$(MODULE).module: $(OBJ) $(if $(OBJECTS_TO_REMOVE),$(MODULE).cleanup) | $(DIRS:%=ALL--%)

$(MODULE).cleanup:
$(Q)# cleanup non selected source files objects
$(Q)$(RM) $(OBJECTS_TO_REMOVE)

CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS)
Expand Down

0 comments on commit 58726bf

Please sign in to comment.