Makefile revision 36397
1139804Simp#
21541Srgrimes#	$Id: Makefile,v 1.180 1998/05/25 17:34:34 sos Exp $
31541Srgrimes#
41541Srgrimes# While porting to the another architecture include the bootstrap instead
51541Srgrimes# of the normal build.
61541Srgrimes#
71541Srgrimes.if exists(${.CURDIR}/Makefile.${MACHINE}) && defined(BOOTSTRAP_WORLD)
81541Srgrimes.include "${.CURDIR}/Makefile.${MACHINE}"
91541Srgrimes.else
101541Srgrimes#
111541Srgrimes# Make command line options:
121541Srgrimes#	-DCLOBBER will remove /usr/include
131541Srgrimes#	-DMAKE_KERBEROS4 to build KerberosIV
141541Srgrimes#	-DALLLANG to build documentation for all languages
151541Srgrimes#	  (where available -- see share/doc/Makefile)
161541Srgrimes#
171541Srgrimes#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
181541Srgrimes#	-DNOCLEAN do not clean at all
191541Srgrimes#	-DNOTOOLS do not rebuild any tools first
201541Srgrimes#	-DNOCRYPT will prevent building of crypt versions
211541Srgrimes#	-DNOLKM do not build loadable kernel modules
221541Srgrimes#	-DNOOBJDIR do not run ``${MAKE} obj''
231541Srgrimes#	-DNOPROFILE do not build profiled libraries
241541Srgrimes#	-DNOSECURE do not go into secure subdir
251541Srgrimes#	-DNOGAMES do not go into games subdir
261541Srgrimes#	-DNOSHARE do not go into share subdir
271541Srgrimes#	-DNOINFO do not make or install info files
281541Srgrimes#	-DNOLIBC_R do not build libc_r.
291541Srgrimes#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
301541Srgrimes
311541Srgrimes#
32116182Sobrien# The intended user-driven targets are:
33116182Sobrien# buildworld  - rebuild *everything*, including glue to help do upgrades
34116182Sobrien# installworld- install everything built by "buildworld"
351541Srgrimes# world       - buildworld + installworld
3648274Speter# update      - convenient way to update your source tree (eg: sup/cvs)
37160910Sdavidxu# most        - build user commands, no libraries or include files
38162954Sphk# installmost - install user commands, no libraries or include files
3976166Smarkm#
4076166Smarkm# Standard targets (not defined here) are documented in the makefiles in
4112221Sbde# /usr/share/mk.  These include:
42153259Sdavidxu#		obj depend all install clean cleandepend cleanobj
431541Srgrimes
443308Sphk.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
451541Srgrimes.MAKEFLAGS:=	-m ${.CURDIR}/share/mk ${.MAKEFLAGS}
46140483Sps.endif
47152983Sdavidxu
4825583Speter# Put initial settings here.
49164033SrwatsonSUBDIR=
501541Srgrimes
51164184Strhodes# We must do share/info early so that installation of info `dir'
5225656Speter# entries works correctly.  Do it first since it is less likely to
53151576Sdavidxu# grow dependencies on include and lib than vice versa.
5458377Sphk.if exists(share/info)
551541SrgrimesSUBDIR+= share/info
5676166Smarkm.endif
5726335Speter
5826335Speter# We must do include and lib early so that the perl *.ph generation
591541Srgrimes# works correctly as it uses the header files installed by this.
60151576Sdavidxu.if exists(include)
61254398SdavidxuSUBDIR+= include
62254398Sdavidxu.endif
63254398Sdavidxu.if exists(lib)
64254398SdavidxuSUBDIR+= lib
65254398Sdavidxu.endif
66254398Sdavidxu
67151576Sdavidxu.if exists(bin)
68151576SdavidxuSUBDIR+= bin
69151576Sdavidxu.endif
70151576Sdavidxu.if exists(games) && !defined(NOGAMES)
718876SrgrimesSUBDIR+= games
721541Srgrimes.endif
731541Srgrimes.if exists(gnu)
741541SrgrimesSUBDIR+= gnu
751541Srgrimes.endif
761541Srgrimes.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
771541Srgrimes    defined(MAKE_KERBEROS4)
781541SrgrimesSUBDIR+= kerberosIV
791541Srgrimes.endif
801541Srgrimes.if exists(libexec)
8194343SjhbSUBDIR+= libexec
8292723Salfred.endif
8313016Sbde.if exists(sbin)
84151576SdavidxuSUBDIR+= sbin
85151576Sdavidxu.endif
86151576Sdavidxu.if exists(share) && !defined(NOSHARE)
87151576SdavidxuSUBDIR+= share
88151576Sdavidxu.endif
89164713Sdavidxu.if exists(sys)
90151576SdavidxuSUBDIR+= sys
91161302Snetchild.endif
92161302Snetchild.if exists(usr.bin)
93151576SdavidxuSUBDIR+= usr.bin
94151576Sdavidxu.endif
95151576Sdavidxu.if exists(usr.sbin)
96151576SdavidxuSUBDIR+= usr.sbin
97151576Sdavidxu.endif
98151869Sdavidxu.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
99151576SdavidxuSUBDIR+= secure
100151576Sdavidxu.endif
101151576Sdavidxu.if exists(lkm) && !defined(NOLKM)
102151576SdavidxuSUBDIR+= lkm
103151869Sdavidxu.endif
104151576Sdavidxu
105151576Sdavidxu# etc must be last for "distribute" to work
106151576Sdavidxu.if exists(etc) && make(distribute)
107151576SdavidxuSUBDIR+= etc
108151576Sdavidxu.endif
109151576Sdavidxu
110151576Sdavidxu# These are last, since it is nice to at least get the base system
11125583Speter# rebuilt before you do them.
112102074Sphk.if defined(LOCAL_DIRS)
11325583Speter.for _DIR in ${LOCAL_DIRS}
11445433Snsayer.if exists(${_DIR}) & exists(${_DIR}/Makefile)
11545438SnsayerSUBDIR+= ${_DIR}
11633690Sphk.endif
11725583Speter.endfor
11825583Speter.endif
11925656Speter
12033818Sbde# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
12135029Sphk.if defined(NOOBJDIR)
12235029SphkOBJDIR=
12325583Speter.else
12425583SpeterOBJDIR=		obj
12533818Sbde.endif
12645433Snsayer
12745433Snsayer.if defined(NOCLEAN)
12845433SnsayerCLEANDIR=
12945433Snsayer.else
13045438Snsayer.if defined(NOCLEANDIR)
13145438SnsayerCLEANDIR=	clean cleandepend
13245438Snsayer.else
13345438SnsayerCLEANDIR=	cleandir
13425583Speter.endif
13594343Sjhb.endif
13645433Snsayer
13745437Smjacob.if !defined(NOCLEAN) && ${.MAKEFLAGS:M-j} == ""
13845438Snsayer_NODEPEND=	true
13945437Smjacob.endif
14045437Smjacob.if defined(_NODEPEND)
14145437Smjacob_DEPEND=	cleandepend
14245437Smjacob.else
14345437Smjacob_DEPEND=	depend
14445437Smjacob.endif
14545437Smjacob
14645433SnsayerSUP?=		cvsup
14745433SnsayerSUPFLAGS?=	-g -L 2 -P -
14845437Smjacob
14945438Snsayer#
15045438Snsayer# While building tools for bootstrapping, we don't need to waste time on
15145438Snsayer# shared or profiled libraries, shared linkage, or documentation, except
15245438Snsayer# when the tools won't get cleaned we must use the defaults for shared
15345438Snsayer# libraries and shared linkage (and this doesn't waste time).
15445438Snsayer# XXX actually, we do need to waste time building shared libraries.
15545438Snsayer#
15645438Snsayer.if defined(NOCLEAN)
15745438SnsayerMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
15845433Snsayer.else
15933818SbdeMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
16033818Sbde.endif
16133690Sphk
16233690Sphk#
16394343Sjhb# world
16458377Sphk#
16525583Speter# Attempt to rebuild and reinstall *everything*, with reasonable chance of
16694343Sjhb# success, regardless of how old your existing system is.
16725583Speter#
16825583Speter# >> Beware, it overwrites the local build environment! <<
16925583Speter#
17012221Sbdeworld:
171254398Sdavidxu	@echo "--------------------------------------------------------------"
172254398Sdavidxu	@echo "make world started on `LC_TIME=C date`"
173254398Sdavidxu	@echo "--------------------------------------------------------------"
174254398Sdavidxu.if target(pre-world)
175254398Sdavidxu	@echo
176254398Sdavidxu	@echo "--------------------------------------------------------------"
177254398Sdavidxu	@echo " Making 'pre-world' target"
178254398Sdavidxu	@echo "--------------------------------------------------------------"
179254398Sdavidxu	cd ${.CURDIR}; ${MAKE} pre-world
180254398Sdavidxu.endif
181254398Sdavidxu	cd ${.CURDIR}; ${MAKE} buildworld
182254664Skib	cd ${.CURDIR}; ${MAKE} -B installworld
183254664Skib.if target(post-world)
184254664Skib	@echo
185254664Skib	@echo "--------------------------------------------------------------"
186254664Skib	@echo " Making 'post-world' target"
187254664Skib	@echo "--------------------------------------------------------------"
188254664Skib	cd ${.CURDIR}; ${MAKE} post-world
189254664Skib.endif
190254664Skib	@echo
191254664Skib	@echo "--------------------------------------------------------------"
192254664Skib	@echo "make world completed on `LC_TIME=C date`"
193254664Skib	@echo "--------------------------------------------------------------"
194254398Sdavidxu
195254398Sdavidxu.if defined(MAKEOBJDIRPREFIX)
196254398SdavidxuWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
197254398Sdavidxu.else
198254398SdavidxuWORLDTMP=	/usr/obj${.CURDIR}/tmp
199254664Skib.endif
200254398SdavidxuSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
201254664SkibTMPPATH=	${STRICTTMPPATH}:${PATH}
202254664Skib
203254398Sdavidxu# XXX COMPILER_PATH is needed for finding cc1, ld and as
204254398Sdavidxu# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
205254398Sdavidxu#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
206254398Sdavidxu#	wouldn't link *crt.o or libgcc if it were used.
207254664Skib# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
208254398Sdavidxu#	want that - all compile-time library paths should be resolved by gcc.
209254664Skib#	It fails for set[ug]id executables (are any used?).
210254398SdavidxuCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
211254398Sdavidxu		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
212254398Sdavidxu		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
213254664Skib		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
214254664Skib		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
215254398Sdavidxu
216254664SkibBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
217254664SkibXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
218254664Skib		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
219254398Sdavidxu
220254398Sdavidxu# used to compile and install 'make' in temporary build tree
221254398SdavidxuMAKETMP=	${WORLDTMP}/make
222254398SdavidxuIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
223254398Sdavidxu# bootstrap make
224254398SdavidxuBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
22525583Speter# cross make used for compilation
22625583SpeterXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
22725583Speter# cross make used for final installation
22825583SpeterIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
22925583Speter
23025583Speter#
23125583Speter# buildworld
232225617Skmacy#
23325583Speter# Attempt to rebuild the entire system, with reasonable chance of
23425583Speter# success, regardless of how old your existing system is.
235151357Sps#
236151357Spsbuildworld:
237151357Sps.if !defined(NOCLEAN)
238151357Sps	@echo
239151357Sps	@echo "--------------------------------------------------------------"
240151357Sps	@echo " Cleaning up the temporary build tree"
241151357Sps	@echo "--------------------------------------------------------------"
242151357Sps	mkdir -p ${WORLDTMP}
243151357Sps	chflags -R noschg ${WORLDTMP}/
244254398Sdavidxu	rm -rf ${WORLDTMP}
245254398Sdavidxu.endif
246254398Sdavidxu.if !defined(NOTOOLS)
247254398Sdavidxu	@echo
248254398Sdavidxu	@echo "--------------------------------------------------------------"
249254398Sdavidxu	@echo " Making make"
250254398Sdavidxu	@echo "--------------------------------------------------------------"
251254398Sdavidxu	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
252254398Sdavidxu	( \
253254398Sdavidxu	cd ${.CURDIR}/usr.bin/make; \
254254398Sdavidxu		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
255254398Sdavidxu		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
256254398Sdavidxu		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
257254398Sdavidxu		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
258254398Sdavidxu	)
259254398Sdavidxu.endif
260254398Sdavidxu	@echo
261254398Sdavidxu	@echo "--------------------------------------------------------------"
262254398Sdavidxu	@echo " Making hierarchy"
263254398Sdavidxu	@echo "--------------------------------------------------------------"
264254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} hierarchy
265254398Sdavidxu.if !defined(NOCLEAN)
266254398Sdavidxu	@echo
267254398Sdavidxu	@echo "--------------------------------------------------------------"
268254398Sdavidxu	@echo " Cleaning up the obj tree"
269254398Sdavidxu	@echo "--------------------------------------------------------------"
270254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} ${CLEANDIR:S/^/par-/}
271254398Sdavidxu.endif
272254398Sdavidxu.if !defined(NOOBJDIR)
273254398Sdavidxu	@echo
274254398Sdavidxu	@echo "--------------------------------------------------------------"
275254398Sdavidxu	@echo " Rebuilding the obj tree"
276254398Sdavidxu	@echo "--------------------------------------------------------------"
277254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} par-${OBJDIR}
278254398Sdavidxu.endif
279254398Sdavidxu.if !defined(NOTOOLS)
280254398Sdavidxu	@echo
281254398Sdavidxu	@echo "--------------------------------------------------------------"
282254398Sdavidxu	@echo " Rebuilding bootstrap tools"
283254398Sdavidxu	@echo "--------------------------------------------------------------"
284254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} bootstrap
285254398Sdavidxu	@echo
286254398Sdavidxu	@echo "--------------------------------------------------------------"
287254398Sdavidxu	@echo " Rebuilding tools necessary to build the include files"
288254398Sdavidxu	@echo "--------------------------------------------------------------"
289254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} include-tools
290254398Sdavidxu.endif
291254398Sdavidxu	@echo
292254398Sdavidxu	@echo "--------------------------------------------------------------"
293254398Sdavidxu	@echo " Rebuilding ${DESTDIR}/usr/include"
294254398Sdavidxu	@echo "--------------------------------------------------------------"
295254398Sdavidxu	cd ${.CURDIR}; SHARED=symlinks ${BMAKE} includes
296254398Sdavidxu	@echo
297254398Sdavidxu	@echo "--------------------------------------------------------------"
298254398Sdavidxu	@echo " Rebuilding bootstrap libraries"
299254398Sdavidxu	@echo "--------------------------------------------------------------"
300254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} bootstrap-libraries
301254398Sdavidxu.if !defined(NOTOOLS)
302254398Sdavidxu	@echo
303254398Sdavidxu	@echo "--------------------------------------------------------------"
304254398Sdavidxu	@echo " Rebuilding tools needed to build libraries"
305254398Sdavidxu	@echo "--------------------------------------------------------------"
306254398Sdavidxu	cd ${.CURDIR}; ${BMAKE} lib-tools
307254398Sdavidxu.endif
308254398Sdavidxu.if !defined(NOTOOLS)
309254398Sdavidxu	@echo
310254398Sdavidxu	@echo "--------------------------------------------------------------"
311254398Sdavidxu	@echo " Rebuilding all other tools needed to build the world"
312254398Sdavidxu	@echo "--------------------------------------------------------------"
313151357Sps	cd ${.CURDIR}; ${BMAKE} build-tools
314151357Sps.endif
315151357Sps.if !defined(_NODEPEND)
316130884Skbyanc	@echo
317136152Sjhb	@echo "--------------------------------------------------------------"
31825583Speter	@echo " Rebuilding dependencies"
319136152Sjhb	@echo "--------------------------------------------------------------"
320151357Sps	cd ${.CURDIR}; ${XMAKE} par-depend
321152844Srwatson.endif
322152844Srwatson	@echo
323151357Sps	@echo "--------------------------------------------------------------"
324130654Skbyanc	@echo " Building libraries"
325152844Srwatson	@echo "--------------------------------------------------------------"
326152844Srwatson	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN libraries
327152844Srwatson	@echo
328130654Skbyanc	@echo "--------------------------------------------------------------"
329136152Sjhb	@echo " Building everything.."
330170472Sattilio	@echo "--------------------------------------------------------------"
331136152Sjhb	cd ${.CURDIR}; ${XMAKE} all
332170472Sattilio
333136152Sjhb#
334151357Sps# installworld
335130654Skbyanc#
336130654Skbyanc# Installs everything compiled by a 'buildworld'.
337136152Sjhb#
338170472Sattilioinstallworld:
339136152Sjhb	cd ${.CURDIR}; ${IXMAKE} reinstall
340170472Sattilio
341136152Sjhb#
342130884Skbyanc# reinstall
343151357Sps#
344130654Skbyanc# If you have a build server, you can NFS mount the source and obj directories
345152844Srwatson# and do a 'make reinstall' on the *client* to install new binaries from the
346152844Srwatson# most recent server build.
347152585Sandre#
348152844Srwatsonreinstall:
349151357Sps	@echo "--------------------------------------------------------------"
350130884Skbyanc	@echo " Making hierarchy"
351152844Srwatson	@echo "--------------------------------------------------------------"
352152844Srwatson	cd ${.CURDIR}; ${MAKE} hierarchy
353152844Srwatson	@echo
354152844Srwatson	@echo "--------------------------------------------------------------"
355152844Srwatson	@echo " Installing everything.."
356152844Srwatson	@echo "--------------------------------------------------------------"
357152844Srwatson	cd ${.CURDIR}; ${MAKE} install
358152844Srwatson	@echo
359175429Sdavidxu	@echo "--------------------------------------------------------------"
360254398Sdavidxu	@echo " Re-scanning the shared libraries.."
361175429Sdavidxu	@echo "--------------------------------------------------------------"
362254398Sdavidxu	cd ${.CURDIR}; ldconfig -R
363254398Sdavidxu	@echo
364254398Sdavidxu	@echo "--------------------------------------------------------------"
365254398Sdavidxu	@echo " Rebuilding man page indexes"
366254398Sdavidxu	@echo "--------------------------------------------------------------"
367130654Skbyanc	cd ${.CURDIR}/share/man; ${MAKE} makedb
368254398Sdavidxu
369254398Sdavidxu#
370254398Sdavidxu# update
371130654Skbyanc#
372151357Sps# Update the source tree, by running sup and/or running cvs to update to the
37325583Speter# latest copy.
37425583Speter#
37525583Speterupdate:
37625583Speter.if defined(SUP_UPDATE)
37725583Speter	@echo "--------------------------------------------------------------"
37825583Speter	@echo "Running ${SUP}"
37925583Speter	@echo "--------------------------------------------------------------"
38025583Speter	@${SUP} ${SUPFLAGS} ${SUPFILE}
38125583Speter.if defined(SUPFILE1)
38225583Speter	@${SUP} ${SUPFLAGS} ${SUPFILE1}
383225617Skmacy.endif
38425583Speter.if defined(SUPFILE2)
38525583Speter	@${SUP} ${SUPFLAGS} ${SUPFILE2}
38625583Speter.endif
38725583Speter.endif
388151357Sps.if defined(CVS_UPDATE)
389151357Sps	@echo "--------------------------------------------------------------"
390151357Sps	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
391151357Sps	@echo "--------------------------------------------------------------"
392151357Sps	cd ${.CURDIR}; cvs -q update -P -d
393151357Sps.endif
394151357Sps
395151357Sps#
396151357Sps# most
397151357Sps#
398151357Sps# Build most of the user binaries on the existing system libs and includes.
399164033Srwatson#
40094343Sjhbmost:
401151357Sps	@echo "--------------------------------------------------------------"
40294343Sjhb	@echo " Building programs only"
403151357Sps	@echo "--------------------------------------------------------------"
40494343Sjhb	cd ${.CURDIR}/bin;		${MAKE} all
40534901Sphk	cd ${.CURDIR}/sbin;		${MAKE} all
406151357Sps	cd ${.CURDIR}/libexec;		${MAKE} all
40794343Sjhb	cd ${.CURDIR}/usr.bin;		${MAKE} all
40882746Sdillon	cd ${.CURDIR}/usr.sbin;		${MAKE} all
40925583Speter	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
41025583Speter	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
41125583Speter	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
41225583Speter#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
41325583Speter#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
41425583Speter#.endif
41525583Speter#.if !defined(NOSECURE) && !defined(NOCRYPT)
41625583Speter#	cd ${.CURDIR}/secure;		${MAKE} most
41725583Speter#.endif
418225617Skmacy
41925583Speter#
42025583Speter# installmost
421151357Sps#
42225583Speter# Install the binaries built by the 'most' target.  This does not include
423151357Sps# libraries or include files.
424151357Sps#
425151357Spsinstallmost:
426151357Sps	@echo "--------------------------------------------------------------"
427151357Sps	@echo " Installing programs only"
428151357Sps	@echo "--------------------------------------------------------------"
429151357Sps	cd ${.CURDIR}/bin;		${MAKE} install
430151357Sps	cd ${.CURDIR}/sbin;		${MAKE} install
431151357Sps	cd ${.CURDIR}/libexec;		${MAKE} install
432151357Sps	cd ${.CURDIR}/usr.bin;		${MAKE} install
433151357Sps	cd ${.CURDIR}/usr.sbin;		${MAKE} install
434151357Sps	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
435151357Sps	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
436151357Sps	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
437151357Sps#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
438130654Skbyanc#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
439152844Srwatson#.endif
440152844Srwatson#.if !defined(NOSECURE) && !defined(NOCRYPT)
441130654Skbyanc#	cd ${.CURDIR}/secure;		${MAKE} installmost
442152844Srwatson#.endif
443152844Srwatson
444152585Sandre#
445152844Srwatson# ------------------------------------------------------------------------
446152844Srwatson#
447103964Sbde# From here onwards are utility targets used by the 'make world' and
448103964Sbde# related targets.  If your 'world' breaks, you may like to try to fix
449103964Sbde# the problem and manually run the following targets to attempt to
450103964Sbde# complete the build.  Beware, this is *not* guaranteed to work, you
451103964Sbde# need to have a pretty good grip on the current state of the system
452151357Sps# to attempt to manually finish it.  If in doubt, 'make world' again.
453130654Skbyanc#
454130654Skbyanc
455130654Skbyanc#
456130654Skbyanc# heirarchy - ensure that all the needed directories are present
457151357Sps#
458130654Skbyanchierarchy:
459152844Srwatson	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
460152844Srwatson
461152844Srwatson#
462152844Srwatson# bootstrap - [re]build tools needed to run the actual build, this includes
463175429Sdavidxu# tools needed by 'make depend', as some tools are needed to generate source
464254398Sdavidxu# for the dependency information to be gathered from.
465254398Sdavidxu#
466175429Sdavidxubootstrap:
467175429Sdavidxu.if defined(DESTDIR)
468175429Sdavidxu	rm -f ${DESTDIR}/usr/src/sys
469175429Sdavidxu	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
470175429Sdavidxu	cd ${.CURDIR}/include; find -dx . | cpio -dump ${DESTDIR}/usr/include
471130654Skbyanc	cd ${.CURDIR}/include; ${MAKE} symlinks
472254398Sdavidxu.endif
473254398Sdavidxu	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
474130654Skbyanc		${MAKE} ${MK_FLAGS} all; \
475130654Skbyanc		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
476151357Sps	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
47725583Speter		${MAKE} ${MK_FLAGS} all; \
47825583Speter		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
47926335Speter	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
48025656Speter		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
481140481Sps		${MAKE} ${MK_FLAGS} -DNOLIB all; \
482140481Sps		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
48325583Speter.if !defined(NOOBJDIR)
48435045Sphk	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
48535042Sphk.endif
48635042Sphk
48725583Speter#
48828773Sbde# include-tools - generally the same as 'bootstrap', except that it's for
48925656Speter# things that are specifically needed to generate include files.
49043301Sdillon#
49128773Sbde# XXX should be merged with bootstrap, it's not worth keeeping them separate.
49236119Sphk# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
49335029Sphk# on cleaned away headers in ${WORLDTMP}.
49435042Sphk#
49535042Sphkinclude-tools:
49635042Sphk.for d in usr.bin/compile_et usr.bin/rpcgen
49735042Sphk	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
49836119Sphk		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
49935042Sphk		${MAKE} ${MK_FLAGS} all; \
50035042Sphk		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
50135042Sphk.endfor
50235042Sphk
50335042Sphk#
50435042Sphk# includes - possibly generate and install the include files.
50535042Sphk#
50635042Sphkincludes:
50735042Sphk.if defined(CLOBBER)
50835042Sphk	rm -rf ${DESTDIR}/usr/include/*
50935042Sphk	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
51035029Sphk		-p ${DESTDIR}/usr/include
51135042Sphk.endif
51235045Sphk	cd ${.CURDIR}/include;			${MAKE} -B all install
51335045Sphk	cd ${.CURDIR}/gnu/include;		${MAKE} install
51435045Sphk	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
51526335Speter	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
51626335Speter	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
51725583Speter	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
51826335Speter	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
51926335Speter	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
52026335Speter	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
52126335Speter	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
52226335Speter.if exists(secure) && !defined(NOCRYPT)
52326335Speter	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
52426335Speter.endif
52526335Speter.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
526225617Skmacy	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
52726335Speter	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
52826335Speter	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
52982746Sdillon	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
53026335Speter	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
531107849Salfred	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
53226335Speter.else
53326335Speter	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
53482746Sdillon.endif
535109521Salfred.if exists(${.CURDIR}/lib/csu/${MACHINE})
536109521Salfred	cd ${.CURDIR}/lib/csu/${MACHINE};	${MAKE} beforeinstall
537109521Salfred.endif
538140481Sps	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
539107849Salfred	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
54082746Sdillon	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
54182746Sdillon	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
542107849Salfred	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
543109521Salfred	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
54482746Sdillon	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
54525583Speter	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
54625656Speter	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
54725583Speter	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
54825583Speter.if !defined(WANT_CSRG_LIBM)
54926335Speter	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
5501541Srgrimes.endif
5511541Srgrimes	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
5521541Srgrimes	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
5531541Srgrimes	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
55412221Sbde	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
5551541Srgrimes.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
5561549Srgrimes	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
557225617Skmacy	cd ${.CURDIR}/lib/libtcl;		${MAKE} installhdrs
5581541Srgrimes.endif
5591541Srgrimes	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
560110286Stjr	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
5611541Srgrimes	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
5621541Srgrimes	cd ${.CURDIR}/lib/libscsi;		${MAKE} beforeinstall
5631541Srgrimes	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
5641541Srgrimes	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
56599012Salfred	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
5661541Srgrimes	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
56790836Sphk	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
568110299Sphk
569110299Sphk#
570110286Stjr# lib-tools - build tools to compile and install the libraries.
57182746Sdillon#
5721541Srgrimes# XXX gperf is required for cc
5731541Srgrimes# XXX a new ld and tsort is required for cc
5741541Srgrimeslib-tools:
57512221Sbde.for d in				\
5761541Srgrimes		gnu/usr.bin/gperf	\
5771541Srgrimes		gnu/usr.bin/ld		\
5781541Srgrimes		usr.bin/tsort		\
5791541Srgrimes		gnu/usr.bin/as		\
58012221Sbde		gnu/usr.bin/bison	\
5811541Srgrimes		gnu/usr.bin/cc		\
5821549Srgrimes		usr.bin/ar		\
583225617Skmacy		usr.bin/lex/lib		\
5841541Srgrimes		usr.bin/mk_cmds		\
585144445Sjhb		usr.bin/nm		\
586144445Sjhb		usr.bin/ranlib		\
587144445Sjhb		usr.bin/strip		\
5881541Srgrimes		usr.bin/objformat	\
589144445Sjhb		usr.bin/env		\
590144445Sjhb		gnu/usr.bin/binutils	\
591144445Sjhb		usr.bin/uudecode
592144445Sjhb	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
593144445Sjhb		${MAKE} ${MK_FLAGS} all; \
594144445Sjhb		${MAKE} ${MK_FLAGS} -B install; \
595144445Sjhb		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
596144445Sjhb.endfor
597144445Sjhb
598144445Sjhb#
599144445Sjhb# We have to know too much about ordering and subdirs in the lib trees:
600144445Sjhb#
601144445Sjhb# To satisfy shared library linkage when only the libraries being built
602144445Sjhb# are visible:
603144445Sjhb#
604144445Sjhb# libcom_err must be built before libss.
605144445Sjhb# libcrypt and libmd must be built before libskey.
606144445Sjhb# libm must be built before libtcl.
607144445Sjhb# libmytinfo must be built before libdialog and libncurses.
608144445Sjhb# libncurses must be built before libdialog.
609144445Sjhb# libtermcap must be built before libcurses, libedit and libreadline.
610144445Sjhb#
611164033Srwatson# Some libraries are built conditionally and/or are in inconsistently
612144445Sjhb# named directories:
61394343Sjhb#
6141541Srgrimes.if exists(lib/csu/${MACHINE}.pcc)
615144445Sjhb_csu=lib/csu/${MACHINE}.pcc
616144445Sjhb.else
61794343Sjhb_csu=lib/csu/${MACHINE}
618144445Sjhb.endif
61925656Speter
620144445Sjhb_libcrypt=	lib/libcrypt
621144445Sjhb.if !defined(NOSECURE) && !defined(NOCRYPT)
622144445Sjhb_libcrypt+=	secure/lib/libcrypt
62382746Sdillon.endif
62482746Sdillon
6251541Srgrimes.if defined(WANT_CSRG_LIBM)
626144445Sjhb_libm=	lib/libm
62782746Sdillon.else
628167232Srwatson_libm=	lib/msun
629167232Srwatson.endif
630167232Srwatson
631167232Srwatson#
6321541Srgrimes# bootstrap-libraries - build just enough libraries for the bootstrap
633167232Srwatson# tools, and install them under ${WORLDTMP}.
634167232Srwatson#
635167232Srwatson# Build csu and libgcc early so that some tools get linked to the new
636167232Srwatson# versions (too late for the main tools, however).  Then build the
6371541Srgrimes# necessary prerequisite libraries (libtermcap just needs to be before
6381541Srgrimes# libcurses, and this only matters for the NOCLEAN case when NOPIC is
639167232Srwatson# not set).
640167232Srwatson#
641167232Srwatson# This is mostly wrong.  The build tools must run on the host system,
642167232Srwatson# so they should use host libraries.  We depend on the target being
643167232Srwatson# similar enough to the host for new target libraries to work on the
644167232Srwatson# host.
645167232Srwatson#
646167232Srwatsonbootstrap-libraries:
6471541Srgrimes.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
64812221Sbde    gnu/lib/libregex gnu/lib/libreadline lib/libc \
6491541Srgrimes    lib/libcrypt lib/libcurses lib/libedit ${_libm} \
6501541Srgrimes    lib/libmd lib/libutil lib/libz usr.bin/lex/lib
6511541Srgrimes.if exists(${.CURDIR}/${_lib})
6521541Srgrimes	cd ${.CURDIR}/${_lib}; \
65312221Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
6541549Srgrimes		${MAKE} ${MK_FLAGS} all; \
655225617Skmacy		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6561541Srgrimes.endif
657141470Sjhb.endfor
658140832Ssobomax
659140832Ssobomax#
660140832Ssobomax# libraries - build all libraries, and install them under ${DESTDIR}.
661140832Ssobomax#
662140832Ssobomax# The ordering is not as special as for bootstrap-libraries.  Build
663140832Ssobomax# the prerequisites first, then build almost everything else in
664140832Ssobomax# alphabetical order.
665140832Ssobomax#
666140832Ssobomaxlibraries:
667140832Ssobomax.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
668140832Ssobomax    lib/libncurses lib/libtermcap \
66983366Sjulian    gnu/lib gnu/usr.bin/cc/libgcc lib usr.bin/lex/lib usr.sbin/pcvt/keycap
67034961Sphk.if exists(${.CURDIR}/${_lib})
6711541Srgrimes	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
672140832Ssobomax.endif
6731541Srgrimes.endfor
67482746Sdillon.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
675140832Ssobomax	cd ${.CURDIR}/secure/lib; ${MAKE} all; ${MAKE} -B install
6761541Srgrimes.endif
67736128Sbde.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
6781541Srgrimes    defined(MAKE_KERBEROS4)
6791541Srgrimes	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} all; ${MAKE} -B install
6801541Srgrimes.endif
6811541Srgrimes
682111034Stjr#
683140832Ssobomax# build-tools - build and install any other tools needed to complete the
684111034Stjr# compile and install.
685140832Ssobomax# ifdef stale
68636119Sphk# bc and cpp are required to build groff.  Otherwise, the order here is
687140832Ssobomax# mostly historical, i.e., bogus.
688140832Ssobomax# chmod is used to build gcc's tmpmultilib[2] at obscure times.
6891541Srgrimes# endif stale
690140832Ssobomax# XXX uname is a bug - the target should not depend on the host.
69134961Sphk#
69282746Sdillonbuild-tools:
693170307Sjeff.for d in				\
694140832Ssobomax		bin/cat 		\
695170307Sjeff		bin/chmod		\
69682746Sdillon		bin/cp 			\
697140832Ssobomax		bin/date		\
6981541Srgrimes		bin/dd			\
6991541Srgrimes		bin/echo		\
70012221Sbde		bin/expr		\
7011541Srgrimes		bin/hostname		\
7021541Srgrimes		bin/ln			\
7031541Srgrimes		bin/ls			\
7041541Srgrimes		bin/mkdir		\
70512221Sbde		bin/mv			\
7061549Srgrimes		bin/rm			\
707225617Skmacy		bin/sh			\
7081541Srgrimes		bin/test		\
709141470Sjhb		gnu/usr.bin/awk		\
710140832Ssobomax		gnu/usr.bin/bc		\
7111541Srgrimes		gnu/usr.bin/grep	\
712111034Stjr		gnu/usr.bin/groff	\
713111034Stjr		gnu/usr.bin/gzip	\
714225617Skmacy		gnu/usr.bin/man/makewhatis	\
715111034Stjr		gnu/usr.bin/patch	\
716111034Stjr		gnu/usr.bin/perl/perl	\
717111034Stjr		gnu/usr.bin/sort	\
7181541Srgrimes		gnu/usr.bin/texinfo	\
719140832Ssobomax		usr.bin/basename	\
720140832Ssobomax		usr.bin/cap_mkdb	\
721140832Ssobomax		usr.bin/chflags		\
722140832Ssobomax		usr.bin/cmp		\
723140832Ssobomax		usr.bin/col		\
724140832Ssobomax		usr.bin/cpp		\
725140832Ssobomax		usr.bin/expand		\
726141470Sjhb		usr.bin/file2c		\
727141470Sjhb		usr.bin/find		\
728140832Ssobomax		usr.bin/gencat		\
729140832Ssobomax		usr.bin/lorder		\
730140832Ssobomax		usr.bin/m4		\
731140832Ssobomax		usr.bin/mkdep		\
732141483Sjhb		usr.bin/paste		\
733141483Sjhb		usr.bin/sed		\
734141483Sjhb		usr.bin/size		\
735140832Ssobomax		usr.bin/soelim		\
736111034Stjr		usr.bin/strip		\
737140832Ssobomax		usr.bin/symorder	\
738111034Stjr		usr.bin/touch		\
739140832Ssobomax		usr.bin/tr		\
740140832Ssobomax		usr.bin/true		\
741140832Ssobomax		usr.bin/uname		\
742140832Ssobomax		usr.bin/uuencode	\
74382746Sdillon		usr.bin/vgrind		\
744140832Ssobomax		usr.bin/vi		\
745111034Stjr		usr.bin/wc		\
74635058Sphk		usr.bin/xargs		\
74769286Sjake		usr.bin/yacc		\
748114980Sjhb		usr.sbin/chown		\
749140832Ssobomax		usr.sbin/mtree		\
750140832Ssobomax		usr.sbin/zic
75169286Sjake	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
752140832Ssobomax		${MAKE} ${MK_FLAGS} all; \
753114980Sjhb		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
754140832Ssobomax.endfor
755140832Ssobomax
756111034Stjr.for __target in clean cleandepend cleandir depend obj
757140832Ssobomax.for entry in ${SUBDIR}
758140832Ssobomax${entry}.${__target}__D: .PHONY
759140832Ssobomax	@if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
760111034Stjr		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
761140832Ssobomax		edir=${entry}.${MACHINE}; \
762111034Stjr		cd ${.CURDIR}/$${edir}; \
76382746Sdillon	else \
764170307Sjeff		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
765140832Ssobomax		edir=${entry}; \
766140832Ssobomax		cd ${.CURDIR}/$${edir}; \
767170307Sjeff	fi; \
76882746Sdillon	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
769140832Ssobomax.endfor
7701541Srgrimespar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
7711541Srgrimes.endfor
7721541Srgrimes
7731541Srgrimes.endif
7741541Srgrimes
7751541Srgrimes.include <bsd.subdir.mk>
7761541Srgrimes