Makefile revision 1.117
1#	$NetBSD: Makefile,v 1.117 2008/05/26 12:45:50 he 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} == "amiga"
87SUBDIR+=	amiga-elf2bb
88SUBDIR+=	amiga-txlt
89.endif
90
91.if ${MACHINE} == "hp300"
92SUBDIR+=	hp300-mkboot
93.endif
94
95.endif	# ! NOSUBDIR					# }
96
97check_MKTOOLS: .PHONY .NOTMAIN
98.if ${MKTOOLS:Uyes} == "no"
99	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
100	@echo '*** updating your host toolchain.  This should be used only as a'
101	@echo '*** temporary workaround for toolchain problems, as it will result'
102	@echo '*** in version skew and build errors over time!'
103.endif
104
105.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
106realall realdepend install: check_MKTOOLS
107
108.for dir in ${SUBDIR:N.WAIT}
109all-${dir} depend-${dir} dependall-${dir} install-${dir}:
110	@true
111.endfor
112.endif							# }
113
114.include <bsd.subdir.mk>
115.include <bsd.obj.mk>
116
117.if !defined(PREVIOUSTOOLDIR)
118.  if exists(PREVIOUSTOOLDIR)
119PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
120.  else
121PREVIOUSTOOLDIR=	
122.  endif
123.endif
124
125CLEANFILES+=	PREVIOUSTOOLDIR
126
127realall realdepend: .MAKE
128.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
129	@echo "*** WARNING: TOOLDIR has moved?"
130	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
131	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
132	@echo "*** Cleaning mis-matched tools"
133	rm -f PREVIOUSTOOLDIR
134	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
135.endif
136	echo ${TOOLDIR} >PREVIOUSTOOLDIR
137
138# For each .WAIT point, make sure the immediately preceding target is
139# installed before building anything after that point.
140# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the
141# install of 'b', but not the install of 'a'.)
142#
143# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
144# to achieve this. These targets look like:
145#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
146#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
147# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
148# places corresponding to the .WAITs in our $SUBDIR variable.
149#
150# Also, since we're now mixing `install' with `all' and `depend' targets
151# an order relationship between those in each individual subdirectory
152# must be established.
153#
154_deps:=
155_prev:=
156
157.for d in ${SUBDIR}
158_this:=		${d}
159
160.if ${_this} == ".WAIT"
161
162# setup dependency to apply to all/depend targets in the next group
163_deps:=		${_deps} ${_prev:S/^/install-/}
164
165# if we're building *only* individual targets (i.e. "dependall-yacc"),
166# make sure prerequisite tools build before installing
167# XXX: dsl: this is likely to generate a dependency loop since there is
168# a .ORDER releation between the nodes as well.
169.if !make(all) && !make(dependall) && !make(install)
170install-${_prev}: dependall-${_prev}
171.endif
172
173.else
174
175# order depend/all/install targets for ${d} subdir.
176.ORDER: depend-${d} all-${d} dependall-${d} install-${d}
177
178# prevent cleandir in real{all,depend} from interfering with subdir makes
179.ORDER: realdepend dependall-${d}
180.ORDER: realdepend depend-${d}
181.ORDER: realall all-${d}
182
183# make all/depend-${d} dependent on list of install targets
184depend-${d} all-${d} dependall-${d}: ${_deps}
185
186.endif
187
188# stash current name in case the next entry is .WAIT
189_prev:=		${d}
190.endfor
191
192cleandir:
193	rm -f ${CLEANFILES}
194