Was trying to convert a basic Makefile into a shell equivalent and was getting lost in some basics.
Below is the piece of code in Makefile
WHAT1_UC := ALOHA WHAT1_NUM := 1 WHAT1_WHERELOG_VAR = $(WHAT1_UC)_WHERE_FILENAME ifeq ($(strip $(WHAT1_NUM)), 1) $(WHAT1_WHERELOG_VAR) = mac.@PATH@.log else $(WHAT1_WHERELOG_VAR) = $(RLDIR)/mac.@[email protected]%.log endif export $(WHAT1_WHERELOG_VAR)
Query: a. In this what does @[email protected] represents ? Is it picking the default env variable PATH ? b. So what will be the final value of WHAT1_WHERELOG_VAR, is it export ALOHA_WHERE_FILENAME = mac.@[email protected] ??
Below is the piece of shell code was trying based on the above Make code, but getting lost to replicate the equivalent of it.
WHAT1_UC="ALOHA"
WHAT1_NUM=1
WHAT1_WHERELOG_VAR=${WHAT1_UC}_WHERE_FILENAME
if [ $WHAT1_NUM == 1 ]; then
export ${WHAT1_WHERELOG_VAR}=mac@$PATH@.log
else
export ${WHAT1_WHERELOG_VAR}=${RLDIR}/mac.@[email protected]%.log
fi
What is the shell equivalent of @PATH@ to be used ??
Please clarify the above queries. Let me know what is getting missed ? Thanks.
CodePudding user response:
Query: a. In this what does @[email protected] represents ?
In POSIX or GNU make
, @[email protected] represents @[email protected]. But the @PATH@ part might not have been intentional -- it has the appearance of a placeholder that was intended to have been filled in by a separate program, such as autoconf
, as part of generating the makefile you're looking at.
Alternatively, it may be that that is intended to be subbed out during the build, instead.
Is it picking the default env variable PATH ?
No, it has no special meaning in any dialect of makefile that I know.
b. So what will be the final value of WHAT1_WHERELOG_VAR,
It is ALOHA_WHERE_FILENAME.
is it export ALOHA_WHERE_FILENAME = mac.@[email protected] ??
No. $(WHAT1_WHERELOG_VAR)
and ${WHAT1_WHERELOG_VAR}
expand to the value of variable WHAT1_WHERELOG_VAR
. They have nothing to do with setting the value of that variable.
What is the shell equivalent of @PATH@ to be used ??
It is @PATH@
, which is no more meaningful to the shell than it is to make
.