Makefile revision 34592
12061Sjkh#
234592Sbde#	$Id: Makefile,v 1.164 1998/03/14 13:58:21 bde Exp $
32061Sjkh#
433611Sjb# While porting to the another architecture include the bootstrap instead
532427Sjb# of the normal build.
632427Sjb#
733611Sjb.if exists(${.CURDIR}/Makefile.${MACHINE})
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
1420710Sasami#	-DALLLANG to build documentation for all languages
1520710Sasami#	  (where available -- see share/doc/Makefile)
163197Scsgr#
172061Sjkh#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
1812483Speter#	-DNOCLEAN do not clean at all
1934509Sbde#	-DNOTOOLS do not rebuild any tools first
202160Scsgr#	-DNOCRYPT will prevent building of crypt versions
212834Swollman#	-DNOLKM do not build loadable kernel modules
222061Sjkh#	-DNOOBJDIR do not run ``${MAKE} obj''
232061Sjkh#	-DNOPROFILE do not build profiled libraries
242160Scsgr#	-DNOSECURE do not go into secure subdir
2517308Speter#	-DNOGAMES do not go into games subdir
2619320Sadam#	-DNOSHARE do not go into share subdir
2727788Sasami#	-DNOINFO do not make or install info files
2830169Sjkh#	-DNOLIBC_R do not build libc_r.
2925980Sasami#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
301594Srgrimes
3117308Speter#
3217308Speter# The intended user-driven targets are:
3327910Sasami# buildworld  - rebuild *everything*, including glue to help do upgrades
3427910Sasami# installworld- install everything built by "buildworld"
3527910Sasami# world       - buildworld + installworld
3617308Speter# update      - convenient way to update your source tree (eg: sup/cvs)
3717308Speter# most        - build user commands, no libraries or include files
3817308Speter# installmost - install user commands, no libraries or include files
3919175Sbde#
4019175Sbde# Standard targets (not defined here) are documented in the makefiles in
4119175Sbde# /usr/share/mk.  These include:
4219175Sbde#		obj depend all install clean cleandepend cleanobj
4317308Speter
4427910Sasami.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
4534509Sbde.MAKEFLAGS:=	-m ${.CURDIR}/share/mk ${.MAKEFLAGS}
4627910Sasami.endif
4717308Speter
482061Sjkh# Put initial settings here.
492061SjkhSUBDIR=
501594Srgrimes
5130169Sjkh# We must do share/info early so that installation of info `dir'
5230169Sjkh# entries works correctly.  Do it first since it is less likely to
5330169Sjkh# grow dependencies on include and lib than vice versa.
5430169Sjkh.if exists(share/info)
5530169SjkhSUBDIR+= share/info
5630169Sjkh.endif
5730169Sjkh
5830169Sjkh# We must do include and lib early so that the perl *.ph generation
597407Srgrimes# works correctly as it uses the header files installed by this.
607108Sphk.if exists(include)
617108SphkSUBDIR+= include
627108Sphk.endif
637407Srgrimes.if exists(lib)
647407SrgrimesSUBDIR+= lib
657407Srgrimes.endif
667108Sphk
672061Sjkh.if exists(bin)
682061SjkhSUBDIR+= bin
692061Sjkh.endif
7017308Speter.if exists(games) && !defined(NOGAMES)
712061SjkhSUBDIR+= games
722061Sjkh.endif
732061Sjkh.if exists(gnu)
742061SjkhSUBDIR+= gnu
752061Sjkh.endif
7630169Sjkh.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
7730169SjkhSUBDIR+= kerberosIV
782626Scsgr.endif
792061Sjkh.if exists(libexec)
802061SjkhSUBDIR+= libexec
812061Sjkh.endif
822061Sjkh.if exists(sbin)
832061SjkhSUBDIR+= sbin
842061Sjkh.endif
8519320Sadam.if exists(share) && !defined(NOSHARE)
862061SjkhSUBDIR+= share
872061Sjkh.endif
882061Sjkh.if exists(sys)
892061SjkhSUBDIR+= sys
902061Sjkh.endif
912061Sjkh.if exists(usr.bin)
922061SjkhSUBDIR+= usr.bin
932061Sjkh.endif
942061Sjkh.if exists(usr.sbin)
952061SjkhSUBDIR+= usr.sbin
962061Sjkh.endif
972834Swollman.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
982834SwollmanSUBDIR+= secure
992834Swollman.endif
1002834Swollman.if exists(lkm) && !defined(NOLKM)
1012834SwollmanSUBDIR+= lkm
1022834Swollman.endif
1031594Srgrimes
1044486Sphk# etc must be last for "distribute" to work
1054486Sphk.if exists(etc) && make(distribute)
1064486SphkSUBDIR+= etc
1074486Sphk.endif
1084486Sphk
1092061Sjkh# These are last, since it is nice to at least get the base system
1102061Sjkh# rebuilt before you do them.
11125979Sjkh.if defined(LOCAL_DIRS)
11225979Sjkh.for _DIR in ${LOCAL_DIRS}
11325979Sjkh.if exists(${_DIR}) & exists(${_DIR}/Makefile)
11425979SjkhSUBDIR+= ${_DIR}
1152061Sjkh.endif
11625979Sjkh.endfor
1172061Sjkh.endif
1182061Sjkh
11917308Speter# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
1202061Sjkh.if defined(NOOBJDIR)
1212061SjkhOBJDIR=
1222061Sjkh.else
1232061SjkhOBJDIR=		obj
1242061Sjkh.endif
12512483Speter
12612483Speter.if defined(NOCLEAN)
12712483SpeterCLEANDIR=
12812483Speter.else
1292061Sjkh.if defined(NOCLEANDIR)
1302061SjkhCLEANDIR=	clean
1318854Srgrimes.else
1322061SjkhCLEANDIR=	cleandir
1332061Sjkh.endif
13412483Speter.endif
1352061Sjkh
13627910SasamiSUP?=		sup
13727910SasamiSUPFLAGS?=	-v
13818714Sache
13917308Speter#
14034541Sbde# While building tools for bootstrapping, we don't need to waste time on
14134575Sbde# shared or profiled libraries, shared linkage, or documentation, except
14234575Sbde# when the tools won't get cleaned we must use the defaults for shared
14334575Sbde# libraries and shared linkage (and this doesn't waste time).
14434592Sbde# XXX actually, we do need to waste time building shared libraries.
14517308Speter#
14634575Sbde.if defined(NOCLEAN)
14734592SbdeMK_FLAGS=	-DNOINFO -DNOMAN -DNOPROFILE
14834575Sbde.else
14934592SbdeMK_FLAGS=	-DNOINFO -DNOMAN -DNOPROFILE -DNOSHARED
15034575Sbde.endif
15115603Smarkm
15217308Speter#
15317308Speter# world
15417308Speter#
15517308Speter# Attempt to rebuild and reinstall *everything*, with reasonable chance of
15617308Speter# success, regardless of how old your existing system is.
15717308Speter#
15817308Speter# >> Beware, it overwrites the local build environment! <<
15917308Speter#
16017308Speterworld:
16118362Sjkh	@echo "--------------------------------------------------------------"
16219966Sache	@echo "make world started on `LC_TIME=C date`"
16318362Sjkh	@echo "--------------------------------------------------------------"
16417308Speter.if target(pre-world)
16527910Sasami	@echo
16617308Speter	@echo "--------------------------------------------------------------"
16717308Speter	@echo " Making 'pre-world' target"
16817308Speter	@echo "--------------------------------------------------------------"
16928803Speter	cd ${.CURDIR} && ${MAKE} pre-world
17027910Sasami.endif
17128803Speter	cd ${.CURDIR} && ${MAKE} buildworld
17230113Sjkh	cd ${.CURDIR} && ${MAKE} -B installworld
17327910Sasami.if target(post-world)
17417308Speter	@echo
1752061Sjkh	@echo "--------------------------------------------------------------"
17627910Sasami	@echo " Making 'post-world' target"
1772061Sjkh	@echo "--------------------------------------------------------------"
17828803Speter	cd ${.CURDIR} && ${MAKE} post-world
17927910Sasami.endif
1802061Sjkh	@echo
18117308Speter	@echo "--------------------------------------------------------------"
18227910Sasami	@echo "make world completed on `LC_TIME=C date`"
18317308Speter	@echo "--------------------------------------------------------------"
18427910Sasami
18527910Sasami.if defined(MAKEOBJDIRPREFIX)
18627910SasamiWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
18717308Speter.else
18827910SasamiWORLDTMP=	/usr/obj${.CURDIR}/tmp
18917308Speter.endif
19027910SasamiSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
19127910SasamiTMPPATH=	${STRICTTMPPATH}:${PATH}
19227910Sasami
19327910Sasami# XXX COMPILER_PATH is needed for finding cc1, ld and as
19427910Sasami# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
19527910Sasami#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
19627910Sasami#	wouldn't link *crt.o or libgcc if it were used.
19727910Sasami# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
19827910Sasami#	want that - all compile-time library paths should be resolved by gcc.
19927910Sasami#	It fails for set[ug]id executables (are any used?).
20027910SasamiCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
20127910Sasami		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
20234509Sbde		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
20327910Sasami		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
20427910Sasami		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
20527910Sasami
20627910SasamiBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
20727910SasamiXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
20827910Sasami		CC='cc -nostdinc'	# XXX -nostdlib
20927910Sasami
21027910Sasami# used to compile and install 'make' in temporary build tree
21127910SasamiIBMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
21227910Sasami# bootstrap make
21327910SasamiBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
21427910Sasami# cross make used for compilation
21527910SasamiXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
21627910Sasami# cross make used for final installation
21727910SasamiIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
21827910Sasami
21927910Sasami#
22027910Sasami# buildworld
22127910Sasami#
22227910Sasami# Attempt to rebuild the entire system, with reasonable chance of
22327910Sasami# success, regardless of how old your existing system is.
22427910Sasami#
22527910Sasamibuildworld:
22627910Sasami.if !defined(NOCLEAN)
22717308Speter	@echo
22817308Speter	@echo "--------------------------------------------------------------"
22927910Sasami	@echo " Cleaning up the temporary build tree"
23017308Speter	@echo "--------------------------------------------------------------"
23127910Sasami	mkdir -p ${WORLDTMP}
23227910Sasami	chflags -R noschg ${WORLDTMP}/
23327910Sasami	rm -rf ${WORLDTMP}
23427910Sasami.endif
23533133Sadam.if !defined(NOTOOLS)
23617466Speter	@echo
23717308Speter	@echo "--------------------------------------------------------------"
23827910Sasami	@echo " Making make"
23917308Speter	@echo "--------------------------------------------------------------"
24027910Sasami	mkdir -p ${WORLDTMP}/usr/bin
24130277Sasami.if !defined(NOCLEAN) || !defined(NOOBJDIR)
24227910Sasami	cd ${.CURDIR}/usr.bin/make && \
24330277Sasami		${IBMAKE} -I${.CURDIR}/share/mk ${CLEANDIR} ${OBJDIR}
24430277Sasami.endif
24530277Sasami	cd ${.CURDIR}/usr.bin/make && \
24634509Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} depend && \
24730113Sjkh		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all && \
24830277Sasami		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install && \
24930277Sasami		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean cleandepend
25033133Sadam.endif
25117308Speter	@echo
25217308Speter	@echo "--------------------------------------------------------------"
25327910Sasami	@echo " Making hierarchy"
25417308Speter	@echo "--------------------------------------------------------------"
25527910Sasami	cd ${.CURDIR} && ${BMAKE} hierarchy
25627910Sasami.if !defined(NOCLEAN)
25717308Speter	@echo
25817308Speter	@echo "--------------------------------------------------------------"
25927910Sasami	@echo " Cleaning up the obj tree"
26017308Speter	@echo "--------------------------------------------------------------"
26130113Sjkh	cd ${.CURDIR} && ${BMAKE} par-${CLEANDIR}
26227910Sasami.endif
26327910Sasami.if !defined(NOOBJDIR)
26417308Speter	@echo
26517308Speter	@echo "--------------------------------------------------------------"
26627910Sasami	@echo " Rebuilding the obj tree"
26717308Speter	@echo "--------------------------------------------------------------"
26834509Sbde	cd ${.CURDIR} && ${BMAKE} par-${OBJDIR}
26927910Sasami.endif
27033133Sadam.if !defined(NOTOOLS)
27117308Speter	@echo
27217308Speter	@echo "--------------------------------------------------------------"
27327910Sasami	@echo " Rebuilding bootstrap tools"
27417308Speter	@echo "--------------------------------------------------------------"
27527910Sasami	cd ${.CURDIR} && ${BMAKE} bootstrap
27617308Speter	@echo
27717308Speter	@echo "--------------------------------------------------------------"
27827910Sasami	@echo " Rebuilding tools necessary to build the include files"
27917308Speter	@echo "--------------------------------------------------------------"
28027910Sasami	cd ${.CURDIR} && ${BMAKE} include-tools
28133133Sadam.endif
28217308Speter	@echo
28317308Speter	@echo "--------------------------------------------------------------"
28434509Sbde	@echo " Rebuilding ${DESTDIR}/usr/include"
28517308Speter	@echo "--------------------------------------------------------------"
28629503Sbde	cd ${.CURDIR} && SHARED=symlinks ${BMAKE} includes
28733133Sadam.if !defined(NOTOOLS)
28817962Speter	@echo
28917962Speter	@echo "--------------------------------------------------------------"
29027910Sasami	@echo " Rebuilding tools needed to build the libraries"
29117962Speter	@echo "--------------------------------------------------------------"
29227910Sasami	cd ${.CURDIR} && ${BMAKE} lib-tools
29333133Sadam.endif
29417962Speter	@echo
29517962Speter	@echo "--------------------------------------------------------------"
29634509Sbde	@echo " Rebuilding ${DESTDIR}/usr/lib"
29717962Speter	@echo "--------------------------------------------------------------"
29827910Sasami	cd ${.CURDIR} && ${BMAKE} libraries
29933133Sadam.if !defined(NOTOOLS)
30017962Speter	@echo
30117962Speter	@echo "--------------------------------------------------------------"
30227910Sasami	@echo " Rebuilding all other tools needed to build the world"
30317962Speter	@echo "--------------------------------------------------------------"
30427910Sasami	cd ${.CURDIR} && ${BMAKE} build-tools
30533133Sadam.endif
30617308Speter	@echo
30717308Speter	@echo "--------------------------------------------------------------"
30827910Sasami	@echo " Rebuilding dependencies"
30917308Speter	@echo "--------------------------------------------------------------"
31030205Sbde	cd ${.CURDIR} && ${XMAKE} par-depend
31117308Speter	@echo
31217308Speter	@echo "--------------------------------------------------------------"
31327910Sasami	@echo " Building everything.."
31417962Speter	@echo "--------------------------------------------------------------"
31527910Sasami	cd ${.CURDIR} && ${XMAKE} all
3162061Sjkh
31717308Speter#
31827910Sasami# installworld
31927910Sasami#
32027910Sasami# Installs everything compiled by a 'buildworld'.
32127910Sasami#
32227910Sasamiinstallworld:
32327910Sasami	cd ${.CURDIR} && ${IXMAKE} reinstall
32427910Sasami
32527910Sasami#
32617308Speter# reinstall
32717308Speter#
32817308Speter# If you have a build server, you can NFS mount the source and obj directories
32917308Speter# and do a 'make reinstall' on the *client* to install new binaries from the
33017308Speter# most recent server build.
33117308Speter#
33217308Speterreinstall:
33312483Speter	@echo "--------------------------------------------------------------"
33417308Speter	@echo " Making hierarchy"
33512483Speter	@echo "--------------------------------------------------------------"
33617308Speter	cd ${.CURDIR} && ${MAKE} hierarchy
33712483Speter	@echo
3382061Sjkh	@echo "--------------------------------------------------------------"
33917962Speter	@echo " Installing everything.."
34017962Speter	@echo "--------------------------------------------------------------"
34117308Speter	cd ${.CURDIR} && ${MAKE} install
34217962Speter	@echo
34317962Speter	@echo "--------------------------------------------------------------"
34433595Snate	@echo " Re-scanning the shared libraries.."
34533595Snate	@echo "--------------------------------------------------------------"
34633595Snate	cd ${.CURDIR} && ldconfig -R
34733595Snate	@echo
34833595Snate	@echo "--------------------------------------------------------------"
34917962Speter	@echo " Rebuilding man page indexes"
35017962Speter	@echo "--------------------------------------------------------------"
35117308Speter	cd ${.CURDIR}/share/man && ${MAKE} makedb
3522061Sjkh
35317308Speter#
35417308Speter# update
35517308Speter#
35617308Speter# Update the source tree, by running sup and/or running cvs to update to the
35717308Speter# latest copy.
35817308Speter#
3592302Spaulupdate:
3602302Spaul.if defined(SUP_UPDATE)
3612302Spaul	@echo "--------------------------------------------------------------"
3622302Spaul	@echo "Running sup"
3632302Spaul	@echo "--------------------------------------------------------------"
36418714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE}
36510760Sache.if defined(SUPFILE1)
36618714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE1}
3672302Spaul.endif
36810760Sache.if defined(SUPFILE2)
36918714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE2}
37010760Sache.endif
37110760Sache.endif
3722302Spaul.if defined(CVS_UPDATE)
3732302Spaul	@echo "--------------------------------------------------------------"
3742302Spaul	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
3752302Spaul	@echo "--------------------------------------------------------------"
37630132Sfsmp	cd ${.CURDIR} && cvs -q update -P -d
3772302Spaul.endif
3782302Spaul
37917308Speter#
38017308Speter# most
38117308Speter#
38217308Speter# Build most of the user binaries on the existing system libs and includes.
38317308Speter#
38417308Spetermost:
3852061Sjkh	@echo "--------------------------------------------------------------"
38617308Speter	@echo " Building programs only"
3872061Sjkh	@echo "--------------------------------------------------------------"
38830205Sbde	cd ${.CURDIR}/bin	&&	${MAKE} all
38930205Sbde	cd ${.CURDIR}/sbin	&&	${MAKE} all
39030205Sbde	cd ${.CURDIR}/libexec	&&	${MAKE} all
39130205Sbde	cd ${.CURDIR}/usr.bin	&&	${MAKE} all
39230205Sbde	cd ${.CURDIR}/usr.sbin	&&	${MAKE} all
39330205Sbde	cd ${.CURDIR}/gnu/libexec &&	${MAKE} all
39430205Sbde	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} all
39530205Sbde	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} all
39630169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
39730205Sbde#	cd ${.CURDIR}/kerberosIV	&&	${MAKE} most
39817308Speter#.endif
39917308Speter#.if !defined(NOSECURE) && !defined(NOCRYPT)
40030205Sbde#	cd ${.CURDIR}/secure	&&	${MAKE} most
40117308Speter#.endif
4022061Sjkh
40317308Speter#
40417308Speter# installmost
40517308Speter#
40617308Speter# Install the binaries built by the 'most' target.  This does not include
40717308Speter# libraries or include files.
40817308Speter#
4093626Swollmaninstallmost:
4103626Swollman	@echo "--------------------------------------------------------------"
4113626Swollman	@echo " Installing programs only"
4123626Swollman	@echo "--------------------------------------------------------------"
41330205Sbde	cd ${.CURDIR}/bin	&&	${MAKE} install
41430205Sbde	cd ${.CURDIR}/sbin	&&	${MAKE} install
41530205Sbde	cd ${.CURDIR}/libexec	&&	${MAKE} install
41630205Sbde	cd ${.CURDIR}/usr.bin	&&	${MAKE} install
41730205Sbde	cd ${.CURDIR}/usr.sbin	&&	${MAKE} install
41830205Sbde	cd ${.CURDIR}/gnu/libexec &&	${MAKE} install
41930205Sbde	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} install
42030205Sbde	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} install
42130169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
42230205Sbde#	cd ${.CURDIR}/kerberosIV &&	${MAKE} installmost
4233626Swollman#.endif
4243626Swollman#.if !defined(NOSECURE) && !defined(NOCRYPT)
42530205Sbde#	cd ${.CURDIR}/secure	&&	${MAKE} installmost
4263626Swollman#.endif
4273626Swollman
42817308Speter#
42917308Speter# ------------------------------------------------------------------------
43017308Speter#
43117308Speter# From here onwards are utility targets used by the 'make world' and
43217308Speter# related targets.  If your 'world' breaks, you may like to try to fix
43317308Speter# the problem and manually run the following targets to attempt to
43417308Speter# complete the build.  Beware, this is *not* guaranteed to work, you
43517308Speter# need to have a pretty good grip on the current state of the system
43617308Speter# to attempt to manually finish it.  If in doubt, 'make world' again.
43717308Speter#
4383626Swollman
43917308Speter#
44017308Speter# heirarchy - ensure that all the needed directories are present
44117308Speter#
44217308Speterhierarchy:
44317308Speter	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
44417308Speter
44517308Speter#
44617308Speter# bootstrap - [re]build tools needed to run the actual build, this includes
44717308Speter# tools needed by 'make depend', as some tools are needed to generate source
44817308Speter# for the dependency information to be gathered from.
44917308Speter#
45017308Speterbootstrap:
45127910Sasami.if defined(DESTDIR)
45227910Sasami	rm -f ${DESTDIR}/usr/src/sys
45327910Sasami	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
45427910Sasami	cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
45534575Sbde	cd ${.CURDIR}/include && ${MAKE} symlinks
45627910Sasami.endif
45734509Sbde	cd ${.CURDIR}/usr.bin/make && ${MAKE} ${MK_FLAGS} depend && \
45830113Sjkh		${MAKE} ${MK_FLAGS} all && \
45930113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
46034509Sbde	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} ${MK_FLAGS} depend && \
46130113Sjkh		${MAKE} ${MK_FLAGS} all && \
46230113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
46334509Sbde	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && \
46434509Sbde		${MAKE} ${MK_FLAGS} depend && \
46530170Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB all && \
46630113Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
46729938Smckay.if !defined(NOOBJDIR)
46834509Sbde	cd ${.CURDIR}/usr.bin/lex && ${MAKE} ${OBJDIR}
46929938Smckay.endif
47017308Speter
47117308Speter#
47217308Speter# include-tools - generally the same as 'bootstrap', except that it's for
47317308Speter# things that are specifically needed to generate include files.
47417308Speter#
47527910Sasami# XXX should be merged with bootstrap, it's not worth keeeping them separate.
47627910Sasami# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
47727910Sasami# on cleaned away headers in ${WORLDTMP}.
47817308Speter#
47917308Speterinclude-tools:
48034520Sbde.for d in usr.bin/compile_et usr.bin/rpcgen
48134520Sbde	cd ${.CURDIR}/$d && ${MAKE} cleandepend && \
48234509Sbde		${MAKE} ${MK_FLAGS} depend && \
48330113Sjkh		${MAKE} ${MK_FLAGS} all && \
48430113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
48534520Sbde.endfor
48617308Speter
48717308Speter#
48817308Speter# includes - possibly generate and install the include files.
48917308Speter#
49014119Speterincludes:
4912061Sjkh.if defined(CLOBBER)
4927130Srgrimes	rm -rf ${DESTDIR}/usr/include/*
4937130Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
4947130Srgrimes		-p ${DESTDIR}/usr/include
4952061Sjkh.endif
49630113Sjkh	cd ${.CURDIR}/include &&		${MAKE} -B all install
49717308Speter	cd ${.CURDIR}/gnu/include &&		${MAKE} install
49830169Sjkh	cd ${.CURDIR}/gnu/lib/libmp &&		${MAKE} beforeinstall
49930169Sjkh	cd ${.CURDIR}/gnu/lib/libobjc &&	${MAKE} beforeinstall
5002685Srgrimes	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
5016927Snate	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
50227790Sasami	cd ${.CURDIR}/gnu/lib/libstdc++ &&	${MAKE} beforeinstall
50327790Sasami	cd ${.CURDIR}/gnu/lib/libg++ &&		${MAKE} beforeinstall
50427790Sasami	cd ${.CURDIR}/gnu/lib/libdialog &&	${MAKE} beforeinstall
50530169Sjkh	cd ${.CURDIR}/gnu/lib/libgmp &&		${MAKE} beforeinstall
50630169Sjkh.if exists(secure) && !defined(NOCRYPT)
50730169Sjkh	cd ${.CURDIR}/secure/lib/libdes &&	${MAKE} beforeinstall
5083197Scsgr.endif
50930169Sjkh.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
51030169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libacl &&	${MAKE} beforeinstall
51130169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkadm &&	${MAKE} beforeinstall
51230169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkafs &&	${MAKE} beforeinstall
51330169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkdb &&	${MAKE} beforeinstall
51430169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkrb &&	${MAKE} beforeinstall
51530169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libtelnet && ${MAKE} beforeinstall
51630169Sjkh.else
51730169Sjkh	cd ${.CURDIR}/lib/libtelnet &&		${MAKE} beforeinstall
51830169Sjkh.endif
51932427Sjb.if exists(${.CURDIR}/lib/csu/${MACHINE})
52032427Sjb	cd ${.CURDIR}/lib/csu/${MACHINE} &&	${MAKE} beforeinstall
52132427Sjb.endif
52226152Speter	cd ${.CURDIR}/lib/libalias &&		${MAKE} beforeinstall
5232061Sjkh	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
5242061Sjkh	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
52530169Sjkh	cd ${.CURDIR}/lib/libdisk &&		${MAKE} beforeinstall
5262061Sjkh	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
52716786Snate	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
5282883Sphk	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
52927790Sasami	cd ${.CURDIR}/lib/libmytinfo &&		${MAKE} beforeinstall
53017308Speter	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
5317281Srgrimes.if !defined(WANT_CSRG_LIBM)
5323242Spaul	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
5333242Spaul.endif
53430169Sjkh	cd ${.CURDIR}/lib/libopie &&		${MAKE} beforeinstall
5357171Sats	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
5362061Sjkh	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
5373213Spst	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
53830169Sjkh.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
53930169Sjkh	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
54030169Sjkh	cd ${.CURDIR}/lib/libtcl &&		${MAKE} installhdrs
54130169Sjkh.endif
54217308Speter	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
5435749Swollman	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
54434520Sbde	cd ${.CURDIR}/lib/libss &&		${MAKE} -B hdrs beforeinstall
54517308Speter	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
54617308Speter	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
54730169Sjkh	cd ${.CURDIR}/lib/libvgl &&		${MAKE} beforeinstall
54826504Sjhay	cd ${.CURDIR}/lib/libz &&		${MAKE} beforeinstall
54930169Sjkh	cd ${.CURDIR}/usr.bin/f2c &&		${MAKE} beforeinstall
55030169Sjkh	cd ${.CURDIR}/usr.bin/lex &&		${MAKE} beforeinstall
5512061Sjkh
55217308Speter#
55317308Speter# lib-tools - build tools to compile and install the libraries.
55417308Speter#
55527910Sasami# XXX gperf is required for cc
55627910Sasami# XXX a new ld and tsort is required for cc
5575366Snatelib-tools:
55827910Sasami.for d in				\
55927910Sasami		gnu/usr.bin/gperf	\
56027910Sasami		gnu/usr.bin/ld		\
56127910Sasami		usr.bin/tsort		\
56227910Sasami		gnu/usr.bin/as		\
56327910Sasami		gnu/usr.bin/bison	\
56427910Sasami		gnu/usr.bin/cc		\
56527910Sasami		usr.bin/ar		\
56627910Sasami		usr.bin/lex/lib		\
56727910Sasami		usr.bin/mk_cmds		\
56827910Sasami		usr.bin/nm		\
56927910Sasami		usr.bin/ranlib		\
57027910Sasami		usr.bin/uudecode
57134509Sbde	cd ${.CURDIR}/$d && ${MAKE} ${MK_FLAGS} depend && \
57230113Sjkh		${MAKE} ${MK_FLAGS} all && \
57334575Sbde		${MAKE} ${MK_FLAGS} install && \
57434575Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
57527910Sasami.endfor
5765366Snate
57717308Speter#
57817308Speter# libraries - build and install the libraries
57917308Speter#
58034541Sbde
58134541Sbde# We have to know too much about botches in the lib tree:
58234541Sbde.if exists(csu/${MACHINE}.pcc)
58334541Sbde_csu=csu/${MACHINE}.pcc
58434541Sbde.else
58534541Sbde_csu=csu/${MACHINE}
58624754Sjdp.endif
58734541Sbde
58834541Sbde.if defined(WANT_CSRG_LIBM)
58934541Sbde_libm=	libm
59034541Sbde.else
59134541Sbde_libm=	msun
5928295Srgrimes.endif
59334541Sbde
59434541Sbdelibraries:
59534541Sbde#
59634541Sbde# Build csu early so that some tools get linked to the new version (too
59734541Sbde# late for the main tools, however).
59834541Sbde#
59934541Sbde# To satisfy shared library or ELF linkage when only the libraries being
60034541Sbde# built are visible:
60134541Sbde#
60234541Sbde# libcom_err must be built before libss.
60334541Sbde# libcrypt and libmd must be built before libskey.
60434541Sbde# libm must be built before libtcl.
60534541Sbde# libmytinfo must be built before libdialog and libncurses.
60634541Sbde# libncurses must be built before libdialog.
60734541Sbde# libtermcap must be built before libcurses, libedit and libreadline.
60834541Sbde#
60934541Sbde.for _lib in ${_csu} libcom_err libcrypt ${_libm} libmytinfo \
61034541Sbde	     libncurses libtermcap
61134541Sbde.if exists(${.CURDIR}/lib/${_lib})
61234541Sbde	cd ${.CURDIR}/lib/${_lib} && \
61334541Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} depend && \
61434541Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} all && \
61534541Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B install
6168489Srgrimes.endif
61734541Sbde.endfor
61834541Sbde.for _lib in gnu/lib lib usr.bin/lex/lib usr.sbin/pcvt/keycap
61934541Sbde.if exists(${.CURDIR}/${_lib})
62034541Sbde	cd ${.CURDIR}/${_lib} && \
62134541Sbde		${MAKE} ${MK_FLAGS} depend && \
62230113Sjkh		${MAKE} ${MK_FLAGS} all && \
62330113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6248489Srgrimes.endif
62534541Sbde.endfor
62634541Sbde.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
62734509Sbde	cd ${.CURDIR}/secure/lib && ${MAKE} ${MK_FLAGS} depend && \
62830113Sjkh		${MAKE} ${MK_FLAGS} all && \
62930113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6302160Scsgr.endif
63134541Sbde.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
63234541Sbde    defined(MAKE_KERBEROS4)
63334509Sbde	cd ${.CURDIR}/kerberosIV/lib && ${MAKE} ${MK_FLAGS} depend && \
63430113Sjkh		${MAKE} ${MK_FLAGS} all && \
63530113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6362626Scsgr.endif
6372061Sjkh
63817308Speter#
63917308Speter# build-tools - build and install any other tools needed to complete the
64017308Speter# compile and install.
64127910Sasami# ifdef stale
64227910Sasami# bc and cpp are required to build groff.  Otherwise, the order here is
64327910Sasami# mostly historical, i.e., bogus.
64427910Sasami# chmod is used to build gcc's tmpmultilib[2] at obscure times.
64527910Sasami# endif stale
64627910Sasami# XXX uname is a bug - the target should not depend on the host.
64717308Speter#
64811806Sphkbuild-tools:
64919175Sbde.for d in				\
65027910Sasami		bin/cat 		\
65127910Sasami		bin/chmod		\
65227910Sasami		bin/cp 			\
65327910Sasami		bin/date		\
65427910Sasami		bin/dd			\
65527910Sasami		bin/echo		\
65627910Sasami		bin/expr		\
65727910Sasami		bin/hostname		\
65827910Sasami		bin/ln			\
65927910Sasami		bin/ls			\
66027910Sasami		bin/mkdir		\
66127910Sasami		bin/mv			\
66227910Sasami		bin/rm			\
66327910Sasami		bin/sh			\
66427910Sasami		bin/test		\
66527910Sasami		gnu/usr.bin/awk		\
66627910Sasami		gnu/usr.bin/bc		\
66727910Sasami		gnu/usr.bin/grep	\
66827910Sasami		gnu/usr.bin/groff	\
66927910Sasami		gnu/usr.bin/gzip	\
67027910Sasami		gnu/usr.bin/man/makewhatis	\
67127910Sasami		gnu/usr.bin/sort	\
67234509Sbde		gnu/usr.bin/texinfo	\
67321673Sjkh		share/info		\
67427910Sasami		usr.bin/basename	\
67527910Sasami		usr.bin/cap_mkdb	\
67627910Sasami		usr.bin/chflags		\
67727910Sasami		usr.bin/cmp		\
67827910Sasami		usr.bin/col		\
67927910Sasami		usr.bin/cpp		\
68027910Sasami		usr.bin/expand		\
68127910Sasami		usr.bin/file2c		\
68227910Sasami		usr.bin/find		\
68327910Sasami		usr.bin/gencat		\
68427910Sasami		usr.bin/lorder		\
68527910Sasami		usr.bin/m4		\
68627910Sasami		usr.bin/mkdep		\
68727910Sasami		usr.bin/paste		\
68827910Sasami		usr.bin/sed		\
68927910Sasami		usr.bin/size		\
69027910Sasami		usr.bin/soelim		\
69127910Sasami		usr.bin/strip		\
69219175Sbde		usr.bin/symorder	\
69327910Sasami		usr.bin/touch		\
69427910Sasami		usr.bin/tr		\
69527910Sasami		usr.bin/true		\
69627910Sasami		usr.bin/uname		\
69727910Sasami		usr.bin/uuencode	\
69827910Sasami		usr.bin/vgrind		\
69927910Sasami		usr.bin/vi		\
70027910Sasami		usr.bin/wc		\
70127910Sasami		usr.bin/yacc		\
70227910Sasami		usr.sbin/chown		\
70327910Sasami		usr.sbin/mtree		\
70427910Sasami		usr.sbin/zic
70534509Sbde	cd ${.CURDIR}/$d && ${MAKE} ${MK_FLAGS} depend && \
70630113Sjkh		${MAKE} ${MK_FLAGS} all && \
70730113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
70819175Sbde.endfor
7092061Sjkh
71030113Sjkh.for __target in clean cleandir obj depend
71130113Sjkh.for entry in ${SUBDIR}
71230113Sjkh${entry}.${__target}__D: .PHONY
71330113Sjkh	if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
71430113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
71530113Sjkh		edir=${entry}.${MACHINE}; \
71630113Sjkh		cd ${.CURDIR}/$${edir}; \
71730113Sjkh	else \
71830113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
71930113Sjkh		edir=${entry}; \
72030113Sjkh		cd ${.CURDIR}/$${edir}; \
72130113Sjkh	fi; \
72230113Sjkh	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
72330113Sjkh.endfor
72430113Sjkhpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
72530113Sjkh.endfor
72630113Sjkh
72732427Sjb.endif
72832427Sjb
7291594Srgrimes.include <bsd.subdir.mk>
730