53 lines · 1.2 KB · Text
RawDownload
# SPDX-License-Identifier: GPL-2.0 # Shorthandwarning = $(warning-if,y,$(1)) # Simply expanded variable.X := 1SIMPLE := $(X)X := 2$(warning,SIMPLE = $(SIMPLE)) # Recursively expanded variable.X := 1RECURSIVE = $(X)X := 2$(warning,RECURSIVE = $(RECURSIVE)) # Append something to a simply expanded variable.Y := 3SIMPLE += $(Y)Y := 4$(warning,SIMPLE = $(SIMPLE)) # Append something to a recursively expanded variable.Y := 3RECURSIVE += $(Y)Y := 4$(warning,RECURSIVE = $(RECURSIVE)) # Use += operator to an undefined variable.# This works as a recursively expanded variable.Y := 3UNDEFINED_VARIABLE += $(Y)Y := 4$(warning,UNDEFINED_VARIABLE = $(UNDEFINED_VARIABLE)) # You can use variable references for the lefthand side of assignment statement.X := AY := B$(X)$(Y) := 5$(warning,AB = $(AB)) # User-defined function.greeting = $(1), my name is $(2).$(warning,$(greeting,Hello,John)) # The number of arguments is not checked for user-defined functions.# If some arguments are optional, it is useful to pass fewer parameters.# $(2) will be blank in this case.$(warning,$(greeting,Hello)) # Unreferenced parameters are just ignored.$(warning,$(greeting,Hello,John,ignored,ignored))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t