tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: make: should -j affect cwd?
On Sat, 14 Jan 2012, James K. Lowden wrote:
It seems make(1) does or does not retain the effect of cd(1) between
commands depending on whether or not the -j option is used. This
behavior is not documented. Is it expected?
Yes, it's expected, and it's vaguely documented under "-B"
and "-j max_jobs" in the make(1) man page.
The target in question is on line 671:
$(DOCDIR)/userguide/index.htm:
I don't know where that file is, but a portable Makefile must
assume that it's unspecified whether or not each line of commands
is run in a different subshell. A portable Makefile must
therefore run both the "cd" command and anything that depends on
it in a single logical line (otherwise it will fail if different
lines get different subshells), and it must explicitly run the
group of commands in a subshell using '(...)' (otherwise the
next line will have the wrong directory, if different do not
automatically get different subshells.
good:
(cd dir1 ; cmd1)
(cd dir2 ; cmd2)
fails_without_-B:
cd dir1 ; cmd1
cd dir2 ; cmd2
fails_with_-B:
cd dir1
cmd1
cd dir2
cmd2
--apb (Alan Barrett)
Home |
Main Index |
Thread Index |
Old Index