aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.lib
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.(none)>2005-07-25 16:10:36 -0400
committerSam Ravnborg <sam@mars.(none)>2005-07-25 16:10:36 -0400
commit8ec4b4ff1c89bb280e662b84eba503ca44abe836 (patch)
treed520638dd0288aba3cff6875928dfa7b7b20d2f1 /scripts/Makefile.lib
parent7c6b155fb49fbc63e0b30a1d49552693c0b45be7 (diff)
kbuild: introduce Kbuild.include
Kbuild.include is a placeholder for definitions originally present in both the top-level Makefile and scripts/Makefile.build. There were a slight difference in the filechk definition, so the most videly used version was kept and usr/Makefile was adopted for this syntax. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> ---
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r--scripts/Makefile.lib94
1 files changed, 0 insertions, 94 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6e079f38a2c6..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,84 +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# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
233# Usage:
234# $(Q)$(MAKE) $(build)=dir
235build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
236
237# filechk is used to check if the content of a generated file is updated.
238# Sample usage:
239# define filechk_sample
240# echo $KERNELRELEASE
241# endef
242# version.h : Makefile
243# $(call filechk,sample)
244# The rule defined shall write to stdout the content of the new file.
245# The existing file will be compared with the new one.
246# - If no file exist it is created
247# - If the content differ the new file is used
248# - If they are equal no change, and no timestamp update
249
250define filechk
251 $(Q)set -e; \
252 echo ' CHK $@'; \
253 mkdir -p $(dir $@); \
254 $(filechk_$(1)) $(2) > $@.tmp; \
255 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
256 rm -f $@.tmp; \
257 else \
258 echo ' UPD $@'; \
259 mv -f $@.tmp $@; \
260 fi
261endef
262 168