• Home
  • Raw
  • Download

Lines Matching +full:sig +full:- +full:dir +full:- +full:cmd

1 # SPDX-License-Identifier: GPL-2.0
11 space_escape := _-_SPACE_-_
16 dot-target = $(dir $@).$(notdir $@)
19 # The temporary file to save gcc -MMD generated dependencies must not
21 depfile = $(subst $(comma),_,$(dot-target).d)
29 real-prereqs = $(filter-out $(PHONY), $^)
56 # - If no file exist it is created
57 # - If the content differ the new file is used
58 # - If they are equal no change, and no timestamp update
60 $(Q)set -e; \
61 mkdir -p $(dir $@); \
62 trap "rm -f $(dot-target).tmp" EXIT; \
63 { $(filechk_$(1)); } > $(dot-target).tmp; \
64 if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
66 mv -f $(dot-target).tmp $@; \
74 # cc-cross-prefix
75 # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
83 cc-cross-prefix = $(firstword $(foreach c, $(1), \
84 $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c))))
89 # try-run
90 # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
93 try-run = $(shell set -e; \
96 mkdir -p $(TMPOUT); \
97 trap "rm -rf $(TMPOUT)" EXIT; \
103 # as-option
104 # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
106 as-option = $(call try-run,\
107 $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
109 # as-instr
110 # Usage: cflags-y += $(call as-instr,instr,option1,option2)
112 as-instr = $(call try-run,\
113 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
115 # __cc-option
116 # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
117 __cc-option = $(call try-run,\
118 $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
120 # cc-option
121 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
123 cc-option = $(call __cc-option, $(CC),\
126 # cc-option-yn
127 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
128 cc-option-yn = $(call try-run,\
129 $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
131 # cc-disable-warning
132 # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
133 cc-disable-warning = $(call try-run,\
134 …$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wn…
136 # cc-ifversion
137 # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
138 cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
140 # ld-option
141 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
142 ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
144 # ld-version
146 ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
148 # ld-ifversion
149 # Usage: $(call ld-ifversion, -ge, 22252, y)
150 ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
155 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
157 # $(Q)$(MAKE) $(build)=dir
158 build := -f $(srctree)/scripts/Makefile.build obj
161 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
163 # $(Q)$(MAKE) $(dtbinst)=dir
164 dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
167 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
169 # $(Q)$(MAKE) $(clean)=dir
170 clean := -f $(srctree)/scripts/Makefile.clean obj
174 echo-cmd = $(if $($(quiet)cmd_$(1)),\
175 echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
177 # sink stdout for 'make -s'
185 # the interrupted recipe. So, you can safely stop the build by Ctrl-C (Make
198 delete-on-interrupt = \
199 $(if $(filter-out $(PHONY), $@), \
200 $(foreach sig, HUP INT QUIT TERM PIPE, \
201 trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);))
204 cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(delete-on-interrupt) $(cmd_$(1))
207 # if_changed - execute command if any prerequisite is newer than
209 # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies
211 # if_changed_rule - as if_changed but execute rule instead
217 cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
220 cmd-check = $(if $(strip $(cmd_$@)),,1)
223 # Replace >$< with >$$< to preserve $ when reloading the .cmd file
225 # Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file
229 make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
232 # (This is not true for now; $? should contain any non-existent prerequisites,
236 newer-prereqs = $(filter-out $(PHONY),$?)
239 if_changed = $(if $(newer-prereqs)$(cmd-check), \
240 $(cmd); \
241 printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
244 if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:)
247 $(cmd); \
248 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
249 rm -f $(depfile)
254 if_changed_rule = $(if $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:)
257 # why - tell why a target got built
260 # (1) - due to target is PHONY
261 # (2) - due to target missing
262 # (3) - due to: file1.h file2.h
263 # (4) - due to command line change
264 # (5) - due to missing .cmd file
265 # (6) - due to target not in $(targets)
269 # (4) The command line stored in the file named dir/.target.cmd
272 # (5) No dir/.target.cmd file (used to store command line)
273 # (6) No dir/.target.cmd file and target not listed in $(targets)
277 $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
279 $(if $(newer-prereqs),- due to: $(newer-prereqs), \
280 $(if $(cmd-check), \
281 $(if $(cmd_$@),- due to command line change, \
283 - due to missing .cmd file, \
284 - due to $(notdir $@) not in $$(targets) \
289 - due to target missing \
293 echo-why = $(call escsq, $(strip $(why)))
299 # passing to shell commands. It is surrounded by double-quotes, and
300 # any double-quotes or backslashes within it are escaped by