
make - exporting shell variable to environment
m> using bash-2.05, linux, make-3.79.1
m> The command "export" in a Makefile only passes an environmental
m> variable to sub-makes. I can't figure out how to get it back to
m> the original environment.
You can't.
m> Any ideas anyone?
It is a technical impossibility in UNIX for a subprocess to modify in
any way the environment of its calling process. This is A Good Thing.
When you invoke make, it's a subprocess of your shell (the parent
process). There's no way for make to "export" environment modifications
to the parent.
The only possible way this could be done would be for the parent process
to actively participate: for example, the makefile could write the
environment variable to a temporary file, then you could create an alias
or something in your shell which ran make, then sourced that temporary
file.
However, there is no _foolproof_ way to do this: first, it assumes that
all your users will have that alias defined; second, anyone running make
directly rather than through the alias (and there's no way to stop this,
really) will not have the output sourced. Not to mention having a
_script_ which invokes make will also not do the right thing.
But it's all you can do. If possible I would re-examine your situation
and try to come up with another alternative altogether.
--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist