Makefile.inc1 revision 40175
1189251Ssam#
2214734Srpaulo#	$Id: Makefile.inc1,v 1.27 1998/10/10 10:54:54 jkh Exp $
3252726Srpaulo#
4189251Ssam# Make command line options:
5252726Srpaulo#	-DCLOBBER will remove /usr/include
6252726Srpaulo#	-DMAKE_KERBEROS4 to build KerberosIV
7189251Ssam#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8189251Ssam#	-DNOCLEAN do not clean at all
9214734Srpaulo#	-DNOTOOLS do not rebuild any tools first
10189251Ssam#	-DNOCRYPT will prevent building of crypt versions
11214734Srpaulo#	-DNOLKM do not build loadable kernel modules
12214734Srpaulo#	-DNOPROFILE do not build profiled libraries
13214734Srpaulo#	-DNOSECURE do not go into secure subdir
14214734Srpaulo#	-DNOGAMES do not go into games subdir
15189251Ssam#	-DNOSHARE do not go into share subdir
16189251Ssam#	-DNOINFO do not make or install info files
17189251Ssam#	-DNOLIBC_R do not build libc_r.
18214734Srpaulo#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19214734Srpaulo
20214734Srpaulo#
21214734Srpaulo# The intended user-driven targets are:
22214734Srpaulo# buildworld  - rebuild *everything*, including glue to help do upgrades
23214734Srpaulo# installworld- install everything built by "buildworld"
24214734Srpaulo# update      - convenient way to update your source tree (eg: sup/cvs)
25214734Srpaulo# most        - build user commands, no libraries or include files
26214734Srpaulo# installmost - install user commands, no libraries or include files
27214734Srpaulo#
28214734Srpaulo# Standard targets (not defined here) are documented in the makefiles in
29214734Srpaulo# /usr/share/mk.  These include:
30214734Srpaulo#		obj depend all install clean cleandepend cleanobj
31214734Srpaulo
32214734Srpaulo# Put initial settings here.
33214734SrpauloSUBDIR=
34214734Srpaulo
35214734Srpaulo# We must do share/info early so that installation of info `dir'
36214734Srpaulo# entries works correctly.  Do it first since it is less likely to
37214734Srpaulo# grow dependencies on include and lib than vice versa.
38214734Srpaulo.if exists(share/info)
39214734SrpauloSUBDIR+= share/info
40214734Srpaulo.endif
41214734Srpaulo
42214734Srpaulo# We must do include and lib early so that the perl *.ph generation
43214734Srpaulo# works correctly as it uses the header files installed by this.
44214734Srpaulo.if exists(include)
45214734SrpauloSUBDIR+= include
46214734Srpaulo.endif
47214734Srpaulo.if exists(lib)
48214734SrpauloSUBDIR+= lib
49214734Srpaulo.endif
50214734Srpaulo
51214734Srpaulo.if exists(bin)
52214734SrpauloSUBDIR+= bin
53189251Ssam.endif
54214734Srpaulo.if exists(games) && !defined(NOGAMES)
55189251SsamSUBDIR+= games
56189251Ssam.endif
57189251Ssam.if exists(gnu)
58214734SrpauloSUBDIR+= gnu
59189251Ssam.endif
60214734Srpaulo.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
61214734Srpaulo    defined(MAKE_KERBEROS4)
62189251SsamSUBDIR+= kerberosIV
63189251Ssam.endif
64214734Srpaulo.if exists(libexec)
65214734SrpauloSUBDIR+= libexec
66214734Srpaulo.endif
67214734Srpaulo.if exists(sbin)
68214734SrpauloSUBDIR+= sbin
69214734Srpaulo.endif
70189251Ssam.if exists(share) && !defined(NOSHARE)
71189251SsamSUBDIR+= share
72214734Srpaulo.endif
73214734Srpaulo.if exists(sys)
74214734SrpauloSUBDIR+= sys
75214734Srpaulo.endif
76189251Ssam.if exists(usr.bin)
77189251SsamSUBDIR+= usr.bin
78189251Ssam.endif
79214734Srpaulo.if exists(usr.sbin)
80189251SsamSUBDIR+= usr.sbin
81252726Srpaulo.endif
82252726Srpaulo.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
83214734SrpauloSUBDIR+= secure
84189251Ssam.endif
85189251Ssam.if exists(lkm) && !defined(NOLKM) && ${OBJFORMAT} == "aout"
86189251SsamSUBDIR+= lkm
87189251Ssam.endif
88189251Ssam
89189251Ssam# etc must be last for "distribute" to work
90189251Ssam.if exists(etc)
91189251SsamSUBDIR+= etc
92189251Ssam.endif
93214734Srpaulo
94214734Srpaulo# These are last, since it is nice to at least get the base system
95214734Srpaulo# rebuilt before you do them.
96214734Srpaulo.if defined(LOCAL_DIRS)
97214734Srpaulo.for _DIR in ${LOCAL_DIRS}
98214734Srpaulo.if exists(${_DIR}) & exists(${_DIR}/Makefile)
99214734SrpauloSUBDIR+= ${_DIR}
100214734Srpaulo.endif
101214734Srpaulo.endfor
102214734Srpaulo.endif
103189251Ssam
104214734SrpauloOBJDIR=		obj
105214734Srpaulo
106214734Srpaulo.if defined(NOCLEAN)
107214734SrpauloCLEANDIR=
108214734Srpaulo.else
109214734Srpaulo.if defined(NOCLEANDIR)
110214734SrpauloCLEANDIR=	clean cleandepend
111214734Srpaulo.else
112214734SrpauloCLEANDIR=	cleandir
113214734Srpaulo.endif
114214734Srpaulo.endif
115214734Srpaulo
116214734Srpaulo.if !defined(NOCLEAN)
117214734Srpaulo_NODEPEND=	true
118214734Srpaulo.endif
119214734Srpaulo.if defined(_NODEPEND)
120189251Ssam_DEPEND=	cleandepend
121189251Ssam.else
122189251Ssam_DEPEND=	depend
123214734Srpaulo.endif
124214734Srpaulo
125214734SrpauloSUP?=		cvsup
126214734SrpauloSUPFLAGS?=	-g -L 2 -P -
127189251Ssam
128189251Ssam#
129214734Srpaulo# While building tools for bootstrapping, we don't need to waste time on
130214734Srpaulo# shared or profiled libraries, shared linkage, or documentation, except
131189251Ssam# when the tools won't get cleaned we must use the defaults for shared
132214734Srpaulo# libraries and shared linkage (and this doesn't waste time).
133189251Ssam# XXX actually, we do need to waste time building shared libraries.
134214734Srpaulo#
135189251Ssam.if defined(NOCLEAN)
136189251SsamMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
137189251Ssam.else
138189251SsamMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
139189251Ssam.endif
140189251Ssam
141189251Ssam#
142189251Ssam# Define the location of the temporary installation directory. Note that
143189251Ssam# MAKEOBJDIRPREFIX normally isn't defined so if the current directory is
144189251Ssam# /usr/src, then the world temporary directory is /usr/obj/usr/src/tmp.
145189251Ssam#
146189251Ssam# During the transition from aout to elf format on i386, MAKEOBJDIRPREFIX
147189251Ssam# is set by the parent makefile (Makefile.inc0) to be /usr/obj/${OBJFORMAT}
148189251Ssam# in order to keep aout and elf format files apart.
149189251Ssam#
150252726Srpaulo.if defined(MAKEOBJDIRPREFIX)
151252726SrpauloWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
152252726Srpaulo.else
153252726SrpauloWORLDTMP=	/usr/obj${.CURDIR}/tmp
154252726Srpaulo.endif
155252726Srpaulo
156189251Ssam#
157189251Ssam# Define the PATH to the build tools.
158189251Ssam#
159189251Ssam# If not building tools, the PATH always points to the installed binaries.
160189251Ssam# The NOTOOLS option assumes that in installed tools are good enough and that
161189251Ssam# the user's PATH will locate to appropriate tools. This option is required
162189251Ssam# for a cross-compiled build environment.
163189251Ssam#
164189251Ssam# If building tools, then the PATH includes the world temporary directories
165189251Ssam# so that the bootstrapped tools are used as soon as they are built. The
166189251Ssam# strict path is for use after all tools are supposed to have been
167189251Ssam# bootstrapped. It doesn't allow any of the installed tools to be used.
168189251Ssam#
169189251Ssam.if	defined(NOTOOLS)
170189251Ssam# Default root of the tool tree
171189251SsamTOOLROOT?=	
172189251Ssam# Choose the PATH relative to the root of the tool tree
173189251SsamPATH=		${TOOLROOT}/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/sbin:${TOOLROOT}/usr/bin:${TOOLROOT}/usr/games
174189251Ssam.else
175189251SsamTOOLROOT=	${WORLDTMP}
176189251Ssam.endif
177189251SsamSTRICTTMPPATH=	${TOOLROOT}/sbin:${TOOLROOT}/usr/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/bin:${TOOLROOT}/usr/games
178189251SsamTMPPATH=	${STRICTTMPPATH}:${PATH}:/usr/games
179189251Ssam
180189251Ssam# XXX COMPILER_PATH is needed for finding cc1, ld and as
181189251Ssam# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecessary now
182189251Ssam#	that LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
183189251Ssam#	wouldn't link *crt.o or libgcc if it were used.
184189251Ssam# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
185189251Ssam#	want that - all compile-time library paths should be resolved by gcc.
186189251Ssam#	It fails for set[ug]id executables (are any used?).
187189251SsamCOMPILER_ENV=	BISON_SIMPLE=${TOOLROOT}/usr/share/misc/bison.simple \
188189251Ssam		COMPILER_PATH=${TOOLROOT}/usr/libexec:${TOOLROOT}/usr/bin \
189189251Ssam		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
190189251Ssam		LD_LIBRARY_PATH=${TOOLROOT}${SHLIBDIR} \
191189251Ssam		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
192189251Ssam
193189251SsamBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t \
194189251Ssam		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec:/usr/libexec
195189251SsamXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
196189251Ssam		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec \
197189251Ssam		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
198189251Ssam
199189251Ssam# used to compile and install 'make' in temporary build tree
200189251SsamMAKETMP=	${WORLDTMP}/make
201189251SsamIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
202189251Ssam
203189251Ssam.if	defined(NOTOOLS)
204189251Ssam# bootstrap make
205189251SsamBMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
206189251Ssam# cross make used for compilation
207189251SsamXMAKE=	${XMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
208189251Ssam# cross make used for final installation
209189251SsamIXMAKE=	${XMAKEENV} ${MAKE}
210189251Ssam.else
211189251Ssam# bootstrap make
212189251SsamBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
213189251Ssam# cross make used for compilation
214189251SsamXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
215189251Ssam# cross make used for final installation
216189251SsamIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
217189251Ssam.endif
218189251Ssam
219189251Ssam#
220189251Ssam# buildworld
221252726Srpaulo#
222252726Srpaulo# Attempt to rebuild the entire system, with reasonable chance of
223189251Ssam# success, regardless of how old your existing system is.
224189251Ssam#
225189251Ssambuildworld: check-objformat
226189251Ssam.if !defined(NOCLEAN)
227189251Ssam	@echo
228189251Ssam	@echo "--------------------------------------------------------------"
229189251Ssam	@echo ">>> Cleaning up the temporary ${OBJFORMAT} build tree"
230189251Ssam	@echo "--------------------------------------------------------------"
231252726Srpaulo	mkdir -p ${WORLDTMP}
232189251Ssam	chflags -R noschg ${WORLDTMP}/
233189251Ssam	rm -rf ${WORLDTMP}
234252726Srpaulo.endif
235189251Ssam.if !defined(NOTOOLS)
236189251Ssam	@echo
237189251Ssam	@echo "--------------------------------------------------------------"
238189251Ssam	@echo ">>> Making make"
239189251Ssam	@echo "--------------------------------------------------------------"
240189251Ssam	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
241189251Ssam	( \
242189251Ssam	cd ${.CURDIR}/usr.bin/make; \
243189251Ssam		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
244189251Ssam		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
245189251Ssam		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
246189251Ssam		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
247189251Ssam	)
248189251Ssam	@echo
249189251Ssam	@echo "--------------------------------------------------------------"
250189251Ssam	@echo ">>> Making mtree"
251189251Ssam	@echo "--------------------------------------------------------------"
252189251Ssam	mkdir -p ${WORLDTMP}/usr/sbin ${WORLDTMP}/mtree
253189251Ssam	( \
254189251Ssam	cd ${.CURDIR}/usr.sbin/mtree; \
255189251Ssam		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
256189251Ssam		export MAKEOBJDIR=${WORLDTMP}/mtree; \
257189251Ssam		${BMAKE} ${MK_FLAGS} all; \
258189251Ssam		${BMAKE} ${MK_FLAGS} -B install clean \
259189251Ssam	)
260189251Ssam.endif
261189251Ssam	@echo
262189251Ssam	@echo "--------------------------------------------------------------"
263189251Ssam	@echo ">>> Making hierarchy"
264189251Ssam	@echo "--------------------------------------------------------------"
265189251Ssam	mkdir -p ${WORLDTMP}
266189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 hierarchy
267189251Ssam.if !defined(NOCLEAN)
268189251Ssam	@echo
269189251Ssam	@echo "--------------------------------------------------------------"
270189251Ssam	@echo ">>> Cleaning up the ${OBJFORMAT} obj tree"
271189251Ssam	@echo "--------------------------------------------------------------"
272252726Srpaulo	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
273189251Ssam.endif
274189251Ssam	@echo
275189251Ssam	@echo "--------------------------------------------------------------"
276189251Ssam	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
277189251Ssam	@echo "--------------------------------------------------------------"
278189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 par-${OBJDIR}
279189251Ssam.if !defined(NOTOOLS)
280189251Ssam	@echo
281189251Ssam	@echo "--------------------------------------------------------------"
282189251Ssam	@echo ">>> Rebuilding ${OBJFORMAT} bootstrap tools"
283189251Ssam	@echo "--------------------------------------------------------------"
284189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap
285189251Ssam	@echo
286189251Ssam	@echo "--------------------------------------------------------------"
287189251Ssam	@echo ">>> Rebuilding tools necessary to build the include files"
288189251Ssam	@echo "--------------------------------------------------------------"
289189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 include-tools
290189251Ssam.endif
291189251Ssam	@echo
292189251Ssam	@echo "--------------------------------------------------------------"
293189251Ssam	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
294189251Ssam	@echo "--------------------------------------------------------------"
295189251Ssam	cd ${.CURDIR}; SHARED=copies ${BMAKE} -f Makefile.inc1 includes
296189251Ssam	@echo
297189251Ssam	@echo "--------------------------------------------------------------"
298189251Ssam	@echo ">>> Rebuilding bootstrap libraries"
299189251Ssam	@echo "--------------------------------------------------------------"
300189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap-libraries
301189251Ssam.if !defined(NOTOOLS)
302189251Ssam	@echo
303189251Ssam	@echo "--------------------------------------------------------------"
304189251Ssam	@echo ">>> Rebuilding tools needed to build libraries"
305189251Ssam	@echo "--------------------------------------------------------------"
306189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 lib-tools
307189251Ssam.endif
308189251Ssam.if !defined(NOTOOLS)
309189251Ssam	@echo
310189251Ssam	@echo "--------------------------------------------------------------"
311189251Ssam	@echo ">>> Rebuilding all other tools needed to build the ${OBJFORMAT} world"
312189251Ssam	@echo "--------------------------------------------------------------"
313189251Ssam	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 build-tools
314189251Ssam.endif
315189251Ssam.if !defined(_NODEPEND)
316189251Ssam	@echo
317189251Ssam	@echo "--------------------------------------------------------------"
318189251Ssam	@echo ">>> Rebuilding dependencies"
319189251Ssam	@echo "--------------------------------------------------------------"
320189251Ssam	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-depend
321189251Ssam.endif
322189251Ssam	@echo
323189251Ssam	@echo "--------------------------------------------------------------"
324189251Ssam	@echo ">>> Building ${OBJFORMAT} libraries"
325189251Ssam	@echo "--------------------------------------------------------------"
326189251Ssam	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
327189251Ssam	@echo
328189251Ssam	@echo "--------------------------------------------------------------"
329189251Ssam	@echo ">>> Building everything.."
330189251Ssam	@echo "--------------------------------------------------------------"
331189251Ssam	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
332189251Ssam
333189251Ssameverything:
334189251Ssam	@echo "--------------------------------------------------------------"
335252726Srpaulo	@echo ">>> Building everything.."
336189251Ssam	@echo "--------------------------------------------------------------"
337189251Ssam	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
338189251Ssam
339189251Ssam#
340189251Ssam# installworld
341189251Ssam#
342189251Ssam# Installs everything compiled by a 'buildworld'.
343189251Ssam#
344189251Ssaminstallworld:
345189251Ssam	cd ${.CURDIR}; ${IXMAKE} -f Makefile.inc1 reinstall
346189251Ssam
347189251Ssam#
348189251Ssam# reinstall
349189251Ssam#
350189251Ssam# If you have a build server, you can NFS mount the source and obj directories
351189251Ssam# and do a 'make reinstall' on the *client* to install new binaries from the
352189251Ssam# most recent server build.
353189251Ssam#
354189251Ssamreinstall:
355189251Ssam	@echo "--------------------------------------------------------------"
356214734Srpaulo	@echo ">>> Making hierarchy"
357214734Srpaulo	@echo "--------------------------------------------------------------"
358189251Ssam	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
359189251Ssam	@echo
360252726Srpaulo	@echo "--------------------------------------------------------------"
361214734Srpaulo	@echo ">>> Installing everything.."
362214734Srpaulo	@echo "--------------------------------------------------------------"
363189251Ssam	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
364252726Srpaulo.if ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
365189251Ssam	@echo
366214734Srpaulo	@echo "--------------------------------------------------------------"
367214734Srpaulo	@echo ">>> Re-scanning the shared libraries.."
368214734Srpaulo	@echo "--------------------------------------------------------------"
369189251Ssam	cd ${.CURDIR}; /sbin/ldconfig -R
370189251Ssam.endif
371189251Ssam	@echo
372189251Ssam	@echo "--------------------------------------------------------------"
373189251Ssam	@echo ">>> Rebuilding man page indexes"
374189251Ssam	@echo "--------------------------------------------------------------"
375189251Ssam	cd ${.CURDIR}/share/man; ${MAKE} makedb
376189251Ssam
377189251Ssam#
378189251Ssam# update
379189251Ssam#
380189251Ssam# Update the source tree, by running sup and/or running cvs to update to the
381189251Ssam# latest copy.
382189251Ssam#
383189251Ssamupdate:
384189251Ssam.if defined(SUP_UPDATE)
385189251Ssam	@echo "--------------------------------------------------------------"
386189251Ssam	@echo ">>> Running ${SUP}"
387189251Ssam	@echo "--------------------------------------------------------------"
388189251Ssam	@${SUP} ${SUPFLAGS} ${SUPFILE}
389189251Ssam.if defined(SUPFILE1)
390252726Srpaulo	@${SUP} ${SUPFLAGS} ${SUPFILE1}
391189251Ssam.endif
392189251Ssam.if defined(SUPFILE2)
393214734Srpaulo	@${SUP} ${SUPFLAGS} ${SUPFILE2}
394214734Srpaulo.endif
395189251Ssam.endif
396189251Ssam.if defined(CVS_UPDATE)
397189251Ssam	@echo "--------------------------------------------------------------"
398189251Ssam	@echo ">>> Updating /usr/src from cvs repository" ${CVSROOT}
399189251Ssam	@echo "--------------------------------------------------------------"
400189251Ssam	cd ${.CURDIR}; cvs -q update -P -d
401214734Srpaulo.endif
402214734Srpaulo
403189251Ssam#
404189251Ssam# most
405189251Ssam#
406189251Ssam# Build most of the user binaries on the existing system libs and includes.
407214734Srpaulo#
408214734Srpaulomost:
409214734Srpaulo	@echo "--------------------------------------------------------------"
410189251Ssam	@echo ">>> Building programs only"
411189251Ssam	@echo "--------------------------------------------------------------"
412189251Ssam	cd ${.CURDIR}/bin;		${MAKE} all
413189251Ssam	cd ${.CURDIR}/sbin;		${MAKE} all
414189251Ssam	cd ${.CURDIR}/libexec;		${MAKE} all
415189251Ssam	cd ${.CURDIR}/usr.bin;		${MAKE} all
416252726Srpaulo	cd ${.CURDIR}/usr.sbin;		${MAKE} all
417252726Srpaulo	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
418252726Srpaulo	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
419252726Srpaulo	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
420252726Srpaulo#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
421252726Srpaulo#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
422252726Srpaulo#.endif
423252726Srpaulo#.if !defined(NOSECURE) && !defined(NOCRYPT)
424252726Srpaulo#	cd ${.CURDIR}/secure;		${MAKE} most
425252726Srpaulo#.endif
426252726Srpaulo
427252726Srpaulo#
428252726Srpaulo# installmost
429252726Srpaulo#
430252726Srpaulo# Install the binaries built by the 'most' target.  This does not include
431252726Srpaulo# libraries or include files.
432252726Srpaulo#
433252726Srpauloinstallmost:
434252726Srpaulo	@echo "--------------------------------------------------------------"
435252726Srpaulo	@echo ">>> Installing programs only"
436252726Srpaulo	@echo "--------------------------------------------------------------"
437252726Srpaulo	cd ${.CURDIR}/bin;		${MAKE} install
438252726Srpaulo	cd ${.CURDIR}/sbin;		${MAKE} install
439252726Srpaulo	cd ${.CURDIR}/libexec;		${MAKE} install
440252726Srpaulo	cd ${.CURDIR}/usr.bin;		${MAKE} install
441252726Srpaulo	cd ${.CURDIR}/usr.sbin;		${MAKE} install
442252726Srpaulo	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
443252726Srpaulo	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
444252726Srpaulo	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
445252726Srpaulo#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
446252726Srpaulo#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
447252726Srpaulo#.endif
448252726Srpaulo#.if !defined(NOSECURE) && !defined(NOCRYPT)
449252726Srpaulo#	cd ${.CURDIR}/secure;		${MAKE} installmost
450252726Srpaulo#.endif
451252726Srpaulo
452252726Srpaulo#
453252726Srpaulo# ------------------------------------------------------------------------
454252726Srpaulo#
455189251Ssam# From here onwards are utility targets used by the 'make world' and
456189251Ssam# related targets.  If your 'world' breaks, you may like to try to fix
457189251Ssam# the problem and manually run the following targets to attempt to
458189251Ssam# complete the build.  Beware, this is *not* guaranteed to work, you
459189251Ssam# need to have a pretty good grip on the current state of the system
460189251Ssam# to attempt to manually finish it.  If in doubt, 'make world' again.
461252726Srpaulo#
462189251Ssam
463214734Srpaulo#
464214734Srpaulo# hierarchy - ensure that all the needed directories are present
465189251Ssam#
466189251Ssamhierarchy:
467189251Ssam	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
468189251Ssam
469214734Srpaulo#
470214734Srpaulo# bootstrap - [re]build tools needed to run the actual build, this includes
471214734Srpaulo# tools needed by 'make depend', as some tools are needed to generate source
472189251Ssam# for the dependency information to be gathered from.
473189251Ssam#
474189251Ssambootstrap:
475189251Ssam.if defined(DESTDIR)
476252726Srpaulo	rm -f ${DESTDIR}/usr/src/sys
477252726Srpaulo	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
478252726Srpaulo	cd ${.CURDIR}/include; find -dx . | cpio -dump ${DESTDIR}/usr/include
479252726Srpaulo.for d in net netatm netinet posix4 sys vm machine
480252726Srpaulo	if [ -h ${DESTDIR}/usr/include/$d ]; then \
481252726Srpaulo		rm -f ${DESTDIR}/usr/include/$d ; \
482252726Srpaulo	fi
483252726Srpaulo.endfor
484252726Srpaulo	cd ${.CURDIR}/sys; \
485252726Srpaulo		find -dx net netatm netinet posix4 sys vm -name '*.h' -o -type d | \
486252726Srpaulo		cpio -dump ${DESTDIR}/usr/include
487252726Srpaulo	mkdir -p ${DESTDIR}/usr/include/machine
488252726Srpaulo	cd ${.CURDIR}/sys/${MACHINE_ARCH}/include; find -dx . -name '*.h' -o -type d | \
489252726Srpaulo		cpio -dump ${DESTDIR}/usr/include/machine
490252726Srpaulo.endif
491252726Srpaulo	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
492252726Srpaulo		${MAKE} ${MK_FLAGS} all; \
493252726Srpaulo		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
494252726Srpaulo	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
495252726Srpaulo		${MAKE} ${MK_FLAGS} all; \
496252726Srpaulo		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
497252726Srpaulo	cd ${.CURDIR}/usr.bin/yacc; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
498252726Srpaulo		${MAKE} ${MK_FLAGS} all; \
499252726Srpaulo		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
500252726Srpaulo	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
501252726Srpaulo		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
502252726Srpaulo		${MAKE} ${MK_FLAGS} -DNOLIB all; \
503252726Srpaulo		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
504252726Srpaulo	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
505252726Srpaulo	cd ${.CURDIR}/usr.sbin/mtree; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
506252726Srpaulo		${MAKE} ${MK_FLAGS} all; \
507252726Srpaulo		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
508252726Srpaulo.if defined(DESTDIR)
509252726Srpaulo	cd ${.CURDIR}/include && ${MAKE} copies
510252726Srpaulo.endif
511252726Srpaulo
512252726Srpaulo#
513252726Srpaulo# include-tools - generally the same as 'bootstrap', except that it's for
514252726Srpaulo# things that are specifically needed to generate include files.
515252726Srpaulo#
516252726Srpaulo# XXX should be merged with bootstrap, it's not worth keeeping them separate.
517252726Srpaulo# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
518252726Srpaulo# on cleaned away headers in ${WORLDTMP}.
519252726Srpaulo#
520252726Srpauloinclude-tools:
521252726Srpaulo.for d in usr.bin/compile_et usr.bin/rpcgen
522252726Srpaulo	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
523252726Srpaulo		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
524252726Srpaulo		${MAKE} ${MK_FLAGS} all; \
525252726Srpaulo		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
526252726Srpaulo.endfor
527252726Srpaulo
528252726Srpaulo#
529252726Srpaulo# includes - possibly generate and install the include files.
530252726Srpaulo#
531252726Srpauloincludes:
532252726Srpaulo.if defined(CLOBBER)
533252726Srpaulo	rm -rf ${DESTDIR}/usr/include/*
534252726Srpaulo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
535252726Srpaulo		-p ${DESTDIR}/usr/include
536252726Srpaulo.endif
537252726Srpaulo	cd ${.CURDIR}/include;			${MAKE} -B all install
538252726Srpaulo	cd ${.CURDIR}/gnu/include;		${MAKE} install
539252726Srpaulo	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
540252726Srpaulo	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
541252726Srpaulo	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
542252726Srpaulo	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
543252726Srpaulo	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
544252726Srpaulo	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
545252726Srpaulo	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
546252726Srpaulo	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
547252726Srpaulo.if exists(secure) && !defined(NOCRYPT)
548252726Srpaulo	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
549252726Srpaulo.endif
550252726Srpaulo.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
551252726Srpaulo	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
552252726Srpaulo	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
553252726Srpaulo	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
554252726Srpaulo	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
555252726Srpaulo	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
556252726Srpaulo	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
557252726Srpaulo.else
558189251Ssam	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
559189251Ssam.endif
560189251Ssam.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
561189251Ssam	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
562189251Ssam.endif
563189251Ssam	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
564189251Ssam	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
565252726Srpaulo	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
566252726Srpaulo	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
567189251Ssam	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
568189251Ssam	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
569189251Ssam	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
570189251Ssam	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
571189251Ssam	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
572189251Ssam	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
573189251Ssam	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
574214734Srpaulo	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
575214734Srpaulo	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
576189251Ssam.if !defined(WANT_CSRG_LIBM)
577189251Ssam	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
578189251Ssam.endif
579189251Ssam	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
580189251Ssam	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
581189251Ssam	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
582189251Ssam	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
583189251Ssam	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
584189251Ssam	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
585189251Ssam	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
586189251Ssam	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
587189251Ssam	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
588189251Ssam	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
589189251Ssam	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
590189251Ssam	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
591189251Ssam	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
592189251Ssam
593214734Srpaulo#
594189251Ssam# Declare tools if they are not required on all architectures.
595214734Srpaulo#
596189251Ssam.if ${MACHINE_ARCH} == "i386"
597214734Srpaulo# aout tools:
598189251Ssam_aout_ar	= usr.bin/ar
599214734Srpaulo_aout_as	= gnu/usr.bin/as
600189251Ssam_aout_ld	= gnu/usr.bin/ld
601189251Ssam_aout_nm	= usr.bin/nm
602214734Srpaulo_aout_ranlib	= usr.bin/ranlib
603189251Ssam_aout_size	= usr.bin/size
604189251Ssam_aout_strip	= usr.bin/strip
605214734Srpaulo.endif
606189251Ssam
607189251Ssam#
608189251Ssam# lib-tools - build tools to compile and install the libraries.
609189251Ssam#
610189251Ssam# XXX gperf is required for cc
611189251Ssam# XXX a new ld and tsort is required for cc
612189251Ssamlib-tools:
613189251Ssam.for d in				\
614214734Srpaulo		gnu/usr.bin/gperf	\
615214734Srpaulo		${_aout_ld}		\
616214734Srpaulo		usr.bin/tsort		\
617214734Srpaulo		${_aout_as}		\
618214734Srpaulo		gnu/usr.bin/bison	\
619214734Srpaulo		gnu/usr.bin/cc		\
620214734Srpaulo		${_aout_ar}		\
621214734Srpaulo		usr.bin/env		\
622214734Srpaulo		usr.bin/lex/lib		\
623214734Srpaulo		usr.bin/mk_cmds		\
624189251Ssam		${_aout_nm}		\
625189251Ssam		${_aout_ranlib}		\
626189251Ssam		${_aout_strip}		\
627189251Ssam		gnu/usr.bin/binutils	\
628189251Ssam		usr.bin/uudecode	\
629189251Ssam		share/info		\
630189251Ssam		usr.bin/objformat
631189251Ssam	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
632189251Ssam		${MAKE} ${MK_FLAGS} all; \
633189251Ssam		${MAKE} ${MK_FLAGS} -B install; \
634189251Ssam		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
635189251Ssam.endfor
636252726Srpaulo
637189251Ssam#
638214734Srpaulo# We have to know too much about ordering and subdirs in the lib trees:
639189251Ssam#
640189251Ssam# To satisfy shared library linkage when only the libraries being built
641189251Ssam# are visible:
642189251Ssam#
643214734Srpaulo# libcom_err must be built before libss.
644214734Srpaulo# libcrypt and libmd must be built before libskey.
645189251Ssam# libmytinfo must be built before libdialog and libncurses.
646189251Ssam# libncurses must be built before libdialog.
647214734Srpaulo# libtermcap must be built before libcurses, libedit and libreadline.
648189251Ssam#
649189251Ssam# Some libraries are built conditionally and/or are in inconsistently
650189251Ssam# named directories:
651214734Srpaulo#
652214734Srpaulo.if exists(lib/csu/${MACHINE_ARCH}.pcc)
653214734Srpaulo_csu=lib/csu/${MACHINE_ARCH}.pcc
654189251Ssam.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
655189251Ssam_csu=lib/csu/i386-elf
656214734Srpaulo.else
657189251Ssam_csu=lib/csu/${MACHINE_ARCH}
658189251Ssam.endif
659214734Srpaulo
660214734Srpaulo.if !defined(NOSECURE) && !defined(NOCRYPT)
661189251Ssam_libcrypt=	secure/lib/libcrypt lib/libcrypt
662189251Ssam.else
663189251Ssam_libcrypt=	lib/libcrypt
664189251Ssam.endif
665189251Ssam
666189251Ssam.if defined(WANT_CSRG_LIBM)
667189251Ssam_libm=	lib/libm
668189251Ssam.else
669189251Ssam_libm=	lib/msun
670189251Ssam.endif
671189251Ssam
672189251Ssam.if !defined(NOPERL)
673189251Ssam_libperl=		gnu/usr.bin/perl/libperl
674189251Ssam.endif
675189251Ssam
676189251Ssam#
677189251Ssam# bootstrap-libraries - build just enough libraries for the bootstrap
678189251Ssam# tools, and install them under ${WORLDTMP}.
679189251Ssam#
680189251Ssam# Build csu and libgcc early so that some tools get linked to the new
681189251Ssam# versions (too late for the main tools, however).  Then build the
682189251Ssam# necessary prerequisite libraries (libtermcap just needs to be before
683189251Ssam# libcurses, and this only matters for the NOCLEAN case when NOPIC is
684189251Ssam# not set).
685189251Ssam#
686189251Ssam# This is mostly wrong.  The build tools must run on the host system,
687189251Ssam# so they should use host libraries.  We depend on the target being
688189251Ssam# similar enough to the host for new target libraries to work on the
689189251Ssam# host.
690189251Ssam#
691189251Ssambootstrap-libraries:
692189251Ssam.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
693189251Ssam    gnu/lib/libregex gnu/lib/libreadline lib/libc \
694189251Ssam    ${_libcrypt} lib/libcurses lib/libedit ${_libm} \
695189251Ssam    lib/libmd lib/libutil lib/libz usr.bin/lex/lib \
696189251Ssam    ${_libperl}
697189251Ssam.if exists(${.CURDIR}/${_lib})
698189251Ssam	cd ${.CURDIR}/${_lib}; \
699189251Ssam		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
700189251Ssam		${MAKE} ${MK_FLAGS} all; \
701189251Ssam		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
702189251Ssam.endif
703189251Ssam.endfor
704189251Ssam
705189251Ssam#
706189251Ssam# libraries - build all libraries, and install them under ${DESTDIR}.
707189251Ssam#
708189251Ssam# The ordering is not as special as for bootstrap-libraries.  Build
709189251Ssam# the prerequisites first, then build almost everything else in
710252726Srpaulo# alphabetical order.
711189251Ssam#
712252726Srpaulolibraries:
713189251Ssam.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
714189251Ssam    lib/libncurses lib/libtermcap \
715189251Ssam    gnu/lib gnu/usr.bin/cc/libgcc ${_libperl} lib usr.bin/lex/lib \
716189251Ssam    usr.sbin/pcvt/keycap
717189251Ssam.if exists(${.CURDIR}/${_lib})
718189251Ssam	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
719189251Ssam.endif
720189251Ssam.endfor
721189251Ssam.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
722252726Srpaulo	cd ${.CURDIR}/secure/lib; ${MAKE} all; ${MAKE} -B install
723252726Srpaulo.endif
724189251Ssam.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
725189251Ssam    defined(MAKE_KERBEROS4)
726189251Ssam	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} all; ${MAKE} -B install
727189251Ssam.endif
728189251Ssam
729189251Ssam#
730252726Srpaulo# Exclude unused tools from build-tools.
731189251Ssam#
732189251Ssam.if !defined(NOGAMES) && exists(${.CURDIR}/games)
733189251Ssam_adventure=	games/adventure
734189251Ssam_caesar=	games/caesar
735189251Ssam_hack=		games/hack
736252726Srpaulo_phantasia=	games/phantasia
737252726Srpaulo_strfile=	games/fortune/strfile
738189251Ssam.endif
739252726Srpaulo.if !defined(NOPERL)
740189251Ssam_perl=		gnu/usr.bin/perl/miniperl
741189251Ssam.endif
742189251Ssam.if !defined(NOSHARE) && exists(${.CURDIR}/share)
743189251Ssam_scrnmaps=	share/syscons/scrnmaps
744189251Ssam.endif
745189251Ssam.if !defined(NOLKM) && exists(${.CURDIR}/lkm) && ${OBJFORMAT} == "aout"
746189251Ssam_linux=		lkm/linux
747189251Ssam.endif
748189251Ssam.if ${OBJFORMAT} == "aout"
749189251Ssam_netboot=	sys/${MACHINE}/boot/netboot
750189251Ssam.endif
751189251Ssam
752189251SsamBTMAKEFLAGS=	${MK_FLAGS} -D_BUILD_TOOLS
753189251Ssam
754189251Ssam#
755189251Ssam# build-tools - build and install any other tools needed to complete the
756189251Ssam# compile and install.
757189251Ssam# ifdef stale
758189251Ssam# bc and cpp are required to build groff.  Otherwise, the order here is
759189251Ssam# mostly historical, i.e., bogus.
760189251Ssam# chmod is used to build gcc's tmpmultilib[2] at obscure times.
761189251Ssam# endif stale
762189251Ssam# XXX uname is a bug - the target should not depend on the host.
763189251Ssam#
764189251Ssambuild-tools:
765189251Ssam.for d in				\
766189251Ssam		bin/cat 		\
767189251Ssam		bin/chmod		\
768189251Ssam		bin/cp 			\
769189251Ssam		bin/date		\
770189251Ssam		bin/dd			\
771189251Ssam		bin/echo		\
772189251Ssam		bin/expr		\
773189251Ssam		bin/hostname		\
774189251Ssam		bin/ln			\
775189251Ssam		bin/ls			\
776189251Ssam		bin/mkdir		\
777189251Ssam		bin/mv			\
778189251Ssam		bin/rm			\
779189251Ssam		bin/test		\
780214734Srpaulo		${_caesar}		\
781214734Srpaulo		${_strfile}		\
782189251Ssam		gnu/usr.bin/awk		\
783189251Ssam		gnu/usr.bin/bc		\
784189251Ssam		gnu/usr.bin/grep	\
785189251Ssam		gnu/usr.bin/groff	\
786189251Ssam		gnu/usr.bin/gzip	\
787189251Ssam		gnu/usr.bin/man/makewhatis	\
788189251Ssam		gnu/usr.bin/patch	\
789189251Ssam		${_perl}		\
790189251Ssam		gnu/usr.bin/sort	\
791189251Ssam		gnu/usr.bin/texinfo	\
792189251Ssam		usr.bin/basename	\
793189251Ssam		usr.bin/cap_mkdb	\
794189251Ssam		usr.bin/chflags		\
795189251Ssam		usr.bin/cmp		\
796189251Ssam		usr.bin/col		\
797189251Ssam		usr.bin/colldef		\
798189251Ssam		usr.bin/cpp		\
799189251Ssam		usr.bin/expand		\
800189251Ssam		usr.bin/file2c		\
801189251Ssam		usr.bin/find		\
802189251Ssam		usr.bin/gencat		\
803189251Ssam		usr.bin/id		\
804189251Ssam		usr.bin/join		\
805189251Ssam		usr.bin/lorder		\
806189251Ssam		usr.bin/m4		\
807189251Ssam		usr.bin/mkdep		\
808189251Ssam		usr.bin/mklocale	\
809189251Ssam		usr.bin/paste		\
810189251Ssam		usr.bin/printf		\
811189251Ssam		usr.bin/sed		\
812189251Ssam		${_aout_size}		\
813189251Ssam		usr.bin/soelim		\
814189251Ssam		usr.bin/symorder	\
815189251Ssam		usr.bin/touch		\
816189251Ssam		usr.bin/tr		\
817189251Ssam		usr.bin/true		\
818189251Ssam		usr.bin/uname		\
819189251Ssam		usr.bin/uuencode	\
820214734Srpaulo		usr.bin/vgrind		\
821214734Srpaulo		usr.bin/vi		\
822189251Ssam		usr.bin/wc		\
823189251Ssam		usr.bin/xargs		\
824189251Ssam		usr.bin/yacc		\
825189251Ssam		usr.sbin/chown		\
826189251Ssam		usr.sbin/mtree		\
827189251Ssam		usr.sbin/zic		\
828189251Ssam		bin/sh
829189251Ssam	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} ${_DEPEND}; \
830189251Ssam		${MAKE} ${BTMAKEFLAGS} all; \
831189251Ssam		${MAKE} ${BTMAKEFLAGS} -B install ${CLEANDIR} ${OBJDIR}
832189251Ssam.endfor
833189251Ssam.if !defined(NOGAMES) && exists(${.CURDIR}/games)
834189251Ssam	cd ${DESTDIR}/usr/games; cp -p caesar strfile ${DESTDIR}/usr/bin
835189251Ssam.endif
836189251Ssam.for d in				\
837189251Ssam		bin/sh			\
838189251Ssam		${_adventure}		\
839189251Ssam		${_hack}		\
840189251Ssam		${_phantasia}		\
841189251Ssam		gnu/usr.bin/cc/cc_tools	\
842189251Ssam		lib/libmytinfo		\
843252726Srpaulo		${_linux}		\
844189251Ssam		${_scrnmaps}		\
845189251Ssam		${_netboot}
846189251Ssam	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} build-tools
847189251Ssam.endfor
848189251Ssam	cd ${.CURDIR}/usr.bin/tn3270/tools; ${MAKE} ${BTMAKEFLAGS} all
849189251Ssam
850189251Ssam#
851189251Ssam# Build aout versions of things that provide legacy support when all the
852189251Ssam# rest of the world is elf.
853189251Ssam#
854189251Ssamlegacy-build:
855189251Ssam.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
856189251Ssam	@echo
857189251Ssam	@echo "--------------------------------------------------------------"
858189251Ssam	@echo ">>> Making hierarchy"
859189251Ssam	@echo "--------------------------------------------------------------"
860189251Ssam	mkdir -p ${WORLDTMP}
861189251Ssam	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 hierarchy
862189251Ssam	@echo
863189251Ssam	@echo "--------------------------------------------------------------"
864189251Ssam	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
865189251Ssam	@echo "--------------------------------------------------------------"
866189251Ssam	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-${OBJDIR}
867189251Ssam	@echo
868189251Ssam	@echo "--------------------------------------------------------------"
869189251Ssam	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
870189251Ssam	@echo "--------------------------------------------------------------"
871189251Ssam	cd ${.CURDIR}; SHARED=copies ${XMAKE} -f Makefile.inc1 includes
872189251Ssam	@echo
873189251Ssam	@echo "--------------------------------------------------------------"
874189251Ssam	@echo ">>> Building legacy libraries"
875189251Ssam	@echo "--------------------------------------------------------------"
876189251Ssam	cd ${.CURDIR}; \
877189251Ssam		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 bootstrap-libraries
878189251Ssam	cd ${.CURDIR}; \
879189251Ssam		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
880189251Ssam	@echo
881189251Ssam	@echo "--------------------------------------------------------------"
882189251Ssam	@echo ">>> Building legacy rtld"
883189251Ssam	@echo "--------------------------------------------------------------"
884189251Ssam	cd ${.CURDIR}/libexec/rtld-aout; \
885189251Ssam		${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
886189251Ssam	@echo
887189251Ssam	@echo "--------------------------------------------------------------"
888189251Ssam	@echo ">>> Building legacy lkms"
889189251Ssam	@echo "--------------------------------------------------------------"
890189251Ssam	cd ${.CURDIR}/lkm; \
891189251Ssam		${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
892189251Ssam	@echo
893189251Ssam	@echo "--------------------------------------------------------------"
894189251Ssam	@echo ">>> Building legacy boot"
895189251Ssam	@echo "--------------------------------------------------------------"
896189251Ssam	cd ${.CURDIR}/sys/boot && ${XMAKE} -DNOMAN -B obj depend; \
897189251Ssam		${XMAKE} -DNOMAN all
898189251Ssam	cd ${.CURDIR}/sys/${MACHINE}/boot && \
899189251Ssam		${XMAKE} -DNOMAN -B obj depend; ${XMAKE} -DNOMAN OBJFORMAT=elf all;
900252726Srpaulo.endif
901252726Srpaulo
902189251Ssam#
903189251Ssam# Install aout versions of things that provide legacy support when all the
904189251Ssam# rest of the world is elf.
905189251Ssam#
906189251Ssamlegacy-install:
907189251Ssam.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
908189251Ssam	@echo
909189251Ssam	@echo "--------------------------------------------------------------"
910189251Ssam	@echo ">>> Installing legacy libraries"
911189251Ssam	@echo "--------------------------------------------------------------"
912189251Ssam	cd ${.CURDIR}/lib; ${MAKE} -B -DNOMAN -DNOINFO install
913189251Ssam	cd ${.CURDIR}/gnu/lib; ${MAKE} -B -DNOMAN -DNOINFO install
914189251Ssam	cd ${.CURDIR}/gnu/usr.bin/cc/libgcc; \
915189251Ssam		${MAKE} -B -DNOMAN -DNOINFO install
916189251Ssam	cd ${.CURDIR}/usr.bin/lex/lib; \
917189251Ssam		${MAKE} -B -DNOMAN -DNOINFO install
918189251Ssam	cd ${.CURDIR}/usr.sbin/pcvt/keycap; \
919189251Ssam		${MAKE} -B -DNOMAN -DNOINFO install
920189251Ssam.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
921189251Ssam	cd ${.CURDIR}/secure/lib; ${MAKE} -B -DNOMAN -DNOINFO install
922189251Ssam.endif
923189251Ssam.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
924189251Ssam    defined(MAKE_KERBEROS4)
925189251Ssam	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} -B -DNOMAN -DNOINFO install
926189251Ssam.endif
927189251Ssam	@echo
928189251Ssam	@echo "--------------------------------------------------------------"
929189251Ssam	@echo ">>> Installing legacy rtld"
930189251Ssam	@echo "--------------------------------------------------------------"
931189251Ssam	cd ${.CURDIR}/libexec/rtld-aout; ${MAKE} -DNOMAN install
932189251Ssam	@echo
933189251Ssam	@echo "--------------------------------------------------------------"
934189251Ssam	@echo ">>> Installing legacy lkms"
935189251Ssam	@echo "--------------------------------------------------------------"
936189251Ssam	cd ${.CURDIR}/lkm; ${MAKE} -DNOMAN install
937189251Ssam	@echo
938189251Ssam	@echo "--------------------------------------------------------------"
939189251Ssam	@echo ">>> Installing legacy boot"
940189251Ssam	@echo "--------------------------------------------------------------"
941189251Ssam	cd ${.CURDIR}/sys/boot && ${MAKE} -DNOMAN install
942189251Ssam	cd ${.CURDIR}/sys/${MACHINE}/boot && ${MAKE} -DNOMAN install
943189251Ssam.endif
944189251Ssam
945189251Ssam
946189251Ssam# Get the object format that the tools see.
947189251Ssam#
948189251Ssam#
949189251Ssam.if exists(/usr/bin/objformat)
950189251Ssam__OBJFORMAT!=	objformat
951189251Ssam.else
952189251Ssam__OBJFORMAT=	${OBJFORMAT}
953189251Ssam.endif
954189251Ssam
955189251Ssam#
956189251Ssam# Check if the local /etc/make.conf or /etc/make.conf.local have attempted
957189251Ssam# to override the OBJFORMAT without updating the environment for the tools
958189251Ssam# to see.
959189251Ssam#
960189251Ssamcheck-objformat	:
961189251Ssam.if	${__OBJFORMAT} != ${OBJFORMAT}
962189251Ssam	@/bin/sh -c "echo \"It looks like you set OBJFORMAT=${OBJFORMAT} in /etc/make.conf. Don't do that!\" "
963189251Ssam	@/bin/sh -c "echo \"If you want to override the installed object format, you must set OBJFORMAT\" "
964189251Ssam	@/bin/sh -c "echo \"in your environment.\" "
965189251Ssam	@exit 1
966189251Ssam.endif
967189251Ssam
968189251Ssam
969189251Ssam.for __target in clean cleandepend cleandir depend obj
970189251Ssam.for entry in ${SUBDIR}
971189251Ssam${entry}.${__target}__D: .PHONY
972189251Ssam	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
973189251Ssam		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
974189251Ssam		edir=${entry}.${MACHINE_ARCH}; \
975189251Ssam		cd ${.CURDIR}/$${edir}; \
976189251Ssam	else \
977189251Ssam		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
978189251Ssam		edir=${entry}; \
979189251Ssam		cd ${.CURDIR}/$${edir}; \
980189251Ssam	fi; \
981189251Ssam	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
982189251Ssam.endfor
983189251Ssampar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
984189251Ssam.endfor
985189251Ssam
986189251Ssam.include <bsd.subdir.mk>
987189251Ssam