The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Makefile on DOS question

This has be bothering me for a while now, so I thought I'd try in here because there seems to be a ton of Windows/DOS experts.

How do you correctly set the PATH environ variable in a makefile?

In a prebuild target, I have something like:

-@set PATH=$(VPATH)

and when I echo the Path out after that, the path is the same as before I called make.  *NOTE: I'm echoing the PATH variable within the makefile.

There's no export command in DOS, so what do I need to do to make this work?

Jared M.
Wednesday, May 25, 2005
P:\>path /?
Displays or sets a search path for executable files.

PATH [[drive:]path[;...][;%PATH%]

Type PATH ; to clear all search-path settings and direct cmd.exe to search
only in the current directory.
Type PATH without parameters to display the current path.
Including %PATH% in the new path setting causes the old path to be
appended to the new setting.
Zach M.
Wednesday, May 25, 2005
Not to be rude, but this doesn't answer my question at all.  I know how path works.  Unfortunately, how path works does not seem to transfer over to make files at all.  Much like other DOS odities in makefiles, your DOS commands stay current for only that one command.  So:

-@set PATH=$(VPATH)

is only good for that ONE line.

-@set PATH=$(VPATH) & PATH

prints the correct path, but:

-@set PATH=$(VPATH)

does not.

This is why I'm asking about a way to Unix-style export the variable so that the PATH will stay current through the entire makefile.
Jared M.
Wednesday, May 25, 2005
Try not using SET.

Wednesday, May 25, 2005
If you're using gnumke

Then "not using SET" should work.

In other words, on a non-rule based line:

PATH=<search path>:<other path>:<etc.>

would work. But, on the other hand, setting PATH within the Makefile does not change the PATH variable in the sense that the the command shell will not acutally use the new PATH you've set.
hoser Send private email
Wednesday, May 25, 2005
Thanks for the suggestions, but unfortunately eliminating the "set" doesn't change anything.  I went ahead and just started using explicit paths for the binaries in question.  It's unfortunate, but easier than trying to muck around anymore.

Again, thanks.
Jared M.
Thursday, May 26, 2005
you can use relative paths (..\, .\) but the user must run from a mapped drive - unc won't work
Thursday, May 26, 2005
I hope I'm not misunderstanding your question but it is the nature of Makefile that commands (all commands including set and others) only affect the current line.  That was a design decision long time ago to allow parallel processing of the Makefile.  In your case, all you need to do is to make the set and the command on one line as in:
  set PATH=... & [execute command] & [execute other command] ...

If the line get too long, you can use "\" as in
  set PATH=... & \
    [command 1] & \
    [command 2]
Francois Bronsard Send private email
Friday, June 03, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz