xref: /netbsd/tools/Makefile (revision 62294d00)
1#	$NetBSD: Makefile,v 1.89 2005/05/30 15:51:36 thorpej 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 genassym gencat hexdump lint lint2 \
26		lorder 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-txlt
83.endif
84
85.if ${MACHINE} == "hp300"
86SUBDIR+=	hp300-mkboot
87.endif
88
89.endif	# ! NOSUBDIR					# }
90
91check_MKTOOLS: .PHONY .NOTMAIN
92.if ${MKTOOLS:Uyes} == "no"
93	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
94	@echo '*** updating your host toolchain.  This should be used only as a'
95	@echo '*** temporary workaround for toolchain problems, as it will result'
96	@echo '*** in version skew and build errors over time!'
97.endif
98
99.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
100realall realdepend install: check_MKTOOLS
101
102.for dir in ${SUBDIR:N.WAIT}
103all-${dir} depend-${dir} dependall-${dir} install-${dir}:
104	@true
105.endfor
106.endif							# }
107
108.include <bsd.subdir.mk>
109.include <bsd.obj.mk>
110
111.if exists(PREVIOUSTOOLDIR)
112PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
113.else
114PREVIOUSTOOLDIR=
115.endif
116
117CLEANFILES+=	PREVIOUSTOOLDIR
118
119realall realdepend:
120.if "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
121	@echo "*** WARNING: TOOLDIR has moved?"
122	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
123	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
124	@echo "*** Cleaning mis-matched tools"
125	rm -f PREVIOUSTOOLDIR
126	(cd ${.CURDIR} && ${MAKE} cleandir)
127.endif
128	echo ${TOOLDIR} > PREVIOUSTOOLDIR
129
130# For each .WAIT point, make sure the immediately preceding target is
131# installed before building anything after that point.
132#
133# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
134# to achieve this. These targets look like:
135#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
136#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
137# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
138# places corresponding to the .WAITs in our $SUBDIR variable.
139#
140# Also, since we're now mixing `install' with `all' and `depend' targets
141# an order relationship between those in each individual subdirectory
142# must be established.
143#
144_deps:=
145_prev:=
146
147.for d in ${SUBDIR}
148_this:=		${d}
149
150.if ${_this} == ".WAIT"
151
152# setup dependency to apply to all/depend targets in the next group
153_deps:=		${_deps} ${_prev:S/^/install-/}
154
155# if we're building *only* individual targets (i.e. "dependall-yacc"),
156# make sure prerequisite tools build before installing
157.if !make(all) && !make(dependall)
158install-${_prev}: dependall-${_prev}
159.endif
160
161.else
162
163# order depend/all/install targets for ${d} subdir.  Note the additional
164# .WAIT to achieve "closure" of the predecessor/successor relationships.
165.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
166
167# make all/depend-${d} dependent on list of install targets
168depend-${d} all-${d} dependall-${d}: ${_deps}
169
170.endif
171
172# stash current name in case the next entry is .WAIT
173_prev:=		${d}
174.endfor
175
176cleandir:
177	rm -f ${CLEANFILES}
178