xref: /linux/scripts/Kbuild.include (revision 7e826c44f5de3be00369d534dc38db485f6f26d5)
196ac6d43SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
28ec4b4ffSSam Ravnborg####
38ec4b4ffSSam Ravnborg# kbuild: Generic definitions
48ec4b4ffSSam Ravnborg
5beda9f3aSRoman Zippel# Convenient variables
68ec4b4ffSSam Ravnborgcomma   := ,
713338935SMasahiro Yamadaquote   := "
8d51bfb78SSam Ravnborgsquote  := '
98ec4b4ffSSam Ravnborgempty   :=
108ec4b4ffSSam Ravnborgspace   := $(empty) $(empty)
119c8fa9bcSMasahiro Yamadaspace_escape := _-_SPACE_-_
129564a8cfSRasmus Villemoespound := \#
138ec4b4ffSSam Ravnborg
148ec4b4ffSSam Ravnborg###
1548f1f058SSam Ravnborg# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
1648f1f058SSam Ravnborgdot-target = $(dir $@).$(notdir $@)
1748f1f058SSam Ravnborg
1848f1f058SSam Ravnborg###
198ec4b4ffSSam Ravnborg# The temporary file to save gcc -MD generated dependencies must not
208ec4b4ffSSam Ravnborg# contain a comma
2148f1f058SSam Ravnborgdepfile = $(subst $(comma),_,$(dot-target).d)
228ec4b4ffSSam Ravnborg
238ec4b4ffSSam Ravnborg###
245e8d780dSSam Ravnborg# filename of target with directory and extension stripped
255e8d780dSSam Ravnborgbasetarget = $(basename $(notdir $@))
265e8d780dSSam Ravnborg
275e8d780dSSam Ravnborg###
28afa974b7SMasahiro Yamada# real prerequisites without phony targets
29afa974b7SMasahiro Yamadareal-prereqs = $(filter-out $(PHONY), $^)
30afa974b7SMasahiro Yamada
31afa974b7SMasahiro Yamada###
32d51bfb78SSam Ravnborg# Escape single quote for use in echo statements
33d51bfb78SSam Ravnborgescsq = $(subst $(squote),'\$(squote)',$1)
34d51bfb78SSam Ravnborg
35d51bfb78SSam Ravnborg###
36*7e826c44SMasahiro Yamada# Quote a string to pass it to C files. foo => '"foo"'
37*7e826c44SMasahiro Yamadastringify = $(squote)$(quote)$1$(quote)$(squote)
38*7e826c44SMasahiro Yamada
39*7e826c44SMasahiro Yamada###
405410ecc0SMike Frysinger# Easy method for doing a status message
415410ecc0SMike Frysinger       kecho := :
425410ecc0SMike Frysinger quiet_kecho := echo
435410ecc0SMike Frysingersilent_kecho := :
445410ecc0SMike Frysingerkecho := $($(quiet)kecho)
455410ecc0SMike Frysinger
465410ecc0SMike Frysinger###
478ec4b4ffSSam Ravnborg# filechk is used to check if the content of a generated file is updated.
488ec4b4ffSSam Ravnborg# Sample usage:
49ba97df45SMasahiro Yamada#
50ba97df45SMasahiro Yamada# filechk_sample = echo $(KERNELRELEASE)
51ba97df45SMasahiro Yamada# version.h: FORCE
528ec4b4ffSSam Ravnborg#	$(call filechk,sample)
53ba97df45SMasahiro Yamada#
548ec4b4ffSSam Ravnborg# The rule defined shall write to stdout the content of the new file.
558ec4b4ffSSam Ravnborg# The existing file will be compared with the new one.
568ec4b4ffSSam Ravnborg# - If no file exist it is created
578ec4b4ffSSam Ravnborg# - If the content differ the new file is used
588ec4b4ffSSam Ravnborg# - If they are equal no change, and no timestamp update
598ec4b4ffSSam Ravnborg# - stdin is piped in from the first prerequisite ($<) so one has
608ec4b4ffSSam Ravnborg#   to specify a valid file as first prerequisite (often the kbuild file)
618ec4b4ffSSam Ravnborgdefine filechk
628ec4b4ffSSam Ravnborg	$(Q)set -e;				\
638ec4b4ffSSam Ravnborg	mkdir -p $(dir $@);			\
64ad774086SMasahiro Yamada	{ $(filechk_$(1)); } > $@.tmp;		\
658ec4b4ffSSam Ravnborg	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
668ec4b4ffSSam Ravnborg		rm -f $@.tmp;			\
678ec4b4ffSSam Ravnborg	else					\
68fd54f502SMike Frysinger		$(kecho) '  UPD     $@';	\
698ec4b4ffSSam Ravnborg		mv -f $@.tmp $@;		\
708ec4b4ffSSam Ravnborg	fi
718ec4b4ffSSam Ravnborgendef
728ec4b4ffSSam Ravnborg
7320a468b5SSam Ravnborg######
749d6e7a70SSam Ravnborg# gcc support functions
75cd238effSMauro Carvalho Chehab# See documentation in Documentation/kbuild/makefiles.rst
7620a468b5SSam Ravnborg
77910b4046SSam Ravnborg# cc-cross-prefix
78910b4046SSam Ravnborg# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
79bd55f96fSMasahiro Yamada# Return first <prefix> where a <prefix>gcc is found in PATH.
80bd55f96fSMasahiro Yamada# If no gcc found in PATH with listed prefixes return nothing
81913ab978SMasahiro Yamada#
82913ab978SMasahiro Yamada# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it
83913ab978SMasahiro Yamada# would try to directly execute the shell builtin 'command'. This workaround
84913ab978SMasahiro Yamada# should be kept for a long time since this issue was fixed only after the
85913ab978SMasahiro Yamada# GNU Make 4.2.1 release.
86d4a74bbfSMasahiro Yamadacc-cross-prefix = $(firstword $(foreach c, $(1), \
87d4a74bbfSMasahiro Yamada			$(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c))))
88910b4046SSam Ravnborg
89beda9f3aSRoman Zippel# output directory for tests below
90beda9f3aSRoman ZippelTMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
91beda9f3aSRoman Zippel
92beda9f3aSRoman Zippel# try-run
93beda9f3aSRoman Zippel# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
94312a3d09SCao jin# Exit code chooses option. "$$TMP" serves as a temporary file and is
95312a3d09SCao jin# automatically cleaned up.
96e08d6de4SMasahiro Yamadatry-run = $(shell set -e;		\
97beda9f3aSRoman Zippel	TMP="$(TMPOUT).$$$$.tmp";	\
98691ef3e7SSam Ravnborg	TMPO="$(TMPOUT).$$$$.o";	\
99beda9f3aSRoman Zippel	if ($(1)) >/dev/null 2>&1;	\
1005de043f4SOleg Verych	then echo "$(2)";		\
1015de043f4SOleg Verych	else echo "$(3)";		\
1025de043f4SOleg Verych	fi;				\
103e08d6de4SMasahiro Yamada	rm -f "$$TMP" "$$TMPO")
104347a00fbSRoman Zippel
10520a468b5SSam Ravnborg# as-option
10620a468b5SSam Ravnborg# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
107beda9f3aSRoman Zippel
108e08d6de4SMasahiro Yamadaas-option = $(call try-run,\
109a0f97e06SSam Ravnborg	$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
11020a468b5SSam Ravnborg
111e2414910SAndi Kleen# as-instr
112e2414910SAndi Kleen# Usage: cflags-y += $(call as-instr,instr,option1,option2)
113beda9f3aSRoman Zippel
114e08d6de4SMasahiro Yamadaas-instr = $(call try-run,\
115875de986SBernhard Walle	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
116e2414910SAndi Kleen
1179f3f1fd2SMatthias Kaehlcke# __cc-option
1189f3f1fd2SMatthias Kaehlcke# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
119e08d6de4SMasahiro Yamada__cc-option = $(call try-run,\
1209f3f1fd2SMatthias Kaehlcke	$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
1219f3f1fd2SMatthias Kaehlcke
122d26e9414SEmese Revfy# Do not attempt to build with gcc plugins during cc-option tests.
123d26e9414SEmese Revfy# (And this uses delayed resolution so the flags will be up to date.)
1246ac38934SIngo MolnarCC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
125d26e9414SEmese Revfy
12620a468b5SSam Ravnborg# cc-option
12720a468b5SSam Ravnborg# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
128beda9f3aSRoman Zippel
1299f3f1fd2SMatthias Kaehlckecc-option = $(call __cc-option, $(CC),\
1309f3f1fd2SMatthias Kaehlcke	$(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
1319f3f1fd2SMatthias Kaehlcke
13220a468b5SSam Ravnborg# cc-option-yn
13320a468b5SSam Ravnborg# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
134e08d6de4SMasahiro Yamadacc-option-yn = $(call try-run,\
135c3f0d0bcSMark Charlebois	$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
13620a468b5SSam Ravnborg
1378417da6fSMichal Marek# cc-disable-warning
1388417da6fSMichal Marek# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
139e08d6de4SMasahiro Yamadacc-disable-warning = $(call try-run,\
140c3f0d0bcSMark Charlebois	$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
1418417da6fSMichal Marek
14220a468b5SSam Ravnborg# cc-ifversion
14320a468b5SSam Ravnborg# Usage:  EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
144d3a918c6SMasahiro Yamadacc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
14520a468b5SSam Ravnborg
146691ef3e7SSam Ravnborg# ld-option
147d503ac53SMasahiro Yamada# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
148d503ac53SMasahiro Yamadald-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
149691ef3e7SSam Ravnborg
150ccbef167SAndi Kleen# ld-version
151ccbef167SAndi Kleen# Note this is mainly for HJ Lu's 3 number binutil versions
152e08d6de4SMasahiro Yamadald-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
153ccbef167SAndi Kleen
154ccbef167SAndi Kleen# ld-ifversion
155ccbef167SAndi Kleen# Usage:  $(call ld-ifversion, -ge, 22252, y)
1566dcb4e5eSMasahiro Yamadald-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
157ccbef167SAndi Kleen
1585de043f4SOleg Verych######
1595de043f4SOleg Verych
160beda9f3aSRoman Zippel###
1618ec4b4ffSSam Ravnborg# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
1628ec4b4ffSSam Ravnborg# Usage:
1638ec4b4ffSSam Ravnborg# $(Q)$(MAKE) $(build)=dir
1645b2389b4SMasahiro Yamadabuild := -f $(srctree)/scripts/Makefile.build obj
1658ec4b4ffSSam Ravnborg
166bc081dd6SMichal Marek###
167bc081dd6SMichal Marek# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
168bc081dd6SMichal Marek# Usage:
169bc081dd6SMichal Marek# $(Q)$(MAKE) $(modbuiltin)=dir
1705b2389b4SMasahiro Yamadamodbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
171bc081dd6SMichal Marek
1729fb5e537SRobert Richter###
1739fb5e537SRobert Richter# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
1749fb5e537SRobert Richter# Usage:
1759fb5e537SRobert Richter# $(Q)$(MAKE) $(dtbinst)=dir
176487c7c77SMasahiro Yamadadtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
1779fb5e537SRobert Richter
178d08372caSLinus Torvalds###
179371fdc77SMasahiro Yamada# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
180371fdc77SMasahiro Yamada# Usage:
181371fdc77SMasahiro Yamada# $(Q)$(MAKE) $(clean)=dir
182371fdc77SMasahiro Yamadaclean := -f $(srctree)/scripts/Makefile.clean obj
183371fdc77SMasahiro Yamada
1845de043f4SOleg Verych# echo command.
1855de043f4SOleg Verych# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
1865de043f4SOleg Verychecho-cmd = $(if $($(quiet)cmd_$(1)),\
1875de043f4SOleg Verych	echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
1885de043f4SOleg Verych
1895de043f4SOleg Verych# printing commands
1903a2429e1SMasahiro Yamadacmd = @set -e; $(echo-cmd) $(cmd_$(1))
1918ec4b4ffSSam Ravnborg
1928ec4b4ffSSam Ravnborg###
1938ec4b4ffSSam Ravnborg# if_changed      - execute command if any prerequisite is newer than
1948ec4b4ffSSam Ravnborg#                   target, or command line has changed
1958ec4b4ffSSam Ravnborg# if_changed_dep  - as if_changed, but uses fixdep to reveal dependencies
1968ec4b4ffSSam Ravnborg#                   including used config symbols
1978ec4b4ffSSam Ravnborg# if_changed_rule - as if_changed but execute rule instead
198cd238effSMauro Carvalho Chehab# See Documentation/kbuild/makefiles.rst for more info
1998ec4b4ffSSam Ravnborg
2008ec4b4ffSSam Ravnborgifneq ($(KBUILD_NOCMDDEP),1)
20150bcca6aSMasahiro Yamada# Check if both commands are the same including their order. Result is empty
2029c8fa9bcSMasahiro Yamada# string if equal. User may override this check using make KBUILD_NOCMDDEP=1
20350bcca6aSMasahiro Yamadacmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
2049c8fa9bcSMasahiro Yamada                         $(subst $(space),$(space_escape),$(strip $(cmd_$1))))
205c4d5ee13SMichal Marekelse
20650bcca6aSMasahiro Yamadacmd-check = $(if $(strip $(cmd_$@)),,1)
2078ec4b4ffSSam Ravnborgendif
2088ec4b4ffSSam Ravnborg
209164f0d2eSMichal Marek# Replace >$< with >$$< to preserve $ when reloading the .cmd file
210164f0d2eSMichal Marek# (needed for make)
2119564a8cfSRasmus Villemoes# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file
212164f0d2eSMichal Marek# (needed for make)
213164f0d2eSMichal Marek# Replace >'< with >'\''< to be able to enclose the whole string in '...'
214164f0d2eSMichal Marek# (needed for the shell)
2159564a8cfSRasmus Villemoesmake-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
2166176aa9aSJan Beulich
2172d3b1b8fSMasahiro Yamada# Find any prerequisites that are newer than target or that do not exist.
2182d3b1b8fSMasahiro Yamada# (This is not true for now; $? should contain any non-existent prerequisites,
2192d3b1b8fSMasahiro Yamada# but it does not work as expected when .SECONDARY is present. This seems a bug
2202d3b1b8fSMasahiro Yamada# of GNU Make.)
22148f1f058SSam Ravnborg# PHONY targets skipped in both cases.
222eba19032SMasahiro Yamadanewer-prereqs = $(filter-out $(PHONY),$?)
22348f1f058SSam Ravnborg
2245de043f4SOleg Verych# Execute command if command has changed or prerequisite(s) are updated.
225eba19032SMasahiro Yamadaif_changed = $(if $(newer-prereqs)$(cmd-check),                              \
22667126965SMasahiro Yamada	$(cmd);                                                              \
2272aedcd09SMasahiro Yamada	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
2288ec4b4ffSSam Ravnborg
2295de043f4SOleg Verych# Execute the command and also postprocess generated .d dependencies file.
230eba19032SMasahiro Yamadaif_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:)
231c1a95fdaSNicolas Pitre
232e4aca459SNicolas Pitrecmd_and_fixdep =                                                             \
2333a2429e1SMasahiro Yamada	$(cmd);                                                              \
234392885eeSMasahiro Yamada	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
235e5d28910SMasahiro Yamada	rm -f $(depfile)
236c1a95fdaSNicolas Pitre
2378ec4b4ffSSam Ravnborg# Usage: $(call if_changed_rule,foo)
238beda9f3aSRoman Zippel# Will check if $(cmd_foo) or any of the prerequisites changed,
239beda9f3aSRoman Zippel# and if so will execute $(rule_foo).
240eba19032SMasahiro Yamadaif_changed_rule = $(if $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:)
24148f1f058SSam Ravnborg
24245d506bdSSam Ravnborg###
243312a3d09SCao jin# why - tell why a target got built
24445d506bdSSam Ravnborg#       enabled by make V=2
24545d506bdSSam Ravnborg#       Output (listed in the order they are checked):
24645d506bdSSam Ravnborg#          (1) - due to target is PHONY
24745d506bdSSam Ravnborg#          (2) - due to target missing
24845d506bdSSam Ravnborg#          (3) - due to: file1.h file2.h
24945d506bdSSam Ravnborg#          (4) - due to command line change
25045d506bdSSam Ravnborg#          (5) - due to missing .cmd file
25145d506bdSSam Ravnborg#          (6) - due to target not in $(targets)
25245d506bdSSam Ravnborg# (1) PHONY targets are always build
25345d506bdSSam Ravnborg# (2) No target, so we better build it
25445d506bdSSam Ravnborg# (3) Prerequisite is newer than target
25545d506bdSSam Ravnborg# (4) The command line stored in the file named dir/.target.cmd
25645d506bdSSam Ravnborg#     differed from actual command line. This happens when compiler
25745d506bdSSam Ravnborg#     options changes
25845d506bdSSam Ravnborg# (5) No dir/.target.cmd file (used to store command line)
25945d506bdSSam Ravnborg# (6) No dir/.target.cmd file and target not listed in $(targets)
26045d506bdSSam Ravnborg#     This is a good hint that there is a bug in the kbuild file
26145d506bdSSam Ravnborgifeq ($(KBUILD_VERBOSE),2)
26245d506bdSSam Ravnborgwhy =                                                                        \
26345d506bdSSam Ravnborg    $(if $(filter $@, $(PHONY)),- due to target is PHONY,                    \
26445d506bdSSam Ravnborg        $(if $(wildcard $@),                                                 \
265eba19032SMasahiro Yamada            $(if $(newer-prereqs),- due to: $(newer-prereqs),                \
26650bcca6aSMasahiro Yamada                $(if $(cmd-check),                                           \
26745d506bdSSam Ravnborg                    $(if $(cmd_$@),- due to command line change,             \
26845d506bdSSam Ravnborg                        $(if $(filter $@, $(targets)),                       \
26945d506bdSSam Ravnborg                            - due to missing .cmd file,                      \
27045d506bdSSam Ravnborg                            - due to $(notdir $@) not in $$(targets)         \
27145d506bdSSam Ravnborg                         )                                                   \
27245d506bdSSam Ravnborg                     )                                                       \
27345d506bdSSam Ravnborg                 )                                                           \
27445d506bdSSam Ravnborg             ),                                                              \
27545d506bdSSam Ravnborg             - due to target missing                                         \
27645d506bdSSam Ravnborg         )                                                                   \
27745d506bdSSam Ravnborg     )
27845d506bdSSam Ravnborg
27945d506bdSSam Ravnborgecho-why = $(call escsq, $(strip $(why)))
28045d506bdSSam Ravnborgendif
2813ee550f1SDavid Woodhouse
2823ee550f1SDavid Woodhouse###############################################################################
2833ee550f1SDavid Woodhouse#
2843ee550f1SDavid Woodhouse# When a Kconfig string contains a filename, it is suitable for
2853ee550f1SDavid Woodhouse# passing to shell commands. It is surrounded by double-quotes, and
2863ee550f1SDavid Woodhouse# any double-quotes or backslashes within it are escaped by
2873ee550f1SDavid Woodhouse# backslashes.
2883ee550f1SDavid Woodhouse#
2893ee550f1SDavid Woodhouse# This is no use for dependencies or $(wildcard). We need to strip the
2903ee550f1SDavid Woodhouse# surrounding quotes and the escaping from quotes and backslashes, and
2913ee550f1SDavid Woodhouse# we *do* need to escape any spaces in the string. So, for example:
2923ee550f1SDavid Woodhouse#
2933ee550f1SDavid Woodhouse# Usage: $(eval $(call config_filename,FOO))
2943ee550f1SDavid Woodhouse#
2953ee550f1SDavid Woodhouse# Defines FOO_FILENAME based on the contents of the CONFIG_FOO option,
2963ee550f1SDavid Woodhouse# transformed as described above to be suitable for use within the
2973ee550f1SDavid Woodhouse# makefile.
2983ee550f1SDavid Woodhouse#
2993ee550f1SDavid Woodhouse# Also, if the filename is a relative filename and exists in the source
3003ee550f1SDavid Woodhouse# tree but not the build tree, define FOO_SRCPREFIX as $(srctree)/ to
3013ee550f1SDavid Woodhouse# be prefixed to *both* command invocation and dependencies.
3023ee550f1SDavid Woodhouse#
3033ee550f1SDavid Woodhouse# Note: We also print the filenames in the quiet_cmd_foo text, and
3043ee550f1SDavid Woodhouse# perhaps ought to have a version specially escaped for that purpose.
3053ee550f1SDavid Woodhouse# But it's only cosmetic, and $(patsubst "%",%,$(CONFIG_FOO)) is good
3063ee550f1SDavid Woodhouse# enough.  It'll strip the quotes in the common case where there's no
3073ee550f1SDavid Woodhouse# space and it's a simple filename, and it'll retain the quotes when
3083ee550f1SDavid Woodhouse# there's a space. There are some esoteric cases in which it'll print
3093ee550f1SDavid Woodhouse# the wrong thing, but we don't really care. The actual dependencies
3103ee550f1SDavid Woodhouse# and commands *do* get it right, with various combinations of single
3113ee550f1SDavid Woodhouse# and double quotes, backslashes and spaces in the filenames.
3123ee550f1SDavid Woodhouse#
3133ee550f1SDavid Woodhouse###############################################################################
3143ee550f1SDavid Woodhouse#
3153ee550f1SDavid Woodhousedefine config_filename
3163ee550f1SDavid Woodhouseifneq ($$(CONFIG_$(1)),"")
3173ee550f1SDavid Woodhouse$(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1)))))))
3183ee550f1SDavid Woodhouseifneq ($$(patsubst /%,%,$$(firstword $$($(1)_FILENAME))),$$(firstword $$($(1)_FILENAME)))
3193ee550f1SDavid Woodhouseelse
3203ee550f1SDavid Woodhouseifeq ($$(wildcard $$($(1)_FILENAME)),)
3213ee550f1SDavid Woodhouseifneq ($$(wildcard $$(srctree)/$$($(1)_FILENAME)),)
3223ee550f1SDavid Woodhouse$(1)_SRCPREFIX := $(srctree)/
3233ee550f1SDavid Woodhouseendif
3243ee550f1SDavid Woodhouseendif
3253ee550f1SDavid Woodhouseendif
3263ee550f1SDavid Woodhouseendif
3273ee550f1SDavid Woodhouseendef
3283ee550f1SDavid Woodhouse#
3293ee550f1SDavid Woodhouse###############################################################################
3309c2af1c7SMasahiro Yamada
3319c2af1c7SMasahiro Yamada# delete partially updated (i.e. corrupted) files on error
3329c2af1c7SMasahiro Yamada.DELETE_ON_ERROR:
3338e9b61b2SMasahiro Yamada
3348e9b61b2SMasahiro Yamada# do not delete intermediate files automatically
3358e9b61b2SMasahiro Yamada.SECONDARY:
336