Makefile revision 37026
12061Sjkh#
237026Sbde#	$Id: Makefile,v 1.202 1998/06/13 02:03:36 peter Exp $
32061Sjkh#
433611Sjb# While porting to the another architecture include the bootstrap instead
532427Sjb# of the normal build.
632427Sjb#
736111Sjb.if exists(${.CURDIR}/Makefile.${MACHINE}) && defined(BOOTSTRAP_WORLD)
833611Sjb.include "${.CURDIR}/Makefile.${MACHINE}"
932427Sjb.else
1032427Sjb#
112061Sjkh# Make command line options:
1215603Smarkm#	-DCLOBBER will remove /usr/include
1330169Sjkh#	-DMAKE_KERBEROS4 to build KerberosIV
142061Sjkh#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
1512483Speter#	-DNOCLEAN do not clean at all
1634509Sbde#	-DNOTOOLS do not rebuild any tools first
172160Scsgr#	-DNOCRYPT will prevent building of crypt versions
182834Swollman#	-DNOLKM do not build loadable kernel modules
192061Sjkh#	-DNOOBJDIR do not run ``${MAKE} obj''
202061Sjkh#	-DNOPROFILE do not build profiled libraries
212160Scsgr#	-DNOSECURE do not go into secure subdir
2217308Speter#	-DNOGAMES do not go into games subdir
2319320Sadam#	-DNOSHARE do not go into share subdir
2427788Sasami#	-DNOINFO do not make or install info files
2530169Sjkh#	-DNOLIBC_R do not build libc_r.
2625980Sasami#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
271594Srgrimes
2817308Speter#
2917308Speter# The intended user-driven targets are:
3027910Sasami# buildworld  - rebuild *everything*, including glue to help do upgrades
3127910Sasami# installworld- install everything built by "buildworld"
3227910Sasami# world       - buildworld + installworld
3317308Speter# update      - convenient way to update your source tree (eg: sup/cvs)
3417308Speter# most        - build user commands, no libraries or include files
3517308Speter# installmost - install user commands, no libraries or include files
3619175Sbde#
3719175Sbde# Standard targets (not defined here) are documented in the makefiles in
3819175Sbde# /usr/share/mk.  These include:
3919175Sbde#		obj depend all install clean cleandepend cleanobj
4017308Speter
4127910Sasami.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
4234509Sbde.MAKEFLAGS:=	-m ${.CURDIR}/share/mk ${.MAKEFLAGS}
4327910Sasami.endif
4417308Speter
452061Sjkh# Put initial settings here.
462061SjkhSUBDIR=
471594Srgrimes
4830169Sjkh# We must do share/info early so that installation of info `dir'
4930169Sjkh# entries works correctly.  Do it first since it is less likely to
5030169Sjkh# grow dependencies on include and lib than vice versa.
5130169Sjkh.if exists(share/info)
5230169SjkhSUBDIR+= share/info
5330169Sjkh.endif
5430169Sjkh
5530169Sjkh# We must do include and lib early so that the perl *.ph generation
567407Srgrimes# works correctly as it uses the header files installed by this.
577108Sphk.if exists(include)
587108SphkSUBDIR+= include
597108Sphk.endif
607407Srgrimes.if exists(lib)
617407SrgrimesSUBDIR+= lib
627407Srgrimes.endif
637108Sphk
642061Sjkh.if exists(bin)
652061SjkhSUBDIR+= bin
662061Sjkh.endif
6717308Speter.if exists(games) && !defined(NOGAMES)
682061SjkhSUBDIR+= games
692061Sjkh.endif
702061Sjkh.if exists(gnu)
712061SjkhSUBDIR+= gnu
722061Sjkh.endif
7335427Sbde.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
7435427Sbde    defined(MAKE_KERBEROS4)
7530169SjkhSUBDIR+= kerberosIV
762626Scsgr.endif
772061Sjkh.if exists(libexec)
782061SjkhSUBDIR+= libexec
792061Sjkh.endif
802061Sjkh.if exists(sbin)
812061SjkhSUBDIR+= sbin
822061Sjkh.endif
8319320Sadam.if exists(share) && !defined(NOSHARE)
842061SjkhSUBDIR+= share
852061Sjkh.endif
862061Sjkh.if exists(sys)
872061SjkhSUBDIR+= sys
882061Sjkh.endif
892061Sjkh.if exists(usr.bin)
902061SjkhSUBDIR+= usr.bin
912061Sjkh.endif
922061Sjkh.if exists(usr.sbin)
932061SjkhSUBDIR+= usr.sbin
942061Sjkh.endif
952834Swollman.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
962834SwollmanSUBDIR+= secure
972834Swollman.endif
982834Swollman.if exists(lkm) && !defined(NOLKM)
992834SwollmanSUBDIR+= lkm
1002834Swollman.endif
1011594Srgrimes
1024486Sphk# etc must be last for "distribute" to work
1034486Sphk.if exists(etc) && make(distribute)
1044486SphkSUBDIR+= etc
1054486Sphk.endif
1064486Sphk
1072061Sjkh# These are last, since it is nice to at least get the base system
1082061Sjkh# rebuilt before you do them.
10925979Sjkh.if defined(LOCAL_DIRS)
11025979Sjkh.for _DIR in ${LOCAL_DIRS}
11125979Sjkh.if exists(${_DIR}) & exists(${_DIR}/Makefile)
11225979SjkhSUBDIR+= ${_DIR}
1132061Sjkh.endif
11425979Sjkh.endfor
1152061Sjkh.endif
1162061Sjkh
11717308Speter# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
1182061Sjkh.if defined(NOOBJDIR)
1192061SjkhOBJDIR=
1202061Sjkh.else
1212061SjkhOBJDIR=		obj
1222061Sjkh.endif
12312483Speter
12412483Speter.if defined(NOCLEAN)
12512483SpeterCLEANDIR=
12612483Speter.else
1272061Sjkh.if defined(NOCLEANDIR)
12835479SbdeCLEANDIR=	clean cleandepend
1298854Srgrimes.else
1302061SjkhCLEANDIR=	cleandir
1312061Sjkh.endif
13212483Speter.endif
1332061Sjkh
13435479Sbde.if !defined(NOCLEAN) && ${.MAKEFLAGS:M-j} == ""
13535479Sbde_NODEPEND=	true
13635479Sbde.endif
13735479Sbde.if defined(_NODEPEND)
13835479Sbde_DEPEND=	cleandepend
13935479Sbde.else
14035479Sbde_DEPEND=	depend
14135479Sbde.endif
14235479Sbde
14335462SjkhSUP?=		cvsup
14435462SjkhSUPFLAGS?=	-g -L 2 -P -
14518714Sache
14617308Speter#
14734541Sbde# While building tools for bootstrapping, we don't need to waste time on
14834575Sbde# shared or profiled libraries, shared linkage, or documentation, except
14934575Sbde# when the tools won't get cleaned we must use the defaults for shared
15034575Sbde# libraries and shared linkage (and this doesn't waste time).
15134592Sbde# XXX actually, we do need to waste time building shared libraries.
15217308Speter#
15334575Sbde.if defined(NOCLEAN)
15435427SbdeMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
15534575Sbde.else
15635427SbdeMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
15734575Sbde.endif
15815603Smarkm
15917308Speter#
16017308Speter# world
16117308Speter#
16217308Speter# Attempt to rebuild and reinstall *everything*, with reasonable chance of
16317308Speter# success, regardless of how old your existing system is.
16417308Speter#
16517308Speter# >> Beware, it overwrites the local build environment! <<
16617308Speter#
16717308Speterworld:
16818362Sjkh	@echo "--------------------------------------------------------------"
16919966Sache	@echo "make world started on `LC_TIME=C date`"
17018362Sjkh	@echo "--------------------------------------------------------------"
17117308Speter.if target(pre-world)
17227910Sasami	@echo
17317308Speter	@echo "--------------------------------------------------------------"
17417308Speter	@echo " Making 'pre-world' target"
17517308Speter	@echo "--------------------------------------------------------------"
17636074Sbde	cd ${.CURDIR}; ${MAKE} pre-world
17727910Sasami.endif
17836074Sbde	cd ${.CURDIR}; ${MAKE} buildworld
17936074Sbde	cd ${.CURDIR}; ${MAKE} -B installworld
18027910Sasami.if target(post-world)
18117308Speter	@echo
1822061Sjkh	@echo "--------------------------------------------------------------"
18327910Sasami	@echo " Making 'post-world' target"
1842061Sjkh	@echo "--------------------------------------------------------------"
18536074Sbde	cd ${.CURDIR}; ${MAKE} post-world
18627910Sasami.endif
1872061Sjkh	@echo
18817308Speter	@echo "--------------------------------------------------------------"
18927910Sasami	@echo "make world completed on `LC_TIME=C date`"
19017308Speter	@echo "--------------------------------------------------------------"
19127910Sasami
19227910Sasami.if defined(MAKEOBJDIRPREFIX)
19327910SasamiWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
19417308Speter.else
19527910SasamiWORLDTMP=	/usr/obj${.CURDIR}/tmp
19617308Speter.endif
19727910SasamiSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
19827910SasamiTMPPATH=	${STRICTTMPPATH}:${PATH}
19927910Sasami
20027910Sasami# XXX COMPILER_PATH is needed for finding cc1, ld and as
20136622Scharnier# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecessary now
20236622Scharnier#	that LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
20327910Sasami#	wouldn't link *crt.o or libgcc if it were used.
20427910Sasami# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
20527910Sasami#	want that - all compile-time library paths should be resolved by gcc.
20627910Sasami#	It fails for set[ug]id executables (are any used?).
20727910SasamiCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
20827910Sasami		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
20934509Sbde		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
21027910Sasami		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
21127910Sasami		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
21227910Sasami
21336423SpeterBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t \
21436423Speter		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:/usr/libexec
21527910SasamiXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
21636423Speter		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
21735479Sbde		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
21827910Sasami
21927910Sasami# used to compile and install 'make' in temporary build tree
22034688SbdeMAKETMP=	${WORLDTMP}/make
22134688SbdeIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
22227910Sasami# bootstrap make
22335427SbdeBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
22427910Sasami# cross make used for compilation
22535427SbdeXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
22627910Sasami# cross make used for final installation
22735427SbdeIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
22827910Sasami
22927910Sasami#
23027910Sasami# buildworld
23127910Sasami#
23227910Sasami# Attempt to rebuild the entire system, with reasonable chance of
23327910Sasami# success, regardless of how old your existing system is.
23427910Sasami#
23527910Sasamibuildworld:
23627910Sasami.if !defined(NOCLEAN)
23717308Speter	@echo
23817308Speter	@echo "--------------------------------------------------------------"
23927910Sasami	@echo " Cleaning up the temporary build tree"
24017308Speter	@echo "--------------------------------------------------------------"
24127910Sasami	mkdir -p ${WORLDTMP}
24227910Sasami	chflags -R noschg ${WORLDTMP}/
24327910Sasami	rm -rf ${WORLDTMP}
24427910Sasami.endif
24533133Sadam.if !defined(NOTOOLS)
24617466Speter	@echo
24717308Speter	@echo "--------------------------------------------------------------"
24827910Sasami	@echo " Making make"
24917308Speter	@echo "--------------------------------------------------------------"
25034688Sbde	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
25134688Sbde	( \
25236074Sbde	cd ${.CURDIR}/usr.bin/make; \
25336074Sbde		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
25436074Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
25536074Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
25634688Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
25734688Sbde	)
25836722Ssos	@echo
25936722Ssos	@echo "--------------------------------------------------------------"
26036800Sbde	@echo " Making mtree"
26136722Ssos	@echo "--------------------------------------------------------------"
26236800Sbde	mkdir -p ${WORLDTMP}/usr/sbin ${WORLDTMP}/mtree
26336722Ssos	( \
26436722Ssos	cd ${.CURDIR}/usr.sbin/mtree; \
26536722Ssos		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
26636800Sbde		export MAKEOBJDIR=${WORLDTMP}/mtree; \
26736800Sbde		${BMAKE} ${MK_FLAGS} all; \
26836800Sbde		${BMAKE} ${MK_FLAGS} -B install clean \
26936722Ssos	)
27033133Sadam.endif
27117308Speter	@echo
27217308Speter	@echo "--------------------------------------------------------------"
27327910Sasami	@echo " Making hierarchy"
27417308Speter	@echo "--------------------------------------------------------------"
27536074Sbde	cd ${.CURDIR}; ${BMAKE} hierarchy
27627910Sasami.if !defined(NOCLEAN)
27717308Speter	@echo
27817308Speter	@echo "--------------------------------------------------------------"
27927910Sasami	@echo " Cleaning up the obj tree"
28017308Speter	@echo "--------------------------------------------------------------"
28136074Sbde	cd ${.CURDIR}; ${BMAKE} ${CLEANDIR:S/^/par-/}
28227910Sasami.endif
28327910Sasami.if !defined(NOOBJDIR)
28417308Speter	@echo
28517308Speter	@echo "--------------------------------------------------------------"
28627910Sasami	@echo " Rebuilding the obj tree"
28717308Speter	@echo "--------------------------------------------------------------"
28836074Sbde	cd ${.CURDIR}; ${BMAKE} par-${OBJDIR}
28927910Sasami.endif
29033133Sadam.if !defined(NOTOOLS)
29117308Speter	@echo
29217308Speter	@echo "--------------------------------------------------------------"
29327910Sasami	@echo " Rebuilding bootstrap tools"
29417308Speter	@echo "--------------------------------------------------------------"
29536074Sbde	cd ${.CURDIR}; ${BMAKE} bootstrap
29617308Speter	@echo
29717308Speter	@echo "--------------------------------------------------------------"
29827910Sasami	@echo " Rebuilding tools necessary to build the include files"
29917308Speter	@echo "--------------------------------------------------------------"
30036074Sbde	cd ${.CURDIR}; ${BMAKE} include-tools
30133133Sadam.endif
30217308Speter	@echo
30317308Speter	@echo "--------------------------------------------------------------"
30434509Sbde	@echo " Rebuilding ${DESTDIR}/usr/include"
30517308Speter	@echo "--------------------------------------------------------------"
30636429Speter	cd ${.CURDIR}; SHARED=copies ${BMAKE} includes
30735851Sjb	@echo
30835851Sjb	@echo "--------------------------------------------------------------"
30935851Sjb	@echo " Rebuilding bootstrap libraries"
31035851Sjb	@echo "--------------------------------------------------------------"
31136074Sbde	cd ${.CURDIR}; ${BMAKE} bootstrap-libraries
31233133Sadam.if !defined(NOTOOLS)
31317962Speter	@echo
31417962Speter	@echo "--------------------------------------------------------------"
31535851Sjb	@echo " Rebuilding tools needed to build libraries"
31617962Speter	@echo "--------------------------------------------------------------"
31736074Sbde	cd ${.CURDIR}; ${BMAKE} lib-tools
31833133Sadam.endif
31933133Sadam.if !defined(NOTOOLS)
32017962Speter	@echo
32117962Speter	@echo "--------------------------------------------------------------"
32227910Sasami	@echo " Rebuilding all other tools needed to build the world"
32317962Speter	@echo "--------------------------------------------------------------"
32436074Sbde	cd ${.CURDIR}; ${BMAKE} build-tools
32533133Sadam.endif
32635479Sbde.if !defined(_NODEPEND)
32717308Speter	@echo
32817308Speter	@echo "--------------------------------------------------------------"
32927910Sasami	@echo " Rebuilding dependencies"
33017308Speter	@echo "--------------------------------------------------------------"
33136074Sbde	cd ${.CURDIR}; ${XMAKE} par-depend
33235479Sbde.endif
33317308Speter	@echo
33417308Speter	@echo "--------------------------------------------------------------"
33535427Sbde	@echo " Building libraries"
33635427Sbde	@echo "--------------------------------------------------------------"
33736074Sbde	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN libraries
33835427Sbde	@echo
33935427Sbde	@echo "--------------------------------------------------------------"
34027910Sasami	@echo " Building everything.."
34117962Speter	@echo "--------------------------------------------------------------"
34236074Sbde	cd ${.CURDIR}; ${XMAKE} all
3432061Sjkh
34417308Speter#
34527910Sasami# installworld
34627910Sasami#
34727910Sasami# Installs everything compiled by a 'buildworld'.
34827910Sasami#
34927910Sasamiinstallworld:
35036074Sbde	cd ${.CURDIR}; ${IXMAKE} reinstall
35127910Sasami
35227910Sasami#
35317308Speter# reinstall
35417308Speter#
35517308Speter# If you have a build server, you can NFS mount the source and obj directories
35617308Speter# and do a 'make reinstall' on the *client* to install new binaries from the
35717308Speter# most recent server build.
35817308Speter#
35917308Speterreinstall:
36012483Speter	@echo "--------------------------------------------------------------"
36117308Speter	@echo " Making hierarchy"
36212483Speter	@echo "--------------------------------------------------------------"
36336074Sbde	cd ${.CURDIR}; ${MAKE} hierarchy
36412483Speter	@echo
3652061Sjkh	@echo "--------------------------------------------------------------"
36617962Speter	@echo " Installing everything.."
36717962Speter	@echo "--------------------------------------------------------------"
36836074Sbde	cd ${.CURDIR}; ${MAKE} install
36936638Sjb.if ${MACHINE_ARCH} == "i386"
37017962Speter	@echo
37117962Speter	@echo "--------------------------------------------------------------"
37233595Snate	@echo " Re-scanning the shared libraries.."
37333595Snate	@echo "--------------------------------------------------------------"
37436683Sbde	cd ${.CURDIR}; /sbin/ldconfig -R
37536638Sjb.endif
37633595Snate	@echo
37733595Snate	@echo "--------------------------------------------------------------"
37817962Speter	@echo " Rebuilding man page indexes"
37917962Speter	@echo "--------------------------------------------------------------"
38036074Sbde	cd ${.CURDIR}/share/man; ${MAKE} makedb
3812061Sjkh
38217308Speter#
38317308Speter# update
38417308Speter#
38517308Speter# Update the source tree, by running sup and/or running cvs to update to the
38617308Speter# latest copy.
38717308Speter#
3882302Spaulupdate:
3892302Spaul.if defined(SUP_UPDATE)
3902302Spaul	@echo "--------------------------------------------------------------"
39135462Sjkh	@echo "Running ${SUP}"
3922302Spaul	@echo "--------------------------------------------------------------"
39318714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE}
39410760Sache.if defined(SUPFILE1)
39518714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE1}
3962302Spaul.endif
39710760Sache.if defined(SUPFILE2)
39818714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE2}
39910760Sache.endif
40010760Sache.endif
4012302Spaul.if defined(CVS_UPDATE)
4022302Spaul	@echo "--------------------------------------------------------------"
4032302Spaul	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
4042302Spaul	@echo "--------------------------------------------------------------"
40536074Sbde	cd ${.CURDIR}; cvs -q update -P -d
4062302Spaul.endif
4072302Spaul
40817308Speter#
40917308Speter# most
41017308Speter#
41117308Speter# Build most of the user binaries on the existing system libs and includes.
41217308Speter#
41317308Spetermost:
4142061Sjkh	@echo "--------------------------------------------------------------"
41517308Speter	@echo " Building programs only"
4162061Sjkh	@echo "--------------------------------------------------------------"
41736074Sbde	cd ${.CURDIR}/bin;		${MAKE} all
41836074Sbde	cd ${.CURDIR}/sbin;		${MAKE} all
41936074Sbde	cd ${.CURDIR}/libexec;		${MAKE} all
42036074Sbde	cd ${.CURDIR}/usr.bin;		${MAKE} all
42136074Sbde	cd ${.CURDIR}/usr.sbin;		${MAKE} all
42236074Sbde	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
42336074Sbde	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
42436074Sbde	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
42530169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
42636074Sbde#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
42717308Speter#.endif
42817308Speter#.if !defined(NOSECURE) && !defined(NOCRYPT)
42936074Sbde#	cd ${.CURDIR}/secure;		${MAKE} most
43017308Speter#.endif
4312061Sjkh
43217308Speter#
43317308Speter# installmost
43417308Speter#
43517308Speter# Install the binaries built by the 'most' target.  This does not include
43617308Speter# libraries or include files.
43717308Speter#
4383626Swollmaninstallmost:
4393626Swollman	@echo "--------------------------------------------------------------"
4403626Swollman	@echo " Installing programs only"
4413626Swollman	@echo "--------------------------------------------------------------"
44236074Sbde	cd ${.CURDIR}/bin;		${MAKE} install
44336074Sbde	cd ${.CURDIR}/sbin;		${MAKE} install
44436074Sbde	cd ${.CURDIR}/libexec;		${MAKE} install
44536074Sbde	cd ${.CURDIR}/usr.bin;		${MAKE} install
44636074Sbde	cd ${.CURDIR}/usr.sbin;		${MAKE} install
44736074Sbde	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
44836074Sbde	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
44936074Sbde	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
45030169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
45136074Sbde#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
4523626Swollman#.endif
4533626Swollman#.if !defined(NOSECURE) && !defined(NOCRYPT)
45436074Sbde#	cd ${.CURDIR}/secure;		${MAKE} installmost
4553626Swollman#.endif
4563626Swollman
45717308Speter#
45817308Speter# ------------------------------------------------------------------------
45917308Speter#
46017308Speter# From here onwards are utility targets used by the 'make world' and
46117308Speter# related targets.  If your 'world' breaks, you may like to try to fix
46217308Speter# the problem and manually run the following targets to attempt to
46317308Speter# complete the build.  Beware, this is *not* guaranteed to work, you
46417308Speter# need to have a pretty good grip on the current state of the system
46517308Speter# to attempt to manually finish it.  If in doubt, 'make world' again.
46617308Speter#
4673626Swollman
46817308Speter#
46917308Speter# heirarchy - ensure that all the needed directories are present
47017308Speter#
47117308Speterhierarchy:
47236074Sbde	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
47317308Speter
47417308Speter#
47517308Speter# bootstrap - [re]build tools needed to run the actual build, this includes
47617308Speter# tools needed by 'make depend', as some tools are needed to generate source
47717308Speter# for the dependency information to be gathered from.
47817308Speter#
47917308Speterbootstrap:
48027910Sasami.if defined(DESTDIR)
48127910Sasami	rm -f ${DESTDIR}/usr/src/sys
48227910Sasami	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
48336074Sbde	cd ${.CURDIR}/include; find -dx . | cpio -dump ${DESTDIR}/usr/include
48436442Speter.for d in net netinet posix4 sys vm machine
48536442Speter	if [ -h ${DESTDIR}/usr/include/$d ]; then \
48636442Speter		rm -f ${DESTDIR}/usr/include/$d ; \
48736442Speter	fi
48836442Speter.endfor
48936429Speter	cd ${.CURDIR}/sys; \
49036429Speter		find -dx net netinet posix4 sys vm -name '*.h' -o -type d | \
49136429Speter		cpio -dump ${DESTDIR}/usr/include
49236429Speter	mkdir -p ${DESTDIR}/usr/include/machine
49336638Sjb	cd ${.CURDIR}/sys/${MACHINE_ARCH}/include; find -dx . -name '*.h' -o -type d | \
49436429Speter		cpio -dump ${DESTDIR}/usr/include/machine
49527910Sasami.endif
49636074Sbde	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
49736074Sbde		${MAKE} ${MK_FLAGS} all; \
49830113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
49936074Sbde	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
50036074Sbde		${MAKE} ${MK_FLAGS} all; \
50130113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
50237026Sbde	cd ${.CURDIR}/usr.bin/yacc; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
50337026Sbde		${MAKE} ${MK_FLAGS} all; \
50437026Sbde		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
50536074Sbde	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
50636074Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
50736074Sbde		${MAKE} ${MK_FLAGS} -DNOLIB all; \
50836682Sbde		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
50936682Sbde.if !defined(NOOBJDIR)
51036682Sbde	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
51136682Sbde.endif
51236672Sjkh	cd ${.CURDIR}/usr.sbin/mtree; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
51336672Sjkh		${MAKE} ${MK_FLAGS} all; \
51436672Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
51536429Speter.if defined(DESTDIR)
51636429Speter	cd ${.CURDIR}/include && ${MAKE} copies
51736429Speter.endif
51817308Speter
51917308Speter#
52017308Speter# include-tools - generally the same as 'bootstrap', except that it's for
52117308Speter# things that are specifically needed to generate include files.
52217308Speter#
52327910Sasami# XXX should be merged with bootstrap, it's not worth keeeping them separate.
52427910Sasami# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
52527910Sasami# on cleaned away headers in ${WORLDTMP}.
52617308Speter#
52717308Speterinclude-tools:
52834520Sbde.for d in usr.bin/compile_et usr.bin/rpcgen
52936074Sbde	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
53036074Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
53136074Sbde		${MAKE} ${MK_FLAGS} all; \
53230113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
53334520Sbde.endfor
53417308Speter
53517308Speter#
53617308Speter# includes - possibly generate and install the include files.
53717308Speter#
53814119Speterincludes:
5392061Sjkh.if defined(CLOBBER)
5407130Srgrimes	rm -rf ${DESTDIR}/usr/include/*
5417130Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
5427130Srgrimes		-p ${DESTDIR}/usr/include
5432061Sjkh.endif
54436074Sbde	cd ${.CURDIR}/include;			${MAKE} -B all install
54536074Sbde	cd ${.CURDIR}/gnu/include;		${MAKE} install
54636074Sbde	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
54736074Sbde	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
54836074Sbde	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
54936074Sbde	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
55036074Sbde	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
55136074Sbde	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
55236074Sbde	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
55336074Sbde	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
55430169Sjkh.if exists(secure) && !defined(NOCRYPT)
55536074Sbde	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
5563197Scsgr.endif
55730169Sjkh.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
55836074Sbde	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
55936074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
56036074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
56136074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
56236074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
56336074Sbde	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
56430169Sjkh.else
56536074Sbde	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
56630169Sjkh.endif
56732427Sjb.if exists(${.CURDIR}/lib/csu/${MACHINE})
56836074Sbde	cd ${.CURDIR}/lib/csu/${MACHINE};	${MAKE} beforeinstall
56932427Sjb.endif
57036074Sbde	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
57136074Sbde	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
57236074Sbde	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
57336074Sbde	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
57436074Sbde	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
57536074Sbde	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
57636074Sbde	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
57736074Sbde	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
57836074Sbde	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
57936074Sbde	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
5807281Srgrimes.if !defined(WANT_CSRG_LIBM)
58136074Sbde	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
5823242Spaul.endif
58336074Sbde	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
58436074Sbde	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
58536074Sbde	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
58636074Sbde	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
58730169Sjkh.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
58830169Sjkh	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
58936074Sbde	cd ${.CURDIR}/lib/libtcl;		${MAKE} installhdrs
59030169Sjkh.endif
59136074Sbde	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
59236074Sbde	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
59336074Sbde	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
59436074Sbde	cd ${.CURDIR}/lib/libscsi;		${MAKE} beforeinstall
59536074Sbde	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
59636074Sbde	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
59736074Sbde	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
59836074Sbde	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
59936074Sbde	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
6002061Sjkh
60117308Speter#
60236638Sjb# Declare tools if they are not required on all architectures.
60336638Sjb#
60436638Sjb.if ${MACHINE_ARCH} == "i386"
60536638Sjb# aout tools:
60636638Sjb_aout_ar	= usr.bin/ar
60736638Sjb_aout_as	= gnu/usr.bin/as
60836638Sjb_aout_ld	= gnu/usr.bin/ld
60936638Sjb_aout_nm	= usr.bin/nm
61036638Sjb_aout_ranlib	= usr.bin/ranlib
61136638Sjb_aout_size	= usr.bin/size
61236638Sjb_aout_strip	= usr.bin/strip
61336638Sjb_objformat	= usr.bin/objformat
61436638Sjb.endif
61536638Sjb
61636638Sjb#
61717308Speter# lib-tools - build tools to compile and install the libraries.
61817308Speter#
61927910Sasami# XXX gperf is required for cc
62027910Sasami# XXX a new ld and tsort is required for cc
6215366Snatelib-tools:
62227910Sasami.for d in				\
62327910Sasami		gnu/usr.bin/gperf	\
62436638Sjb		${_aout_ld}		\
62527910Sasami		usr.bin/tsort		\
62636638Sjb		${_aout_as}		\
62727910Sasami		gnu/usr.bin/bison	\
62827910Sasami		gnu/usr.bin/cc		\
62936638Sjb		${_aout_ar}		\
63036683Sbde		usr.bin/env		\
63127910Sasami		usr.bin/lex/lib		\
63227910Sasami		usr.bin/mk_cmds		\
63336638Sjb		${_aout_nm}		\
63436638Sjb		${_aout_ranlib}		\
63536638Sjb		${_aout_strip}		\
63636374Ssos		gnu/usr.bin/binutils	\
63736419Speter		usr.bin/uudecode	\
63836638Sjb		${_objformat}
63936074Sbde	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
64036074Sbde		${MAKE} ${MK_FLAGS} all; \
64136074Sbde		${MAKE} ${MK_FLAGS} -B install; \
64234575Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
64327910Sasami.endfor
6445366Snate
64517308Speter#
64635427Sbde# We have to know too much about ordering and subdirs in the lib trees:
64717308Speter#
64835427Sbde# To satisfy shared library linkage when only the libraries being built
64935427Sbde# are visible:
65035427Sbde#
65135427Sbde# libcom_err must be built before libss.
65235427Sbde# libcrypt and libmd must be built before libskey.
65335427Sbde# libm must be built before libtcl.
65435427Sbde# libmytinfo must be built before libdialog and libncurses.
65535427Sbde# libncurses must be built before libdialog.
65635427Sbde# libtermcap must be built before libcurses, libedit and libreadline.
65735427Sbde#
65835427Sbde# Some libraries are built conditionally and/or are in inconsistently
65935427Sbde# named directories:
66035427Sbde#
66135427Sbde.if exists(lib/csu/${MACHINE}.pcc)
66235427Sbde_csu=lib/csu/${MACHINE}.pcc
66334541Sbde.else
66435427Sbde_csu=lib/csu/${MACHINE}
66524754Sjdp.endif
66634541Sbde
66736683Sbde.if !defined(NOSECURE) && !defined(NOCRYPT)
66836683Sbde_libcrypt=	secure/lib/libcrypt lib/libcrypt
66936444Speter.else
67035427Sbde_libcrypt=	lib/libcrypt
67135427Sbde.endif
67235427Sbde
67334541Sbde.if defined(WANT_CSRG_LIBM)
67435427Sbde_libm=	lib/libm
67534541Sbde.else
67635427Sbde_libm=	lib/msun
6778295Srgrimes.endif
67834541Sbde
67934541Sbde#
68035427Sbde# bootstrap-libraries - build just enough libraries for the bootstrap
68135427Sbde# tools, and install them under ${WORLDTMP}.
68234541Sbde#
68335427Sbde# Build csu and libgcc early so that some tools get linked to the new
68435427Sbde# versions (too late for the main tools, however).  Then build the
68535427Sbde# necessary prerequisite libraries (libtermcap just needs to be before
68635427Sbde# libcurses, and this only matters for the NOCLEAN case when NOPIC is
68735427Sbde# not set).
68834541Sbde#
68935427Sbde# This is mostly wrong.  The build tools must run on the host system,
69035427Sbde# so they should use host libraries.  We depend on the target being
69135427Sbde# similar enough to the host for new target libraries to work on the
69235427Sbde# host.
69334541Sbde#
69435427Sbdebootstrap-libraries:
69535427Sbde.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
69636397Ssos    gnu/lib/libregex gnu/lib/libreadline lib/libc \
69736444Speter    ${_libcrypt} lib/libcurses lib/libedit ${_libm} \
69835427Sbde    lib/libmd lib/libutil lib/libz usr.bin/lex/lib
69934541Sbde.if exists(${.CURDIR}/${_lib})
70036074Sbde	cd ${.CURDIR}/${_lib}; \
70136074Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
70236074Sbde		${MAKE} ${MK_FLAGS} all; \
70330113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
7048489Srgrimes.endif
70534541Sbde.endfor
70635427Sbde
70735427Sbde#
70835427Sbde# libraries - build all libraries, and install them under ${DESTDIR}.
70935427Sbde#
71035427Sbde# The ordering is not as special as for bootstrap-libraries.  Build
71135427Sbde# the prerequisites first, then build almost everything else in
71235427Sbde# alphabetical order.
71335427Sbde#
71435427Sbdelibraries:
71535427Sbde.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
71635427Sbde    lib/libncurses lib/libtermcap \
71735427Sbde    gnu/lib gnu/usr.bin/cc/libgcc lib usr.bin/lex/lib usr.sbin/pcvt/keycap
71835427Sbde.if exists(${.CURDIR}/${_lib})
71936074Sbde	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
72035427Sbde.endif
72135427Sbde.endfor
72234541Sbde.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
72336074Sbde	cd ${.CURDIR}/secure/lib; ${MAKE} all; ${MAKE} -B install
7242160Scsgr.endif
72534541Sbde.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
72634541Sbde    defined(MAKE_KERBEROS4)
72736074Sbde	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} all; ${MAKE} -B install
7282626Scsgr.endif
7292061Sjkh
73036589Sjhay# Exclude perl from the build-tools if NOPERL is defined.
73136589Sjhay.if defined(NOPERL)
73236589Sjhay_perl=
73336589Sjhay.else
73436589Sjhay_perl=	gnu/usr.bin/perl/perl
73536589Sjhay.endif
73636589Sjhay
73717308Speter#
73817308Speter# build-tools - build and install any other tools needed to complete the
73917308Speter# compile and install.
74027910Sasami# ifdef stale
74127910Sasami# bc and cpp are required to build groff.  Otherwise, the order here is
74227910Sasami# mostly historical, i.e., bogus.
74327910Sasami# chmod is used to build gcc's tmpmultilib[2] at obscure times.
74427910Sasami# endif stale
74527910Sasami# XXX uname is a bug - the target should not depend on the host.
74617308Speter#
74711806Sphkbuild-tools:
74819175Sbde.for d in				\
74927910Sasami		bin/cat 		\
75027910Sasami		bin/chmod		\
75127910Sasami		bin/cp 			\
75227910Sasami		bin/date		\
75327910Sasami		bin/dd			\
75427910Sasami		bin/echo		\
75527910Sasami		bin/expr		\
75627910Sasami		bin/hostname		\
75727910Sasami		bin/ln			\
75827910Sasami		bin/ls			\
75927910Sasami		bin/mkdir		\
76027910Sasami		bin/mv			\
76127910Sasami		bin/rm			\
76227910Sasami		bin/test		\
76327910Sasami		gnu/usr.bin/awk		\
76427910Sasami		gnu/usr.bin/bc		\
76527910Sasami		gnu/usr.bin/grep	\
76627910Sasami		gnu/usr.bin/groff	\
76727910Sasami		gnu/usr.bin/gzip	\
76827910Sasami		gnu/usr.bin/man/makewhatis	\
76935621Sbde		gnu/usr.bin/patch	\
77036589Sjhay		${_perl}		\
77127910Sasami		gnu/usr.bin/sort	\
77234509Sbde		gnu/usr.bin/texinfo	\
77327910Sasami		usr.bin/basename	\
77427910Sasami		usr.bin/cap_mkdb	\
77527910Sasami		usr.bin/chflags		\
77627910Sasami		usr.bin/cmp		\
77727910Sasami		usr.bin/col		\
77827910Sasami		usr.bin/cpp		\
77927910Sasami		usr.bin/expand		\
78027910Sasami		usr.bin/file2c		\
78127910Sasami		usr.bin/find		\
78227910Sasami		usr.bin/gencat		\
78336454Sjkh		usr.bin/id		\
78436939Speter		usr.bin/join		\
78527910Sasami		usr.bin/lorder		\
78627910Sasami		usr.bin/m4		\
78727910Sasami		usr.bin/mkdep		\
78827910Sasami		usr.bin/paste		\
78927910Sasami		usr.bin/sed		\
79036638Sjb		${_aout_size}		\
79127910Sasami		usr.bin/soelim		\
79219175Sbde		usr.bin/symorder	\
79327910Sasami		usr.bin/touch		\
79427910Sasami		usr.bin/tr		\
79527910Sasami		usr.bin/true		\
79627910Sasami		usr.bin/uname		\
79727910Sasami		usr.bin/uuencode	\
79827910Sasami		usr.bin/vgrind		\
79927910Sasami		usr.bin/vi		\
80027910Sasami		usr.bin/wc		\
80134688Sbde		usr.bin/xargs		\
80227910Sasami		usr.bin/yacc		\
80327910Sasami		usr.sbin/chown		\
80427910Sasami		usr.sbin/mtree		\
80536455Sjkh		usr.sbin/zic		\
80636455Sjkh		bin/sh
80736074Sbde	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
80836074Sbde		${MAKE} ${MK_FLAGS} all; \
80930113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
81019175Sbde.endfor
8112061Sjkh
81235479Sbde.for __target in clean cleandepend cleandir depend obj
81330113Sjkh.for entry in ${SUBDIR}
81430113Sjkh${entry}.${__target}__D: .PHONY
81535294Sdt	@if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
81630113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
81730113Sjkh		edir=${entry}.${MACHINE}; \
81830113Sjkh		cd ${.CURDIR}/$${edir}; \
81930113Sjkh	else \
82030113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
82130113Sjkh		edir=${entry}; \
82230113Sjkh		cd ${.CURDIR}/$${edir}; \
82330113Sjkh	fi; \
82430113Sjkh	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
82530113Sjkh.endfor
82630113Sjkhpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
82730113Sjkh.endfor
82830113Sjkh
82932427Sjb.endif
83032427Sjb
8311594Srgrimes.include <bsd.subdir.mk>
832