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