diff --git a/Makefile.base b/Makefile.base index 9bd0ebe62daa..c973425b0f1d 100644 --- a/Makefile.base +++ b/Makefile.base @@ -118,7 +118,9 @@ 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: @# cleanup non selected source files objects @$(RM) $(OBJECTS_TO_REMOVE)