summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-01-17 05:02:43 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-01-27 19:11:17 -0500
commitafa974b771281fd89e8fdcb71152152f17fb8303 (patch)
treeb6a3de04148c2207d3cd094b70820160e24d0420
parent5d680056cb6de18f0221e321ee51d60ccd700781 (diff)
kbuild: add real-prereqs shorthand for $(filter-out FORCE,$^)
In Kbuild, if_changed and friends must have FORCE as a prerequisite. Hence, $(filter-out FORCE,$^) or $(filter-out $(PHONY),$^) is a common idiom to get the names of all the prerequisites except phony targets. Add real-prereqs as a shorthand. Note: We cannot replace $(filter %.o,$^) in cmd_link_multi-m because $^ may include auto-generated dependencies from the .*.cmd file when a single object module is changed into a multi object module. Refer to commit 69ea912fda74 ("kbuild: remove unneeded link_multi_deps"). I added some comment to avoid accidental breakage. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Rob Herring <robh@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/Makefile2
-rw-r--r--arch/mips/boot/Makefile2
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/s390/boot/Makefile2
-rw-r--r--arch/x86/realmode/rm/Makefile3
-rw-r--r--scripts/Kbuild.include4
-rw-r--r--scripts/Makefile.build9
-rw-r--r--scripts/Makefile.lib18
-rw-r--r--scripts/Makefile.modpost2
9 files changed, 25 insertions, 19 deletions
diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/devicetree/bindings/Makefile
index 6e5cef0ed6fb..e4eb5d1ea3b5 100644
--- a/Documentation/devicetree/bindings/Makefile
+++ b/Documentation/devicetree/bindings/Makefile
@@ -15,7 +15,7 @@ DT_TMP_SCHEMA := processed-schema.yaml
15extra-y += $(DT_TMP_SCHEMA) 15extra-y += $(DT_TMP_SCHEMA)
16 16
17quiet_cmd_mk_schema = SCHEMA $@ 17quiet_cmd_mk_schema = SCHEMA $@
18 cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(filter-out FORCE, $^) 18 cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs)
19 19
20DT_DOCS = $(shell cd $(srctree)/$(src) && find * -name '*.yaml') 20DT_DOCS = $(shell cd $(srctree)/$(src) && find * -name '*.yaml')
21DT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS)) 21DT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS))
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 35704c28a28b..3ce4dd578370 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -115,7 +115,7 @@ endif
115targets += vmlinux.its.S 115targets += vmlinux.its.S
116 116
117quiet_cmd_its_cat = CAT $@ 117quiet_cmd_its_cat = CAT $@
118 cmd_its_cat = cat $(filter-out $(PHONY), $^) >$@ 118 cmd_its_cat = cat $(real-prereqs) >$@
119 119
120$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE 120$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
121 $(call if_changed,its_cat) 121 $(call if_changed,its_cat)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 0e8dadd011bc..73d1f3562978 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -218,7 +218,7 @@ quiet_cmd_bootas = BOOTAS $@
218 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 218 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
219 219
220quiet_cmd_bootar = BOOTAR $@ 220quiet_cmd_bootar = BOOTAR $@
221 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ 221 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@
222 222
223$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE 223$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
224 $(call if_changed_dep,bootcc) 224 $(call if_changed_dep,bootcc)
diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
index b4d8a426ec74..11ca8795b74a 100644
--- a/arch/s390/boot/Makefile
+++ b/arch/s390/boot/Makefile
@@ -58,7 +58,7 @@ $(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
58 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 58 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
59 59
60quiet_cmd_ar = AR $@ 60quiet_cmd_ar = AR $@
61 cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(filter $(OBJECTS), $^) 61 cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
62 62
63$(obj)/startup.a: $(OBJECTS) FORCE 63$(obj)/startup.a: $(OBJECTS) FORCE
64 $(call if_changed,ar) 64 $(call if_changed,ar)
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 4463fa72db94..394377c9f7f8 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -37,8 +37,7 @@ REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))
37sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p' 37sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'
38 38
39quiet_cmd_pasyms = PASYMS $@ 39quiet_cmd_pasyms = PASYMS $@
40 cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \ 40 cmd_pasyms = $(NM) $(real-prereqs) | sed $(sed-pasyms) | sort | uniq > $@
41 sed $(sed-pasyms) | sort | uniq > $@
42 41
43targets += pasyms.h 42targets += pasyms.h
44$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE 43$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 30816037036e..d93250b33bf6 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -24,6 +24,10 @@ depfile = $(subst $(comma),_,$(dot-target).d)
24basetarget = $(basename $(notdir $@)) 24basetarget = $(basename $(notdir $@))
25 25
26### 26###
27# real prerequisites without phony targets
28real-prereqs = $(filter-out $(PHONY), $^)
29
30###
27# Escape single quote for use in echo statements 31# Escape single quote for use in echo statements
28escsq = $(subst $(squote),'\$(squote)',$1) 32escsq = $(subst $(squote),'\$(squote)',$1)
29 33
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 681ab58a1548..9800178fdcd2 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -399,8 +399,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
399ifdef builtin-target 399ifdef builtin-target
400 400
401quiet_cmd_ar_builtin = AR $@ 401quiet_cmd_ar_builtin = AR $@
402 cmd_ar_builtin = rm -f $@; \ 402 cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
403 $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^)
404 403
405$(builtin-target): $(real-obj-y) FORCE 404$(builtin-target): $(real-obj-y) FORCE
406 $(call if_changed,ar_builtin) 405 $(call if_changed,ar_builtin)
@@ -428,7 +427,7 @@ ifdef lib-target
428quiet_cmd_link_l_target = AR $@ 427quiet_cmd_link_l_target = AR $@
429 428
430# lib target archives do get a symbol table and index 429# lib target archives do get a symbol table and index
431cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) 430cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
432 431
433$(lib-target): $(lib-y) FORCE 432$(lib-target): $(lib-y) FORCE
434 $(call if_changed,link_l_target) 433 $(call if_changed,link_l_target)
@@ -453,6 +452,10 @@ targets += $(obj)/lib-ksyms.o
453 452
454endif 453endif
455 454
455# NOTE:
456# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
457# module is turned into a multi object module, $^ will contain header file
458# dependencies recorded in the .*.cmd file.
456quiet_cmd_link_multi-m = LD [M] $@ 459quiet_cmd_link_multi-m = LD [M] $@
457cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) 460cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis)
458 461
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ebaa348c9981..c6fc295e0c48 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -231,7 +231,7 @@ $(obj)/%: $(src)/%_shipped
231# --------------------------------------------------------------------------- 231# ---------------------------------------------------------------------------
232 232
233quiet_cmd_ld = LD $@ 233quiet_cmd_ld = LD $@
234cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ 234 cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@
235 235
236# Objcopy 236# Objcopy
237# --------------------------------------------------------------------------- 237# ---------------------------------------------------------------------------
@@ -243,7 +243,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
243# --------------------------------------------------------------------------- 243# ---------------------------------------------------------------------------
244 244
245quiet_cmd_gzip = GZIP $@ 245quiet_cmd_gzip = GZIP $@
246 cmd_gzip = cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@ 246 cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@
247 247
248# DTC 248# DTC
249# --------------------------------------------------------------------------- 249# ---------------------------------------------------------------------------
@@ -321,7 +321,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
321# append the size as a 32-bit littleendian number as gzip does. 321# append the size as a 32-bit littleendian number as gzip does.
322size_append = printf $(shell \ 322size_append = printf $(shell \
323dec_size=0; \ 323dec_size=0; \
324for F in $(filter-out FORCE,$^); do \ 324for F in $(real-prereqs); do \
325 fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ 325 fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \
326 dec_size=$$(expr $$dec_size + $$fsize); \ 326 dec_size=$$(expr $$dec_size + $$fsize); \
327done; \ 327done; \
@@ -335,19 +335,19 @@ printf "%08x\n" $$dec_size | \
335) 335)
336 336
337quiet_cmd_bzip2 = BZIP2 $@ 337quiet_cmd_bzip2 = BZIP2 $@
338 cmd_bzip2 = (cat $(filter-out FORCE,$^) | bzip2 -9 && $(size_append)) > $@ 338 cmd_bzip2 = (cat $(real-prereqs) | bzip2 -9 && $(size_append)) > $@
339 339
340# Lzma 340# Lzma
341# --------------------------------------------------------------------------- 341# ---------------------------------------------------------------------------
342 342
343quiet_cmd_lzma = LZMA $@ 343quiet_cmd_lzma = LZMA $@
344 cmd_lzma = (cat $(filter-out FORCE,$^) | lzma -9 && $(size_append)) > $@ 344 cmd_lzma = (cat $(real-prereqs) | lzma -9 && $(size_append)) > $@
345 345
346quiet_cmd_lzo = LZO $@ 346quiet_cmd_lzo = LZO $@
347 cmd_lzo = (cat $(filter-out FORCE,$^) | lzop -9 && $(size_append)) > $@ 347 cmd_lzo = (cat $(real-prereqs) | lzop -9 && $(size_append)) > $@
348 348
349quiet_cmd_lz4 = LZ4 $@ 349quiet_cmd_lz4 = LZ4 $@
350 cmd_lz4 = (cat $(filter-out FORCE,$^) | lz4c -l -c1 stdin stdout && \ 350 cmd_lz4 = (cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \
351 $(size_append)) > $@ 351 $(size_append)) > $@
352 352
353# U-Boot mkimage 353# U-Boot mkimage
@@ -390,11 +390,11 @@ quiet_cmd_uimage = UIMAGE $@
390# big dictionary would increase the memory usage too much in the multi-call 390# big dictionary would increase the memory usage too much in the multi-call
391# decompression mode. A BCJ filter isn't used either. 391# decompression mode. A BCJ filter isn't used either.
392quiet_cmd_xzkern = XZKERN $@ 392quiet_cmd_xzkern = XZKERN $@
393cmd_xzkern = (cat $(filter-out FORCE,$^) | \ 393 cmd_xzkern = (cat $(real-prereqs) | \
394 sh $(srctree)/scripts/xz_wrap.sh && $(size_append)) > $@ 394 sh $(srctree)/scripts/xz_wrap.sh && $(size_append)) > $@
395 395
396quiet_cmd_xzmisc = XZMISC $@ 396quiet_cmd_xzmisc = XZMISC $@
397cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ 397 cmd_xzmisc = (cat $(real-prereqs) | \
398 xz --check=crc32 --lzma2=dict=1MiB) > $@ 398 xz --check=crc32 --lzma2=dict=1MiB) > $@
399 399
400# ASM offsets 400# ASM offsets
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 7d4af0d0accb..c0b7f526f95e 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -122,7 +122,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
122 cmd_ld_ko_o = \ 122 cmd_ld_ko_o = \
123 $(LD) -r $(KBUILD_LDFLAGS) \ 123 $(LD) -r $(KBUILD_LDFLAGS) \
124 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 124 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
125 -o $@ $(filter-out FORCE,$^) ; \ 125 -o $@ $(real-prereqs) ; \
126 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 126 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
127 127
128$(modules): %.ko :%.o %.mod.o FORCE 128$(modules): %.ko :%.o %.mod.o FORCE