aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r--scripts/Makefile.lib99
1 files changed, 0 insertions, 99 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 7cf75cc4f849..0f81dcfd6909 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -1,13 +1,3 @@
1# ===========================================================================
2# kbuild: Generic definitions
3# ===========================================================================
4
5# Standard vars
6
7comma := ,
8empty :=
9space := $(empty) $(empty)
10
11# Backward compatibility - to be removed... 1# Backward compatibility - to be removed...
12extra-y += $(EXTRA_TARGETS) 2extra-y += $(EXTRA_TARGETS)
13# Figure out what we need to build from the various variables 3# Figure out what we need to build from the various variables
@@ -84,10 +74,6 @@ multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
84subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 74subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
85obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) 75obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
86 76
87# The temporary file to save gcc -MD generated dependencies must not
88# contain a comma
89depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
90
91# These flags are needed for modversions and compiling, so we define them here 77# These flags are needed for modversions and compiling, so we define them here
92# already 78# already
93# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will 79# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
@@ -179,89 +165,4 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
179quiet_cmd_gzip = GZIP $@ 165quiet_cmd_gzip = GZIP $@
180cmd_gzip = gzip -f -9 < $< > $@ 166cmd_gzip = gzip -f -9 < $< > $@
181 167
182# ===========================================================================
183# Generic stuff
184# ===========================================================================
185
186ifneq ($(KBUILD_NOCMDDEP),1)
187# Check if both arguments has same arguments. Result in empty string if equal
188# User may override this check using make KBUILD_NOCMDDEP=1
189arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) )
190
191endif
192
193# echo command. Short version is $(quiet) equals quiet, otherwise full command
194echo-cmd = $(if $($(quiet)cmd_$(1)), \
195 echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';)
196
197# function to only execute the passed command if necessary
198# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
199# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
200#
201if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
202 @set -e; \
203 $(echo-cmd) \
204 $(cmd_$(1)); \
205 echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
206
207
208# execute the command and also postprocess generated .d dependencies
209# file
210
211if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
212 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
213 @set -e; \
214 $(echo-cmd) \
215 $(cmd_$(1)); \
216 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
217 rm -f $(depfile); \
218 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
219
220# Usage: $(call if_changed_rule,foo)
221# will check if $(cmd_foo) changed, or any of the prequisites changed,
222# and if so will execute $(rule_foo)
223
224if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
225 @set -e; \
226 $(rule_$(1)))
227
228# If quiet is set, only print short version of command
229
230cmd = @$(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
231
232# $(call descend,<dir>,<target>)
233# Recursively call a sub-make in <dir> with target <target>
234# Usage is deprecated, because make do not see this as an invocation of make.
235descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
236
237# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
238# Usage:
239# $(Q)$(MAKE) $(build)=dir
240build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
241
242# filechk is used to check if the content of a generated file is updated.
243# Sample usage:
244# define filechk_sample
245# echo $KERNELRELEASE
246# endef
247# version.h : Makefile
248# $(call filechk,sample)
249# The rule defined shall write to stdout the content of the new file.
250# The existing file will be compared with the new one.
251# - If no file exist it is created
252# - If the content differ the new file is used
253# - If they are equal no change, and no timestamp update
254
255define filechk
256 $(Q)set -e; \
257 echo ' CHK $@'; \
258 mkdir -p $(dir $@); \
259 $(filechk_$(1)) $(2) > $@.tmp; \
260 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
261 rm -f $@.tmp; \
262 else \
263 echo ' UPD $@'; \
264 mv -f $@.tmp $@; \
265 fi
266endef
267 168