I want to include a file based on my sandbox base directory inside my m4 text, without using a switch -I.
So far I have figured out how to capture environment variables using a sys call:
define(MODEL_ROOT,`syscmd(`printf $MODEL_ROOT')')dnl
Next, I want to include a file based on this environment variable:
include(MODEL_ROOT/sw/lib/m4_macros/foreach2.m4)
In general, I have:
define(MODEL_ROOT,`syscmd(`printf $MODEL_ROOT')')
MODEL_ROOT
MODEL_ROOT/sw/lib/m4_macros/foreach2.m4
include(MODEL_ROOT/sw/lib/m4_macros/foreach2.m4)
What prints:
/home/ross/sandbox
/home/ross/sandbox/sw/lib/m4_macros/foreach2.m4
/home/ross/sandboxforeach_example.m4:7: m4: Cannot open /sw/lib/m4_macros/foreach2.m4: No such file or directory
I know that for the standard syntax for include there is
include(`file.m4')
But if I quote MODEL_ROOT/sw/lib/m4_macros/foreach2.m4, then m4 is like:
[...]
include(`MODEL_ROOT/sw/lib/m4_macros/foreach2.m4')
m4 complains:
[...]
foreach_example.m4:7: m4: Cannot open MODEL_ROOT/sw/lib/m4_macros/foreach2.m4: No such file or directory
How to include an environment variable file in my path?
source
share