11

I have a rather huge autotools-powered project that lives in a directory tree consisting of a lot of directories with subdirectories. It's got a target check (in each subdirectory as well as the main directory) that executes a whole lot of automated tests. The check target is built recursively.

Building as well as testing in parallel (via the -j option to make) works for most of the directories. There is however one directory that contains test that don't work when executed in parallel (timing sensitivity), but pass when run serially.

The question is: Is there a way to force make to build the check target serially in just this one subdirectory while building everything else in parallel?

arne
  • 4,514
  • 1
  • 28
  • 47
  • The only trick I can think of is inserting a false dependency for the serial check. There's a [basic idea](http://www.gnu.org/software/automake/manual/automake.html#true) in the manual. – Brett Hale Jun 19 '13 at 17:41
  • Why not solve this the make way by making the targets depend on each other? – reinierpost Jan 05 '15 at 13:34

2 Answers2

24

Add to your Makefile:

.NOTPARALLEL:

See the documentation of GNU make here.

Anthony Scemama
  • 1,563
  • 12
  • 19
5

If I understood you correctly, then when you run the recursive make that builds the check target you can just pass -j1 specifically, to ensure that it runs serially:

check: ; $(MAKE) -j1 ...
MadScientist
  • 92,819
  • 9
  • 109
  • 136
  • I'll try that when I find a couple of minutes. – arne Jun 19 '13 at 06:31
  • This does not work: this gives me warning: -jN forced in submake – Vincent Fourmond May 24 '14 at 19:22
  • 4
    It DOES absolutely work. Yes, you'll get a warning. But it will not run jobs in parallel. Using NOTPARALLEL is cleaner IF you always want every invocation of that makefile to be run not parallel (rather than just a specific invocation that invokes a specific target), and you can change the makefile. If one or both of these is not true, then NOTPARALLEL is less helpful. – MadScientist Jan 07 '15 at 23:12