I am writing installation in a Makefile in which I need to set the PATH env. variable.
In the windows part of it, I found the following:
set: Withset PATH="%PATH%;%CD%"I can change thePATHinside the running environment. There are two problems with this:- The environment is a spawned
cmd.exeby make which gets its variable affected and the effect removed as soon as it closes - Even if the previous problem could be solved, still the
cmd.exethat callsmakewould close one day and the modifiedPATHlost.
- The environment is a spawned
setx: A microsoft tool that can permanently change env. variables. According to microsoft itself, this is the only command-line option to do this. Usingsetx PATH "%PATH%;%CD%" -mhowever, turns path into the literal%PATH%;%CD%and doesn’t replace the variables by their contents!
Note that I am calling make from cmd.exe not cygwin or other modified windows shells that act more like linux. What I’m saying is that, although I can use $(PATH) in my makefile (instead of %PATH%), I can’t use pwd (instead of %CD%)
Also note that if in cmd itself I run:
setx PATH "%PATH%;%CD%" -m
it works perfectly. Somehow I need to make make execute this command.
Do you have any idea how to fix this, or what workaround do I have?
P.S. Just for the record, echo "%PATH%;%CD%" in the Makefile also echoes the literal "%PATH%;%CD%" rather than let cmd.exe handle it
Workaround:
Create a
.batfile, put the command there, and invoke it from the Makefile.I still am interested in a direct fix in the Makefile though.