diff --git a/Makefile.include b/Makefile.include index 26aeddd850..3d21e76e54 100644 --- a/Makefile.include +++ b/Makefile.include @@ -678,9 +678,11 @@ pkg-build-%: $(BUILDDEPS) $(QQ)"$(MAKE)" -C $(RIOTPKG)/$* clean: +ifndef MAKE_RESTARTS -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done -@rm -rf $(BINDIR) -@rm -rf $(SCANBUILD_OUTPUTDIR) +endif # Remove intermediates, but keep the .elf, .hex and .map etc. clean-intermediates: diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index 01ffba758a..7fa4feb30f 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -38,17 +38,10 @@ KCONFIG_MERGED_CONFIG = $(GENERATED_DIR)/merged.config # configuration symbols to the build system. KCONFIG_OUT_CONFIG = $(GENERATED_DIR)/out.config -# Include configuration symbols if available, only when not cleaning. This -# allows to check for Kconfig symbols in makefiles. -# Make tries to 'remake' all included files -# (see https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html). -# So if this file was included even when 'clean' is called, make would enter a -# loop, as it always is out-of-date. -# This has the side effect of requiring a Kconfig user to run 'clean' on a -# separate call (e.g. 'make clean && make all'), to get the symbols correctly. -ifneq ($(CLEAN),clean) - -include $(KCONFIG_OUT_CONFIG) -endif +# Include configuration symbols if available. This allows to check for Kconfig +# symbols in makefiles. Make tries to 'remake' all included files (see +# https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html). +-include $(KCONFIG_OUT_CONFIG) # Flag that indicates that the configuration has been edited KCONFIG_EDITED_CONFIG = $(GENERATED_DIR)/.editedconfig @@ -128,6 +121,9 @@ $(KCONFIG_MERGED_CONFIG): $(MERGECONFIG) $(KCONFIG_GENERATED_DEPENDENCIES) FORCE # Build a header file with all the Kconfig configurations. genconfig will avoid # any unnecessary rewrites of the header file if no configurations changed. +# The rule is not included when only `make clean` is called in order to keep the +# $(BINDIR) folder clean +ifneq (clean,$(MAKECMDGOALS)) $(KCONFIG_OUT_CONFIG) $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) &: $(KCONFIG_GENERATED_DEPENDENCIES) $(GENCONFIG) $(KCONFIG_MERGED_CONFIG) FORCE $(Q) \ KCONFIG_CONFIG=$(KCONFIG_MERGED_CONFIG) $(GENCONFIG) \ @@ -136,3 +132,5 @@ $(KCONFIG_OUT_CONFIG) $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) &: $(KCONFIG_GENERA $(if $(KCONFIG_SYNC_DEPS),--sync-deps $(KCONFIG_SYNC_DIR)) \ $(KCONFIG) endif + +endif