Makefile defining a variable in the if statement in a target
source link: https://www.codesd.com/item/makefile-defining-a-variable-in-the-if-statement-in-a-target.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Makefile defining a variable in the if statement in a target
I have a Makefile with the following:
AVAR=""
all :
if [ -d ../old ]; then \
(echo "$@ Ping!"; AVAR="../old"; echo $(AVAR)) \
fi
@echo $(AVAR)
The idea is that depending on the presence of directory "../old" i will or not have information in AVAR (available for use later), however, the if is evaluating to true, and the Ping! is echoed, but nothing is assigned to AVAR, either inside or outside the if statement.
Output is as follows:
$ make all
if [ -d ../old ]; then \
(echo "all Ping!"; AVAR="../old"; echo "") \
fi
all Ping!
Any Insight appreciated.
(echo "$@ Ping!"; AVAR="../old"; echo $$AVAR) \
instead of
(echo "$@ Ping!"; AVAR="../old"; echo $(AVAR)) \
Related Articles
Define a variable in the SELECT statement - MySQL
Pass the .each loop variable to the if statement in the function
Retrieves the variable of the if statement embedded in the .each function
SSIS 2012 - Assigning variables to the SQL statement of an SQL task
Define environment variables in the GAS control panel
Comparing many variables in the if statement
Define a variable on the data element
Why the final java variable indicating the inaccessible state
PHP: Affects Variables in the if Statement
Specify the file name as a variable in the infiltration statement
Javascript Variables in the if statement
Must declare the scalar variable with the SELECT statement
Initialize the variable in the if statement (Java)
Windows batch files: how to define a variable with the result of a command?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK