make-3.81 excludes PHONY dependencies from $?, make 3.82+ includes them.
This leads to always rebuilding klibc targets that depend on .PHONY
dependencies. From the make 3.82 release notes
https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html:
* WARNING: Backward-incompatibility!
The '$?' variable now contains all prerequisites that caused the
target to
be considered out of date, even if they do not exist (previously only
existing targets were provided in $?).
Linux fixed this with commit 4f1933620f57 ("kbuild: change kbuild to not
rely on incorrect GNU make behavior").
Similar to Linux, klibc if_changed already excludes $(PHONY) from $?
when determining if a target is up-to-date. Klibc also has a $(PHONY)
list of phony targets. But klibc does not add many .PHONY targets to
$(PHONY).
Changes in this patch:
- add previously defined .PHONY targets to PHONY, so existing if_changed
filtering applies to them as well
- declare $(PHONY) targets as .PHONY
Signed-off-by: Greg Thelen <gthelen at google.com>
---
scripts/Kbuild.install | 10 +++++++---
scripts/Kbuild.klibc | 8 ++++++--
scripts/Makefile.clean | 8 ++++++--
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
index 8af569777cc3..bafd42328ddb 100644
--- a/scripts/Kbuild.install
+++ b/scripts/Kbuild.install
@@ -14,7 +14,7 @@
SHLIBDIR = /lib
# First rule
-.PHONY: __install install-rule
+PHONY := __install install-rule
__install:
# Install commands
@@ -64,7 +64,7 @@ else
endif
# Descending
-.PHONY: $(subdir-)
+PHONY += $(subdir-)
$(subdir-):
$(Q)$(MAKE) KLIBC_INSTALL=1 \
-f $(srctree)/scripts/Kbuild.install obj=$@
@@ -84,7 +84,7 @@ else
# 1) Create directories, install headers and man pages
# 2) Tell that we now install binaries
# 3) Install binaries by descending
-.PHONY: header footer descend
+PHONY += header footer descend
header:
$(Q)echo " INSTALL headers + man pages to
$(INSTALLROOT)$(INSTALLDIR)"
$(Q)mkdir -p $(INSTALLROOT)$(bindir)
@@ -111,3 +111,7 @@ descend: footer
__install: descend
@:
endif
+
+# Declare the contents of the PHONY variable as phony. We keep the variable
for
+# if_changed.
+.PHONY: $(PHONY)
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index f500d5358ef6..f147a37309e3 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -54,7 +54,7 @@ src := $(obj)
# Preset target and make sure it is a ':=' variable
targets :
-.phony: __build
+PHONY := __build
__build:
# Read .config if it exist, otherwise ignore
@@ -374,7 +374,7 @@ endif
# Descending
# ---------------------------------------------------------------------------
-.PHONY: $(subdir-y) $(kprog-dirs) $(klib-dirs)
+PHONY += $(subdir-y) $(kprog-dirs) $(klib-dirs)
$(sort $(subdir-y) $(kprog-dirs) $(klib-dirs)): $(lib-target)
$(Q)$(MAKE) $(klibc)=$@
@@ -419,3 +419,7 @@ endif
# Usage:
# $(Q)$(MAKE) $(klibc)=dir
klibc := -rR -f $(srctree)/scripts/Kbuild.klibc obj
+
+# Declare the contents of the PHONY variable as phony. We keep the variable
for
+# if_changed.
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index a5887492bac5..abc4e3fc06fe 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -4,7 +4,7 @@
src := $(obj)
-.PHONY: __clean
+.PHONY := __clean
__clean:
# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
@@ -83,10 +83,14 @@ endif
# Descending
# ---------------------------------------------------------------------------
-.PHONY: $(subdirs)
+PHONY += $(subdirs)
$(subdirs):
$(Q)$(MAKE) $(clean)=$@
# If quiet is set, only print short version of command
cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))'
&&) $(cmd_$(1))
+
+# Declare the contents of the PHONY variable as phony. We keep the variable
for
+# if_changed.
+.PHONY: $(PHONY)
--
2.18.0.rc2.346.g013aa6912e-goog