Makefile revision 28531
1104476Ssam#
2139825Simp#	$Id: Makefile,v 1.137 1997/08/18 06:54:18 peter Exp $
3104476Ssam#
4104476Ssam# Make command line options:
5104476Ssam#	-DCLOBBER will remove /usr/include
6104476Ssam#	-DMAKE_EBONES to build eBones (KerberosIV)
7104476Ssam#	-DALLLANG to build documentation for all languages
8104476Ssam#	  (where available -- see share/doc/Makefile)
9104476Ssam#
10104476Ssam#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
11104476Ssam#	-DNOCLEAN do not clean at all
12104476Ssam#	-DNOCRYPT will prevent building of crypt versions
13104476Ssam#	-DNOLKM do not build loadable kernel modules
14104476Ssam#	-DNOOBJDIR do not run ``${MAKE} obj''
15104476Ssam#	-DNOPROFILE do not build profiled libraries
16104476Ssam#	-DNOSECURE do not go into secure subdir
17104476Ssam#	-DNOGAMES do not go into games subdir
18104476Ssam#	-DNOSHARE do not go into share subdir
19104476Ssam#	-DNOINFO do not make or install info files
20104476Ssam#	-DNOLIBC_R do not build libc_r.
21104476Ssam#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
22116191Sobrien
23116191Sobrien#
24116191Sobrien# The intended user-driven targets are:
25116191Sobrien# buildworld  - rebuild *everything*, including glue to help do upgrades
26108587Ssam# installworld- install everything built by "buildworld"
27104476Ssam# world       - buildworld + installworld
28104476Ssam# update      - convenient way to update your source tree (eg: sup/cvs)
29104476Ssam# most        - build user commands, no libraries or include files
30104476Ssam# installmost - install user commands, no libraries or include files
31104476Ssam#
32104476Ssam# Standard targets (not defined here) are documented in the makefiles in
33104476Ssam# /usr/share/mk.  These include:
34129880Sphk#		obj depend all install clean cleandepend cleanobj
35104476Ssam
36104476Ssam.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
37104476Ssam.MAKEFLAGS:=	${.MAKEFLAGS} -m ${.CURDIR}/share/mk
38104476Ssam.endif
39104476Ssam
40104476Ssam# Put initial settings here.
41104476SsamSUBDIR=
42104628Ssam
43104476Ssam# We must do share/info early so that installation of info `dir'
44104476Ssam# entries works correctly.  Do it first since it is less likely to
45104476Ssam# grow dependencies on include and lib than vice versa.
46104476Ssam.if exists(share/info)
47104476SsamSUBDIR+= share/info
48104476Ssam.endif
49104476Ssam
50104476Ssam# We must do include and lib early so that the perl *.ph generation
51104476Ssam# works correctly as it uses the header files installed by this.
52104476Ssam.if exists(include)
53104476SsamSUBDIR+= include
54104476Ssam.endif
55104476Ssam.if exists(lib)
56104476SsamSUBDIR+= lib
57104476Ssam.endif
58104476Ssam
59104476Ssam.if exists(bin)
60104476SsamSUBDIR+= bin
61104476Ssam.endif
62158827Spjd.if exists(games) && !defined(NOGAMES)
63104476SsamSUBDIR+= games
64104476Ssam.endif
65104476Ssam.if exists(gnu)
66104476SsamSUBDIR+= gnu
67104476Ssam.endif
68104476Ssam.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
69104476SsamSUBDIR+= eBones
70104476Ssam.endif
71104476Ssam.if exists(libexec)
72104476SsamSUBDIR+= libexec
73104476Ssam.endif
74104476Ssam.if exists(sbin)
75104476SsamSUBDIR+= sbin
76104476Ssam.endif
77104476Ssam.if exists(share) && !defined(NOSHARE)
78104476SsamSUBDIR+= share
79104476Ssam.endif
80104476Ssam.if exists(sys)
81104476SsamSUBDIR+= sys
82158826Spjd.endif
83104476Ssam.if exists(usr.bin)
84104476SsamSUBDIR+= usr.bin
85104476Ssam.endif
86104476Ssam.if exists(usr.sbin)
87104476SsamSUBDIR+= usr.sbin
88104476Ssam.endif
89104476Ssam.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
90104476SsamSUBDIR+= secure
91104476Ssam.endif
92104476Ssam.if exists(lkm) && !defined(NOLKM)
93104476SsamSUBDIR+= lkm
94104476Ssam.endif
95104476Ssam
96104476Ssam# etc must be last for "distribute" to work
97104476Ssam.if exists(etc) && make(distribute)
98108588SsamSUBDIR+= etc
99108588Ssam.endif
100108588Ssam
101108588Ssam# These are last, since it is nice to at least get the base system
102108588Ssam# rebuilt before you do them.
103158702Spjd.if defined(LOCAL_DIRS)
104158702Spjd.for _DIR in ${LOCAL_DIRS}
105108588Ssam.if exists(${_DIR}) & exists(${_DIR}/Makefile)
106108587SsamSUBDIR+= ${_DIR}
107108587Ssam.endif
108108587Ssam.endfor
109108587Ssam.endif
110108587Ssam
111108587Ssam# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
112108587Ssam.if defined(NOOBJDIR)
113108587SsamOBJDIR=
114108587Ssam.else
115108587SsamOBJDIR=		obj
116108588Ssam.endif
117104476Ssam
118104476Ssam.if defined(NOCLEAN)
119108588SsamCLEANDIR=
120108588Ssam.else
121115746Ssam.if defined(NOCLEANDIR)
122115746SsamCLEANDIR=	clean
123108588Ssam.else
124108588SsamCLEANDIR=	cleandir
125108588Ssam.endif
126115746Ssam.endif
127108588Ssam
128108588SsamSUP?=		sup
129108588SsamSUPFLAGS?=	-v
130115746Ssam
131108588Ssam#
132104476Ssam# While building tools for bootstrapping, we dont need to waste time on
133104476Ssam# profiled libraries or man pages.  This speeds things up somewhat.
134104476Ssam#
135104476SsamMK_FLAGS=	-DNOINFO -DNOMAN -DNOPROFILE
136104476Ssam
137104476Ssam#
138108588Ssam# world
139108588Ssam#
140108588Ssam# Attempt to rebuild and reinstall *everything*, with reasonable chance of
141108588Ssam# success, regardless of how old your existing system is.
142108588Ssam#
143104476Ssam# >> Beware, it overwrites the local build environment! <<
144104476Ssam#
145104476Ssamworld:
146104476Ssam	@echo "--------------------------------------------------------------"
147108588Ssam	@echo "make world started on `LC_TIME=C date`"
148108588Ssam	@echo "--------------------------------------------------------------"
149108588Ssam.if target(pre-world)
150108588Ssam	@echo
151108588Ssam	@echo "--------------------------------------------------------------"
152104476Ssam	@echo " Making 'pre-world' target"
153108588Ssam	@echo "--------------------------------------------------------------"
154108588Ssam	cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} pre-world
155108588Ssam.endif
156108588Ssam	cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} buildworld
157108588Ssam	cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} installworld
158108588Ssam.if target(post-world)
159108588Ssam	@echo
160104476Ssam	@echo "--------------------------------------------------------------"
161108588Ssam	@echo " Making 'post-world' target"
162108588Ssam	@echo "--------------------------------------------------------------"
163108588Ssam	cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} post-world
164108588Ssam.endif
165108588Ssam	@echo
166108588Ssam	@echo "--------------------------------------------------------------"
167108588Ssam	@echo "make world completed on `LC_TIME=C date`"
168108588Ssam	@echo "--------------------------------------------------------------"
169108588Ssam
170108588Ssam.if defined(MAKEOBJDIRPREFIX)
171108588SsamWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
172104476Ssam.else
173104476SsamWORLDTMP=	/usr/obj${.CURDIR}/tmp
174104476Ssam.endif
175108588SsamSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
176108588SsamTMPPATH=	${STRICTTMPPATH}:${PATH}
177108588Ssam
178108588Ssam# XXX COMPILER_PATH is needed for finding cc1, ld and as
179108588Ssam# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
180108588Ssam#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
181108588Ssam#	wouldn't link *crt.o or libgcc if it were used.
182108588Ssam# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
183108588Ssam#	want that - all compile-time library paths should be resolved by gcc.
184108588Ssam#	It fails for set[ug]id executables (are any used?).
185108588SsamCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
186108588Ssam		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
187108588Ssam		GCC_EXEC_PREFIX=${WORLDTMP}/usr/lib/ \
188108588Ssam		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
189108588Ssam		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
190108588Ssam
191108588SsamBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
192108588SsamXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
193108588Ssam		CC='cc -nostdinc'	# XXX -nostdlib
194108588Ssam
195108588Ssam# used to compile and install 'make' in temporary build tree
196108588SsamIBMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
197108588Ssam# bootstrap make
198108588SsamBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
199108588Ssam# cross make used for compilation
200108588SsamXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
201108588Ssam# cross make used for final installation
202108588SsamIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
203108588Ssam
204108588Ssam#
205108588Ssam# buildworld
206108588Ssam#
207108588Ssam# Attempt to rebuild the entire system, with reasonable chance of
208108588Ssam# success, regardless of how old your existing system is.
209108588Ssam#
210108588Ssambuildworld:
211108588Ssam.if !defined(NOCLEAN)
212108588Ssam	@echo
213108588Ssam	@echo "--------------------------------------------------------------"
214108588Ssam	@echo " Cleaning up the temporary build tree"
215108588Ssam	@echo "--------------------------------------------------------------"
216108588Ssam	mkdir -p ${WORLDTMP}
217108588Ssam	chflags -R noschg ${WORLDTMP}/
218108588Ssam	rm -rf ${WORLDTMP}
219108588Ssam.endif
220108588Ssam	@echo
221108588Ssam	@echo "--------------------------------------------------------------"
222108588Ssam	@echo " Making make"
223108588Ssam	@echo "--------------------------------------------------------------"
224108588Ssam	mkdir -p ${WORLDTMP}/usr/bin
225108588Ssam	cd ${.CURDIR}/usr.bin/make && \
226108588Ssam		${IBMAKE} -I${.CURDIR}/share/mk \
227108588Ssam			${OBJDIR} clean cleandepend depend && \
228105251Smarkm		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} \
229105251Smarkm			all install clean cleandepend
230105251Smarkm	@echo
231105251Smarkm	@echo "--------------------------------------------------------------"
232105251Smarkm	@echo " Making hierarchy"
233108588Ssam	@echo "--------------------------------------------------------------"
234108588Ssam	cd ${.CURDIR} && ${BMAKE} hierarchy
235105251Smarkm.if !defined(NOCLEAN)
236105251Smarkm	@echo
237108588Ssam	@echo "--------------------------------------------------------------"
238108588Ssam	@echo " Cleaning up the obj tree"
239105251Smarkm	@echo "--------------------------------------------------------------"
240108588Ssam	cd ${.CURDIR} && ${BMAKE} ${CLEANDIR}
241105251Smarkm.endif
242105251Smarkm.if !defined(NOOBJDIR)
243108588Ssam	@echo
244108588Ssam	@echo "--------------------------------------------------------------"
245105251Smarkm	@echo " Rebuilding the obj tree"
246105251Smarkm	@echo "--------------------------------------------------------------"
247108588Ssam	cd ${.CURDIR} && ${BMAKE} obj
248105251Smarkm.endif
249105251Smarkm	@echo
250105251Smarkm	@echo "--------------------------------------------------------------"
251105251Smarkm	@echo " Rebuilding bootstrap tools"
252105251Smarkm	@echo "--------------------------------------------------------------"
253105251Smarkm	cd ${.CURDIR} && ${BMAKE} bootstrap
254105251Smarkm	@echo
255105251Smarkm	@echo "--------------------------------------------------------------"
256106676Ssam	@echo " Rebuilding tools necessary to build the include files"
257156281Swkoszek	@echo "--------------------------------------------------------------"
258105251Smarkm	cd ${.CURDIR} && ${BMAKE} include-tools
259105251Smarkm	@echo
260104476Ssam	@echo "--------------------------------------------------------------"
261104476Ssam	@echo " Rebuilding /usr/include"
262104476Ssam	@echo "--------------------------------------------------------------"
263104476Ssam	cd ${.CURDIR} && ${BMAKE} includes
264104476Ssam	@echo
265104476Ssam	@echo "--------------------------------------------------------------"
266104476Ssam	@echo " Rebuilding tools needed to build the libraries"
267104476Ssam	@echo "--------------------------------------------------------------"
268104476Ssam	cd ${.CURDIR} && ${BMAKE} lib-tools
269104476Ssam	@echo
270104476Ssam	@echo "--------------------------------------------------------------"
271104476Ssam	@echo " Rebuilding /usr/lib"
272104476Ssam	@echo "--------------------------------------------------------------"
273104476Ssam	cd ${.CURDIR} && ${BMAKE} libraries
274104476Ssam	@echo
275104476Ssam	@echo "--------------------------------------------------------------"
276104476Ssam	@echo " Rebuilding all other tools needed to build the world"
277104476Ssam	@echo "--------------------------------------------------------------"
278104476Ssam	cd ${.CURDIR} && ${BMAKE} build-tools
279104476Ssam	@echo
280104476Ssam	@echo "--------------------------------------------------------------"
281104476Ssam	@echo " Rebuilding dependencies"
282104476Ssam	@echo "--------------------------------------------------------------"
283116924Ssam	cd ${.CURDIR} && ${XMAKE} depend
284104476Ssam	@echo
285104476Ssam	@echo "--------------------------------------------------------------"
286104476Ssam	@echo " Building everything.."
287104476Ssam	@echo "--------------------------------------------------------------"
288116924Ssam	cd ${.CURDIR} && ${XMAKE} all
289116924Ssam
290104476Ssam#
291104476Ssam# installworld
292104476Ssam#
293116924Ssam# Installs everything compiled by a 'buildworld'.
294104476Ssam#
295104476Ssaminstallworld:
296116924Ssam	cd ${.CURDIR} && ${IXMAKE} reinstall
297104476Ssam
298104476Ssam#
299104476Ssam# reinstall
300104476Ssam#
301116924Ssam# If you have a build server, you can NFS mount the source and obj directories
302104476Ssam# and do a 'make reinstall' on the *client* to install new binaries from the
303104476Ssam# most recent server build.
304104476Ssam#
305104476Ssamreinstall:
306104476Ssam	@echo "--------------------------------------------------------------"
307104476Ssam	@echo " Making hierarchy"
308104476Ssam	@echo "--------------------------------------------------------------"
309104476Ssam	cd ${.CURDIR} && ${MAKE} hierarchy
310104476Ssam	@echo
311104476Ssam	@echo "--------------------------------------------------------------"
312104476Ssam	@echo " Installing everything.."
313104476Ssam	@echo "--------------------------------------------------------------"
314104476Ssam	cd ${.CURDIR} && ${MAKE} install
315104476Ssam	@echo
316116924Ssam	@echo "--------------------------------------------------------------"
317104476Ssam	@echo " Rebuilding man page indexes"
318116924Ssam	@echo "--------------------------------------------------------------"
319116924Ssam	cd ${.CURDIR}/share/man && ${MAKE} makedb
320116924Ssam
321104476Ssam#
322104476Ssam# update
323116924Ssam#
324104476Ssam# Update the source tree, by running sup and/or running cvs to update to the
325104476Ssam# latest copy.
326104476Ssam#
327104476Ssamupdate:
328104476Ssam.if defined(SUP_UPDATE)
329104476Ssam	@echo "--------------------------------------------------------------"
330104476Ssam	@echo "Running sup"
331104476Ssam	@echo "--------------------------------------------------------------"
332104476Ssam	@${SUP} ${SUPFLAGS} ${SUPFILE}
333158702Spjd.if defined(SUPFILE1)
334158702Spjd	@${SUP} ${SUPFLAGS} ${SUPFILE1}
335158702Spjd.endif
336158702Spjd.if defined(SUPFILE2)
337158702Spjd	@${SUP} ${SUPFLAGS} ${SUPFILE2}
338158702Spjd.endif
339158702Spjd.endif
340158702Spjd.if defined(CVS_UPDATE)
341158702Spjd	@echo "--------------------------------------------------------------"
342104476Ssam	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
343104476Ssam	@echo "--------------------------------------------------------------"
344104476Ssam	cd ${.CURDIR} && cvs -q update -P -d
345104476Ssam.endif
346104476Ssam
347104476Ssam#
348104476Ssam# most
349158702Spjd#
350104476Ssam# Build most of the user binaries on the existing system libs and includes.
351104476Ssam#
352104476Ssammost:
353104476Ssam	@echo "--------------------------------------------------------------"
354104476Ssam	@echo " Building programs only"
355104476Ssam	@echo "--------------------------------------------------------------"
356104476Ssam	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} all
357104476Ssam	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} all
358104476Ssam	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} all
359104476Ssam	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} all
360104476Ssam	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} all
361116924Ssam	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} all
362104476Ssam	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} all
363104476Ssam	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} all
364104476Ssam#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
365104476Ssam#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} most
366104476Ssam#.endif
367158702Spjd#.if !defined(NOSECURE) && !defined(NOCRYPT)
368104476Ssam#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} most
369158702Spjd#.endif
370158702Spjd
371104476Ssam#
372104476Ssam# installmost
373158702Spjd#
374158702Spjd# Install the binaries built by the 'most' target.  This does not include
375104476Ssam# libraries or include files.
376104476Ssam#
377104476Ssaminstallmost:
378158702Spjd	@echo "--------------------------------------------------------------"
379158702Spjd	@echo " Installing programs only"
380104476Ssam	@echo "--------------------------------------------------------------"
381104476Ssam	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} install
382104476Ssam	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} install
383104476Ssam	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} install
384104476Ssam	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} install
385104476Ssam	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} install
386104476Ssam	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} install
387104476Ssam	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} install
388104476Ssam	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} install
389104476Ssam#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
390104476Ssam#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} installmost
391104476Ssam#.endif
392104476Ssam#.if !defined(NOSECURE) && !defined(NOCRYPT)
393104476Ssam#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} installmost
394104476Ssam#.endif
395104476Ssam
396104476Ssam#
397104476Ssam# ------------------------------------------------------------------------
398158702Spjd#
399104476Ssam# From here onwards are utility targets used by the 'make world' and
400158702Spjd# related targets.  If your 'world' breaks, you may like to try to fix
401104476Ssam# the problem and manually run the following targets to attempt to
402158702Spjd# complete the build.  Beware, this is *not* guaranteed to work, you
403158702Spjd# need to have a pretty good grip on the current state of the system
404104476Ssam# to attempt to manually finish it.  If in doubt, 'make world' again.
405104476Ssam#
406104476Ssam
407104476Ssam#
408104476Ssam# heirarchy - ensure that all the needed directories are present
409104476Ssam#
410104476Ssamhierarchy:
411104476Ssam	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
412104476Ssam
413104476Ssam#
414104476Ssam# bootstrap - [re]build tools needed to run the actual build, this includes
415104476Ssam# tools needed by 'make depend', as some tools are needed to generate source
416104476Ssam# for the dependency information to be gathered from.
417104476Ssam#
418104476Ssambootstrap:
419104476Ssam.if defined(DESTDIR)
420104476Ssam	rm -f ${DESTDIR}/usr/src/sys
421104476Ssam	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
422104476Ssam	cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
423104476Ssam	cd ${.CURDIR}/include && make symlinks
424104476Ssam.endif
425104476Ssam	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
426104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
427104476Ssam	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
428104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
429104476Ssam	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
430104476Ssam		${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
431104476Ssam
432104476Ssam#
433104476Ssam# include-tools - generally the same as 'bootstrap', except that it's for
434104476Ssam# things that are specifically needed to generate include files.
435104476Ssam#
436104476Ssam# XXX should be merged with bootstrap, it's not worth keeeping them separate.
437104476Ssam# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
438104476Ssam# on cleaned away headers in ${WORLDTMP}.
439104476Ssam#
440104476Ssaminclude-tools:
441104476Ssam	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} cleandepend depend && \
442104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
443104476Ssam
444104476Ssam#
445104476Ssam# includes - possibly generate and install the include files.
446104476Ssam#
447104476Ssamincludes:
448104476Ssam.if defined(CLOBBER)
449104476Ssam	rm -rf ${DESTDIR}/usr/include/*
450104476Ssam	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
451104476Ssam		-p ${DESTDIR}/usr/include
452104476Ssam.endif
453104476Ssam	cd ${.CURDIR}/include &&		${MAKE} all installhdrs symlinks
454104476Ssam	cd ${.CURDIR}/gnu/include &&		${MAKE} install
455104476Ssam	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
456104476Ssam	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
457104476Ssam	cd ${.CURDIR}/gnu/lib/libstdc++ &&	${MAKE} beforeinstall
458104476Ssam	cd ${.CURDIR}/gnu/lib/libg++ &&		${MAKE} beforeinstall
459104476Ssam	cd ${.CURDIR}/gnu/lib/libdialog &&	${MAKE} beforeinstall
460104476Ssam	cd ${.CURDIR}/gnu/lib/libgmp &&		${MAKE} beforeinstall
461104476Ssam.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
462104476Ssam	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
463104476Ssam	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
464104476Ssam	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
465104476Ssam.endif
466104476Ssam	cd ${.CURDIR}/lib/csu/i386 &&		${MAKE} beforeinstall
467104476Ssam	cd ${.CURDIR}/lib/libalias &&		${MAKE} beforeinstall
468104476Ssam	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
469104476Ssam	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
470104476Ssam	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
471104476Ssam	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
472104476Ssam	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
473104476Ssam	cd ${.CURDIR}/lib/libmytinfo &&		${MAKE} beforeinstall
474104476Ssam	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
475104476Ssam.if !defined(WANT_CSRG_LIBM)
476104476Ssam	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
477104476Ssam.endif
478104476Ssam	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
479104476Ssam	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
480104476Ssam	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
481104476Ssam.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
482104476Ssam	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
483104476Ssam	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
484104476Ssam.endif
485104476Ssam	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
486104476Ssam	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
487104476Ssam	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
488104476Ssam	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
489104476Ssam	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
490104476Ssam	cd ${.CURDIR}/lib/libz &&		${MAKE} beforeinstall
491104476Ssam
492104476Ssam#
493104476Ssam# lib-tools - build tools to compile and install the libraries.
494104476Ssam#
495104476Ssam# XXX gperf is required for cc
496104476Ssam# XXX a new ld and tsort is required for cc
497104476Ssamlib-tools:
498104476Ssam.for d in				\
499104476Ssam		gnu/usr.bin/gperf	\
500104476Ssam		gnu/usr.bin/ld		\
501104476Ssam		usr.bin/tsort		\
502104476Ssam		gnu/usr.bin/as		\
503104476Ssam		gnu/usr.bin/bison	\
504104476Ssam		gnu/usr.bin/cc		\
505104476Ssam		usr.bin/ar		\
506104476Ssam		usr.bin/compile_et	\
507104476Ssam		usr.bin/lex/lib		\
508104476Ssam		usr.bin/mk_cmds		\
509104476Ssam		usr.bin/nm		\
510104476Ssam		usr.bin/ranlib		\
511104476Ssam		usr.bin/uudecode
512104476Ssam	cd ${.CURDIR}/$d && ${MAKE} depend && \
513104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
514104476Ssam.endfor
515104476Ssam
516104476Ssam#
517104476Ssam# libraries - build and install the libraries
518104476Ssam#
519104476Ssamlibraries:
520104476Ssam.if exists(lib/csu/i386)
521104476Ssam	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
522104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
523104476Ssam.endif
524104476Ssam.if exists(lib/libcompat)
525104476Ssam	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
526104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
527104476Ssam.endif
528104476Ssam.if exists(lib/libncurses)
529104476Ssam	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
530104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
531104476Ssam.endif
532104476Ssam.if exists(lib/libtermcap)
533104476Ssam	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
534104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
535104476Ssam.endif
536104476Ssam.if exists(gnu)
537104476Ssam	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
538104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
539104476Ssam.endif
540104476Ssam.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
541104476Ssam	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
542104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
543104476Ssam.endif
544104476Ssam.if exists(lib)
545104476Ssam	cd ${.CURDIR}/lib && ${MAKE} depend && \
546104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
547104476Ssam.endif
548104476Ssam.if exists(usr.bin/lex/lib)
549104476Ssam	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
550104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
551104476Ssam.endif
552104476Ssam.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
553104476Ssam	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
554158702Spjd		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
555158702Spjd.endif
556104476Ssam.if exists(usr.sbin/pcvt/keycap)
557104476Ssam	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
558104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
559104476Ssam.endif
560104476Ssam
561104476Ssam#
562104476Ssam# build-tools - build and install any other tools needed to complete the
563104476Ssam# compile and install.
564104476Ssam# ifdef stale
565104476Ssam# bc and cpp are required to build groff.  Otherwise, the order here is
566104476Ssam# mostly historical, i.e., bogus.
567104476Ssam# chmod is used to build gcc's tmpmultilib[2] at obscure times.
568104476Ssam# endif stale
569104476Ssam# XXX uname is a bug - the target should not depend on the host.
570104476Ssam#
571104476Ssambuild-tools:
572104476Ssam.for d in				\
573104476Ssam		bin/cat 		\
574158702Spjd		bin/chmod		\
575158702Spjd		bin/cp 			\
576158702Spjd		bin/date		\
577104476Ssam		bin/dd			\
578104476Ssam		bin/echo		\
579104476Ssam		bin/expr		\
580104476Ssam		bin/hostname		\
581104476Ssam		bin/ln			\
582158702Spjd		bin/ls			\
583104476Ssam		bin/mkdir		\
584104476Ssam		bin/mv			\
585104476Ssam		bin/rm			\
586104476Ssam		bin/sh			\
587104476Ssam		bin/test		\
588104476Ssam		gnu/usr.bin/awk		\
589104476Ssam		gnu/usr.bin/bc		\
590104476Ssam		gnu/usr.bin/grep	\
591104476Ssam		gnu/usr.bin/groff	\
592104476Ssam		gnu/usr.bin/gzip	\
593104476Ssam		gnu/usr.bin/man/makewhatis	\
594104476Ssam		gnu/usr.bin/sort	\
595104476Ssam		gnu/usr.bin/texinfo     \
596104476Ssam		share/info		\
597104476Ssam		usr.bin/basename	\
598104476Ssam		usr.bin/cap_mkdb	\
599104476Ssam		usr.bin/chflags		\
600104476Ssam		usr.bin/cmp		\
601104476Ssam		usr.bin/col		\
602104476Ssam		usr.bin/cpp		\
603158702Spjd		usr.bin/expand		\
604158702Spjd		usr.bin/file2c		\
605104476Ssam		usr.bin/find		\
606104476Ssam		usr.bin/gencat		\
607104476Ssam		usr.bin/lorder		\
608104476Ssam		usr.bin/m4		\
609104476Ssam		usr.bin/mkdep		\
610104476Ssam		usr.bin/paste		\
611104476Ssam		usr.bin/sed		\
612104476Ssam		usr.bin/size		\
613104476Ssam		usr.bin/soelim		\
614104476Ssam		usr.bin/strip		\
615104476Ssam		usr.bin/symorder	\
616158702Spjd		usr.bin/touch		\
617158702Spjd		usr.bin/tr		\
618158702Spjd		usr.bin/true		\
619104476Ssam		usr.bin/uname		\
620104476Ssam		usr.bin/uuencode	\
621104476Ssam		usr.bin/vgrind		\
622104476Ssam		usr.bin/vi		\
623104476Ssam		usr.bin/wc		\
624158702Spjd		usr.bin/yacc		\
625104476Ssam		usr.sbin/chown		\
626104476Ssam		usr.sbin/mtree		\
627104476Ssam		usr.sbin/zic
628104476Ssam	cd ${.CURDIR}/$d && ${MAKE} depend && \
629104476Ssam		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
630104476Ssam.endfor
631104476Ssam
632104476Ssam.include <bsd.subdir.mk>
633104476Ssam