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