2

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?

Community
  • 1
  • 1
Walter
  • 44,150
  • 20
  • 113
  • 196
  • May be that sub-make invokes another sub-make without `+` and that causes this warning? – Maxim Egorushkin Jun 10 '15 at 09:27
  • @MaximEgorushkin *Obviously not* as can be clearly seen from the output of `make` given in the question. – Walter Jun 10 '15 at 09:44
  • Well, the output mentions target `default`, whereas your make rule does not have `default` in the command line. Are you looking at the right rule? – Maxim Egorushkin Jun 10 '15 at 09:46
  • @MaximEgorushkin you observed that correctly. I was indeed looking at the wrong line in my makefile, but even when using the corret one (and after modifying it to use `$(MAKE)`), things stay the same. I have amended the question – Walter Jun 10 '15 at 11:53
  • 1
    I agree with Maxim: the example you've shown us works fine and will not generate that message. So if you're seeing that message, it's being caused by something you _didn't_ show us. Clearly we can't help you find problems in something you didn't show us. You'll need to come up with an actual reproducible case (SSCCE). For example, are you setting the SHELL variable in your makefile? Maybe to, I dunno... `/usr/bin/csh`? If so, don't do that. – MadScientist Jun 10 '15 at 11:54
  • @MadScientist I appreciate that this was not a SSCCE. Your point with the SHELL variable solved the problem. Why does this cause a problem and what's the point of defining it? (I must have had a reason to put this in there at some point, but cannot remember it.) – Walter Jun 10 '15 at 12:00

1 Answers1

4

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.

MadScientist
  • 92,819
  • 9
  • 109
  • 136