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