Change the environment variable `PATH’ in Makefile does NOT take effect with make in CLT, and it’s OK with the make util which I compiled from original source.
The simple Makefile
PATH := $(PATH):/opt/bin
export PATH
all:
@cscope --version
My tests
/tmp $ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin
/tmp $ ls /opt/bin/cscope
/opt/bin/cscope
/tmp $ which make
/usr/bin/make
/tmp $ make
make: cscope: No such file or directory
make: *** [all] Error 1
/tmp $ ./_install/bin/make
cscope: version 15.7a
/tmp $ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
/tmp $ ./_install/bin/make --version
GNU Make 3.82
Built for x86_64-apple-darwin12.0.0
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Can anyone help?
You are confusing
makevariables withshellvariables. With your setup, the shell command that gets invoked is not influenced by themakevariablePATHthat you have set.You should set the
PATHvariable inside your recipe, like inYou have to to both on one line because every line in the recipe will be run in another shell, effectively losing the
PATHsetting that you just did. Or you can divide it over multiple lines by adding a backslash\at the end of each line:Update
Sorry, I missed the importance of your makefile working with
make 3.82. I tried with both versions and indeed,3.81and3.82behave differently in this case.I did get this to work with
3.81though by invokingmakeas follows:or