Undo part of the last commit. OBJFORMAT_PATH controls how the cross
[dragonfly.git] / share / mk / bsd.subdir.mk
1 #       from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
2 # $FreeBSD: src/share/mk/bsd.subdir.mk,v 1.30.2.5 2002/07/22 14:21:51 ru Exp $
3 # $DragonFly: src/share/mk/bsd.subdir.mk,v 1.2 2003/06/17 04:37:02 dillon Exp $
4 #
5 # The include file <bsd.subdir.mk> contains the default targets
6 # for building subdirectories. 
7 #
8 # For all of the directories listed in the variable SUBDIRS, the
9 # specified directory will be visited and the target made. There is
10 # also a default target which allows the command "make subdir" where
11 # subdir is any directory listed in the variable SUBDIRS.
12 #
13 #
14 # +++ variables +++
15 #
16 # DISTRIBUTION  Name of distribution. [bin]
17 #
18 # SUBDIR        A list of subdirectories that should be built as well.
19 #               Each of the targets will execute the same target in the
20 #               subdirectories.
21 #
22 # +++ targets +++
23 #
24 #       distribute:
25 #               This is a variant of install, which will
26 #               put the stuff into the right "distribution".
27 #
28 #       afterinstall, all, all-man, beforeinstall, checkdpadd,
29 #       clean, cleandepend, cleandir, depend, install, lint, maninstall,
30 #       obj, objlink, realinstall, regress, tags
31 #
32
33 .include <bsd.init.mk>
34
35 DISTRIBUTION?=  bin
36 .if !target(distribute)
37 distribute:
38 .for dist in ${DISTRIBUTION}
39         cd ${.CURDIR}; \
40             ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
41 .endfor
42 .endif
43
44 _SUBDIR: .USE
45 .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
46         @for entry in ${SUBDIR}; do \
47                 if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
48                         ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
49                         edir=$${entry}.${MACHINE_ARCH}; \
50                         cd ${.CURDIR}/$${edir}; \
51                 else \
52                         ${ECHODIR} "===> ${DIRPRFX}$$entry"; \
53                         edir=$${entry}; \
54                         cd ${.CURDIR}/$${edir}; \
55                 fi; \
56                 ${MAKE} ${.TARGET:realinstall=install} \
57                     DIRPRFX=${DIRPRFX}$$edir/; \
58         done
59 .endif
60
61 ${SUBDIR}::
62         @if test -d ${.TARGET}.${MACHINE_ARCH}; then \
63                 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
64         else \
65                 cd ${.CURDIR}/${.TARGET}; \
66         fi; \
67         ${MAKE} all
68
69
70 .for __target in all all-man checkdpadd clean cleandepend cleandir \
71     depend distribute lint maninstall \
72     obj objlink realinstall regress tags
73 ${__target}: _SUBDIR
74 .endfor
75
76 .for __target in files includes
77 .for __stage in build install
78 ${__stage}${__target}:
79 .if make(${__stage}${__target})
80 ${__stage}${__target}: _SUBDIR
81 .endif
82 .endfor
83 ${__target}:
84         cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
85 .endfor
86
87 .if !target(install)
88 .if !target(beforeinstall)
89 beforeinstall:
90 .endif
91 .if !target(afterinstall)
92 afterinstall:
93 .endif
94 install: beforeinstall realinstall afterinstall
95 .ORDER: beforeinstall realinstall afterinstall
96 .endif