xref: /netbsd/tools/Makefile (revision 949cd54d)
1#	$NetBSD: Makefile,v 1.77 2003/12/04 10:08:58 mrg Exp $
2
3.include <bsd.own.mk>
4
5.if ${TOOLCHAIN_MISSING} != "yes"
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} == ibmnws
44SUBDIR+=	ibmnws-ncdcs
45.endif
46
47.if ${MACHINE} == prep
48SUBDIR+=	prep-mkbootimage
49.endif
50
51.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
52SUBDIR+=	mips-elf2ecoff
53.endif
54
55.if (${MACHINE} == "sgimips")
56SUBDIR+=	sgivol
57.endif
58
59.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
60SUBDIR+=	fgen
61.endif
62
63.endif	# ! NOSUBDIR					# }
64
65check_MKTOOLS: .PHONY .NOTMAIN
66.if ${MKTOOLS:Uyes} == "no"
67	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
68	@echo '*** updating your host toolchain.  This should be used only as a'
69	@echo '*** temporary workaround for toolchain problems, as it will result'
70	@echo '*** in version skew and build errors over time!'
71.endif
72
73.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
74realall realdepend install: check_MKTOOLS
75
76.for dir in ${SUBDIR:N.WAIT}
77all-${dir} depend-${dir} dependall-${dir} install-${dir}:
78	@true
79.endfor
80.endif							# }
81
82.include <bsd.subdir.mk>
83.include <bsd.obj.mk>
84
85.if exists(PREVIOUSTOOLDIR)
86PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
87.else
88PREVIOUSTOOLDIR=
89.endif
90
91CLEANFILES+=	PREVIOUSTOOLDIR
92
93realall realdepend:
94.if (${PREVIOUSTOOLDIR} != ${TOOLDIR})
95	@echo "*** WARNING: TOOLDIR has moved?"
96	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
97	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
98	@echo "*** Cleaning mis-matched tools"
99	rm -f PREVIOUSTOOLDIR
100	${MAKE} cleandir
101.endif
102	echo ${TOOLDIR} > PREVIOUSTOOLDIR
103
104# For each .WAIT point, make sure the immediately preceding target is
105# installed before building anything after that point.
106#
107# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
108# to achieve this. These targets look like:
109#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
110#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
111# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
112# places corresponding to the .WAITs in our $SUBDIR variable.
113#
114# Also, since we're now mixing `install' with `all' and `depend' targets
115# an order relationship between those in each individual subdirectory
116# must be established.
117#
118_deps:=
119_prev:=
120
121.for d in ${SUBDIR}
122_this:=		${d}
123
124.if ${_this} == ".WAIT"
125
126# setup dependency to apply to all/depend targets in the next group
127_deps:=		${_deps} ${_prev:S/^/install-/}
128
129# if we're building *only* individual targets (i.e. "dependall-yacc"),
130# make sure prerequisite tools build before installing
131.if !make(all) && !make(dependall)
132install-${_prev}: dependall-${_prev}
133.endif
134
135.else
136
137# order depend/all/install targets for ${d} subdir.  Note the additional
138# .WAIT to achieve "closure" of the predecessor/successor relationships.
139.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
140
141# make all/depend-${d} dependent on list of install targets
142depend-${d} all-${d} dependall-${d}: ${_deps}
143
144.endif
145
146# stash current name in case the next entry is .WAIT
147_prev:=		${d}
148.endfor
149
150cleandir:
151	rm -f ${CLEANFILES}
152