source: rtems/cpukit/automake/subdirs.am @ 9ff0f40

5
Last change on this file since 9ff0f40 was 7ec982bf, checked in by Chris Johns <chrisj@…>, on 05/26/17 at 00:35:17

build-system: Fix the targets support for the parallel build.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1## Copyright 2017 Chris Johns <chrisj@rtems.org>
2
3##
4## The following builds in parallel. The subdirectories are
5## expanded into separate rules and all the targets are listed
6## and make runs as many as it can.
7##
8## A macro is defined and evaluated once for each directory. This
9## creates the instance of the rule. Use $(info ...) to print them.
10##
11
12SUBDIRS_dot              = $(filter     .,$(_SUBDIRS))
13SUBDIRS_no_dot           = $(filter-out .,$(_SUBDIRS))
14SUBDIRS_no_dot_no_wrapup = $(filter-out wrapup,$(SUBDIRS_no_dot))
15SUBDIRS_wrapup           = $(filter     wrapup,$(SUBDIRS_no_dot))
16
17SUBDIR_TARGET     = $(subst /,-,$1)
18PREINSTALL_TARGET = preinstall-$(call SUBDIR_TARGET,$(1))
19
20preintstall_targets  = $(if "$(SUBDIRS_dot)" ".",preinstall-dot) $(foreach D,$(SUBDIRS_no_dot),$(call PREINSTALL_TARGET,$(D)))
21
22define PREINSTALL_DIR
23.PHONY: $1
24$1:
25        @+set fnord $(MAKEFLAGS); amf=$$$$2; \
26        subdir=$(2); \
27        subdir_label=`echo $(1) | sed -e 's/preinstall-//'`; \
28        target=`echo $$@ | sed -e 's/-recursive//' -e "s/-$$$${subdir_label}//"`$(3); \
29        echo "Making $$$$target in $$$$subdir"; \
30        (cd $$$$subdir && $(MAKE) $(AM_MAKEFLAGS) $$$$target) \
31         || case "$$$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac;
32endef
33
34$(if "$(SUBDIRS_dot)" ".",$(eval $(call PREINSTALL_DIR,preinstall-dot,.,-am)))
35
36$(foreach D,$(SUBDIRS_no_dot),$(eval $(call PREINSTALL_DIR,$(call PREINSTALL_TARGET,$(D)),$(D))))
37
38preinstall: $(preintstall_targets)
39.PHONY: preinstall
40
41define CPUKITDIR
42.PHONY: $1
43$1: $(preintstall_targets)
44        @+set fnord $(MAKEFLAGS); amf=$$$$2; \
45        subdir=$(2); \
46        target=`echo $(MAKECMDGOALS) | sed s/-recursive//`; \
47        if test "$$$$target" = "all-local-am"; then \
48          target="all-am"; \
49        fi; \
50        if test "$$$$target" = "all-local"; then \
51          target="all"; \
52        fi; \
53        echo "Making $$$$target in $$$$subdir"; \
54        if test "$$$$subdir" != "."; then \
55          cd $$$$subdir; \
56          $(MAKE) $(AM_MAKEFLAGS) $$$$target; \
57        fi;
58endef
59
60#
61# This GNU make syntax is being used to stop automake thinking the code is for
62# it.
63#
64$(if "$(SUBDIRS_dot)" ".",$(eval $(call CPUKITDIR,dot,.)))
65
66$(foreach D,$(SUBDIRS_no_dot),$(eval $(call CPUKITDIR,$(D),$(D))))
67
68#
69# If there is a wrapup make it depend on all other directories so it is not
70# entered until they have finished.
71#
72$(if "$(SUBDIRS_wrapup)" "wrapup",wrapup: dot $(foreach D,$(SUBDIRS_no_dot_no_wrapup),$(D)),)
73
74all-local: preinstall $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot)
Note: See TracBrowser for help on using the repository browser.