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