Just in case, someone accidentally came across a condition in the rule itself. below, as I did, I thought that this could help others.
Suppose in the Makefile we have the following rule with check target, and we need to check if var was passed.
check: @[ "${var}" ] && echo "all good" || ( echo "var is not set"; exit 1 )
To verify this, run the following commands
$ make check var is not set make: *** [check] Error 1 $ make check var=test all good
So, now we can pass the value of the variable or the default value if it has not been passed to the bash script, which will be responsible for the execution of the logic. something like the following:
@[ "${var}" ] && ./b.sh ${var} || ./b.sh 'ss'
Below b.sh may look b.sh , although you can add more logic to it.
#!/bin/sh echo $1
msoliman
source share