1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
## Copyright 2017 Chris Johns <chrisj@rtems.org>
##
## 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_no_dot_no_testsuites = $(filter-out testsuites,$(SUBDIRS_no_dot))
SUBDIRS_no_dot_no_wrapup_no_testsuites = $(filter-out testsuites,$(SUBDIRS_no_dot_no_wrapup))
SUBDIRS_wrapup = $(filter wrapup,$(SUBDIRS_no_dot))
SUBDIRS_testsuites = $(filter testsuites,$(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) $$$$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 except the
# testsuite so it is not entered until everything but the testsuite has
# finished.
#
$(if "$(SUBDIRS_wrapup)" "wrapup",wrapup: dot $(SUBDIRS_no_dot_no_wrapup_no_testsuites))
#
# If there is a testsuite make it depend on all other directories so it is not
# entered until everything else has finished.
#
$(if "$(SUBDIRS_testsuites)" "testsuites",testsuites: dot $(SUBDIRS_no_dot_no_testsuites))
#
# The general build all rule for automake.
#
all-local: preinstall $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot)
|