just want to make sure i understand the details of exporting
variables in gnu make.

  first, if i set an environment variable either in the shell with:

  $ VAR=value
  $ export VAR
  $ make ...

or as a one-time thing on the make command line with:

  $ VAR=value make ...

is it true that that variable VAR is now part of the make invocation
environment and through all sub-make invocations? that is, there is no
need for me to "export" that variable agin in my Makefile -- it
wouldn't hurt but it's superfluous, and those two ways of doing it are
entirely equivalent? am i right so far?

  also, if i do the above, in any part of that invocation, i can
reassign the value of VAR, that new value would now be part of the
environment at that level and all further sub-makes, and there is of
course no need to "export" that variable again -- once it's part of
the environment, it stays in the environment (short of explicitly
"unexport"ing it). still good so far?

  next, i can always explicitly add a variable to the environment
within a Makefile with:

  export VAR

but if that variable is *already* in my environment from the command
line, the make "export" directive is superfluous -- again, doesn't
hurt, just unnecessary.

  finally, if i change the origin of the variable to:

  $ make VAR=value ...

is that variable still part of the environment? i realize that i have
the freedom to check the origin of a variable from within a Makefile,
but how does that last construct work with the environment compared to
the first versions?  thanks muchly.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to