fix multithreaded building
authorDennis Groenen <tj.groenen@gmail.com>
Sun, 5 Feb 2012 13:29:37 +0000 (14:29 +0100)
committerDennis Groenen <tj.groenen@gmail.com>
Sun, 5 Feb 2012 13:36:54 +0000 (14:36 +0100)
debian/rules

index 6a83a53..e0a7f6a 100755 (executable)
@@ -17,6 +17,17 @@ ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
 THUMB := -mthumb
 endif
 
+ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
+    PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
+        sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
+    ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS))
+        PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \
+            then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \
+            else echo 1; fi)
+    endif
+    NJOBS := -j$(PARALLEL_JOBS)
+endif
+
 source: $(STAMPS_DIR)/source
 
 $(STAMPS_DIR)/source: SOURCE_FILES = $(filter-out debian, $(wildcard * .[^.]*))
@@ -46,7 +57,7 @@ build: $(STAMPS_DIR)/build_busybox
 $(STAMPS_DIR)/build_%: DIR=$(BUILD_DIR)/build_$*
 $(STAMPS_DIR)/build_%: $(STAMPS_DIR)/setup_%
        dh_testdir
-       make -C '$(DIR)' THUMB=$(THUMB) busybox docs/busybox.1 BB_EXTRA_VERSION="$(shell lsb_release -is) $(VERSION_DEBIAN)"
+       make -C '$(DIR)' $(NJOBS) THUMB=$(THUMB) busybox docs/busybox.1 BB_EXTRA_VERSION="$(shell lsb_release -is) $(VERSION_DEBIAN)"
        make -C '$(DIR)' busybox.links
        touch $@