]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/mk/subdir.mk
Merge ACPICA 20170303.
[FreeBSD/FreeBSD.git] / contrib / bmake / mk / subdir.mk
1 #       $Id: subdir.mk,v 1.15 2016/04/05 15:58:37 sjg Exp $
2 #       skip missing directories...
3
4 #       $NetBSD: bsd.subdir.mk,v 1.11 1996/04/04 02:05:06 jtc Exp $
5 #       @(#)bsd.subdir.mk       5.9 (Berkeley) 2/1/91
6
7 .if ${.MAKE.LEVEL} == 0 && ${.MAKE.MODE:Uno:Mmeta*} != ""
8 .include <meta.subdir.mk>
9 # keep everyone happy
10 _SUBDIRUSE:
11 .elif !commands(_SUBDIRUSE) && !defined(NO_SUBDIR) && !defined(NOSUBDIR)
12 .-include <${.CURDIR}/Makefile.inc>
13 .if !target(.MAIN)
14 .MAIN: all
15 .endif
16
17 ECHO_DIR ?= echo
18 .ifdef SUBDIR_MUST_EXIST
19 MISSING_DIR=echo "Missing ===> ${.CURDIR}/$${entry}"; exit 1
20 .else
21 MISSING_DIR=echo "Skipping ===> ${.CURDIR}/$${entry}"; continue
22 .endif
23
24 _SUBDIRUSE: .USE
25 .if defined(SUBDIR)
26         @Exists() { test -f $$1; }; \
27         for entry in ${SUBDIR}; do \
28                 (set -e; \
29                 if Exists ${.CURDIR}/$${entry}.${MACHINE}/[mM]akefile; then \
30                         _newdir_="$${entry}.${MACHINE}"; \
31                 elif  Exists ${.CURDIR}/$${entry}/[mM]akefile; then \
32                         _newdir_="$${entry}"; \
33                 else \
34                         ${MISSING_DIR}; \
35                 fi; \
36                 if test X"${_THISDIR_}" = X""; then \
37                         _nextdir_="$${_newdir_}"; \
38                 else \
39                         _nextdir_="$${_THISDIR_}/$${_newdir_}"; \
40                 fi; \
41                 ${ECHO_DIR} "===> $${_nextdir_}"; \
42                 cd ${.CURDIR}/$${_newdir_}; \
43                 ${.MAKE} _THISDIR_="$${_nextdir_}" \
44                     ${.TARGET:S/realinstall/install/:S/.depend/depend/}) || exit 1; \
45         done
46
47 ${SUBDIR}::
48         @set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
49                 _newdir_=${.TARGET}.${MACHINE}; \
50         else \
51                 _newdir_=${.TARGET}; \
52         fi; \
53         ${ECHO_DIR} "===> $${_newdir_}"; \
54         cd ${.CURDIR}/$${_newdir_}; \
55         ${.MAKE} _THISDIR_="$${_newdir_}" all
56 .endif
57
58 .if !target(install)
59 .if !target(beforeinstall)
60 beforeinstall:
61 .endif
62 .if !target(afterinstall)
63 afterinstall:
64 .endif
65 install: maninstall
66 maninstall: afterinstall
67 afterinstall: realinstall
68 realinstall: beforeinstall _SUBDIRUSE
69 .endif
70
71 .if defined(SRCS)
72 etags: ${SRCS}
73         -cd ${.CURDIR}; etags `echo ${.ALLSRC:N*.h} | sed 's;${.CURDIR}/;;'`
74 .endif
75
76 SUBDIR_TARGETS += \
77         all \
78         clean \
79         cleandir \
80         includes \
81         depend \
82         lint \
83         obj \
84         tags \
85         etags
86
87 .for t in ${SUBDIR_TARGETS:O:u}
88 $t: _SUBDIRUSE
89 .endfor
90
91 .include <own.mk>
92 .if make(destroy*)
93 .include <obj.mk>
94 .endif
95 .endif
96 # make sure this exists
97 all: