List Info

Thread: Expanding PATH variable in dynamic way




Expanding PATH variable in dynamic way
country flaguser name
United States
2007-11-01 01:21:46
Hi,
in my makefile there're some rules which use external
program call. 
The called program's binary is placed in some directory,
that I doesn't want
to place in PATH in a constant way,but only for comilation
time.

Is there any way to do this?
Thank you.
-- 
View this message in context: http://www.nabble.com/Expan
ding-PATH-variable-in-dynamic-way-tf4729614.html#a13523984
Sent from the Gnu - Make - Help mailing list archive at
Nabble.com.



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: Expanding PATH variable in dynamic way
country flaguser name
United States
2007-11-01 08:39:13
ElenaR wrote:

> in my makefile there're some rules which use external
program call.
> The called program's binary is placed in some
directory, that I doesn't want
> to place in PATH in a constant way,but only for
comilation time.

You can do this the same way you would in a shell script,
because that's
all that make is doing -- running fragments of shell script
for each
target.

foo:
	PATH="/some/where:$$PATH" some-prog --arg $

You have to use $$ for variables that you want the shell to
expand so
that make doesn't do the expansion.  The modified value of
PATH only
applies for that one command because modifications to a
child's
environment have no effect on the parent process and are
effectively
discarded when the child terminates.

But I don't really see why you need to change the PATH to
accomplish
this, you could have accomplished the same thing with:

foo:
	/some/where/some-prog --arg $

The only reason I can see to modify the PATH is if some-prog
itself
tries to spawn further child processes that are located in
/some/where.

Brian


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: Expanding PATH variable in dynamic way
country flaguser name
United States
2007-11-01 08:41:21
On 2007-11-01 06:21Z, ElenaR wrote:
>
> in my makefile there're some rules which use external
program call. 
> The called program's binary is placed in some
directory, that I doesn't want
> to place in PATH in a constant way,but only for
comilation time.

Write the program's full path explicitly.

For example, instead of setting
  PATH=$PATH:/some-directory
globally and then writing
  some-program some-arguments
in your rule, just write the rule this way:
  /some-directory/some-program some-arguments

Even better, put the program's full path in a variable
  SOME_PROGRAM := /some-directory/some-program
and use that variable in the rule:
  $(SOME_PROGRAM) some-arguments


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

RE: Expanding PATH variable in dynamic way
country flaguser name
United Kingdom
2007-11-01 12:18:52
On 01 November 2007 13:41, Greg Chicares wrote:

> On 2007-11-01 06:21Z, ElenaR wrote:
>> 
>> in my makefile there're some rules which use
external program call.
>> The called program's binary is placed in some
directory, that I doesn't
>> want to place in PATH in a constant way,but only
for comilation time.
> 
> Write the program's full path explicitly.

  Both Greg and Brian suggest modifying the build rule to
specify the PATH.

  Which is fine as far as it goes, but doesn't necessarily
help ElenaR if
she's relying on the implicit built-in rules.

  If you want to change the $PATH setting used by implicit
rules, it might
work to add a pattern-specific definition.  For instance, to
add /some/path to
$PATH whenever a C file is being compiled to an object file
by an implicit
rule, you could try

%.o : PATH=/some/path:$(PATH)

  Alternatively, since the implicit rules always use a
variable to specify the
compiler invoked, you can try redefining those to have a
full path instead,
i.e.

CC:=/some/path/gcc
CXX:=/some/path/g++

etc.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )