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 | |
---|
12 | SUBDIRS_dot = $(filter .,$(_SUBDIRS)) |
---|
13 | SUBDIRS_no_dot = $(filter-out .,$(_SUBDIRS)) |
---|
14 | SUBDIRS_no_dot_no_wrapup = $(filter-out wrapup,$(SUBDIRS_no_dot)) |
---|
15 | SUBDIRS_no_dot_no_testsuites = $(filter-out testsuites,$(SUBDIRS_no_dot)) |
---|
16 | SUBDIRS_no_dot_no_wrapup_no_testsuites = $(filter-out testsuites,$(SUBDIRS_no_dot_no_wrapup)) |
---|
17 | SUBDIRS_wrapup = $(filter wrapup,$(SUBDIRS_no_dot)) |
---|
18 | SUBDIRS_testsuites = $(filter testsuites,$(SUBDIRS_no_dot)) |
---|
19 | |
---|
20 | preinstall: $(preintstall_targets) |
---|
21 | |
---|
22 | define CPUKITDIR |
---|
23 | .PHONY: $1 |
---|
24 | $1: $(preintstall_targets) |
---|
25 | @+set fnord $(MAKEFLAGS); amf=$$$$2; \ |
---|
26 | subdir=$(2); \ |
---|
27 | target=`echo $(MAKECMDGOALS) | sed s/-recursive//`; \ |
---|
28 | if test "$$$$target" = "all-local-am"; then \ |
---|
29 | target="all-am"; \ |
---|
30 | fi; \ |
---|
31 | if test "$$$$target" = "all-local"; then \ |
---|
32 | target="all"; \ |
---|
33 | fi; \ |
---|
34 | echo "Making $$$$target in $$$$subdir"; \ |
---|
35 | if test "$$$$subdir" != "."; then \ |
---|
36 | cd $$$$subdir; \ |
---|
37 | $(MAKE) $(AM_MAKEFLAGS) $$$$target; \ |
---|
38 | fi; |
---|
39 | endef |
---|
40 | |
---|
41 | # |
---|
42 | # This GNU make syntax is being used to stop automake thinking the code is for |
---|
43 | # it. |
---|
44 | # |
---|
45 | $(if "$(SUBDIRS_dot)" ".",$(eval $(call CPUKITDIR,dot,.))) |
---|
46 | |
---|
47 | $(foreach D,$(SUBDIRS_no_dot),$(eval $(call CPUKITDIR,$(D),$(D)))) |
---|
48 | |
---|
49 | # |
---|
50 | # If there is a wrapup make it depend on all other directories except the |
---|
51 | # testsuite so it is not entered until everything but the testsuite has |
---|
52 | # finished. |
---|
53 | # |
---|
54 | $(if "$(SUBDIRS_wrapup)" "wrapup",wrapup: dot $(SUBDIRS_no_dot_no_wrapup_no_testsuites)) |
---|
55 | |
---|
56 | # |
---|
57 | # If there is a testsuite make it depend on all other directories so it is not |
---|
58 | # entered until everything else has finished. |
---|
59 | # |
---|
60 | $(if "$(SUBDIRS_testsuites)" "testsuites",testsuites: dot $(SUBDIRS_no_dot_no_testsuites)) |
---|
61 | |
---|
62 | # |
---|
63 | # The general build all rule for automake. |
---|
64 | # |
---|
65 | all-local: $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot) |
---|