Makefiles take an adjustable number of jobs
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 6 Apr 2010 00:39:42 +0000 (17:39 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:40 +0000 (17:35 -0700)
Set MAKE_JOBS in your Makelocal if you want to provide an argument to
make -j (like if you don't have an obscene number of cores).

GNUmakefile
tools/compilers/gcc-glibc/Makefile

index 8898ba4..ccf8d8d 100644 (file)
@@ -21,9 +21,9 @@ $(TARGET_ARCH):
        @if [ "$(ARCH_LINK)" != "$@" ];\
        then\
          $(MAKE) realclean;\
-         $(MAKE) realall -j;\
+         $(MAKE) realall -j $(MAKE_JOBS);\
        else\
-         $(MAKE) all -j;\
+         $(MAKE) all -j $(MAKE_JOBS);\
        fi
 
 ############################################################################# 
@@ -38,6 +38,9 @@ V := @
 # Make sure that 'all' is the first target when not erroring out
 realall: symlinks
 
+# Number of make jobs to spawn.  Define it in Makelocal
+MAKE_JOBS := 
+
 # Then grab the users Makelocal file to let them override Make system variables
 # and set up other Make targets
 include Makeconfig
@@ -137,7 +140,7 @@ symlinks: error
        ln -fs ../arch/$(ROS_ARCH_DIR) kern/include/arch
        ln -fs arch/$(ROS_ARCH_DIR)/boot kern/boot
        ln -fs $(ROS_ARCH_DIR) user/include/arch
-       @$(MAKE) -j all
+       @$(MAKE) -j $(MAKE_JOBS) all
 
 # Include Makefrags for subdirectories
 ifneq ($(TARGET_ARCH),)
@@ -150,7 +153,7 @@ ifeq ($(GCCPREFIX),$(TARGET_ARCH)-ros-)
 GCC_ROOT := $(shell which $(GCCPREFIX)gcc | xargs dirname)/../
 tests/: tests
 tests:
-       @$(MAKE) -j realtests
+       @$(MAKE) -j $(MAKE_JOBS) realtests
 realtests: $(TESTS_EXECS)
        @mkdir -p fs/$(TARGET_ARCH)/tests
        cp -R $(OBJDIR)/$(TESTS_DIR)/* $(TOP_DIR)/fs/$(TARGET_ARCH)/tests
index 16991cf..27be4fe 100644 (file)
@@ -1,3 +1,6 @@
+# Number of make jobs to spawn.  Define it in Makelocal
+MAKE_JOBS := 
+
 # Defines where to install the toolchain
 -include Makelocal
 
@@ -187,11 +190,11 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 
 .$(BINARY_PREFIX)binutils-make: .$(BINARY_PREFIX)binutils-configure
        cd $(BINARY_PREFIX)binutils-builddir; \
-       make -j
+       make -j $(MAKE_JOBS)
 
 .$(BINARY_PREFIX)binutils-install:
        cd $(BINARY_PREFIX)binutils-builddir; \
-       make -j install
+       make -j $(MAKE_JOBS) install
 
 .$(BINARY_PREFIX)glibc-headers-configure:
        $(MAKE) $(BINARY_PREFIX)glibc-headers-builddir
@@ -212,7 +215,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 
 .$(BINARY_PREFIX)glibc-headers-install: .$(BINARY_PREFIX)glibc-headers-configure
        cd $(BINARY_PREFIX)glibc-headers-builddir; \
-       make -j install-headers; \
+       make -j $(MAKE_JOBS) install-headers; \
        mkdir -p $(INSTDIR)/$(ARCH)-ros/include/gnu; \
        echo > $(INSTDIR)/$(ARCH)-ros/include/gnu/stubs.h; \
        cp bits/stdio_lim.h $(INSTDIR)/$(ARCH)-ros/include/bits/
@@ -252,11 +255,11 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
        # It appears to still work though since this is just stage 1 of compiling
        # Should really look into fixing this though...
        -cd $(BINARY_PREFIX)gcc-stage1-builddir; \
-       make -j inhibit_libc=true cross-compiling=yes
+       make -j $(MAKE_JOBS) inhibit_libc=true cross-compiling=yes
 
 .$(BINARY_PREFIX)gcc-stage1-install: 
        cd $(BINARY_PREFIX)gcc-stage1-builddir; \
-       make -j install
+       make -j $(MAKE_JOBS) install
        #-ln -vs libgcc.a `$(BINARY_PREFIX)gcc -print-libgcc-file-name | \
        #                 sed 's/libgcc/&_eh/'`
 
@@ -280,11 +283,11 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 
 .$(BINARY_PREFIX)glibc-make: .$(BINARY_PREFIX)glibc-configure
        cd $(BINARY_PREFIX)glibc-builddir; \
-       make -j
+       make -j $(MAKE_JOBS)
 
 .$(BINARY_PREFIX)glibc-install: 
        cd $(BINARY_PREFIX)glibc-builddir; \
-       make -j install
+       make -j $(MAKE_JOBS) install
 
 .$(BINARY_PREFIX)gcc-stage2-configure:
        $(MAKE) $(BINARY_PREFIX)gcc-stage2-builddir
@@ -306,11 +309,11 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 
 .$(BINARY_PREFIX)gcc-stage2-make: .$(BINARY_PREFIX)gcc-stage2-configure
        cd $(BINARY_PREFIX)gcc-stage2-builddir; \
-       make -j
+       make -j $(MAKE_JOBS)
 
 .$(BINARY_PREFIX)gcc-stage2-install:
        cd $(BINARY_PREFIX)gcc-stage2-builddir; \
-       make -j install
+       make -j $(MAKE_JOBS) install
 
 patches:
        mv gcc-$(GCC_VERSION)/gmp .