From a748603cb4565d395db1acf812cb1aee2f0642d9 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Sun, 14 May 2017 11:52:52 +1000 Subject: build-system: Parallel build all subdirs. --- cpukit/Makefile.am | 44 +++++++++--------- cpukit/automake/subdirs.am | 104 ++++++++++++++++++++++++++++++------------- cpukit/libfs/Makefile.am | 2 +- cpukit/score/Makefile.am | 2 +- cpukit/score/cpu/Makefile.am | 2 +- 5 files changed, 99 insertions(+), 55 deletions(-) (limited to 'cpukit') diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 3206ee2123..ae5ed9b19e 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -4,30 +4,30 @@ include $(top_srcdir)/automake/compile.am include $(top_srcdir)/automake/multilib.am # librtemscpu -SUBDIRS = . score rtems sapi posix -SUBDIRS += dev -SUBDIRS += dtc/libfdt -SUBDIRS += libcrypt -SUBDIRS += libcsupport libblock libfs -SUBDIRS += libdrvmgr -SUBDIRS += libnetworking librpc -SUBDIRS += libpci -SUBDIRS += libi2c -SUBDIRS += libmisc -SUBDIRS += libmd -SUBDIRS += libgnat -SUBDIRS += libdl -SUBDIRS += libstdthreads -SUBDIRS += libdebugger -SUBDIRS += wrapup - -SUBDIRS += zlib +_SUBDIRS = . score rtems sapi posix +_SUBDIRS += dev +_SUBDIRS += dtc/libfdt +_SUBDIRS += libcrypt +_SUBDIRS += libcsupport libblock libfs +_SUBDIRS += libdrvmgr +_SUBDIRS += libnetworking librpc +_SUBDIRS += libpci +_SUBDIRS += libi2c +_SUBDIRS += libmisc +_SUBDIRS += libmd +_SUBDIRS += libgnat +_SUBDIRS += libdl +_SUBDIRS += libstdthreads +_SUBDIRS += libdebugger +_SUBDIRS += wrapup + +_SUBDIRS += zlib # applications -SUBDIRS += ftpd -SUBDIRS += telnetd -SUBDIRS += pppd -SUBDIRS += mghttpd +_SUBDIRS += ftpd +_SUBDIRS += telnetd +_SUBDIRS += pppd +_SUBDIRS += mghttpd noinst_DATA = preinstall-stamp preinstall-stamp: diff --git a/cpukit/automake/subdirs.am b/cpukit/automake/subdirs.am index 1e0a9a757a..723aec8af2 100644 --- a/cpukit/automake/subdirs.am +++ b/cpukit/automake/subdirs.am @@ -1,30 +1,74 @@ -## Borrowed from automake-1.4 and adapted to RTEMS - -## NOTE: This is a temporary work-around to keep -## RTEMS's non automake standard make targets working. -## Once automake is fully integrated these make targets -## and this file will probably be removed - -preinstall-recursive: - @set fnord $(MAKEFLAGS); amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ -## This trick allows "-k" to keep its natural meaning when running a -## recursive rule. - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -preinstall: preinstall-recursive -.PHONY: preinstall-recursive +## Copyright 2017 Chris Johns + +## +## The following builds in parallel. The subdirectories are +## expanded into separate rules and all the targets are listed +## and make runs as many as it can. +## +## A macro is defined and evaluated once for each directory. This +## creates the instance of the rule. Use $(info ...) to print them. +## + +SUBDIRS_dot = $(filter .,$(_SUBDIRS)) +SUBDIRS_no_dot = $(filter-out .,$(_SUBDIRS)) +SUBDIRS_no_dot_no_wrapup = $(filter-out wrapup,$(SUBDIRS_no_dot)) +SUBDIRS_wrapup = $(filter wrapup,$(SUBDIRS_no_dot)) + +SUBDIR_TARGET = $(subst /,-,$1) +PREINSTALL_TARGET = preinstall-$(call SUBDIR_TARGET,$(1)) + +preintstall_targets = $(if "$(SUBDIRS_dot)" ".",preinstall-dot) $(foreach D,$(SUBDIRS_no_dot),$(call PREINSTALL_TARGET,$(D))) + +define PREINSTALL_DIR +.PHONY: $1 +$1: + @+set fnord $(MAKEFLAGS); amf=$$$$2; \ + subdir=$(2); \ + subdir_label=`echo $(1) | sed -e 's/preinstall-//'`; \ + target=`echo $$@ | sed -e 's/-recursive//' -e "s/-$$$${subdir_label}//"`$(3); \ + echo "Making $$$$target in $$$$subdir"; \ + (cd $$$$subdir && $(MAKE) $(AM_MAKEFLAGS) $$$$target) \ + || case "$$$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; +endef + +$(if "$(SUBDIRS_dot)" ".",$(eval $(call PREINSTALL_DIR,preinstall-dot,.,-am))) + +$(foreach D,$(SUBDIRS_no_dot),$(eval $(call PREINSTALL_DIR,$(call PREINSTALL_TARGET,$(D)),$(D)))) + +preinstall: $(preintstall_targets) +.PHONY: preinstall + +define CPUKITDIR +.PHONY: $1 +$1: $(preintstall_targets) + @+set fnord $(MAKEFLAGS); amf=$$$$2; \ + subdir=$(2); \ + target=`echo $(MAKECMDGOALS) | sed s/-recursive//`; \ + if test "$$$$target" = "all-local-am"; then \ + target="all-am"; \ + fi; \ + if test "$$$$target" = "all-local"; then \ + target="all"; \ + fi; \ + echo "Making $$$$target in $$$$subdir"; \ + if test "$$$$subdir" != "."; then \ + cd $$$$subdir; \ + $(MAKE) $(AM_MAKEFLAGS) $$$$local_target; \ + fi; +endef + +# +# This GNU make syntax is being used to stop automake thinking the code is for +# it. +# +$(if "$(SUBDIRS_dot)" ".",$(eval $(call CPUKITDIR,dot,.))) + +$(foreach D,$(SUBDIRS_no_dot),$(eval $(call CPUKITDIR,$(D),$(D)))) + +# +# If there is a wrapup make it depend on all other directories so it is not +# entered until they have finished. +# +$(if "$(SUBDIRS_wrapup)" "wrapup",wrapup: dot $(foreach D,$(SUBDIRS_no_dot_no_wrapup),$(D)),) + +all-local: preinstall $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot) diff --git a/cpukit/libfs/Makefile.am b/cpukit/libfs/Makefile.am index 89e7581b28..2a09aaa62d 100644 --- a/cpukit/libfs/Makefile.am +++ b/cpukit/libfs/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/automake/multilib.am include $(top_srcdir)/automake/compile.am -SUBDIRS = src/nfsclient +_SUBDIRS = src/nfsclient EXTRA_DIST = README diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 0288c5393a..a3de792fdf 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/automake/multilib.am include $(top_srcdir)/automake/compile.am -SUBDIRS = cpu +_SUBDIRS = cpu ## include diff --git a/cpukit/score/cpu/Makefile.am b/cpukit/score/cpu/Makefile.am index 1f57984105..51835109fb 100644 --- a/cpukit/score/cpu/Makefile.am +++ b/cpukit/score/cpu/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = @RTEMS_CPU@ +_SUBDIRS = @RTEMS_CPU@ DIST_SUBDIRS = DIST_SUBDIRS += arm -- cgit v1.2.3