Makefile revision 1.116
1#	$NetBSD: Makefile,v 1.116 2008/04/30 21:18:17 garbled 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 join \
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 atf-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		pwd_mkdb stat sunlabel zic
45
46.if ${MKMAN} != "no"
47SUBDIR+=	groff
48.endif
49
50.if ${MKMAINTAINERTOOLS:Uno} != "no"
51SUBDIR+=	autoconf .WAIT gettext
52.endif
53
54.if ${MACHINE} == "hp700"
55SUBDIR+=	hp700-mkboot
56.endif
57
58.if ${MACHINE} == "ibmnws"
59SUBDIR+=	ibmnws-ncdcs
60.endif
61
62.if ${MACHINE} == "macppc"
63SUBDIR+=	macppc-fixcoff
64.endif
65
66.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
67SUBDIR+=	powerpc-mkbootimage
68.endif
69
70.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
71SUBDIR+=	mips-elf2ecoff
72.endif
73
74.if (${MACHINE} == "sgimips")
75SUBDIR+=	sgivol
76.endif
77
78.if ${MACHINE} == "acorn32"
79SUBDIR+=	sparkcrc
80.endif
81
82.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
83SUBDIR+=	fgen
84.endif
85
86.if ${MACHINE} == "bebox"
87SUBDIR+=	bebox-elf2pef
88SUBDIR+=	bebox-mkbootimage
89.endif
90
91.if ${MACHINE} == "amiga"
92SUBDIR+=	amiga-elf2bb
93SUBDIR+=	amiga-txlt
94.endif
95
96.if ${MACHINE} == "hp300"
97SUBDIR+=	hp300-mkboot
98.endif
99
100.endif	# ! NOSUBDIR					# }
101
102check_MKTOOLS: .PHONY .NOTMAIN
103.if ${MKTOOLS:Uyes} == "no"
104	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
105	@echo '*** updating your host toolchain.  This should be used only as a'
106	@echo '*** temporary workaround for toolchain problems, as it will result'
107	@echo '*** in version skew and build errors over time!'
108.endif
109
110.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
111realall realdepend install: check_MKTOOLS
112
113.for dir in ${SUBDIR:N.WAIT}
114all-${dir} depend-${dir} dependall-${dir} install-${dir}:
115	@true
116.endfor
117.endif							# }
118
119.include <bsd.subdir.mk>
120.include <bsd.obj.mk>
121
122.if !defined(PREVIOUSTOOLDIR)
123.  if exists(PREVIOUSTOOLDIR)
124PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
125.  else
126PREVIOUSTOOLDIR=	
127.  endif
128.endif
129
130CLEANFILES+=	PREVIOUSTOOLDIR
131
132realall realdepend: .MAKE
133.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
134	@echo "*** WARNING: TOOLDIR has moved?"
135	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
136	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
137	@echo "*** Cleaning mis-matched tools"
138	rm -f PREVIOUSTOOLDIR
139	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
140.endif
141	echo ${TOOLDIR} >PREVIOUSTOOLDIR
142
143# For each .WAIT point, make sure the immediately preceding target is
144# installed before building anything after that point.
145# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the
146# install of 'b', but not the install of 'a'.)
147#
148# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
149# to achieve this. These targets look like:
150#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
151#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
152# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
153# places corresponding to the .WAITs in our $SUBDIR variable.
154#
155# Also, since we're now mixing `install' with `all' and `depend' targets
156# an order relationship between those in each individual subdirectory
157# must be established.
158#
159_deps:=
160_prev:=
161
162.for d in ${SUBDIR}
163_this:=		${d}
164
165.if ${_this} == ".WAIT"
166
167# setup dependency to apply to all/depend targets in the next group
168_deps:=		${_deps} ${_prev:S/^/install-/}
169
170# if we're building *only* individual targets (i.e. "dependall-yacc"),
171# make sure prerequisite tools build before installing
172# XXX: dsl: this is likely to generate a dependency loop since there is
173# a .ORDER releation between the nodes as well.
174.if !make(all) && !make(dependall) && !make(install)
175install-${_prev}: dependall-${_prev}
176.endif
177
178.else
179
180# order depend/all/install targets for ${d} subdir.
181.ORDER: depend-${d} all-${d} dependall-${d} install-${d}
182
183# prevent cleandir in real{all,depend} from interfering with subdir makes
184.ORDER: realdepend dependall-${d}
185.ORDER: realdepend depend-${d}
186.ORDER: realall all-${d}
187
188# make all/depend-${d} dependent on list of install targets
189depend-${d} all-${d} dependall-${d}: ${_deps}
190
191.endif
192
193# stash current name in case the next entry is .WAIT
194_prev:=		${d}
195.endfor
196
197cleandir:
198	rm -f ${CLEANFILES}
199