1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun# Shorthand 4*4882a593Smuzhiyunwarning = $(warning-if,y,$(1)) 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun# You can not pass commas directly to a function since they are treated as 7*4882a593Smuzhiyun# delimiters. You can use the following trick to do so. 8*4882a593Smuzhiyuncomma := , 9*4882a593Smuzhiyun$(warning,hello$(comma) world) 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun# Like Make, single quotes, double quotes, spaces are treated verbatim. 12*4882a593Smuzhiyun# The following prints the text as-is. 13*4882a593Smuzhiyun$(warning, ' " '" ' ''' "'") 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun# Unlike Make, '$' has special meaning only when it is followed by '('. 16*4882a593Smuzhiyun# No need to escape '$' itself. 17*4882a593Smuzhiyun$(warning,$) 18*4882a593Smuzhiyun$(warning,$$) 19*4882a593Smuzhiyun$ := 1 20*4882a593Smuzhiyun$(warning,$($)) 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun# You need a trick to escape '$' followed by '(' 23*4882a593Smuzhiyun# The following should print "$(X)". It should not be expanded further. 24*4882a593Smuzhiyundollar := $ 25*4882a593Smuzhiyun$(warning,$(dollar)(X)) 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun# You need a trick to treat unbalanced parentheses. 28*4882a593Smuzhiyun# The following should print "(". 29*4882a593Smuzhiyunleft_paren := ( 30*4882a593Smuzhiyun$(warning,$(left_paren)) 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun# A simple expanded should not be expanded multiple times. 33*4882a593Smuzhiyun# The following should print "$(X)". It should not be expanded further. 34*4882a593SmuzhiyunY := $(dollar)(X) 35*4882a593Smuzhiyun$(warning,$(Y)) 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun# The following should print "$(X)" as well. 38*4882a593SmuzhiyunY = $(dollar)(X) 39*4882a593Smuzhiyun$(warning,$(Y)) 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun# The following should print "$(". 42*4882a593Smuzhiyun# It should not be emit "unterminated reference" error. 43*4882a593Smuzhiyununterminated := $(dollar)( 44*4882a593Smuzhiyun$(warning,$(unterminated)) 45