I have a Makefile that has a variable that needs to have a default value in case when variable is unset or if set but has null value.
How can I achieve this?
I need this, as I invoke make inside a shell script and the value required by the makefile can be passed from the shell as $1. And to pass this to makefile I have to set it inside bash-script.
Ideas: (Not elegant) Inside the bash script the variable could be checked if its set but has null value, in that case it can be unset.
Snippets
Note: the following won't work if the variable are not defined in the terminal, as they are set in the bash script.
Makefile
dSourceP?=$(shell pwd)
Source?=$(notdir $(wildcard $(dSourceP)/*.md))
Bash Script
make all dSourceP="${1}" Source="${2}"
Terminal
bash ./MyScript.sh
bash ./MyScript.sh /home/nikhil/MyDocs
bash ./MyScript.sh /home/nikhil/MyDocs index.md