For example, I have a configuration file that I can source from either make or bash:
# mycfg.sh
FOO='bar'
BAR="${FOO}bar"
MYHOST=localhost # local, although will be arbitrary IP in deployment
And now I am trying to keep that tidy interchange remote and local deployment friendly. I’ve gotten around this w/ some finesse by deferring to the runtime env at the make invoke via -e
. Deleting that -e
would break things in deployment, so I view the workaround as fragile.
So my question amounts to: is there some way to have a variable get a default value when source in bash, a default value when included in make, and defer to the environment definition in both cases?
# e.g., mycfg.mk might do
MYHOST?=localhost
# and mycfg.sh might:
MYHOST=${MYHOST:-localhost}
But if only I could write out that behavior in an identical manner for make and BASH, then I could have the one config file for both use cases. Alternatively, I could bypass make entirely and source the bash file as part of the shell entrypoint.
However, I’d really like to just know everything is the same, has the same names and so on in both make and bash.
Is this something that exists, or could exist? If so, is there a good place to make a GNU Make feature request?
1