Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 
0003 # Shorthand
0004 warning = $(warning-if,y,$(1))
0005 
0006 # Simply expanded variable.
0007 X := 1
0008 SIMPLE := $(X)
0009 X := 2
0010 $(warning,SIMPLE = $(SIMPLE))
0011 
0012 # Recursively expanded variable.
0013 X := 1
0014 RECURSIVE = $(X)
0015 X := 2
0016 $(warning,RECURSIVE = $(RECURSIVE))
0017 
0018 # Append something to a simply expanded variable.
0019 Y := 3
0020 SIMPLE += $(Y)
0021 Y := 4
0022 $(warning,SIMPLE = $(SIMPLE))
0023 
0024 # Append something to a recursively expanded variable.
0025 Y := 3
0026 RECURSIVE += $(Y)
0027 Y := 4
0028 $(warning,RECURSIVE = $(RECURSIVE))
0029 
0030 # Use += operator to an undefined variable.
0031 # This works as a recursively expanded variable.
0032 Y := 3
0033 UNDEFINED_VARIABLE += $(Y)
0034 Y := 4
0035 $(warning,UNDEFINED_VARIABLE = $(UNDEFINED_VARIABLE))
0036 
0037 # You can use variable references for the lefthand side of assignment statement.
0038 X := A
0039 Y := B
0040 $(X)$(Y) := 5
0041 $(warning,AB = $(AB))
0042 
0043 # User-defined function.
0044 greeting = $(1), my name is $(2).
0045 $(warning,$(greeting,Hello,John))
0046 
0047 # The number of arguments is not checked for user-defined functions.
0048 # If some arguments are optional, it is useful to pass fewer parameters.
0049 # $(2) will be blank in this case.
0050 $(warning,$(greeting,Hello))
0051 
0052 # Unreferenced parameters are just ignored.
0053 $(warning,$(greeting,Hello,John,ignored,ignored))