getconf: don't include xpg4 bits, gcc7 includes xpg6 bits for us
[unleashed.git] / share / mk / subdir.mk
blobf94a2f6508a3a95a0bb49922ad571d668ca13df7
1 # $Id: subdir.mk,v 1.16 2017/02/08 22:16:59 sjg Exp $
2 # skip missing directories...
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
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
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
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
47 ${SUBDIR}::
48 @set -e; _r=${.CURDIR}/; \
49 if test -z "${.TARGET:M/*}"; then \
50 if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
51 _newdir_=${.TARGET}.${MACHINE}; \
52 else \
53 _newdir_=${.TARGET}; \
54 fi; \
55 else \
56 _r= _newdir_=${.TARGET}; \
57 fi; \
58 ${ECHO_DIR} "===> $${_newdir_}"; \
59 cd $${_r}$${_newdir_}; \
60 ${.MAKE} _THISDIR_="$${_newdir_}" all
61 .endif
63 .if !target(install)
64 .if !target(beforeinstall)
65 beforeinstall:
66 .endif
67 .if !target(afterinstall)
68 afterinstall:
69 .endif
70 install: maninstall
71 maninstall: afterinstall
72 afterinstall: realinstall
73 realinstall: beforeinstall _SUBDIRUSE
74 .endif
76 .if defined(SRCS)
77 etags: ${SRCS}
78 -cd ${.CURDIR}; etags `echo ${.ALLSRC:N*.h} | sed 's;${.CURDIR}/;;'`
79 .endif
81 SUBDIR_TARGETS += \
82 all \
83 clean \
84 cleandir \
85 includes \
86 depend \
87 lint \
88 obj \
89 tags \
90 etags
92 .for t in ${SUBDIR_TARGETS:O:u}
93 .if !target($t)
94 $t: _SUBDIRUSE
95 .endif
96 .endfor
98 .include <own.mk>
99 .endif
100 # make sure this exists
101 all: