Showing the changes to scripts (1 of 11 files). Show all
Unified · Split
| @@ -303,3 +303,54 @@ why = \ · 302 unmodified lines | ||
| 303 | 303 | |
| 304 | 304 | echo-why = $(call escsq, $(strip $(why))) |
| 305 | 305 | endif |
| 306 | + | |
| 307 | +############################################################################### | |
| 308 | +# | |
| 309 | +# When a Kconfig string contains a filename, it is suitable for | |
| 310 | +# passing to shell commands. It is surrounded by double-quotes, and | |
| 311 | +# any double-quotes or backslashes within it are escaped by | |
| 312 | +# backslashes. | |
| 313 | +# | |
| 314 | +# This is no use for dependencies or $(wildcard). We need to strip the | |
| 315 | +# surrounding quotes and the escaping from quotes and backslashes, and | |
| 316 | +# we *do* need to escape any spaces in the string. So, for example: | |
| 317 | +# | |
| 318 | +# Usage: $(eval $(call config_filename,FOO)) | |
| 319 | +# | |
| 320 | +# Defines FOO_FILENAME based on the contents of the CONFIG_FOO option, | |
| 321 | +# transformed as described above to be suitable for use within the | |
| 322 | +# makefile. | |
| 323 | +# | |
| 324 | +# Also, if the filename is a relative filename and exists in the source | |
| 325 | +# tree but not the build tree, define FOO_SRCPREFIX as $(srctree)/ to | |
| 326 | +# be prefixed to *both* command invocation and dependencies. | |
| 327 | +# | |
| 328 | +# Note: We also print the filenames in the quiet_cmd_foo text, and | |
| 329 | +# perhaps ought to have a version specially escaped for that purpose. | |
| 330 | +# But it's only cosmetic, and $(patsubst "%",%,$(CONFIG_FOO)) is good | |
| 331 | +# enough. It'll strip the quotes in the common case where there's no | |
| 332 | +# space and it's a simple filename, and it'll retain the quotes when | |
| 333 | +# there's a space. There are some esoteric cases in which it'll print | |
| 334 | +# the wrong thing, but we don't really care. The actual dependencies | |
| 335 | +# and commands *do* get it right, with various combinations of single | |
| 336 | +# and double quotes, backslashes and spaces in the filenames. | |
| 337 | +# | |
| 338 | +############################################################################### | |
| 339 | +# | |
| 340 | +space_escape := %%%SPACE%%% | |
| 341 | +# | |
| 342 | +define config_filename | |
| 343 | +ifneq ($$(CONFIG_$(1)),"") | |
| 344 | +$(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1))))))) | |
| 345 | +ifneq ($$(patsubst /%,%,$$(firstword $$($(1)_FILENAME))),$$(firstword $$($(1)_FILENAME))) | |
| 346 | +else | |
| 347 | +ifeq ($$(wildcard $$($(1)_FILENAME)),) | |
| 348 | +ifneq ($$(wildcard $$(srctree)/$$($(1)_FILENAME)),) | |
| 349 | +$(1)_SRCPREFIX := $(srctree)/ | |
| 350 | +endif | |
| 351 | +endif | |
| 352 | +endif | |
| 353 | +endif | |
| 354 | +endef | |
| 355 | +# | |
| 356 | +############################################################################### | |