Makefile.inc1 revision 43094
1207536Smav#
2207536Smav#	$Id: Makefile.inc1,v 1.59 1999/01/20 05:45:57 markm Exp $
3207536Smav#
4207536Smav# Make command line options:
5207536Smav#	-DCLOBBER will remove /usr/include
6207536Smav#	-DMAKE_KERBEROS4 to build KerberosIV
7207536Smav#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8207536Smav#	-DNOCLEAN do not clean at all
9207536Smav#	-DNOTOOLS do not rebuild any tools first
10207536Smav#	-DNOCRYPT will prevent building of crypt versions
11207536Smav#	-DNOPROFILE do not build profiled libraries
12207536Smav#	-DNOSECURE do not go into secure subdir
13207536Smav#	-DNOGAMES do not go into games subdir
14207536Smav#	-DNOSHARE do not go into share subdir
15207536Smav#	-DNOINFO do not make or install info files
16207536Smav#	-DNOLIBC_R do not build libc_r.
17207536Smav#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
18207536Smav
19207536Smav#
20207536Smav# The intended user-driven targets are:
21207536Smav# buildworld  - rebuild *everything*, including glue to help do upgrades
22207536Smav# installworld- install everything built by "buildworld"
23207536Smav# update      - convenient way to update your source tree (eg: sup/cvs)
24207536Smav# most        - build user commands, no libraries or include files
25207536Smav# installmost - install user commands, no libraries or include files
26207536Smav#
27207536Smav# Standard targets (not defined here) are documented in the makefiles in
28207536Smav# /usr/share/mk.  These include:
29207536Smav#		obj depend all install clean cleandepend cleanobj
30207536Smav
31207536Smav# Put initial settings here.
32207536SmavSUBDIR=
33207536Smav
34207536Smav# We must do share/info early so that installation of info `dir'
35207536Smav# entries works correctly.  Do it first since it is less likely to
36220615Smav# grow dependencies on include and lib than vice versa.
37207536Smav.if exists(share/info)
38207536SmavSUBDIR+= share/info
39207536Smav.endif
40207536Smav
41207536Smav# We must do include and lib early so that the perl *.ph generation
42207536Smav# works correctly as it uses the header files installed by this.
43207536Smav.if exists(include)
44207536SmavSUBDIR+= include
45207536Smav.endif
46210471Smav.if exists(lib)
47207536SmavSUBDIR+= lib
48207536Smav.endif
49207536Smav
50207536Smav.if exists(bin)
51207536SmavSUBDIR+= bin
52207536Smav.endif
53207536Smav.if exists(games) && !defined(NOGAMES)
54207536SmavSUBDIR+= games
55207536Smav.endif
56208393Smav.if exists(gnu)
57208393SmavSUBDIR+= gnu
58207536Smav.endif
59207536Smav.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
60207536Smav    defined(MAKE_KERBEROS4)
61214099SmavSUBDIR+= kerberosIV
62214099Smav.endif
63207536Smav.if exists(libexec)
64207536SmavSUBDIR+= libexec
65207536Smav.endif
66207536Smav.if exists(sbin)
67207536SmavSUBDIR+= sbin
68207536Smav.endif
69207536Smav.if exists(share) && !defined(NOSHARE)
70207536SmavSUBDIR+= share
71207536Smav.endif
72207536Smav.if exists(sys)
73207536SmavSUBDIR+= sys
74207536Smav.endif
75207536Smav.if exists(usr.bin)
76207536SmavSUBDIR+= usr.bin
77207536Smav.endif
78207536Smav.if exists(usr.sbin)
79220615SmavSUBDIR+= usr.sbin
80207536Smav.endif
81207536Smav.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
82207536SmavSUBDIR+= secure
83207536Smav.endif
84214099Smav
85214099Smav# etc must be last for "distribute" to work
86207536Smav.if exists(etc)
87207536SmavSUBDIR+= etc
88207536Smav.endif
89207536Smav
90220569Smav# These are last, since it is nice to at least get the base system
91207536Smav# rebuilt before you do them.
92220569Smav.if defined(LOCAL_DIRS)
93207536Smav.for _DIR in ${LOCAL_DIRS}
94207536Smav.if exists(${_DIR}) & exists(${_DIR}/Makefile)
95207536SmavSUBDIR+= ${_DIR}
96207536Smav.endif
97207536Smav.endfor
98207536Smav.endif
99220569Smav
100220569SmavOBJDIR=		obj
101220569Smav
102220569Smav.if defined(NOCLEAN)
103220569SmavCLEANDIR=
104220569Smav.else
105207536Smav.if defined(NOCLEANDIR)
106207536SmavCLEANDIR=	clean cleandepend
107207536Smav.else
108207536SmavCLEANDIR=	cleandir
109207536Smav.endif
110207536Smav.endif
111207536Smav
112207536Smav.if !defined(NOCLEAN)
113207536Smav_NODEPEND=	true
114207536Smav.endif
115207536Smav.if defined(_NODEPEND)
116207536Smav_DEPEND=	cleandepend
117207536Smav.else
118207536Smav_DEPEND=	depend
119207536Smav.endif
120207536Smav
121207536SmavSUP?=		cvsup
122207536SmavSUPFLAGS?=	-g -L 2 -P -
123207536Smav
124207536Smav#
125207536Smav# While building tools for bootstrapping, we don't need to waste time on
126207536Smav# shared or profiled libraries, shared linkage, or documentation, except
127207536Smav# when the tools won't get cleaned we must use the defaults for shared
128207536Smav# libraries and shared linkage (and this doesn't waste time).
129220615Smav# XXX actually, we do need to waste time building shared libraries.
130207536Smav#
131207536Smav.if defined(NOCLEAN)
132207536SmavMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
133207536Smav.else
134207536SmavMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
135207536Smav.endif
136207536Smav
137207536Smav#
138207536Smav# Define the location of the temporary installation directory. Note that
139207536Smav# MAKEOBJDIRPREFIX normally isn't defined so if the current directory is
140207536Smav# /usr/src, then the world temporary directory is /usr/obj/usr/src/tmp.
141207536Smav#
142207536Smav# During the transition from aout to elf format on i386, MAKEOBJDIRPREFIX
143220602Smav# is set by the parent makefile (Makefile.inc0) to be /usr/obj/${OBJFORMAT}
144207536Smav# in order to keep aout and elf format files apart.
145207536Smav#
146207536Smav.if defined(MAKEOBJDIRPREFIX)
147207536SmavWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
148207536Smav.else
149207536SmavWORLDTMP=	/usr/obj${.CURDIR}/tmp
150207536Smav.endif
151208393Smav
152207536Smav#
153207536Smav# Define the PATH to the build tools.
154207536Smav#
155207536Smav# If not building tools, the PATH always points to the installed binaries.
156207536Smav# The NOTOOLS option assumes that in installed tools are good enough and that
157207536Smav# the user's PATH will locate to appropriate tools. This option is required
158207536Smav# for a cross-compiled build environment.
159207536Smav#
160207536Smav# If building tools, then the PATH includes the world temporary directories
161207536Smav# so that the bootstrapped tools are used as soon as they are built. The
162207536Smav# strict path is for use after all tools are supposed to have been
163207536Smav# bootstrapped. It doesn't allow any of the installed tools to be used.
164207536Smav#
165207536Smav.if	defined(NOTOOLS)
166207536Smav# Default root of the tool tree
167207536SmavTOOLROOT?=	
168207536Smav# Choose the PATH relative to the root of the tool tree
169207536SmavPATH=		${TOOLROOT}/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/sbin:${TOOLROOT}/usr/bin
170207536Smav.else
171207536SmavTOOLROOT=	${WORLDTMP}
172207536Smav.endif
173207536SmavSTRICTTMPPATH=	${TOOLROOT}/sbin:${TOOLROOT}/usr/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/bin
174207536SmavTMPPATH=	${STRICTTMPPATH}:${PATH}
175207536Smav
176207536Smav# XXX COMPILER_PATH is needed for finding cc1, ld and as
177207536Smav# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecessary now
178207536Smav#	that LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
179207536Smav#	wouldn't link *crt.o or libgcc if it were used.
180207536Smav# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
181207536Smav#	want that - all compile-time library paths should be resolved by gcc.
182207536Smav#	It fails for set[ug]id executables (are any used?).
183207536SmavCOMPILER_ENV=	BISON_SIMPLE=${TOOLROOT}/usr/share/misc/bison.simple \
184207536Smav		COMPILER_PATH=${TOOLROOT}/usr/libexec:${TOOLROOT}/usr/bin \
185207536Smav		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
186207536Smav		LD_LIBRARY_PATH=${TOOLROOT}${SHLIBDIR} \
187207536Smav		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
188207536Smav
189207536SmavBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t \
190207536Smav		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec:/usr/libexec
191207536SmavXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
192207536Smav		PERL5LIB=${DESTDIR}/usr/libdata/perl/5.00502 \
193207536Smav		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec \
194207536Smav		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
195207536Smav
196207536Smav# used to compile and install 'make' in temporary build tree
197207536SmavMAKETMP=	${WORLDTMP}/make
198207536SmavIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
199207536Smav
200207536Smav.if	defined(NOTOOLS)
201207536Smav# bootstrap make
202207536SmavBMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
203207536Smav# cross make used for compilation
204207536SmavXMAKE=	${XMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
205207536Smav# cross make used for final installation
206207536SmavIXMAKE=	${XMAKEENV} ${MAKE}
207207536Smav.else
208207536Smav# bootstrap make
209207536SmavBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
210207536Smav# cross make used for compilation
211207536SmavXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
212207536Smav# cross make used for final installation
213207536SmavIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
214207536Smav.endif
215207536Smav
216207536Smav#
217207536Smav# buildworld
218207536Smav#
219207536Smav# Attempt to rebuild the entire system, with reasonable chance of
220207536Smav# success, regardless of how old your existing system is.
221207536Smav#
222207536Smavbuildworld: check-objformat
223220615Smav.if !defined(NOCLEAN)
224220615Smav	@echo
225220615Smav	@echo "--------------------------------------------------------------"
226220615Smav	@echo ">>> Cleaning up the temporary ${OBJFORMAT} build tree"
227220615Smav	@echo "--------------------------------------------------------------"
228207536Smav	mkdir -p ${WORLDTMP}
229207536Smav	chflags -R noschg ${WORLDTMP}/
230207536Smav	rm -rf ${WORLDTMP}
231207536Smav.endif
232207536Smav.if !defined(NOTOOLS)
233207536Smav	@echo
234207536Smav	@echo "--------------------------------------------------------------"
235220615Smav	@echo ">>> Making make"
236207536Smav	@echo "--------------------------------------------------------------"
237207536Smav	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
238207536Smav	( \
239208393Smav	cd ${.CURDIR}/usr.bin/make; \
240207536Smav		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
241207536Smav		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
242207536Smav		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
243207536Smav		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
244207536Smav	)
245207536Smav	@echo
246207536Smav	@echo "--------------------------------------------------------------"
247207536Smav	@echo ">>> Making mtree"
248207536Smav	@echo "--------------------------------------------------------------"
249208393Smav	mkdir -p ${WORLDTMP}/usr/sbin ${WORLDTMP}/mtree
250207536Smav	( \
251207536Smav	cd ${.CURDIR}/usr.sbin/mtree; \
252207536Smav		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
253207536Smav		export MAKEOBJDIR=${WORLDTMP}/mtree; \
254207536Smav		${BMAKE} ${MK_FLAGS} all; \
255207536Smav		${BMAKE} ${MK_FLAGS} -B install clean \
256207536Smav	)
257207536Smav.endif
258207536Smav	@echo
259207536Smav	@echo "--------------------------------------------------------------"
260207536Smav	@echo ">>> Making hierarchy"
261207536Smav	@echo "--------------------------------------------------------------"
262207536Smav	mkdir -p ${WORLDTMP}
263207536Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 hierarchy
264207536Smav.if !defined(NOCLEAN)
265207536Smav	@echo
266207536Smav	@echo "--------------------------------------------------------------"
267207536Smav	@echo ">>> Cleaning up the ${OBJFORMAT} obj tree"
268207536Smav	@echo "--------------------------------------------------------------"
269207536Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
270207536Smav.endif
271207536Smav	@echo
272207536Smav	@echo "--------------------------------------------------------------"
273207536Smav	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
274207536Smav	@echo "--------------------------------------------------------------"
275207536Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 par-${OBJDIR}
276208393Smav.if !defined(NOTOOLS)
277208393Smav	@echo
278208393Smav	@echo "--------------------------------------------------------------"
279208393Smav	@echo ">>> Rebuilding ${OBJFORMAT} bootstrap tools"
280208393Smav	@echo "--------------------------------------------------------------"
281208393Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap
282208393Smav	@echo
283208393Smav	@echo "--------------------------------------------------------------"
284208393Smav	@echo ">>> Rebuilding tools necessary to build the include files"
285208393Smav	@echo "--------------------------------------------------------------"
286208393Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 include-tools
287208393Smav.endif
288208393Smav	@echo
289208393Smav	@echo "--------------------------------------------------------------"
290208393Smav	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
291208393Smav	@echo "--------------------------------------------------------------"
292208393Smav	cd ${.CURDIR}; SHARED=copies ${BMAKE} -f Makefile.inc1 includes
293208393Smav	@echo
294208393Smav	@echo "--------------------------------------------------------------"
295208393Smav	@echo ">>> Rebuilding bootstrap libraries"
296208393Smav	@echo "--------------------------------------------------------------"
297220615Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap-libraries
298220615Smav.if !defined(NOTOOLS)
299220615Smav	@echo
300220615Smav	@echo "--------------------------------------------------------------"
301220615Smav	@echo ">>> Rebuilding tools needed to build libraries"
302220615Smav	@echo "--------------------------------------------------------------"
303208393Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 lib-tools
304208393Smav.endif
305208393Smav.if !defined(NOTOOLS)
306208393Smav	@echo
307208393Smav	@echo "--------------------------------------------------------------"
308208393Smav	@echo ">>> Rebuilding all other tools needed to build the ${OBJFORMAT} world"
309208393Smav	@echo "--------------------------------------------------------------"
310208393Smav	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 build-tools
311208393Smav.endif
312208393Smav.if !defined(_NODEPEND)
313208393Smav	@echo
314208393Smav	@echo "--------------------------------------------------------------"
315208393Smav	@echo ">>> Rebuilding dependencies"
316208393Smav	@echo "--------------------------------------------------------------"
317208393Smav	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-depend
318208393Smav.endif
319208393Smav	@echo
320208393Smav	@echo "--------------------------------------------------------------"
321207536Smav	@echo ">>> Building ${OBJFORMAT} libraries"
322207536Smav	@echo "--------------------------------------------------------------"
323207536Smav	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
324207536Smav	@echo
325207536Smav	@echo "--------------------------------------------------------------"
326207536Smav	@echo ">>> Building everything.."
327207536Smav	@echo "--------------------------------------------------------------"
328207536Smav	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
329207536Smav
330207536Smaveverything:
331207536Smav	@echo "--------------------------------------------------------------"
332207536Smav	@echo ">>> Building everything.."
333207536Smav	@echo "--------------------------------------------------------------"
334207536Smav	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
335207536Smav
336207536Smav#
337207536Smav# installworld
338207536Smav#
339207536Smav# Installs everything compiled by a 'buildworld'.
340207536Smav#
341214099Smavinstallworld:
342214099Smav	cd ${.CURDIR}; ${IXMAKE} -f Makefile.inc1 reinstall
343214099Smav
344214099Smav#
345214099Smav# reinstall
346207536Smav#
347207536Smav# If you have a build server, you can NFS mount the source and obj directories
348207536Smav# and do a 'make reinstall' on the *client* to install new binaries from the
349207536Smav# most recent server build.
350207536Smav#
351207536Smavreinstall:
352207536Smav	@echo "--------------------------------------------------------------"
353207536Smav	@echo ">>> Making hierarchy"
354207536Smav	@echo "--------------------------------------------------------------"
355207536Smav	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
356207536Smav	@echo
357207536Smav	@echo "--------------------------------------------------------------"
358214099Smav	@echo ">>> Installing everything.."
359214099Smav	@echo "--------------------------------------------------------------"
360214099Smav	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
361214099Smav.if ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout" && !defined(DESTDIR)
362214099Smav	@echo
363207536Smav	@echo "--------------------------------------------------------------"
364207536Smav	@echo ">>> Re-scanning the shared libraries.."
365207536Smav	@echo "--------------------------------------------------------------"
366207536Smav	cd ${.CURDIR}; /sbin/ldconfig -R
367207536Smav.endif
368207536Smav	@echo
369207536Smav	@echo "--------------------------------------------------------------"
370207536Smav	@echo ">>> Rebuilding man page indexes"
371207536Smav	@echo "--------------------------------------------------------------"
372207536Smav	cd ${.CURDIR}/share/man; ${MAKE} makedb
373207536Smav
374207536Smav#
375207536Smav# update
376207536Smav#
377207536Smav# Update the source tree, by running sup and/or running cvs to update to the
378207536Smav# latest copy.
379207536Smav#
380207536Smavupdate:
381207536Smav.if defined(SUP_UPDATE)
382207536Smav	@echo "--------------------------------------------------------------"
383207536Smav	@echo ">>> Running ${SUP}"
384207536Smav	@echo "--------------------------------------------------------------"
385207536Smav	@${SUP} ${SUPFLAGS} ${SUPFILE}
386207536Smav.if defined(SUPFILE1)
387207536Smav	@${SUP} ${SUPFLAGS} ${SUPFILE1}
388207536Smav.endif
389207536Smav.if defined(SUPFILE2)
390207536Smav	@${SUP} ${SUPFLAGS} ${SUPFILE2}
391207536Smav.endif
392207536Smav.endif
393207536Smav.if defined(CVS_UPDATE)
394207536Smav	@echo "--------------------------------------------------------------"
395207536Smav	@echo ">>> Updating /usr/src from cvs repository" ${CVSROOT}
396207536Smav	@echo "--------------------------------------------------------------"
397207536Smav	cd ${.CURDIR}; cvs -q update -P -d
398207536Smav.endif
399207536Smav
400207536Smav#
401207536Smav# most
402214099Smav#
403214099Smav# Build most of the user binaries on the existing system libs and includes.
404207536Smav#
405207536Smavmost:
406207536Smav	@echo "--------------------------------------------------------------"
407207536Smav	@echo ">>> Building programs only"
408207536Smav	@echo "--------------------------------------------------------------"
409207536Smav	cd ${.CURDIR}/bin;		${MAKE} all
410207536Smav	cd ${.CURDIR}/sbin;		${MAKE} all
411207536Smav	cd ${.CURDIR}/libexec;		${MAKE} all
412207536Smav	cd ${.CURDIR}/usr.bin;		${MAKE} all
413207536Smav	cd ${.CURDIR}/usr.sbin;		${MAKE} all
414214099Smav	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
415214099Smav	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
416207536Smav	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
417207536Smav#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
418207536Smav#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
419207536Smav#.endif
420207536Smav#.if !defined(NOSECURE) && !defined(NOCRYPT)
421207536Smav#	cd ${.CURDIR}/secure;		${MAKE} most
422207536Smav#.endif
423207536Smav
424207536Smav#
425207536Smav# installmost
426207536Smav#
427207536Smav# Install the binaries built by the 'most' target.  This does not include
428207536Smav# libraries or include files.
429207536Smav#
430207536Smavinstallmost:
431207536Smav	@echo "--------------------------------------------------------------"
432207536Smav	@echo ">>> Installing programs only"
433207536Smav	@echo "--------------------------------------------------------------"
434207536Smav	cd ${.CURDIR}/bin;		${MAKE} install
435207536Smav	cd ${.CURDIR}/sbin;		${MAKE} install
436207536Smav	cd ${.CURDIR}/libexec;		${MAKE} install
437207536Smav	cd ${.CURDIR}/usr.bin;		${MAKE} install
438207536Smav	cd ${.CURDIR}/usr.sbin;		${MAKE} install
439207536Smav	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
440207536Smav	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
441207536Smav	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
442207536Smav#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
443207536Smav#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
444207536Smav#.endif
445207536Smav#.if !defined(NOSECURE) && !defined(NOCRYPT)
446207536Smav#	cd ${.CURDIR}/secure;		${MAKE} installmost
447207536Smav#.endif
448207536Smav
449207536Smav#
450207536Smav# ------------------------------------------------------------------------
451207536Smav#
452207536Smav# From here onwards are utility targets used by the 'make world' and
453207536Smav# related targets.  If your 'world' breaks, you may like to try to fix
454207536Smav# the problem and manually run the following targets to attempt to
455207536Smav# complete the build.  Beware, this is *not* guaranteed to work, you
456207536Smav# need to have a pretty good grip on the current state of the system
457207536Smav# to attempt to manually finish it.  If in doubt, 'make world' again.
458207536Smav#
459207536Smav
460207536Smav#
461207536Smav# hierarchy - ensure that all the needed directories are present
462207536Smav#
463207536Smavhierarchy:
464207536Smav	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
465207536Smav
466207536Smav#
467207536Smav# bootstrap - [re]build tools needed to run the actual build, this includes
468207536Smav# tools needed by 'make depend', as some tools are needed to generate source
469207536Smav# for the dependency information to be gathered from.
470207536Smav#
471207536Smavbootstrap:
472207536Smav	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
473207536Smav		${MAKE} ${MK_FLAGS} all; \
474207536Smav		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
475207536Smav	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
476207536Smav		${MAKE} ${MK_FLAGS} all; \
477214099Smav		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
478214099Smav	cd ${.CURDIR}/usr.bin/yacc; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
479207536Smav		${MAKE} ${MK_FLAGS} all; \
480214102Smav		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
481207536Smav	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
482207536Smav		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
483207536Smav		${MAKE} ${MK_FLAGS} -DNOLIB all; \
484207536Smav		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
485214099Smav	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
486214099Smav	cd ${.CURDIR}/usr.sbin/mtree; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
487207536Smav		${MAKE} ${MK_FLAGS} all; \
488207536Smav		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
489207536Smav
490207536Smav#
491207536Smav# include-tools - generally the same as 'bootstrap', except that it's for
492207536Smav# things that are specifically needed to generate include files.
493207536Smav#
494207536Smav# XXX should be merged with bootstrap, it's not worth keeeping them separate.
495207536Smav# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
496207536Smav# on cleaned away headers in ${WORLDTMP}.
497207536Smav#
498207536Smavinclude-tools:
499207536Smav.for d in usr.bin/compile_et usr.bin/rpcgen
500207536Smav	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
501207536Smav		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
502207536Smav		${MAKE} ${MK_FLAGS} all; \
503207536Smav		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
504207536Smav.endfor
505207536Smav
506207536Smav#
507207536Smav# includes - possibly generate and install the include files.
508207536Smav#
509207536Smavincludes:
510207536Smav.if defined(CLOBBER)
511207536Smav	rm -rf ${DESTDIR}/usr/include/*
512207536Smav	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
513207536Smav		-p ${DESTDIR}/usr/include
514207536Smav.endif
515207536Smav	cd ${.CURDIR}/include;			${MAKE} -B all install
516207536Smav	cd ${.CURDIR}/gnu/include;		${MAKE} install
517207536Smav	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
518207536Smav	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
519207536Smav	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
520207536Smav	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
521207536Smav	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
522207536Smav	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
523207536Smav	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
524207536Smav	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
525207536Smav.if exists(secure) && !defined(NOCRYPT)
526207536Smav	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
527207536Smav.endif
528207536Smav.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
529207536Smav	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
530207536Smav	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
531207536Smav	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
532207536Smav	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
533207536Smav	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
534207536Smav	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
535207536Smav.else
536207536Smav	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
537207536Smav.endif
538207536Smav.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
539207536Smav	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
540207536Smav.endif
541207536Smav	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
542207536Smav	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
543207536Smav	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
544207536Smav	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
545207536Smav	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
546207536Smav	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
547207536Smav	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
548207536Smav	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
549207536Smav	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
550207536Smav	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
551207536Smav	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
552207536Smav	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
553207536Smav	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
554207536Smav.if !defined(WANT_CSRG_LIBM)
555207536Smav	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
556207536Smav.endif
557207536Smav	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
558207536Smav	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
559207536Smav	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
560207536Smav	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
561207536Smav	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
562207536Smav	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
563207536Smav	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
564207536Smav	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
565207536Smav	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
566207536Smav	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
567207536Smav	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
568207536Smav	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
569207536Smav	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
570207536Smav	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
571207536Smav	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
572207536Smav	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
573207536Smav
574207536Smav#
575207536Smav# Declare tools if they are not required on all architectures.
576207536Smav#
577207536Smav.if ${MACHINE_ARCH} == "i386"
578207536Smav# aout tools:
579207536Smav_aout_ar	= usr.bin/ar
580207536Smav_aout_as	= gnu/usr.bin/as
581207536Smav_aout_ld	= gnu/usr.bin/ld
582207536Smav_aout_nm	= usr.bin/nm
583207536Smav_aout_ranlib	= usr.bin/ranlib
584207536Smav_aout_size	= usr.bin/size
585207536Smav_aout_strip	= usr.bin/strip
586207536Smav# boot block/loader tools:
587207536Smav_btxld		= usr.sbin/btxld
588207536Smav.endif
589207536Smav
590207536Smav#
591207536Smav# lib-tools - build tools to compile and install the libraries.
592207536Smav#
593207536Smav# XXX gperf is required for cc
594207536Smav# XXX a new ld and tsort is required for cc
595207536Smavlib-tools:
596207536Smav.for d in				\
597207536Smav		gnu/usr.bin/gperf	\
598207536Smav		${_aout_ld}		\
599207536Smav		usr.bin/tsort		\
600207536Smav		${_aout_as}		\
601207536Smav		gnu/usr.bin/bison	\
602207536Smav		gnu/usr.bin/cc		\
603207536Smav		${_aout_ar}		\
604207536Smav		usr.bin/env		\
605207536Smav		usr.bin/lex/lib		\
606207536Smav		usr.bin/mk_cmds		\
607207536Smav		${_aout_nm}		\
608207536Smav		${_aout_ranlib}		\
609207536Smav		${_aout_strip}		\
610207536Smav		gnu/usr.bin/binutils	\
611207536Smav		usr.bin/uudecode	\
612207536Smav		usr.bin/objformat
613207536Smav	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
614207536Smav		${MAKE} ${MK_FLAGS} all; \
615207536Smav		${MAKE} ${MK_FLAGS} -B install; \
616207536Smav		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
617207536Smav.endfor
618207536Smav
619207536Smav#
620207536Smav# We have to know too much about ordering and subdirs in the lib trees:
621207536Smav#
622207536Smav# To satisfy shared library linkage when only the libraries being built
623207536Smav# are visible:
624207536Smav#
625207536Smav# csu must be built before all shared libaries for ELF.
626207536Smav# libcom_err must be built before libss.
627207536Smav# libcrypt must be built before libskey and libkrb.
628207536Smav# libdes must be built before libpam.
629207536Smav# libkrb must be built before libpam.
630207536Smav# libm must be built before libf2c, libg++ and libstdc++.
631207536Smav# libmd must be built before libatm, libopie, libradius, libskey,
632207536Smav# and libtacplus.
633207536Smav# libmytinfo must be built before libdialog and libncurses.
634207536Smav# libncurses must be built before libdialog.
635207536Smav# libradius must be built before libpam.
636207536Smav# libskey must be built before libpam.
637207536Smav# libtacplus must be built before libpam.
638207536Smav# libtermcap must be built before libcurses, libedit and libreadline.
639207536Smav#
640207536Smav# Some libraries are built conditionally and/or are in inconsistently
641207536Smav# named directories:
642207536Smav#
643207536Smav.if exists(lib/csu/${MACHINE_ARCH}.pcc)
644207536Smav_csu=lib/csu/${MACHINE_ARCH}.pcc
645207536Smav.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
646207536Smav_csu=lib/csu/i386-elf
647207536Smav.else
648207536Smav_csu=lib/csu/${MACHINE_ARCH}
649207536Smav.endif
650207536Smav
651207536Smav.if !defined(NOSECURE) && !defined(NOCRYPT)
652207536Smav_libcrypt=	secure/lib/libcrypt lib/libcrypt
653207536Smav_secure_lib=	secure/lib
654207536Smav.else
655207536Smav_libcrypt=	lib/libcrypt
656207536Smav.endif
657207536Smav
658207536Smav.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
659207536Smav_kerberosIV_lib=kerberosIV/lib
660207536Smav.endif
661207536Smav
662207536Smav.if defined(WANT_CSRG_LIBM)
663207536Smav_libm=	lib/libm
664207536Smav.else
665207536Smav_libm=	lib/msun
666207536Smav.endif
667207536Smav
668207536Smav.if !defined(NOPERL)
669207536Smav_libperl=		gnu/usr.bin/perl/libperl
670207536Smav.endif
671207536Smav
672207536Smav#
673207536Smav# bootstrap-libraries - build just enough libraries for the bootstrap
674207536Smav# tools, and install them under ${WORLDTMP}.
675207536Smav#
676207536Smav# Build csu and libgcc early so that some tools get linked to the new
677207536Smav# versions (too late for the main tools, however).  Then build the
678207536Smav# necessary prerequisite libraries (libtermcap just needs to be before
679207536Smav# libcurses, and this only matters for the NOCLEAN case when NOPIC is
680207536Smav# not set).
681207536Smav#
682207536Smav# This is mostly wrong.  The build tools must run on the host system,
683207536Smav# so they should use host libraries.  We depend on the target being
684207536Smav# similar enough to the host for new target libraries to work on the
685207536Smav# host.
686207536Smav#
687207536Smavbootstrap-libraries:
688207536Smav.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
689207536Smav    gnu/lib/libregex gnu/lib/libreadline lib/libc \
690207536Smav    lib/libcrypt lib/libcurses lib/libedit ${_libm} \
691207536Smav    lib/libmd lib/libutil lib/libz usr.bin/lex/lib \
692207536Smav    ${_libperl}
693207536Smav.if exists(${.CURDIR}/${_lib})
694207536Smav	cd ${.CURDIR}/${_lib}; \
695207536Smav		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
696207536Smav		${MAKE} ${MK_FLAGS} all; \
697207536Smav		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
698207536Smav.endif
699207536Smav.endfor
700207536Smav
701207536Smav#
702207536Smav# libraries - build all libraries, and install them under ${DESTDIR}.
703207536Smav#
704207536Smav# The ordering is not as special as for bootstrap-libraries.  Build
705207536Smav# the prerequisites first, then build almost everything else in
706207536Smav# alphabetical order.
707207536Smav#
708207536Smavlibraries:
709207536Smav.for _lib in ${_csu} lib/libcom_err ${_libcrypt} ${_libm} lib/libmd \
710207536Smav    lib/libmytinfo lib/libncurses lib/libtermcap \
711207536Smav    lib/libradius lib/libskey lib/libtacplus \
712207536Smav    ${_secure_lib} ${_kerberosIV_lib} \
713207536Smav    gnu/lib gnu/usr.bin/cc/libgcc ${_libperl} lib usr.bin/lex/lib \
714207536Smav    usr.sbin/pcvt/keycap
715207536Smav.if exists(${.CURDIR}/${_lib})
716207536Smav	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
717207536Smav.endif
718207536Smav.endfor
719207536Smav
720207536Smav#
721207536Smav# Exclude unused tools from build-tools.
722207536Smav#
723207536Smav.if !defined(NOGAMES) && exists(${.CURDIR}/games)
724207536Smav_adventure=	games/adventure
725207536Smav_caesar=	games/caesar
726207536Smav_hack=		games/hack
727207536Smav_phantasia=	games/phantasia
728207536Smav_strfile=	games/fortune/strfile
729207536Smav.endif
730207536Smav.if !defined(NOPERL)
731207536Smav_perl=		gnu/usr.bin/perl/miniperl
732207536Smav.endif
733207536Smav.if !defined(NOSHARE) && exists(${.CURDIR}/share)
734207536Smav_scrnmaps=	share/syscons/scrnmaps
735207536Smav.endif
736207536Smav.if ${MACHINE_ARCH} == i386
737207536Smav_kldlinux=	sys/modules/linux
738207536Smav.endif
739207536Smav.if ${OBJFORMAT} == "aout"
740207536Smav_netboot=	sys/${MACHINE}/boot/netboot
741207536Smav.endif
742207536Smav
743207536SmavBTMAKEFLAGS=	${MK_FLAGS} -D_BUILD_TOOLS
744207536Smav
745207536Smav#
746207536Smav# build-tools - build and install any other tools needed to complete the
747207536Smav# compile and install.
748207536Smav# ifdef stale
749207536Smav# bc and cpp are required to build groff.  Otherwise, the order here is
750207536Smav# mostly historical, i.e., bogus.
751207536Smav# chmod is used to build gcc's tmpmultilib[2] at obscure times.
752207536Smav# endif stale
753207536Smav# XXX uname is a bug - the target should not depend on the host.
754207536Smav#
755207536Smavbuild-tools:
756207536Smav.for d in				\
757207536Smav		bin/cat 		\
758207536Smav		bin/chmod		\
759207536Smav		bin/cp 			\
760207536Smav		bin/date		\
761207536Smav		bin/dd			\
762207536Smav		bin/echo		\
763207536Smav		bin/expr		\
764207536Smav		bin/hostname		\
765207536Smav		bin/ln			\
766207536Smav		bin/ls			\
767207536Smav		bin/mkdir		\
768207536Smav		bin/mv			\
769207536Smav		bin/rm			\
770207536Smav		bin/test		\
771207536Smav		${_caesar}		\
772207536Smav		${_strfile}		\
773207536Smav		gnu/usr.bin/awk		\
774207536Smav		gnu/usr.bin/bc		\
775207536Smav		gnu/usr.bin/grep	\
776207536Smav		gnu/usr.bin/groff	\
777207536Smav		gnu/usr.bin/gzip	\
778207536Smav		gnu/usr.bin/man/makewhatis	\
779207536Smav		gnu/usr.bin/patch	\
780207536Smav		${_perl}		\
781207536Smav		gnu/usr.bin/sort	\
782207536Smav		gnu/usr.bin/texinfo	\
783207536Smav		usr.bin/basename	\
784207536Smav		usr.bin/cap_mkdb	\
785207536Smav		usr.bin/chflags		\
786207536Smav		usr.bin/cmp		\
787207536Smav		usr.bin/col		\
788207536Smav		usr.bin/colldef		\
789207536Smav		usr.bin/cpp		\
790207536Smav		usr.bin/expand		\
791207536Smav		usr.bin/file2c		\
792207536Smav		usr.bin/find		\
793207536Smav		usr.bin/gencat		\
794207536Smav		usr.bin/gensetdefs	\
795207536Smav		usr.bin/id		\
796207536Smav		usr.bin/join		\
797207536Smav		usr.bin/lorder		\
798207536Smav		usr.bin/m4		\
799214099Smav		usr.bin/mkdep		\
800214099Smav		usr.bin/mklocale	\
801207536Smav		usr.bin/paste		\
802207536Smav		usr.bin/printf		\
803207536Smav		usr.bin/sed		\
804207536Smav		${_aout_size}		\
805207536Smav		usr.bin/soelim		\
806207536Smav		usr.bin/symorder	\
807207536Smav		usr.bin/touch		\
808207536Smav		usr.bin/tr		\
809207536Smav		usr.bin/true		\
810207536Smav		usr.bin/uname		\
811207536Smav		usr.bin/uuencode	\
812207536Smav		usr.bin/vgrind		\
813207536Smav		usr.bin/vi		\
814207536Smav		usr.bin/wc		\
815207536Smav		usr.bin/xargs		\
816207536Smav		usr.bin/yacc		\
817207536Smav		${_btxld}		\
818207536Smav		usr.sbin/chown		\
819207536Smav		usr.sbin/mtree		\
820207536Smav		usr.sbin/zic		\
821220615Smav		bin/sh
822207536Smav	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} ${_DEPEND}; \
823207536Smav		${MAKE} ${BTMAKEFLAGS} all; \
824207536Smav		${MAKE} ${BTMAKEFLAGS} -B install ${CLEANDIR} ${OBJDIR}
825207536Smav.endfor
826207536Smav.if !defined(NOGAMES) && exists(${.CURDIR}/games)
827207536Smav	cd ${DESTDIR}/usr/games; cp -p caesar strfile ${DESTDIR}/usr/bin
828207536Smav.endif
829207536Smav.for d in				\
830207536Smav		bin/sh			\
831207536Smav		${_adventure}		\
832207536Smav		${_hack}		\
833207536Smav		${_phantasia}		\
834207536Smav		gnu/usr.bin/cc/cc_tools	\
835207536Smav		lib/libmytinfo		\
836207536Smav		${_linux}		\
837207536Smav		${_kldlinux}		\
838207536Smav		${_scrnmaps}		\
839207536Smav		${_netboot}
840220615Smav	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} build-tools
841207536Smav.endfor
842207536Smav	cd ${.CURDIR}/usr.bin/tn3270/tools; ${MAKE} ${BTMAKEFLAGS} all
843207536Smav
844207536Smav#
845207536Smav# Build aout versions of things that provide legacy support when all the
846207536Smav# rest of the world is elf.
847220569Smav#
848220569Smavlegacy-build:
849207536Smav.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
850207536Smav	@echo
851207536Smav	@echo "--------------------------------------------------------------"
852207536Smav	@echo ">>> Making hierarchy"
853207536Smav	@echo "--------------------------------------------------------------"
854207536Smav	mkdir -p ${WORLDTMP}
855207536Smav	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 hierarchy
856207536Smav	@echo
857207536Smav	@echo "--------------------------------------------------------------"
858220615Smav	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
859220615Smav	@echo "--------------------------------------------------------------"
860207536Smav	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-${OBJDIR}
861207536Smav	@echo
862207536Smav	@echo "--------------------------------------------------------------"
863207536Smav	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
864207536Smav	@echo "--------------------------------------------------------------"
865207536Smav	cd ${.CURDIR}; SHARED=copies ${XMAKE} -f Makefile.inc1 includes
866207536Smav	@echo
867207536Smav	@echo "--------------------------------------------------------------"
868207536Smav	@echo ">>> Building legacy libraries"
869207536Smav	@echo "--------------------------------------------------------------"
870207536Smav	cd ${.CURDIR}; \
871207536Smav		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 bootstrap-libraries
872207536Smav	cd ${.CURDIR}; \
873207536Smav		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
874207536Smav	@echo
875207536Smav	@echo "--------------------------------------------------------------"
876207536Smav	@echo ">>> Building legacy rtld"
877207536Smav	@echo "--------------------------------------------------------------"
878207536Smav	cd ${.CURDIR}/libexec/rtld-aout; \
879207536Smav		${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
880207536Smav	@echo
881220602Smav	@echo "--------------------------------------------------------------"
882220602Smav	@echo ">>> Building legacy boot"
883207536Smav	@echo "--------------------------------------------------------------"
884207536Smav	cd ${.CURDIR}/sys/${MACHINE}/boot && \
885207536Smav		${XMAKE} -DNOMAN -B obj depend; ${XMAKE} -DNOMAN all;
886207536Smav.endif
887207536Smav
888207536Smav#
889207536Smav# Install aout versions of things that provide legacy support when all the
890207536Smav# rest of the world is elf.
891207536Smav#
892207536Smavlegacy-install:
893207536Smav.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
894207536Smav	@echo
895207536Smav	@echo "--------------------------------------------------------------"
896207536Smav	@echo ">>> Installing legacy libraries"
897207536Smav	@echo "--------------------------------------------------------------"
898207536Smav	cd ${.CURDIR}/lib; ${MAKE} -B -DNOMAN -DNOINFO install
899214099Smav	cd ${.CURDIR}/gnu/lib; ${MAKE} -B -DNOMAN -DNOINFO install
900214099Smav	cd ${.CURDIR}/gnu/usr.bin/cc/libgcc; \
901207536Smav		${MAKE} -B -DNOMAN -DNOINFO install
902220602Smav	cd ${.CURDIR}/usr.bin/lex/lib; \
903220602Smav		${MAKE} -B -DNOMAN -DNOINFO install
904207536Smav	cd ${.CURDIR}/usr.sbin/pcvt/keycap; \
905207536Smav		${MAKE} -B -DNOMAN -DNOINFO install
906207536Smav.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
907207536Smav	cd ${.CURDIR}/secure/lib; ${MAKE} -B -DNOMAN -DNOINFO install
908207536Smav.endif
909207536Smav.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
910207536Smav    defined(MAKE_KERBEROS4)
911207536Smav	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} -B -DNOMAN -DNOINFO install
912207536Smav.endif
913207536Smav	@echo
914207536Smav	@echo "--------------------------------------------------------------"
915207536Smav	@echo ">>> Installing legacy rtld"
916207536Smav	@echo "--------------------------------------------------------------"
917207536Smav	cd ${.CURDIR}/libexec/rtld-aout; ${MAKE} -DNOMAN install
918207536Smav	@echo
919207536Smav.if ${MACHINE_ARCH} != "alpha"
920207536Smav	@echo "--------------------------------------------------------------"
921207536Smav	@echo ">>> Installing legacy boot"
922207536Smav	@echo "--------------------------------------------------------------"
923207536Smav	cd ${.CURDIR}/sys/${MACHINE}/boot && ${MAKE} -DNOMAN install
924207536Smav.endif
925214099Smav.endif
926214099Smav
927220569Smav
928207536Smav# Get the object format that the tools see.
929207536Smav#
930207536Smav#
931207536Smav.if exists(/usr/bin/objformat)
932207536Smav__OBJFORMAT!=	objformat
933214099Smav.else
934207536Smav__OBJFORMAT=	${OBJFORMAT}
935207536Smav.endif
936207536Smav
937207536Smav#
938207536Smav# Check if the local /etc/make.conf or /etc/make.conf.local have attempted
939207536Smav# to override the OBJFORMAT without updating the environment for the tools
940207536Smav# to see.
941207536Smav#
942207536Smavcheck-objformat	:
943207536Smav.if	${__OBJFORMAT} != ${OBJFORMAT}
944207536Smav	@/bin/sh -c "echo \"It looks like you set OBJFORMAT=${OBJFORMAT} in /etc/make.conf. Don't do that!\" "
945207536Smav	@/bin/sh -c "echo \"If you want to override the installed object format, you must set OBJFORMAT\" "
946220569Smav	@/bin/sh -c "echo \"in your environment.\" "
947220569Smav	@exit 1
948220569Smav.endif
949220569Smav.if	!defined(REALLY_WANT_DEPRECIATED_AOUT) && ${OBJFORMAT} == "aout"
950207536Smav	@echo "==== NOTICE: a.out buildworld is depreciated and disabled! ====="
951207536Smav	@echo "Read: http://www.freebsd.org/~peter/elfday.html for information."
952207536Smav	@echo "You need to complete a 'make aout-to-elf' to bring your system"
953207536Smav	@echo "up to date with ELF tools.  This requires a fair amount of disk"
954207536Smav	@echo "space to complete.  Alternatively, you can do a binary upgrade"
955207536Smav	@echo "using the 3.0-RELEASE binaries from CD or ftp.freebsd.org in"
956207536Smav	@echo "/pub/FreeBSD/3.0-RELEASE/bin/ to convert your userland to ELF."
957207536Smav	@exit 1
958207536Smav.endif
959207536Smav
960207536Smav
961207536Smav.for __target in clean cleandepend cleandir depend obj
962207536Smav.for entry in ${SUBDIR}
963220569Smav${entry}.${__target}__D: .PHONY
964220569Smav	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
965220569Smav		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
966220569Smav		edir=${entry}.${MACHINE_ARCH}; \
967220569Smav		cd ${.CURDIR}/$${edir}; \
968220569Smav	else \
969220569Smav		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
970220569Smav		edir=${entry}; \
971220569Smav		cd ${.CURDIR}/$${edir}; \
972220569Smav	fi; \
973220569Smav	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
974220569Smav.endfor
975220569Smavpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
976207536Smav.endfor
977207536Smav
978207536Smav.include <bsd.subdir.mk>
979207536Smav