Makefile revision 35462
12061Sjkh#
235462Sjkh#	$Id: Makefile,v 1.171 1998/04/25 14:32:22 andreas 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
7635427Sbde.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
7735427Sbde    defined(MAKE_KERBEROS4)
7830169SjkhSUBDIR+= kerberosIV
792626Scsgr.endif
802061Sjkh.if exists(libexec)
812061SjkhSUBDIR+= libexec
822061Sjkh.endif
832061Sjkh.if exists(sbin)
842061SjkhSUBDIR+= sbin
852061Sjkh.endif
8619320Sadam.if exists(share) && !defined(NOSHARE)
872061SjkhSUBDIR+= share
882061Sjkh.endif
892061Sjkh.if exists(sys)
902061SjkhSUBDIR+= sys
912061Sjkh.endif
922061Sjkh.if exists(usr.bin)
932061SjkhSUBDIR+= usr.bin
942061Sjkh.endif
952061Sjkh.if exists(usr.sbin)
962061SjkhSUBDIR+= usr.sbin
972061Sjkh.endif
982834Swollman.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
992834SwollmanSUBDIR+= secure
1002834Swollman.endif
1012834Swollman.if exists(lkm) && !defined(NOLKM)
1022834SwollmanSUBDIR+= lkm
1032834Swollman.endif
1041594Srgrimes
1054486Sphk# etc must be last for "distribute" to work
1064486Sphk.if exists(etc) && make(distribute)
1074486SphkSUBDIR+= etc
1084486Sphk.endif
1094486Sphk
1102061Sjkh# These are last, since it is nice to at least get the base system
1112061Sjkh# rebuilt before you do them.
11225979Sjkh.if defined(LOCAL_DIRS)
11325979Sjkh.for _DIR in ${LOCAL_DIRS}
11425979Sjkh.if exists(${_DIR}) & exists(${_DIR}/Makefile)
11525979SjkhSUBDIR+= ${_DIR}
1162061Sjkh.endif
11725979Sjkh.endfor
1182061Sjkh.endif
1192061Sjkh
12017308Speter# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
1212061Sjkh.if defined(NOOBJDIR)
1222061SjkhOBJDIR=
1232061Sjkh.else
1242061SjkhOBJDIR=		obj
1252061Sjkh.endif
12612483Speter
12712483Speter.if defined(NOCLEAN)
12812483SpeterCLEANDIR=
12912483Speter.else
1302061Sjkh.if defined(NOCLEANDIR)
1312061SjkhCLEANDIR=	clean
1328854Srgrimes.else
1332061SjkhCLEANDIR=	cleandir
1342061Sjkh.endif
13512483Speter.endif
1362061Sjkh
13735462SjkhSUP?=		cvsup
13835462SjkhSUPFLAGS?=	-g -L 2 -P -
13918714Sache
14017308Speter#
14134541Sbde# While building tools for bootstrapping, we don't need to waste time on
14234575Sbde# shared or profiled libraries, shared linkage, or documentation, except
14334575Sbde# when the tools won't get cleaned we must use the defaults for shared
14434575Sbde# libraries and shared linkage (and this doesn't waste time).
14534592Sbde# XXX actually, we do need to waste time building shared libraries.
14617308Speter#
14734575Sbde.if defined(NOCLEAN)
14835427SbdeMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
14934575Sbde.else
15035427SbdeMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
15134575Sbde.endif
15215603Smarkm
15317308Speter#
15417308Speter# world
15517308Speter#
15617308Speter# Attempt to rebuild and reinstall *everything*, with reasonable chance of
15717308Speter# success, regardless of how old your existing system is.
15817308Speter#
15917308Speter# >> Beware, it overwrites the local build environment! <<
16017308Speter#
16117308Speterworld:
16218362Sjkh	@echo "--------------------------------------------------------------"
16319966Sache	@echo "make world started on `LC_TIME=C date`"
16418362Sjkh	@echo "--------------------------------------------------------------"
16517308Speter.if target(pre-world)
16627910Sasami	@echo
16717308Speter	@echo "--------------------------------------------------------------"
16817308Speter	@echo " Making 'pre-world' target"
16917308Speter	@echo "--------------------------------------------------------------"
17028803Speter	cd ${.CURDIR} && ${MAKE} pre-world
17127910Sasami.endif
17228803Speter	cd ${.CURDIR} && ${MAKE} buildworld
17330113Sjkh	cd ${.CURDIR} && ${MAKE} -B installworld
17427910Sasami.if target(post-world)
17517308Speter	@echo
1762061Sjkh	@echo "--------------------------------------------------------------"
17727910Sasami	@echo " Making 'post-world' target"
1782061Sjkh	@echo "--------------------------------------------------------------"
17928803Speter	cd ${.CURDIR} && ${MAKE} post-world
18027910Sasami.endif
1812061Sjkh	@echo
18217308Speter	@echo "--------------------------------------------------------------"
18327910Sasami	@echo "make world completed on `LC_TIME=C date`"
18417308Speter	@echo "--------------------------------------------------------------"
18527910Sasami
18627910Sasami.if defined(MAKEOBJDIRPREFIX)
18727910SasamiWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
18817308Speter.else
18927910SasamiWORLDTMP=	/usr/obj${.CURDIR}/tmp
19017308Speter.endif
19127910SasamiSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
19227910SasamiTMPPATH=	${STRICTTMPPATH}:${PATH}
19327910Sasami
19427910Sasami# XXX COMPILER_PATH is needed for finding cc1, ld and as
19527910Sasami# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
19627910Sasami#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
19727910Sasami#	wouldn't link *crt.o or libgcc if it were used.
19827910Sasami# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
19927910Sasami#	want that - all compile-time library paths should be resolved by gcc.
20027910Sasami#	It fails for set[ug]id executables (are any used?).
20127910SasamiCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
20227910Sasami		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
20334509Sbde		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
20427910Sasami		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
20527910Sasami		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
20627910Sasami
20727910SasamiBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
20827910SasamiXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
20927910Sasami		CC='cc -nostdinc'	# XXX -nostdlib
21027910Sasami
21127910Sasami# used to compile and install 'make' in temporary build tree
21234688SbdeMAKETMP=	${WORLDTMP}/make
21334688SbdeIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
21427910Sasami# bootstrap make
21535427SbdeBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
21627910Sasami# cross make used for compilation
21735427SbdeXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
21827910Sasami# cross make used for final installation
21935427SbdeIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
22027910Sasami
22127910Sasami#
22227910Sasami# buildworld
22327910Sasami#
22427910Sasami# Attempt to rebuild the entire system, with reasonable chance of
22527910Sasami# success, regardless of how old your existing system is.
22627910Sasami#
22727910Sasamibuildworld:
22827910Sasami.if !defined(NOCLEAN)
22917308Speter	@echo
23017308Speter	@echo "--------------------------------------------------------------"
23127910Sasami	@echo " Cleaning up the temporary build tree"
23217308Speter	@echo "--------------------------------------------------------------"
23327910Sasami	mkdir -p ${WORLDTMP}
23427910Sasami	chflags -R noschg ${WORLDTMP}/
23527910Sasami	rm -rf ${WORLDTMP}
23627910Sasami.endif
23733133Sadam.if !defined(NOTOOLS)
23817466Speter	@echo
23917308Speter	@echo "--------------------------------------------------------------"
24027910Sasami	@echo " Making make"
24117308Speter	@echo "--------------------------------------------------------------"
24234688Sbde	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
24334688Sbde	( \
24427910Sasami	cd ${.CURDIR}/usr.bin/make && \
24534688Sbde		MAKEOBJDIRPREFIX= && unset MAKEOBJDIRPREFIX && \
24630113Sjkh		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all && \
24730277Sasami		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install && \
24834688Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
24934688Sbde	)
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 "--------------------------------------------------------------"
29035427Sbde	@echo " Rebuilding tools needed to build the bootstrap libraries"
29117962Speter	@echo "--------------------------------------------------------------"
29227910Sasami	cd ${.CURDIR} && ${BMAKE} lib-tools
29333133Sadam.endif
29417962Speter	@echo
29517962Speter	@echo "--------------------------------------------------------------"
29635427Sbde	@echo " Rebuilding bootstrap libraries"
29717962Speter	@echo "--------------------------------------------------------------"
29835427Sbde	cd ${.CURDIR} && ${BMAKE} bootstrap-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 "--------------------------------------------------------------"
31335427Sbde	@echo " Building libraries"
31435427Sbde	@echo "--------------------------------------------------------------"
31535427Sbde	cd ${.CURDIR} && ${XMAKE} libraries
31635427Sbde	@echo
31735427Sbde	@echo "--------------------------------------------------------------"
31827910Sasami	@echo " Building everything.."
31917962Speter	@echo "--------------------------------------------------------------"
32027910Sasami	cd ${.CURDIR} && ${XMAKE} all
3212061Sjkh
32217308Speter#
32327910Sasami# installworld
32427910Sasami#
32527910Sasami# Installs everything compiled by a 'buildworld'.
32627910Sasami#
32727910Sasamiinstallworld:
32827910Sasami	cd ${.CURDIR} && ${IXMAKE} reinstall
32927910Sasami
33027910Sasami#
33117308Speter# reinstall
33217308Speter#
33317308Speter# If you have a build server, you can NFS mount the source and obj directories
33417308Speter# and do a 'make reinstall' on the *client* to install new binaries from the
33517308Speter# most recent server build.
33617308Speter#
33717308Speterreinstall:
33812483Speter	@echo "--------------------------------------------------------------"
33917308Speter	@echo " Making hierarchy"
34012483Speter	@echo "--------------------------------------------------------------"
34117308Speter	cd ${.CURDIR} && ${MAKE} hierarchy
34212483Speter	@echo
3432061Sjkh	@echo "--------------------------------------------------------------"
34417962Speter	@echo " Installing everything.."
34517962Speter	@echo "--------------------------------------------------------------"
34617308Speter	cd ${.CURDIR} && ${MAKE} install
34717962Speter	@echo
34817962Speter	@echo "--------------------------------------------------------------"
34933595Snate	@echo " Re-scanning the shared libraries.."
35033595Snate	@echo "--------------------------------------------------------------"
35133595Snate	cd ${.CURDIR} && ldconfig -R
35233595Snate	@echo
35333595Snate	@echo "--------------------------------------------------------------"
35417962Speter	@echo " Rebuilding man page indexes"
35517962Speter	@echo "--------------------------------------------------------------"
35617308Speter	cd ${.CURDIR}/share/man && ${MAKE} makedb
3572061Sjkh
35817308Speter#
35917308Speter# update
36017308Speter#
36117308Speter# Update the source tree, by running sup and/or running cvs to update to the
36217308Speter# latest copy.
36317308Speter#
3642302Spaulupdate:
3652302Spaul.if defined(SUP_UPDATE)
3662302Spaul	@echo "--------------------------------------------------------------"
36735462Sjkh	@echo "Running ${SUP}"
3682302Spaul	@echo "--------------------------------------------------------------"
36918714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE}
37010760Sache.if defined(SUPFILE1)
37118714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE1}
3722302Spaul.endif
37310760Sache.if defined(SUPFILE2)
37418714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE2}
37510760Sache.endif
37610760Sache.endif
3772302Spaul.if defined(CVS_UPDATE)
3782302Spaul	@echo "--------------------------------------------------------------"
3792302Spaul	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
3802302Spaul	@echo "--------------------------------------------------------------"
38130132Sfsmp	cd ${.CURDIR} && cvs -q update -P -d
3822302Spaul.endif
3832302Spaul
38417308Speter#
38517308Speter# most
38617308Speter#
38717308Speter# Build most of the user binaries on the existing system libs and includes.
38817308Speter#
38917308Spetermost:
3902061Sjkh	@echo "--------------------------------------------------------------"
39117308Speter	@echo " Building programs only"
3922061Sjkh	@echo "--------------------------------------------------------------"
39330205Sbde	cd ${.CURDIR}/bin	&&	${MAKE} all
39430205Sbde	cd ${.CURDIR}/sbin	&&	${MAKE} all
39530205Sbde	cd ${.CURDIR}/libexec	&&	${MAKE} all
39630205Sbde	cd ${.CURDIR}/usr.bin	&&	${MAKE} all
39730205Sbde	cd ${.CURDIR}/usr.sbin	&&	${MAKE} all
39830205Sbde	cd ${.CURDIR}/gnu/libexec &&	${MAKE} all
39930205Sbde	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} all
40030205Sbde	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} all
40130169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
40230205Sbde#	cd ${.CURDIR}/kerberosIV	&&	${MAKE} most
40317308Speter#.endif
40417308Speter#.if !defined(NOSECURE) && !defined(NOCRYPT)
40530205Sbde#	cd ${.CURDIR}/secure	&&	${MAKE} most
40617308Speter#.endif
4072061Sjkh
40817308Speter#
40917308Speter# installmost
41017308Speter#
41117308Speter# Install the binaries built by the 'most' target.  This does not include
41217308Speter# libraries or include files.
41317308Speter#
4143626Swollmaninstallmost:
4153626Swollman	@echo "--------------------------------------------------------------"
4163626Swollman	@echo " Installing programs only"
4173626Swollman	@echo "--------------------------------------------------------------"
41830205Sbde	cd ${.CURDIR}/bin	&&	${MAKE} install
41930205Sbde	cd ${.CURDIR}/sbin	&&	${MAKE} install
42030205Sbde	cd ${.CURDIR}/libexec	&&	${MAKE} install
42130205Sbde	cd ${.CURDIR}/usr.bin	&&	${MAKE} install
42230205Sbde	cd ${.CURDIR}/usr.sbin	&&	${MAKE} install
42330205Sbde	cd ${.CURDIR}/gnu/libexec &&	${MAKE} install
42430205Sbde	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} install
42530205Sbde	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} install
42630169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
42730205Sbde#	cd ${.CURDIR}/kerberosIV &&	${MAKE} installmost
4283626Swollman#.endif
4293626Swollman#.if !defined(NOSECURE) && !defined(NOCRYPT)
43030205Sbde#	cd ${.CURDIR}/secure	&&	${MAKE} installmost
4313626Swollman#.endif
4323626Swollman
43317308Speter#
43417308Speter# ------------------------------------------------------------------------
43517308Speter#
43617308Speter# From here onwards are utility targets used by the 'make world' and
43717308Speter# related targets.  If your 'world' breaks, you may like to try to fix
43817308Speter# the problem and manually run the following targets to attempt to
43917308Speter# complete the build.  Beware, this is *not* guaranteed to work, you
44017308Speter# need to have a pretty good grip on the current state of the system
44117308Speter# to attempt to manually finish it.  If in doubt, 'make world' again.
44217308Speter#
4433626Swollman
44417308Speter#
44517308Speter# heirarchy - ensure that all the needed directories are present
44617308Speter#
44717308Speterhierarchy:
44817308Speter	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
44917308Speter
45017308Speter#
45117308Speter# bootstrap - [re]build tools needed to run the actual build, this includes
45217308Speter# tools needed by 'make depend', as some tools are needed to generate source
45317308Speter# for the dependency information to be gathered from.
45417308Speter#
45517308Speterbootstrap:
45627910Sasami.if defined(DESTDIR)
45727910Sasami	rm -f ${DESTDIR}/usr/src/sys
45827910Sasami	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
45927910Sasami	cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
46034575Sbde	cd ${.CURDIR}/include && ${MAKE} symlinks
46127910Sasami.endif
46234509Sbde	cd ${.CURDIR}/usr.bin/make && ${MAKE} ${MK_FLAGS} depend && \
46330113Sjkh		${MAKE} ${MK_FLAGS} all && \
46430113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
46534509Sbde	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} ${MK_FLAGS} depend && \
46630113Sjkh		${MAKE} ${MK_FLAGS} all && \
46730113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
46834509Sbde	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && \
46934509Sbde		${MAKE} ${MK_FLAGS} depend && \
47030170Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB all && \
47130113Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
47229938Smckay.if !defined(NOOBJDIR)
47334509Sbde	cd ${.CURDIR}/usr.bin/lex && ${MAKE} ${OBJDIR}
47429938Smckay.endif
47517308Speter
47617308Speter#
47717308Speter# include-tools - generally the same as 'bootstrap', except that it's for
47817308Speter# things that are specifically needed to generate include files.
47917308Speter#
48027910Sasami# XXX should be merged with bootstrap, it's not worth keeeping them separate.
48127910Sasami# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
48227910Sasami# on cleaned away headers in ${WORLDTMP}.
48317308Speter#
48417308Speterinclude-tools:
48534520Sbde.for d in usr.bin/compile_et usr.bin/rpcgen
48634520Sbde	cd ${.CURDIR}/$d && ${MAKE} cleandepend && \
48734509Sbde		${MAKE} ${MK_FLAGS} depend && \
48830113Sjkh		${MAKE} ${MK_FLAGS} all && \
48930113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
49034520Sbde.endfor
49117308Speter
49217308Speter#
49317308Speter# includes - possibly generate and install the include files.
49417308Speter#
49514119Speterincludes:
4962061Sjkh.if defined(CLOBBER)
4977130Srgrimes	rm -rf ${DESTDIR}/usr/include/*
4987130Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
4997130Srgrimes		-p ${DESTDIR}/usr/include
5002061Sjkh.endif
50130113Sjkh	cd ${.CURDIR}/include &&		${MAKE} -B all install
50217308Speter	cd ${.CURDIR}/gnu/include &&		${MAKE} install
50330169Sjkh	cd ${.CURDIR}/gnu/lib/libmp &&		${MAKE} beforeinstall
50430169Sjkh	cd ${.CURDIR}/gnu/lib/libobjc &&	${MAKE} beforeinstall
5052685Srgrimes	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
5066927Snate	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
50727790Sasami	cd ${.CURDIR}/gnu/lib/libstdc++ &&	${MAKE} beforeinstall
50827790Sasami	cd ${.CURDIR}/gnu/lib/libg++ &&		${MAKE} beforeinstall
50927790Sasami	cd ${.CURDIR}/gnu/lib/libdialog &&	${MAKE} beforeinstall
51030169Sjkh	cd ${.CURDIR}/gnu/lib/libgmp &&		${MAKE} beforeinstall
51130169Sjkh.if exists(secure) && !defined(NOCRYPT)
51230169Sjkh	cd ${.CURDIR}/secure/lib/libdes &&	${MAKE} beforeinstall
5133197Scsgr.endif
51430169Sjkh.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
51530169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libacl &&	${MAKE} beforeinstall
51630169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkadm &&	${MAKE} beforeinstall
51730169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkafs &&	${MAKE} beforeinstall
51830169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkdb &&	${MAKE} beforeinstall
51930169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkrb &&	${MAKE} beforeinstall
52030169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libtelnet && ${MAKE} beforeinstall
52130169Sjkh.else
52230169Sjkh	cd ${.CURDIR}/lib/libtelnet &&		${MAKE} beforeinstall
52330169Sjkh.endif
52432427Sjb.if exists(${.CURDIR}/lib/csu/${MACHINE})
52532427Sjb	cd ${.CURDIR}/lib/csu/${MACHINE} &&	${MAKE} beforeinstall
52632427Sjb.endif
52726152Speter	cd ${.CURDIR}/lib/libalias &&		${MAKE} beforeinstall
5282061Sjkh	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
52935452Sandreas	cd ${.CURDIR}/lib/libcalendar &&	${MAKE} beforeinstall
5302061Sjkh	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
53130169Sjkh	cd ${.CURDIR}/lib/libdisk &&		${MAKE} beforeinstall
5322061Sjkh	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
53316786Snate	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
5342883Sphk	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
53527790Sasami	cd ${.CURDIR}/lib/libmytinfo &&		${MAKE} beforeinstall
53617308Speter	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
5377281Srgrimes.if !defined(WANT_CSRG_LIBM)
5383242Spaul	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
5393242Spaul.endif
54030169Sjkh	cd ${.CURDIR}/lib/libopie &&		${MAKE} beforeinstall
5417171Sats	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
5422061Sjkh	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
5433213Spst	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
54430169Sjkh.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
54530169Sjkh	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
54630169Sjkh	cd ${.CURDIR}/lib/libtcl &&		${MAKE} installhdrs
54730169Sjkh.endif
54817308Speter	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
5495749Swollman	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
55034520Sbde	cd ${.CURDIR}/lib/libss &&		${MAKE} -B hdrs beforeinstall
55117308Speter	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
55217308Speter	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
55330169Sjkh	cd ${.CURDIR}/lib/libvgl &&		${MAKE} beforeinstall
55426504Sjhay	cd ${.CURDIR}/lib/libz &&		${MAKE} beforeinstall
55530169Sjkh	cd ${.CURDIR}/usr.bin/f2c &&		${MAKE} beforeinstall
55630169Sjkh	cd ${.CURDIR}/usr.bin/lex &&		${MAKE} beforeinstall
5572061Sjkh
55817308Speter#
55917308Speter# lib-tools - build tools to compile and install the libraries.
56017308Speter#
56127910Sasami# XXX gperf is required for cc
56227910Sasami# XXX a new ld and tsort is required for cc
5635366Snatelib-tools:
56427910Sasami.for d in				\
56527910Sasami		gnu/usr.bin/gperf	\
56627910Sasami		gnu/usr.bin/ld		\
56727910Sasami		usr.bin/tsort		\
56827910Sasami		gnu/usr.bin/as		\
56927910Sasami		gnu/usr.bin/bison	\
57027910Sasami		gnu/usr.bin/cc		\
57127910Sasami		usr.bin/ar		\
57227910Sasami		usr.bin/lex/lib		\
57327910Sasami		usr.bin/mk_cmds		\
57427910Sasami		usr.bin/nm		\
57527910Sasami		usr.bin/ranlib		\
57627910Sasami		usr.bin/uudecode
57734509Sbde	cd ${.CURDIR}/$d && ${MAKE} ${MK_FLAGS} depend && \
57830113Sjkh		${MAKE} ${MK_FLAGS} all && \
57934623Sbde		${MAKE} ${MK_FLAGS} -B install && \
58034575Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
58127910Sasami.endfor
5825366Snate
58317308Speter#
58435427Sbde# We have to know too much about ordering and subdirs in the lib trees:
58517308Speter#
58635427Sbde# To satisfy shared library linkage when only the libraries being built
58735427Sbde# are visible:
58835427Sbde#
58935427Sbde# libcom_err must be built before libss.
59035427Sbde# libcrypt and libmd must be built before libskey.
59135427Sbde# libm must be built before libtcl.
59235427Sbde# libmytinfo must be built before libdialog and libncurses.
59335427Sbde# libncurses must be built before libdialog.
59435427Sbde# libtermcap must be built before libcurses, libedit and libreadline.
59535427Sbde#
59635427Sbde# Some libraries are built conditionally and/or are in inconsistently
59735427Sbde# named directories:
59835427Sbde#
59935427Sbde.if exists(lib/csu/${MACHINE}.pcc)
60035427Sbde_csu=lib/csu/${MACHINE}.pcc
60134541Sbde.else
60235427Sbde_csu=lib/csu/${MACHINE}
60324754Sjdp.endif
60434541Sbde
60535427Sbde_libcrypt=	lib/libcrypt
60635427Sbde.if !defined(NOSECURE) && !defined(NOCRYPT)
60735427Sbde_libcrypt+=	secure/lib/libcrypt
60835427Sbde.endif
60935427Sbde
61034541Sbde.if defined(WANT_CSRG_LIBM)
61135427Sbde_libm=	lib/libm
61234541Sbde.else
61335427Sbde_libm=	lib/msun
6148295Srgrimes.endif
61534541Sbde
61634541Sbde#
61735427Sbde# bootstrap-libraries - build just enough libraries for the bootstrap
61835427Sbde# tools, and install them under ${WORLDTMP}.
61934541Sbde#
62035427Sbde# Build csu and libgcc early so that some tools get linked to the new
62135427Sbde# versions (too late for the main tools, however).  Then build the
62235427Sbde# necessary prerequisite libraries (libtermcap just needs to be before
62335427Sbde# libcurses, and this only matters for the NOCLEAN case when NOPIC is
62435427Sbde# not set).
62534541Sbde#
62635427Sbde# This is mostly wrong.  The build tools must run on the host system,
62735427Sbde# so they should use host libraries.  We depend on the target being
62835427Sbde# similar enough to the host for new target libraries to work on the
62935427Sbde# host.
63034541Sbde#
63135427Sbdebootstrap-libraries:
63235427Sbde.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
63335427Sbde    gnu/lib/libregex lib/libc lib/libcurses lib/libedit ${_libm} \
63435427Sbde    lib/libmd lib/libutil lib/libz usr.bin/lex/lib
63534541Sbde.if exists(${.CURDIR}/${_lib})
63634541Sbde	cd ${.CURDIR}/${_lib} && \
63734541Sbde		${MAKE} ${MK_FLAGS} depend && \
63830113Sjkh		${MAKE} ${MK_FLAGS} all && \
63930113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6408489Srgrimes.endif
64134541Sbde.endfor
64235427Sbde
64335427Sbde#
64435427Sbde# libraries - build all libraries, and install them under ${DESTDIR}.
64535427Sbde#
64635427Sbde# The ordering is not as special as for bootstrap-libraries.  Build
64735427Sbde# the prerequisites first, then build almost everything else in
64835427Sbde# alphabetical order.
64935427Sbde#
65035427Sbdelibraries:
65135427Sbde.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
65235427Sbde    lib/libncurses lib/libtermcap \
65335427Sbde    gnu/lib gnu/usr.bin/cc/libgcc lib usr.bin/lex/lib usr.sbin/pcvt/keycap
65435427Sbde.if exists(${.CURDIR}/${_lib})
65535427Sbde	cd ${.CURDIR}/${_lib} && ${MAKE} all && ${MAKE} -B install
65635427Sbde.endif
65735427Sbde.endfor
65834541Sbde.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
65935427Sbde	cd ${.CURDIR}/secure/lib && ${MAKE} all && ${MAKE} -B install
6602160Scsgr.endif
66134541Sbde.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
66234541Sbde    defined(MAKE_KERBEROS4)
66335427Sbde	cd ${.CURDIR}/kerberosIV/lib && ${MAKE} all && ${MAKE} -B install
6642626Scsgr.endif
6652061Sjkh
66617308Speter#
66717308Speter# build-tools - build and install any other tools needed to complete the
66817308Speter# compile and install.
66927910Sasami# ifdef stale
67027910Sasami# bc and cpp are required to build groff.  Otherwise, the order here is
67127910Sasami# mostly historical, i.e., bogus.
67227910Sasami# chmod is used to build gcc's tmpmultilib[2] at obscure times.
67327910Sasami# endif stale
67427910Sasami# XXX uname is a bug - the target should not depend on the host.
67517308Speter#
67611806Sphkbuild-tools:
67719175Sbde.for d in				\
67827910Sasami		bin/cat 		\
67927910Sasami		bin/chmod		\
68027910Sasami		bin/cp 			\
68127910Sasami		bin/date		\
68227910Sasami		bin/dd			\
68327910Sasami		bin/echo		\
68427910Sasami		bin/expr		\
68527910Sasami		bin/hostname		\
68627910Sasami		bin/ln			\
68727910Sasami		bin/ls			\
68827910Sasami		bin/mkdir		\
68927910Sasami		bin/mv			\
69027910Sasami		bin/rm			\
69127910Sasami		bin/sh			\
69227910Sasami		bin/test		\
69327910Sasami		gnu/usr.bin/awk		\
69427910Sasami		gnu/usr.bin/bc		\
69527910Sasami		gnu/usr.bin/grep	\
69627910Sasami		gnu/usr.bin/groff	\
69727910Sasami		gnu/usr.bin/gzip	\
69827910Sasami		gnu/usr.bin/man/makewhatis	\
69927910Sasami		gnu/usr.bin/sort	\
70034509Sbde		gnu/usr.bin/texinfo	\
70121673Sjkh		share/info		\
70227910Sasami		usr.bin/basename	\
70327910Sasami		usr.bin/cap_mkdb	\
70427910Sasami		usr.bin/chflags		\
70527910Sasami		usr.bin/cmp		\
70627910Sasami		usr.bin/col		\
70727910Sasami		usr.bin/cpp		\
70827910Sasami		usr.bin/expand		\
70927910Sasami		usr.bin/file2c		\
71027910Sasami		usr.bin/find		\
71127910Sasami		usr.bin/gencat		\
71227910Sasami		usr.bin/lorder		\
71327910Sasami		usr.bin/m4		\
71427910Sasami		usr.bin/mkdep		\
71527910Sasami		usr.bin/paste		\
71627910Sasami		usr.bin/sed		\
71727910Sasami		usr.bin/size		\
71827910Sasami		usr.bin/soelim		\
71927910Sasami		usr.bin/strip		\
72019175Sbde		usr.bin/symorder	\
72127910Sasami		usr.bin/touch		\
72227910Sasami		usr.bin/tr		\
72327910Sasami		usr.bin/true		\
72427910Sasami		usr.bin/uname		\
72527910Sasami		usr.bin/uuencode	\
72627910Sasami		usr.bin/vgrind		\
72727910Sasami		usr.bin/vi		\
72827910Sasami		usr.bin/wc		\
72934688Sbde		usr.bin/xargs		\
73027910Sasami		usr.bin/yacc		\
73127910Sasami		usr.sbin/chown		\
73227910Sasami		usr.sbin/mtree		\
73327910Sasami		usr.sbin/zic
73434509Sbde	cd ${.CURDIR}/$d && ${MAKE} ${MK_FLAGS} depend && \
73530113Sjkh		${MAKE} ${MK_FLAGS} all && \
73630113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
73719175Sbde.endfor
7382061Sjkh
73930113Sjkh.for __target in clean cleandir obj depend
74030113Sjkh.for entry in ${SUBDIR}
74130113Sjkh${entry}.${__target}__D: .PHONY
74235294Sdt	@if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
74330113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
74430113Sjkh		edir=${entry}.${MACHINE}; \
74530113Sjkh		cd ${.CURDIR}/$${edir}; \
74630113Sjkh	else \
74730113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
74830113Sjkh		edir=${entry}; \
74930113Sjkh		cd ${.CURDIR}/$${edir}; \
75030113Sjkh	fi; \
75130113Sjkh	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
75230113Sjkh.endfor
75330113Sjkhpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
75430113Sjkh.endfor
75530113Sjkh
75632427Sjb.endif
75732427Sjb
7581594Srgrimes.include <bsd.subdir.mk>
759