Add files from parent branch HEAD:
[pkgsrc.git] / mk / bsd.pkg.barrier.mk
1 # $NetBSD: bsd.pkg.barrier.mk,v 1.15 2007/11/30 18:54:40 rillig Exp $
2
3 _COOKIE.barrier=        ${WRKDIR}/.barrier_cookie
4
5 # _BARRIER_PRE_TARGETS is a list of the targets that must be built before
6 #       the "barrier" target invokes a new make.
7 #
8 _BARRIER_PRE_TARGETS=   checksum-phase makedirs depends
9
10 # _BARRIER_POST_TARGETS is a list of the targets that must be built after
11 #       the "barrier" target invokes a new make.  This list is specially
12 #       ordered so that if more than one is specified on the command-line,
13 #       then pkgsrc will still do the right thing.
14 #
15
16 # FIXME: why is wrapper before extract?
17 _BARRIER_POST_TARGETS=  tools
18 _BARRIER_POST_TARGETS+= wrapper
19 _BARRIER_POST_TARGETS+= extract
20 _BARRIER_POST_TARGETS+= patch
21 _BARRIER_POST_TARGETS+= configure
22 _BARRIER_POST_TARGETS+= build build-env
23 _BARRIER_POST_TARGETS+= test
24 _BARRIER_POST_TARGETS+= all
25 _BARRIER_POST_TARGETS+= install
26 _BARRIER_POST_TARGETS+= reinstall
27 _BARRIER_POST_TARGETS+= replace
28 _BARRIER_POST_TARGETS+= package
29 _BARRIER_POST_TARGETS+= repackage
30 _BARRIER_POST_TARGETS+= package-install
31
32 .for _target_ in ${_BARRIER_POST_TARGETS}
33 .  if make(${_target_})
34 _BARRIER_CMDLINE_TARGETS+=      ${_target_}
35 .  endif
36 .endfor
37
38 ######################################################################
39 ### barrier (PRIVATE)
40 ######################################################################
41 ### barrier is a helper target that can be used to separate targets
42 ### that should be built in a new make process from being built in
43 ### the current one.  The targets that must be built after the "barrier"
44 ### target invokes a new make should be listed in _BARRIER_POST_TARGETS,
45 ### and should be of the form:
46 ###
47 ###     .if !defined(_PKGSRC_BARRIER)
48 ###     foo: barrier
49 ###     .else
50 ###     foo: foo's real source dependencies
51 ###     .endif
52 ###
53 ### Note that none of foo's real source dependencies should include
54 ### targets that occur before the barrier.
55 ###
56
57 .PHONY: barrier-error-check
58 barrier-error-check: error-check
59
60 .PHONY: barrier
61 barrier: ${_BARRIER_PRE_TARGETS} ${_COOKIE.barrier}
62 .if !defined(_PKGSRC_BARRIER)
63 .  if defined(PKG_VERBOSE)
64         @${PHASE_MSG} "Invoking \`\`"${_BARRIER_CMDLINE_TARGETS:Q}"'' after barrier for ${PKGNAME}"
65 .  endif
66         ${RUN}                                  \
67         cd ${.CURDIR}                                                   \
68         && ${RECURSIVE_MAKE} ${MAKEFLAGS} _PKGSRC_BARRIER=yes ALLOW_VULNERABLE_PACKAGES= ${_BARRIER_CMDLINE_TARGETS} \
69         || {                                                            \
70                 exitcode="$$?";                                         \
71                 ${RECURSIVE_MAKE} ${MAKEFLAGS} _PKGSRC_BARRIER=yes barrier-error-check; \
72                 exit "$$exitcode";                                      \
73         }
74 .  if defined(PKG_VERBOSE)
75         @${PHASE_MSG} "Leaving \`\`"${_BARRIER_CMDLINE_TARGETS:Q}"'' after barrier for ${PKGNAME}"
76 .  endif
77 .endif
78
79 ######################################################################
80 ### barrier-cookie (PRIVATE)
81 ######################################################################
82 ### barrier-cookie creates the "barrier" cookie file.
83 ###
84 ${_COOKIE.barrier}:
85         ${RUN}${MKDIR} ${.TARGET:H}
86         ${RUN}${ECHO} ${PKGNAME} > ${.TARGET}