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