From 5ce0720bcf0bec8a0a6c919f4155fb6ef8f56342 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Mon, 23 Jul 2018 17:03:07 +0200 Subject: [PATCH 1/5] Makefile.include: Explain usage of FORCE and PHONY. --- Makefile.include | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index a809d22910..0915216c83 100644 --- a/Makefile.include +++ b/Makefile.include @@ -349,9 +349,20 @@ 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 -# Target can depend on FORCE to always rebuild but still let make use file -# modification timestamp (contrary to .PHONY). -# Use it for goals that may keep outputs unchanged when executed. + +# Targets that depend on FORCE will always be rebuilt. Contrary to a .PHONY +# target, they are considered real files and the modification timestamp is taken +# into account. +# +# FORCE is useful for goals that may keep outputs unchanged (for example, if it +# depends on environment or configuration variables). If the goal were .PHONY, it +# would trigger a rebuild of all its dependents regardless of file modification. +# +# As general rule, use .PHONY only for non-file targets. +# +# For more information, see: +# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html +# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html .PHONY: FORCE ELFFILE ?= $(BINDIR)/$(APPLICATION).elf From 8667758cb02d9da64ca58208c2e551d6c83b3a08 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Mon, 23 Jul 2018 17:04:15 +0200 Subject: [PATCH 2/5] Makefile.include: make pkgs Makefile.include FORCE instead of PHONY The rule to rebuild the Makefile.include(s) should be removed at some point. --- Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index 0915216c83..98d8c40927 100644 --- a/Makefile.include +++ b/Makefile.include @@ -323,7 +323,7 @@ include $(RIOTBASE)/drivers/Makefile.include $(RIOTPKG)/%/Makefile.include:: $(Q)"$(MAKE)" -C $(RIOTPKG)/$* Makefile.include -.PHONY: $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) +$(USEPKG:%=$(RIOTPKG)/%/Makefile.include): FORCE -include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) # Deduplicate includes without sorting them From b86a326de605350d37043a02d341f65c139f4f97 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Mon, 23 Jul 2018 17:05:44 +0200 Subject: [PATCH 3/5] Makefile.include: Make archives FORCE instead of PHONY. --- Makefile.include | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.include b/Makefile.include index 98d8c40927..e465eadfa5 100644 --- a/Makefile.include +++ b/Makefile.include @@ -451,11 +451,11 @@ ifneq (, $(filter clean, $(MAKECMDGOALS))) all $(BASELIBS) $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) $(BUILDDEPS): clean endif -.PHONY: pkg-prepare $(USEPKG:%=$(BINDIR)/%.a) +.PHONY: pkg-prepare pkg-prepare: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done -$(USEPKG:%=$(BINDIR)/%.a): $(BUILDDEPS) +$(USEPKG:%=$(BINDIR)/%.a): $(BUILDDEPS) FORCE @mkdir -p $(BINDIR) $(QQ)"$(MAKE)" -C $(RIOTPKG)/$(patsubst $(BINDIR)/%.a,%,$@) From c60a06b0580da01278d5dda09f3ffb015eb2df01 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Mon, 23 Jul 2018 17:06:29 +0200 Subject: [PATCH 4/5] Makefile.include: Make eclipsesym.xml FORCE (not PHONY). --- Makefile.include | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.include b/Makefile.include index e465eadfa5..01eefcd9f2 100644 --- a/Makefile.include +++ b/Makefile.include @@ -525,11 +525,11 @@ objdump: # Generate an XML file containing all macro definitions and include paths for # use in Eclipse CDT -.PHONY: eclipsesym eclipsesym.xml $(CURDIR)/eclipsesym.xml +.PHONY: eclipsesym eclipsesym.xml eclipsesym: $(CURDIR)/eclipsesym.xml eclipsesym.xml: $(CURDIR)/eclipsesym.xml -$(CURDIR)/eclipsesym.xml: +$(CURDIR)/eclipsesym.xml: FORCE $(Q)printf "%s\n" $(CC) $(CFLAGS_WITH_MACROS) $(INCLUDES) | \ $(RIOTTOOLS)/eclipsesym/cmdline2xml.sh > $@ From 2ba86833153964292dff3f9191c08000be205698 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Mon, 23 Jul 2018 17:06:56 +0200 Subject: [PATCH 5/5] Makefile.include: Make config header FORCE instead of PHONY. --- Makefile.include | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index 01eefcd9f2..7233704fdb 100644 --- a/Makefile.include +++ b/Makefile.include @@ -642,10 +642,9 @@ endif include $(RIOTTOOLS)/desvirt/Makefile.desvirt # 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 +# make it depend on FORCE to 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. -.PHONY: $(RIOTBUILD_CONFIG_HEADER_C) -$(RIOTBUILD_CONFIG_HEADER_C): +$(RIOTBUILD_CONFIG_HEADER_C): FORCE @mkdir -p '$(dir $@)' $(Q)'$(RIOTTOOLS)/genconfigheader/genconfigheader.sh' '$@' $(CFLAGS_WITH_MACROS)