Makefile revision 1.72
1#	$NetBSD: Makefile,v 1.72 2003/10/19 03:35:30 matt Exp $
2
3.include <bsd.own.mk>
4
5.if ${TOOLCHAIN_MISSING} != "yes"
6.  if ${USE_TOOLS_TOOLCHAIN} != "yes"
7TOOLCHAIN_BITS= binutils .WAIT gcc
8.  else
9TOOLCHAIN_BITS= toolchain
10.  endif
11TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
12# XXX Eventually, we want to be able to build dbsym and mdsetimage
13# XXX if EXTERNAL_TOOLCHAIN is set.
14.endif
15
16# Dependencies in SUBDIR below ordered to maximize parallel ability.
17.if !defined(NOSUBDIR)					# {
18
19SUBDIR=	host-mkdep .WAIT compat .WAIT \
20	binstall .WAIT mktemp .WAIT \
21		cap_mkdb crunchgen ctags gencat hexdump lint lint2 lorder \
22		m4 makewhatis mkdep mtree rpcgen tsort uudecode \
23	texinfo .WAIT \
24	yacc .WAIT \
25	lex .WAIT \
26	${TOOLCHAIN_BITS} \
27		asn1_compile cat cksum compile_et config db file installboot \
28		lint1 makefs menuc mklocale mkcsmapper mkesdb msgc pax \
29		pwd_mkdb stat sunlabel zic
30
31.if ${MKMAN} != "no"
32SUBDIR+=	groff
33.endif
34
35.if ${MKMAINTAINERTOOLS:Uno} != "no"
36SUBDIR+=	autoconf gettext
37.endif
38
39.if ${MACHINE} == ibmnws
40SUBDIR+=	ibmnws-ncdcs
41.endif
42
43.if ${MACHINE} == prep
44SUBDIR+=	prep-mkbootimage
45.endif
46
47.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
48SUBDIR+=	mips-elf2ecoff
49.endif
50
51.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
52SUBDIR+=	fgen
53.endif
54
55.endif	# ! NOSUBDIR					# }
56
57check_MKTOOLS: .PHONY .NOTMAIN
58.if ${MKTOOLS:Uyes} == "no"
59	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
60	@echo '*** updating your host toolchain.  This should be used only as a'
61	@echo '*** temporary workaround for toolchain problems, as it will result'
62	@echo '*** in version skew and build errors over time!'
63.endif
64
65.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
66realall realdepend install: check_MKTOOLS
67
68.for dir in ${SUBDIR:N.WAIT}
69all-${dir} depend-${dir} dependall-${dir} install-${dir}:
70	@true
71.endfor
72.endif							# }
73
74.include <bsd.subdir.mk>
75.include <bsd.obj.mk>
76
77.if exists(PREVIOUSTOOLDIR)
78PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
79.else
80PREVIOUSTOOLDIR=	
81.endif
82
83CLEANFILES+=	PREVIOUSTOOLDIR
84
85realall realdepend:
86.if (${PREVIOUSTOOLDIR} != ${TOOLDIR})
87	@echo "*** WARNING: TOOLDIR has moved?"
88	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
89	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
90	@echo "*** Cleaning mis-matched tools"
91	${_MKCMD}\
92	rm -f PREVIOUSTOOLDIR
93	${MAKE} cleandir
94.endif
95	echo ${TOOLDIR} > PREVIOUSTOOLDIR
96
97# For each .WAIT point, make sure the immediately preceding target is
98# installed before building anything after that point.
99#
100# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
101# to achieve this. These targets look like:
102#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
103#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
104# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
105# places corresponding to the .WAITs in our $SUBDIR variable.
106#
107# Also, since we're now mixing `install' with `all' and `depend' targets
108# an order relationship between those in each individual subdirectory
109# must be established.
110#
111_deps:=
112_prev:=
113
114.for d in ${SUBDIR}
115_this:=		${d}
116
117.if ${_this} == ".WAIT"
118
119# setup dependency to apply to all/depend targets in the next group
120_deps:=		${_deps} ${_prev:S/^/install-/}
121
122# if we're building *only* individual targets (i.e. "dependall-yacc"),
123# make sure prerequisite tools build before installing
124.if !make(all) && !make(dependall)
125install-${_prev}: dependall-${_prev}
126.endif
127
128.else
129
130# order depend/all/install targets for ${d} subdir.  Note the additional
131# .WAIT to achieve "closure" of the predecessor/successor relationships.
132.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
133
134# make all/depend-${d} dependent on list of install targets
135depend-${d} all-${d} dependall-${d}: ${_deps}
136
137.endif
138
139# stash current name in case the next entry is .WAIT
140_prev:=		${d}
141.endfor
142
143cleandir:
144	${_MKCMD}\
145	rm -f ${CLEANFILES}
146