how to parallel sub-make?

1.5k views Asked by At

In my makefile, I have a line

# in makefile:
SHELL   := csh
.PHONY  : foo
foo :
        $(MAKE) -C foo

When calling make -j8 (running linux using GNU Make 3.81), I get

make -C foo
make[1]: Entering directory `/some/dir/foo'
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
make[1]: Nothing to be done for `default'.
make[1]: Leaving directory `/some/dir/foo'

What is the correct rule in my parent makefile to avoid this warning?

(Note I looked at this and this SO questions, but cannot find a satisfactory answer. In particular +$(MAKE) -C foo doesn't work. Perhaps I should also say that in the parent make the parallel making works as intended.)

Or is my operating system not supporting parallel sub-makes? (this documentation says most unix system do). How can I find out for sure?

1

There are 1 answers

0
MadScientist On

As per your comment above, you cannot set SHELL to csh (or a variant of that like tcsh) if you want to use GNU make's jobserver feature.

Setting SHELL to csh allows you to write your shell recipes in csh scripting instead of sh (Bourne/POSIX shell) scripting.

Unfortunately, csh is a terrible scripting language. One of its terrible things is that it "helpfully" futzes with your file descriptors... including the ones that GNU make is using to control the jobserver.

So, do not use csh. Or at the very least, do not use csh in your makefile recipes. Unfortunately just changing this value might cause your makefile to break, if you've written your recipes using csh scripting instead of sh scripting.