18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci# Shorthand 48c2ecf20Sopenharmony_ciwarning = $(warning-if,y,$(1)) 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci# You can not pass commas directly to a function since they are treated as 78c2ecf20Sopenharmony_ci# delimiters. You can use the following trick to do so. 88c2ecf20Sopenharmony_cicomma := , 98c2ecf20Sopenharmony_ci$(warning,hello$(comma) world) 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci# Like Make, single quotes, double quotes, spaces are treated verbatim. 128c2ecf20Sopenharmony_ci# The following prints the text as-is. 138c2ecf20Sopenharmony_ci$(warning, ' " '" ' ''' "'") 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci# Unlike Make, '$' has special meaning only when it is followed by '('. 168c2ecf20Sopenharmony_ci# No need to escape '$' itself. 178c2ecf20Sopenharmony_ci$(warning,$) 188c2ecf20Sopenharmony_ci$(warning,$$) 198c2ecf20Sopenharmony_ci$ := 1 208c2ecf20Sopenharmony_ci$(warning,$($)) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci# You need a trick to escape '$' followed by '(' 238c2ecf20Sopenharmony_ci# The following should print "$(X)". It should not be expanded further. 248c2ecf20Sopenharmony_cidollar := $ 258c2ecf20Sopenharmony_ci$(warning,$(dollar)(X)) 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci# You need a trick to treat unbalanced parentheses. 288c2ecf20Sopenharmony_ci# The following should print "(". 298c2ecf20Sopenharmony_cileft_paren := ( 308c2ecf20Sopenharmony_ci$(warning,$(left_paren)) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci# A simple expanded should not be expanded multiple times. 338c2ecf20Sopenharmony_ci# The following should print "$(X)". It should not be expanded further. 348c2ecf20Sopenharmony_ciY := $(dollar)(X) 358c2ecf20Sopenharmony_ci$(warning,$(Y)) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci# The following should print "$(X)" as well. 388c2ecf20Sopenharmony_ciY = $(dollar)(X) 398c2ecf20Sopenharmony_ci$(warning,$(Y)) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci# The following should print "$(". 428c2ecf20Sopenharmony_ci# It should not be emit "unterminated reference" error. 438c2ecf20Sopenharmony_ciunterminated := $(dollar)( 448c2ecf20Sopenharmony_ci$(warning,$(unterminated)) 45