0001 # SPDX-License-Identifier: GPL-2.0
0002
0003 # Shorthand
0004 warning = $(warning-if,y,$(1))
0005
0006 # You can not pass commas directly to a function since they are treated as
0007 # delimiters. You can use the following trick to do so.
0008 comma := ,
0009 $(warning,hello$(comma) world)
0010
0011 # Like Make, single quotes, double quotes, spaces are treated verbatim.
0012 # The following prints the text as-is.
0013 $(warning, ' " '" ' ''' "'")
0014
0015 # Unlike Make, '$' has special meaning only when it is followed by '('.
0016 # No need to escape '$' itself.
0017 $(warning,$)
0018 $(warning,$$)
0019 $ := 1
0020 $(warning,$($))
0021
0022 # You need a trick to escape '$' followed by '('
0023 # The following should print "$(X)". It should not be expanded further.
0024 dollar := $
0025 $(warning,$(dollar)(X))
0026
0027 # You need a trick to treat unbalanced parentheses.
0028 # The following should print "(".
0029 left_paren := (
0030 $(warning,$(left_paren))
0031
0032 # A simple expanded should not be expanded multiple times.
0033 # The following should print "$(X)". It should not be expanded further.
0034 Y := $(dollar)(X)
0035 $(warning,$(Y))
0036
0037 # The following should print "$(X)" as well.
0038 Y = $(dollar)(X)
0039 $(warning,$(Y))
0040
0041 # The following should print "$(".
0042 # It should not be emit "unterminated reference" error.
0043 unterminated := $(dollar)(
0044 $(warning,$(unterminated))