dotwait.mk revision 1.1 1 1.1 apb # $NetBSD: dotwait.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
2 1.1 apb
3 1.1 apb THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}
4 1.1 apb
5 1.1 apb TESTS= simple recursive shared cycle
6 1.1 apb PAUSE= sleep 1
7 1.1 apb
8 1.1 apb # Use a .for loop rather than dependencies here, to ensure
9 1.1 apb # that the tests are run one by one, with parallelism
10 1.1 apb # only within tests.
11 1.1 apb # Ignore "--- target ---" lines printed by parallel make.
12 1.1 apb all:
13 1.1 apb .for t in ${TESTS}
14 1.1 apb @${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- "
15 1.1 apb .endfor
16 1.1 apb
17 1.1 apb #
18 1.1 apb # Within each test, the names of the sub-targets follow these
19 1.1 apb # conventions:
20 1.1 apb # * If it's expected that two or more targets may be made in parallel,
21 1.1 apb # then the target names will differ only in an alphabetic component
22 1.1 apb # such as ".a" or ".b".
23 1.1 apb # * If it's expected that two or more targets should be made in sequence
24 1.1 apb # then the target names will differ in numeric components, such that
25 1.1 apb # lexical ordering of the target names matches the expected order
26 1.1 apb # in which the targets should be made.
27 1.1 apb #
28 1.1 apb # Targets may echo ${PARALLEL_TARG} to print a modified version
29 1.1 apb # of their own name, in which alphabetic components like ".a" or ".b"
30 1.1 apb # are converted to ".*". Two targets that are expected to
31 1.1 apb # be made in parallel will thus print the same strings, so that the
32 1.1 apb # output is independent of the order in which these targets are made.
33 1.1 apb #
34 1.1 apb PARALLEL_TARG= ${.TARGET:C/\.[a-z]/.*/g:Q}
35 1.1 apb .DEFAULT:
36 1.1 apb @echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
37 1.1 apb _ECHOUSE: .USE
38 1.1 apb @echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
39 1.1 apb
40 1.1 apb # simple: no recursion, no cycles
41 1.1 apb simple: simple.1 .WAIT simple.2
42 1.1 apb
43 1.1 apb # recursive: all children of the left hand side of the .WAIT
44 1.1 apb # must be made before any child of the right hand side.
45 1.1 apb recursive: recursive.1.99 .WAIT recursive.2.99
46 1.1 apb recursive.1.99: recursive.1.1.a recursive.1.1.b _ECHOUSE
47 1.1 apb recursive.2.99: recursive.2.1.a recursive.2.1.b _ECHOUSE
48 1.1 apb
49 1.1 apb # shared: both shared.1.99 and shared.2.99 depend on shared.0.
50 1.1 apb # shared.0 must be made first, even though it is a child of
51 1.1 apb # the right hand side of the .WAIT.
52 1.1 apb shared: shared.1.99 .WAIT shared.2.99
53 1.1 apb shared.1.99: shared.0 _ECHOUSE
54 1.1 apb shared.2.99: shared.2.1 shared.0 _ECHOUSE
55 1.1 apb
56 1.1 apb # cycle: the cyclic dependency must not cause infinite recursion
57 1.1 apb # leading to stack overflow and a crash.
58 1.1 apb cycle: cycle.1.99 .WAIT cycle.2.99
59 1.1 apb cycle.2.99: cycle.2.98 _ECHOUSE
60 1.1 apb cycle.2.98: cycle.2.97 _ECHOUSE
61 1.1 apb cycle.2.97: cycle.2.99 _ECHOUSE
62