home | list info | list archive | date index | thread index

[OCLUG-Tech] how to add a variable to the environment for gnu make?

  • Subject: [OCLUG-Tech] how to add a variable to the environment for gnu make?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Mon, 20 Apr 2015 07:27:54 -0400 (EDT)
  just want to make sure i understand the mechanics of setting an env
variable for the purpose of a gnu make invocation, as i'm looking at
something a bit subtle and want to make absolutely sure i'm not
missing something.

  AIUI, i can set an environment variable for make outside the
makefile a number of ways -- first, as a regular shell env variable:

  $ export VAR=value
  $ make ...

  second, i can add it as an env var on the command line:

  $ VAR=value make ...

  finally, i can do this:

  $ make VAR=value ...

i realize that this last variation lets me use the make "origin" test
to see where the variable comes from, but that aside, does it still
add the variable to the standard make environment just like the first
two techniques? it *seems* to but i want to make sure.

  also, of course, at any point, i can set and add env variables from
within the makefile with

  VAR = value
  export VAR

but does everything else look correct here?

rday

-- 

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

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