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