2

I'm using make on Windows 8

C:\Users\<User>\Desktop\A\test_compile>make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for Windows32

This is my makefile

CPP_FILES := $(wildcard *.cpp)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
LD_FLAGS := -o

all: $(patsubst %.cpp, %.o, $(wildcard *.cpp))
    @echo MAKEFLAGS=$(MAKEFLAGS)
    rm *.o

%.o: %.cpp
    @echo MAKEFLAGS=$(MAKEFLAGS)
    qcc.exe $(CC_FLAGS) $@ $< 

Notice the @echo MAKEFLAGS=$(MAKEFLAGS) line I added for debug.

When I run the makefile make all -j64 I do get parallel jobs - all my cores are active - but the echo MAKEFLAGS is:

MAKEFLAGS=-j 1

Why doesn't it say MAKEFLAGS=-j 64?

Bob
  • 4,576
  • 7
  • 39
  • 107
  • possible duplicate with http://stackoverflow.com/questions/5303553/gnu-make-extracting-argument-to-j-within-makefile – jyvet May 20 '16 at 21:59

1 Answers1

3

From the manual

The ‘-j’ option is a special case (see Parallel Execution). If you set it to some numeric value ‘N’ and your operating system supports it (most any UNIX system will; others typically won’t), the parent make and all the sub-makes will communicate to ensure that there are only ‘N’ jobs running at the same time between them all. Note that any job that is marked recursive (see Instead of Executing Recipes) doesn’t count against the total jobs (otherwise we could get ‘N’ sub-makes running and have no slots left over for any real work!)

If your operating system doesn’t support the above communication, then ‘-j 1’ is always put into MAKEFLAGS instead of the value you specified. This is because if the ‘-j’ option were passed down to sub-makes, you would get many more jobs running in parallel than you asked for.

Your version of make does support parallel jobs, but it doesn't have the necessary machinery to sync the jobs between recursive invocations of make so it sets the jobs to 1 in MAKEFLAGS.

Support for this feature was added for windows in make 4.0.

Community
  • 1
  • 1
user657267
  • 20,568
  • 5
  • 58
  • 77
  • I'll try using a different version of make on Monday – Bob May 21 '16 at 00:28
  • Turns out http://gnuwin32.sourceforge.net/packages/make.htm only has 3.81 for windows and I'll have to compile 4.2 myself. – Bob May 23 '16 at 16:37
  • Well I built make 4.2 for Windows and make flags was the correct value. But turned out to be moot since the existing make files are not executable on parallel mode and I had to use Electric Cloud to accelerate it. – Bob May 28 '16 at 02:00