rework parallel building to get rid of some warnings and add back support for parallelizing the kernel build fixes #3882
SVN-Revision: 12322
This commit is contained in:
		
							
								
								
									
										8
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								Makefile
									
									
									
									
									
								
							| @@ -20,7 +20,7 @@ ifneq ($(OPENWRT_BUILD),1) | |||||||
|   # but we can't include that file in this context |   # but we can't include that file in this context | ||||||
|   empty:= |   empty:= | ||||||
|   space:= $(empty) $(empty) |   space:= $(empty) $(empty) | ||||||
|   _SINGLE=MAKEFLAGS=$(space) |   _SINGLE=export MAKEFLAGS=$(space); | ||||||
|  |  | ||||||
|   override OPENWRT_BUILD=1 |   override OPENWRT_BUILD=1 | ||||||
|   export OPENWRT_BUILD |   export OPENWRT_BUILD | ||||||
| @@ -50,7 +50,7 @@ $(BUILD_DIR)/.prepared: Makefile | |||||||
|  |  | ||||||
| clean: FORCE | clean: FORCE | ||||||
| 	rm -rf $(BUILD_DIR) $(BIN_DIR) | 	rm -rf $(BUILD_DIR) $(BIN_DIR) | ||||||
| 	$(SUBMAKE) target/linux/clean | 	$(_SINGLE)$(SUBMAKE) target/linux/clean | ||||||
|  |  | ||||||
| dirclean: clean | dirclean: clean | ||||||
| 	rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) | 	rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) | ||||||
| @@ -59,7 +59,7 @@ dirclean: clean | |||||||
| tmp/.prereq_packages: .config | tmp/.prereq_packages: .config | ||||||
| 	unset ERROR; \ | 	unset ERROR; \ | ||||||
| 	for package in $(sort $(prereq-y) $(prereq-m)); do \ | 	for package in $(sort $(prereq-y) $(prereq-m)); do \ | ||||||
| 		$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \ | 		$(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \ | ||||||
| 	done; \ | 	done; \ | ||||||
| 	if [ -n "$$ERROR" ]; then \ | 	if [ -n "$$ERROR" ]; then \ | ||||||
| 		echo "Package prerequisite check failed."; \ | 		echo "Package prerequisite check failed."; \ | ||||||
| @@ -72,7 +72,7 @@ prereq: $(target/stamp-prereq) tmp/.prereq_packages | |||||||
|  |  | ||||||
| prepare: .config $(tools/stamp-install) $(toolchain/stamp-install) | prepare: .config $(tools/stamp-install) $(toolchain/stamp-install) | ||||||
| world: prepare $(target/stamp-compile) $(package/stamp-cleanup) $(package/stamp-compile) $(package/stamp-install) $(package/stamp-rootfs-prepare) $(target/stamp-install) FORCE | world: prepare $(target/stamp-compile) $(package/stamp-cleanup) $(package/stamp-compile) $(package/stamp-install) $(package/stamp-rootfs-prepare) $(target/stamp-install) FORCE | ||||||
| 	$(SUBMAKE) package/index | 	$(_SINGLE)$(SUBMAKE) package/index | ||||||
|  |  | ||||||
| # update all feeds, re-create index files, install symlinks | # update all feeds, re-create index files, install symlinks | ||||||
| package/symlinks: | package/symlinks: | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ include $(INCLUDE_DIR)/prereq.mk | |||||||
| include $(INCLUDE_DIR)/kernel.mk | include $(INCLUDE_DIR)/kernel.mk | ||||||
| include $(INCLUDE_DIR)/host.mk | include $(INCLUDE_DIR)/host.mk | ||||||
|  |  | ||||||
|  | .NOTPARALLEL: | ||||||
| override MAKEFLAGS= | override MAKEFLAGS= | ||||||
| override MAKE:=$(SUBMAKE) | override MAKE:=$(SUBMAKE) | ||||||
| KDIR=$(KERNEL_BUILD_DIR) | KDIR=$(KERNEL_BUILD_DIR) | ||||||
|   | |||||||
| @@ -80,25 +80,18 @@ define BuildKernel | |||||||
| 	[ -e "$(LINUX_CONFIG)" ] || touch "$(LINUX_CONFIG)" | 	[ -e "$(LINUX_CONFIG)" ] || touch "$(LINUX_CONFIG)" | ||||||
| 	$(LINUX_CONFCMD) > $(LINUX_DIR)/.config | 	$(LINUX_CONFCMD) > $(LINUX_DIR)/.config | ||||||
| 	touch $(LINUX_CONFIG) | 	touch $(LINUX_CONFIG) | ||||||
| 	$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $$@ | 	$(_SINGLE)$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $$@ | ||||||
| 	$(SCRIPT_DIR)/kconfig.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG) | 	$(SCRIPT_DIR)/kconfig.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG) | ||||||
| 	$(Kernel/Configure) | 	$(Kernel/Configure) | ||||||
|  |  | ||||||
|   install: $(LINUX_DIR)/.image |   install: $(LINUX_DIR)/.image | ||||||
| 	TARGET_BUILD="" $(MAKE) -C image compile install | 	+$(MAKE) -C image compile install TARGET_BUILD= | ||||||
|  |  | ||||||
|   clean: FORCE |   clean: FORCE | ||||||
| 	rm -rf $(KERNEL_BUILD_DIR) | 	rm -rf $(KERNEL_BUILD_DIR) | ||||||
|  |  | ||||||
|   rebuild: FORCE |  | ||||||
| 	@$(MAKE) mostlyclean |  | ||||||
| 	@if [ -f $(LINUX_KERNEL) ]; then \ |  | ||||||
| 		$(MAKE) clean; \ |  | ||||||
| 	fi |  | ||||||
| 	@$(MAKE) compile |  | ||||||
|  |  | ||||||
|   image-prereq: |   image-prereq: | ||||||
| 	@$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD= | 	@+$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD= | ||||||
|  |  | ||||||
|   prereq: image-prereq |   prereq: image-prereq | ||||||
|  |  | ||||||
|   | |||||||
| @@ -69,11 +69,11 @@ endif | |||||||
|  |  | ||||||
| define Kernel/Configure/2.4 | define Kernel/Configure/2.4 | ||||||
| 	$(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile | 	$(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile | ||||||
| 	$(MAKE) $(KERNEL_MAKEOPTS) oldconfig include/linux/compile.h include/linux/version.h | 	$(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) oldconfig include/linux/compile.h include/linux/version.h | ||||||
| 	$(MAKE) $(KERNEL_MAKEOPTS) dep | 	$(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) dep | ||||||
| endef | endef | ||||||
| define Kernel/Configure/2.6 | define Kernel/Configure/2.6 | ||||||
| 	-$(MAKE) $(KERNEL_MAKEOPTS) oldconfig prepare scripts | 	-$(_SINGLE)$(MAKE) $(KERNEL_MAKEOPTS) oldconfig prepare scripts | ||||||
| endef | endef | ||||||
| define Kernel/Configure/Default | define Kernel/Configure/Default | ||||||
| 	$(LINUX_CONFCMD) > $(LINUX_DIR)/.config.target | 	$(LINUX_CONFCMD) > $(LINUX_DIR)/.config.target | ||||||
| @@ -86,12 +86,12 @@ endef | |||||||
|  |  | ||||||
| define Kernel/CompileModules/Default | define Kernel/CompileModules/Default | ||||||
| 	rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map | 	rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map | ||||||
| 	$(MAKE) $(KERNEL_MAKEOPTS) modules | 	+$(MAKE) $(KERNEL_MAKEOPTS) modules | ||||||
| endef | endef | ||||||
|  |  | ||||||
| define Kernel/CompileImage/Default | define Kernel/CompileImage/Default | ||||||
| 	$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),,rm -f $(TARGET_DIR)/init) | 	$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),,rm -f $(TARGET_DIR)/init) | ||||||
| 	$(MAKE) $(KERNEL_MAKEOPTS) $(KERNELNAME) | 	+$(MAKE) $(KERNEL_MAKEOPTS) $(KERNELNAME) | ||||||
| 	$(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL) | 	$(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL) | ||||||
| 	$(KERNEL_CROSS)objcopy -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf | 	$(KERNEL_CROSS)objcopy -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf | ||||||
| endef | endef | ||||||
| @@ -99,7 +99,7 @@ endef | |||||||
| define Kernel/Clean/Default | define Kernel/Clean/Default | ||||||
| 	rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured | 	rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured | ||||||
| 	rm -f $(LINUX_KERNEL) | 	rm -f $(LINUX_KERNEL) | ||||||
| 	$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean | 	$(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean | ||||||
| endef | endef | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ define subdir | |||||||
|     $(call warn,$(1),d,BD $(1)/$(bd)) |     $(call warn,$(1),d,BD $(1)/$(bd)) | ||||||
|     $(foreach target,$(SUBTARGETS), |     $(foreach target,$(SUBTARGETS), | ||||||
|       $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $(if $(QUILT),,$($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd)))) |       $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $(if $(QUILT),,$($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd)))) | ||||||
| 		$(if $(findstring $(bd),$($(1)/builddirs-parallel)),$$(SUBMAKE),$$(SUBMAKE) -j1) \ | 		+$(if $(findstring $(bd),$($(1)/builddirs-parallel)),$$(SUBMAKE),$(_SINGLE)$$(SUBMAKE) -j1) \ | ||||||
| 			-C $(1)/$(bd) $(target) $(if $(findstring $(bd),$($(1)/builddirs-ignore-$(target))), || $(call MESSAGE,   ERROR: $(1)/$(bd) failed to build.)) | 			-C $(1)/$(bd) $(target) $(if $(findstring $(bd),$($(1)/builddirs-ignore-$(target))), || $(call MESSAGE,   ERROR: $(1)/$(bd) failed to build.)) | ||||||
|         $$(if $(call debug,$(1)/$(bd),v),,.SILENT: $(1)/$(bd)/$(target)) |         $$(if $(call debug,$(1)/$(bd),v),,.SILENT: $(1)/$(bd)/$(target)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -47,22 +47,22 @@ prepare-tmpinfo: FORCE | |||||||
| .config: ./scripts/config/conf prepare-tmpinfo $(if $(CONFIG_HAVE_DOT_CONFIG),,FORCE) | .config: ./scripts/config/conf prepare-tmpinfo $(if $(CONFIG_HAVE_DOT_CONFIG),,FORCE) | ||||||
| 	@+if [ \! -f .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \ | 	@+if [ \! -f .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \ | ||||||
| 		[ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \ | 		[ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \ | ||||||
| 		$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \ | 		$(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \ | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| scripts/config/mconf: | scripts/config/mconf: | ||||||
| 	@$(SUBMAKE) -s -j1 -C scripts/config all | 	@$(_SINGLE)$(SUBMAKE) -s -C scripts/config all | ||||||
|  |  | ||||||
| $(eval $(call rdep,scripts/config,scripts/config/mconf)) | $(eval $(call rdep,scripts/config,scripts/config/mconf)) | ||||||
|  |  | ||||||
| scripts/config/conf: | scripts/config/conf: | ||||||
| 	@$(SUBMAKE) -s -j1 -C scripts/config conf | 	@$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf | ||||||
|  |  | ||||||
| config: scripts/config/conf prepare-tmpinfo FORCE | config: scripts/config/conf prepare-tmpinfo FORCE | ||||||
| 	$< Config.in | 	$< Config.in | ||||||
|  |  | ||||||
| config-clean: FORCE | config-clean: FORCE | ||||||
| 	$(NO_TRACE_MAKE) -C scripts/config clean | 	$(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean | ||||||
|  |  | ||||||
| defconfig: scripts/config/conf prepare-tmpinfo FORCE | defconfig: scripts/config/conf prepare-tmpinfo FORCE | ||||||
| 	touch .config | 	touch .config | ||||||
| @@ -78,10 +78,10 @@ menuconfig: scripts/config/mconf prepare-tmpinfo FORCE | |||||||
| 	$< Config.in | 	$< Config.in | ||||||
|  |  | ||||||
| kernel_oldconfig: .config FORCE | kernel_oldconfig: .config FORCE | ||||||
| 	$(NO_TRACE_MAKE) -C target/linux oldconfig | 	$(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig | ||||||
|  |  | ||||||
| kernel_menuconfig: .config FORCE | kernel_menuconfig: .config FORCE | ||||||
| 	$(NO_TRACE_MAKE) -C target/linux menuconfig | 	$(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig | ||||||
|  |  | ||||||
| tmp/.prereq-build: include/prereq-build.mk | tmp/.prereq-build: include/prereq-build.mk | ||||||
| 	mkdir -p tmp | 	mkdir -p tmp | ||||||
| @@ -103,7 +103,7 @@ clean dirclean: .config | |||||||
|  |  | ||||||
| prereq:: .config | prereq:: .config | ||||||
| 	@+$(MAKE) -s tmp/.prereq-build $(PREP_MK) | 	@+$(MAKE) -s tmp/.prereq-build $(PREP_MK) | ||||||
| 	@$(NO_TRACE_MAKE) -s $@ | 	@+$(NO_TRACE_MAKE) -s $@ | ||||||
|  |  | ||||||
| %:: | %:: | ||||||
| 	@+$(PREP_MK) $(NO_TRACE_MAKE) -s prereq | 	@+$(PREP_MK) $(NO_TRACE_MAKE) -s prereq | ||||||
| @@ -113,14 +113,14 @@ help: | |||||||
| 	cat README | 	cat README | ||||||
|  |  | ||||||
| docs docs/compile: FORCE | docs docs/compile: FORCE | ||||||
| 	@$(SUBMAKE) -j1 -C docs compile | 	@$(_SINGLE)$(SUBMAKE) -C docs compile | ||||||
|  |  | ||||||
| docs/clean: FORCE | docs/clean: FORCE | ||||||
| 	@$(SUBMAKE) -j1 -C docs clean | 	@$(_SINGLE)$(SUBMAKE) -C docs clean | ||||||
|  |  | ||||||
| distclean: | distclean: | ||||||
| 	rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin | 	rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin | ||||||
| 	@$(SUBMAKE) -j1 -C scripts/config clean | 	@$(_SINGLE)$(SUBMAKE) -C scripts/config clean | ||||||
|  |  | ||||||
| ifeq ($(findstring v,$(DEBUG)),) | ifeq ($(findstring v,$(DEBUG)),) | ||||||
|   .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package prepare-tmpinfo |   .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package prepare-tmpinfo | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								rules.mk
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								rules.mk
									
									
									
									
									
								
							| @@ -29,7 +29,7 @@ merge=$(subst $(space),,$(1)) | |||||||
| confvar=$(call merge,$(foreach v,$(1),$(if $($(v)),y,n))) | confvar=$(call merge,$(foreach v,$(1),$(if $($(v)),y,n))) | ||||||
| strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1)) | strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1)) | ||||||
|  |  | ||||||
| _SINGLE=MAKEFLAGS=$(space) | _SINGLE=export MAKEFLAGS=$(space); | ||||||
| ARCH:=$(call qstrip,$(shell echo $(CONFIG_ARCH) | sed -e 's/i[3-9]86/i386/')) | ARCH:=$(call qstrip,$(shell echo $(CONFIG_ARCH) | sed -e 's/i[3-9]86/i386/')) | ||||||
| BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) | BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) | ||||||
| TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) | TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) | ||||||
|   | |||||||
| @@ -10,4 +10,4 @@ include $(INCLUDE_DIR)/target.mk | |||||||
| export TARGET_BUILD=1 | export TARGET_BUILD=1 | ||||||
|  |  | ||||||
| prereq clean download prepare compile install menuconfig oldconfig update refresh: FORCE | prereq clean download prepare compile install menuconfig oldconfig update refresh: FORCE | ||||||
| 	@$(NO_TRACE_MAKE) -C $(BOARD) $@ | 	@+$(NO_TRACE_MAKE) -C $(BOARD) $@ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Felix Fietkau
					Felix Fietkau