Makefile revision 34689
12061Sjkh#
234688Sbde#	$Id: Makefile,v 1.166 1998/03/16 11:58:46 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
21134688SbdeMAKETMP=	${WORLDTMP}/make
21234688SbdeIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
21327910Sasami# bootstrap make
21427910SasamiBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
21527910Sasami# cross make used for compilation
21627910SasamiXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
21727910Sasami# cross make used for final installation
21827910SasamiIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
21927910Sasami
22027910Sasami#
22127910Sasami# buildworld
22227910Sasami#
22327910Sasami# Attempt to rebuild the entire system, with reasonable chance of
22427910Sasami# success, regardless of how old your existing system is.
22527910Sasami#
22627910Sasamibuildworld:
22727910Sasami.if !defined(NOCLEAN)
22817308Speter	@echo
22917308Speter	@echo "--------------------------------------------------------------"
23027910Sasami	@echo " Cleaning up the temporary build tree"
23117308Speter	@echo "--------------------------------------------------------------"
23227910Sasami	mkdir -p ${WORLDTMP}
23327910Sasami	chflags -R noschg ${WORLDTMP}/
23427910Sasami	rm -rf ${WORLDTMP}
23527910Sasami.endif
23633133Sadam.if !defined(NOTOOLS)
23717466Speter	@echo
23817308Speter	@echo "--------------------------------------------------------------"
23927910Sasami	@echo " Making make"
24017308Speter	@echo "--------------------------------------------------------------"
24134688Sbde	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
24234688Sbde	( \
24327910Sasami	cd ${.CURDIR}/usr.bin/make && \
24434688Sbde		MAKEOBJDIRPREFIX= && unset MAKEOBJDIRPREFIX && \
24530113Sjkh		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all && \
24630277Sasami		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install && \
24734688Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
24834688Sbde	)
24933133Sadam.endif
25017308Speter	@echo
25117308Speter	@echo "--------------------------------------------------------------"
25227910Sasami	@echo " Making hierarchy"
25317308Speter	@echo "--------------------------------------------------------------"
25427910Sasami	cd ${.CURDIR} && ${BMAKE} hierarchy
25527910Sasami.if !defined(NOCLEAN)
25617308Speter	@echo
25717308Speter	@echo "--------------------------------------------------------------"
25827910Sasami	@echo " Cleaning up the obj tree"
25917308Speter	@echo "--------------------------------------------------------------"
26030113Sjkh	cd ${.CURDIR} && ${BMAKE} par-${CLEANDIR}
26127910Sasami.endif
26227910Sasami.if !defined(NOOBJDIR)
26317308Speter	@echo
26417308Speter	@echo "--------------------------------------------------------------"
26527910Sasami	@echo " Rebuilding the obj tree"
26617308Speter	@echo "--------------------------------------------------------------"
26734509Sbde	cd ${.CURDIR} && ${BMAKE} par-${OBJDIR}
26827910Sasami.endif
26933133Sadam.if !defined(NOTOOLS)
27017308Speter	@echo
27117308Speter	@echo "--------------------------------------------------------------"
27227910Sasami	@echo " Rebuilding bootstrap tools"
27317308Speter	@echo "--------------------------------------------------------------"
27427910Sasami	cd ${.CURDIR} && ${BMAKE} bootstrap
27517308Speter	@echo
27617308Speter	@echo "--------------------------------------------------------------"
27727910Sasami	@echo " Rebuilding tools necessary to build the include files"
27817308Speter	@echo "--------------------------------------------------------------"
27927910Sasami	cd ${.CURDIR} && ${BMAKE} include-tools
28033133Sadam.endif
28117308Speter	@echo
28217308Speter	@echo "--------------------------------------------------------------"
28334509Sbde	@echo " Rebuilding ${DESTDIR}/usr/include"
28417308Speter	@echo "--------------------------------------------------------------"
28529503Sbde	cd ${.CURDIR} && SHARED=symlinks ${BMAKE} includes
28633133Sadam.if !defined(NOTOOLS)
28717962Speter	@echo
28817962Speter	@echo "--------------------------------------------------------------"
28927910Sasami	@echo " Rebuilding tools needed to build the libraries"
29017962Speter	@echo "--------------------------------------------------------------"
29127910Sasami	cd ${.CURDIR} && ${BMAKE} lib-tools
29233133Sadam.endif
29317962Speter	@echo
29417962Speter	@echo "--------------------------------------------------------------"
29534509Sbde	@echo " Rebuilding ${DESTDIR}/usr/lib"
29617962Speter	@echo "--------------------------------------------------------------"
29727910Sasami	cd ${.CURDIR} && ${BMAKE} libraries
29833133Sadam.if !defined(NOTOOLS)
29917962Speter	@echo
30017962Speter	@echo "--------------------------------------------------------------"
30127910Sasami	@echo " Rebuilding all other tools needed to build the world"
30217962Speter	@echo "--------------------------------------------------------------"
30327910Sasami	cd ${.CURDIR} && ${BMAKE} build-tools
30433133Sadam.endif
30517308Speter	@echo
30617308Speter	@echo "--------------------------------------------------------------"
30727910Sasami	@echo " Rebuilding dependencies"
30817308Speter	@echo "--------------------------------------------------------------"
30930205Sbde	cd ${.CURDIR} && ${XMAKE} par-depend
31017308Speter	@echo
31117308Speter	@echo "--------------------------------------------------------------"
31227910Sasami	@echo " Building everything.."
31317962Speter	@echo "--------------------------------------------------------------"
31427910Sasami	cd ${.CURDIR} && ${XMAKE} all
3152061Sjkh
31617308Speter#
31727910Sasami# installworld
31827910Sasami#
31927910Sasami# Installs everything compiled by a 'buildworld'.
32027910Sasami#
32127910Sasamiinstallworld:
32227910Sasami	cd ${.CURDIR} && ${IXMAKE} reinstall
32327910Sasami
32427910Sasami#
32517308Speter# reinstall
32617308Speter#
32717308Speter# If you have a build server, you can NFS mount the source and obj directories
32817308Speter# and do a 'make reinstall' on the *client* to install new binaries from the
32917308Speter# most recent server build.
33017308Speter#
33117308Speterreinstall:
33212483Speter	@echo "--------------------------------------------------------------"
33317308Speter	@echo " Making hierarchy"
33412483Speter	@echo "--------------------------------------------------------------"
33517308Speter	cd ${.CURDIR} && ${MAKE} hierarchy
33612483Speter	@echo
3372061Sjkh	@echo "--------------------------------------------------------------"
33817962Speter	@echo " Installing everything.."
33917962Speter	@echo "--------------------------------------------------------------"
34017308Speter	cd ${.CURDIR} && ${MAKE} install
34117962Speter	@echo
34217962Speter	@echo "--------------------------------------------------------------"
34333595Snate	@echo " Re-scanning the shared libraries.."
34433595Snate	@echo "--------------------------------------------------------------"
34533595Snate	cd ${.CURDIR} && ldconfig -R
34633595Snate	@echo
34733595Snate	@echo "--------------------------------------------------------------"
34817962Speter	@echo " Rebuilding man page indexes"
34917962Speter	@echo "--------------------------------------------------------------"
35017308Speter	cd ${.CURDIR}/share/man && ${MAKE} makedb
3512061Sjkh
35217308Speter#
35317308Speter# update
35417308Speter#
35517308Speter# Update the source tree, by running sup and/or running cvs to update to the
35617308Speter# latest copy.
35717308Speter#
3582302Spaulupdate:
3592302Spaul.if defined(SUP_UPDATE)
3602302Spaul	@echo "--------------------------------------------------------------"
3612302Spaul	@echo "Running sup"
3622302Spaul	@echo "--------------------------------------------------------------"
36318714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE}
36410760Sache.if defined(SUPFILE1)
36518714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE1}
3662302Spaul.endif
36710760Sache.if defined(SUPFILE2)
36818714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE2}
36910760Sache.endif
37010760Sache.endif
3712302Spaul.if defined(CVS_UPDATE)
3722302Spaul	@echo "--------------------------------------------------------------"
3732302Spaul	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
3742302Spaul	@echo "--------------------------------------------------------------"
37530132Sfsmp	cd ${.CURDIR} && cvs -q update -P -d
3762302Spaul.endif
3772302Spaul
37817308Speter#
37917308Speter# most
38017308Speter#
38117308Speter# Build most of the user binaries on the existing system libs and includes.
38217308Speter#
38317308Spetermost:
3842061Sjkh	@echo "--------------------------------------------------------------"
38517308Speter	@echo " Building programs only"
3862061Sjkh	@echo "--------------------------------------------------------------"
38730205Sbde	cd ${.CURDIR}/bin	&&	${MAKE} all
38830205Sbde	cd ${.CURDIR}/sbin	&&	${MAKE} all
38930205Sbde	cd ${.CURDIR}/libexec	&&	${MAKE} all
39030205Sbde	cd ${.CURDIR}/usr.bin	&&	${MAKE} all
39130205Sbde	cd ${.CURDIR}/usr.sbin	&&	${MAKE} all
39230205Sbde	cd ${.CURDIR}/gnu/libexec &&	${MAKE} all
39330205Sbde	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} all
39430205Sbde	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} all
39530169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
39630205Sbde#	cd ${.CURDIR}/kerberosIV	&&	${MAKE} most
39717308Speter#.endif
39817308Speter#.if !defined(NOSECURE) && !defined(NOCRYPT)
39930205Sbde#	cd ${.CURDIR}/secure	&&	${MAKE} most
40017308Speter#.endif
4012061Sjkh
40217308Speter#
40317308Speter# installmost
40417308Speter#
40517308Speter# Install the binaries built by the 'most' target.  This does not include
40617308Speter# libraries or include files.
40717308Speter#
4083626Swollmaninstallmost:
4093626Swollman	@echo "--------------------------------------------------------------"
4103626Swollman	@echo " Installing programs only"
4113626Swollman	@echo "--------------------------------------------------------------"
41230205Sbde	cd ${.CURDIR}/bin	&&	${MAKE} install
41330205Sbde	cd ${.CURDIR}/sbin	&&	${MAKE} install
41430205Sbde	cd ${.CURDIR}/libexec	&&	${MAKE} install
41530205Sbde	cd ${.CURDIR}/usr.bin	&&	${MAKE} install
41630205Sbde	cd ${.CURDIR}/usr.sbin	&&	${MAKE} install
41730205Sbde	cd ${.CURDIR}/gnu/libexec &&	${MAKE} install
41830205Sbde	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} install
41930205Sbde	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} install
42030169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
42130205Sbde#	cd ${.CURDIR}/kerberosIV &&	${MAKE} installmost
4223626Swollman#.endif
4233626Swollman#.if !defined(NOSECURE) && !defined(NOCRYPT)
42430205Sbde#	cd ${.CURDIR}/secure	&&	${MAKE} installmost
4253626Swollman#.endif
4263626Swollman
42717308Speter#
42817308Speter# ------------------------------------------------------------------------
42917308Speter#
43017308Speter# From here onwards are utility targets used by the 'make world' and
43117308Speter# related targets.  If your 'world' breaks, you may like to try to fix
43217308Speter# the problem and manually run the following targets to attempt to
43317308Speter# complete the build.  Beware, this is *not* guaranteed to work, you
43417308Speter# need to have a pretty good grip on the current state of the system
43517308Speter# to attempt to manually finish it.  If in doubt, 'make world' again.
43617308Speter#
4373626Swollman
43817308Speter#
43917308Speter# heirarchy - ensure that all the needed directories are present
44017308Speter#
44117308Speterhierarchy:
44217308Speter	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
44317308Speter
44417308Speter#
44517308Speter# bootstrap - [re]build tools needed to run the actual build, this includes
44617308Speter# tools needed by 'make depend', as some tools are needed to generate source
44717308Speter# for the dependency information to be gathered from.
44817308Speter#
44917308Speterbootstrap:
45027910Sasami.if defined(DESTDIR)
45127910Sasami	rm -f ${DESTDIR}/usr/src/sys
45227910Sasami	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
45327910Sasami	cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
45434575Sbde	cd ${.CURDIR}/include && ${MAKE} symlinks
45527910Sasami.endif
45634509Sbde	cd ${.CURDIR}/usr.bin/make && ${MAKE} ${MK_FLAGS} depend && \
45730113Sjkh		${MAKE} ${MK_FLAGS} all && \
45830113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
45934509Sbde	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} ${MK_FLAGS} depend && \
46030113Sjkh		${MAKE} ${MK_FLAGS} all && \
46130113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
46234509Sbde	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && \
46334509Sbde		${MAKE} ${MK_FLAGS} depend && \
46430170Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB all && \
46530113Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
46629938Smckay.if !defined(NOOBJDIR)
46734509Sbde	cd ${.CURDIR}/usr.bin/lex && ${MAKE} ${OBJDIR}
46829938Smckay.endif
46917308Speter
47017308Speter#
47117308Speter# include-tools - generally the same as 'bootstrap', except that it's for
47217308Speter# things that are specifically needed to generate include files.
47317308Speter#
47427910Sasami# XXX should be merged with bootstrap, it's not worth keeeping them separate.
47527910Sasami# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
47627910Sasami# on cleaned away headers in ${WORLDTMP}.
47717308Speter#
47817308Speterinclude-tools:
47934520Sbde.for d in usr.bin/compile_et usr.bin/rpcgen
48034520Sbde	cd ${.CURDIR}/$d && ${MAKE} cleandepend && \
48134509Sbde		${MAKE} ${MK_FLAGS} depend && \
48230113Sjkh		${MAKE} ${MK_FLAGS} all && \
48330113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
48434520Sbde.endfor
48517308Speter
48617308Speter#
48717308Speter# includes - possibly generate and install the include files.
48817308Speter#
48914119Speterincludes:
4902061Sjkh.if defined(CLOBBER)
4917130Srgrimes	rm -rf ${DESTDIR}/usr/include/*
4927130Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
4937130Srgrimes		-p ${DESTDIR}/usr/include
4942061Sjkh.endif
49530113Sjkh	cd ${.CURDIR}/include &&		${MAKE} -B all install
49617308Speter	cd ${.CURDIR}/gnu/include &&		${MAKE} install
49730169Sjkh	cd ${.CURDIR}/gnu/lib/libmp &&		${MAKE} beforeinstall
49830169Sjkh	cd ${.CURDIR}/gnu/lib/libobjc &&	${MAKE} beforeinstall
4992685Srgrimes	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
5006927Snate	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
50127790Sasami	cd ${.CURDIR}/gnu/lib/libstdc++ &&	${MAKE} beforeinstall
50227790Sasami	cd ${.CURDIR}/gnu/lib/libg++ &&		${MAKE} beforeinstall
50327790Sasami	cd ${.CURDIR}/gnu/lib/libdialog &&	${MAKE} beforeinstall
50430169Sjkh	cd ${.CURDIR}/gnu/lib/libgmp &&		${MAKE} beforeinstall
50530169Sjkh.if exists(secure) && !defined(NOCRYPT)
50630169Sjkh	cd ${.CURDIR}/secure/lib/libdes &&	${MAKE} beforeinstall
5073197Scsgr.endif
50830169Sjkh.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
50930169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libacl &&	${MAKE} beforeinstall
51030169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkadm &&	${MAKE} beforeinstall
51130169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkafs &&	${MAKE} beforeinstall
51230169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkdb &&	${MAKE} beforeinstall
51330169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libkrb &&	${MAKE} beforeinstall
51430169Sjkh	cd ${.CURDIR}/kerberosIV/lib/libtelnet && ${MAKE} beforeinstall
51530169Sjkh.else
51630169Sjkh	cd ${.CURDIR}/lib/libtelnet &&		${MAKE} beforeinstall
51730169Sjkh.endif
51832427Sjb.if exists(${.CURDIR}/lib/csu/${MACHINE})
51932427Sjb	cd ${.CURDIR}/lib/csu/${MACHINE} &&	${MAKE} beforeinstall
52032427Sjb.endif
52126152Speter	cd ${.CURDIR}/lib/libalias &&		${MAKE} beforeinstall
5222061Sjkh	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
5232061Sjkh	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
52430169Sjkh	cd ${.CURDIR}/lib/libdisk &&		${MAKE} beforeinstall
5252061Sjkh	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
52616786Snate	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
5272883Sphk	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
52827790Sasami	cd ${.CURDIR}/lib/libmytinfo &&		${MAKE} beforeinstall
52917308Speter	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
5307281Srgrimes.if !defined(WANT_CSRG_LIBM)
5313242Spaul	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
5323242Spaul.endif
53330169Sjkh	cd ${.CURDIR}/lib/libopie &&		${MAKE} beforeinstall
5347171Sats	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
5352061Sjkh	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
5363213Spst	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
53730169Sjkh.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
53830169Sjkh	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
53930169Sjkh	cd ${.CURDIR}/lib/libtcl &&		${MAKE} installhdrs
54030169Sjkh.endif
54117308Speter	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
5425749Swollman	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
54334520Sbde	cd ${.CURDIR}/lib/libss &&		${MAKE} -B hdrs beforeinstall
54417308Speter	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
54517308Speter	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
54630169Sjkh	cd ${.CURDIR}/lib/libvgl &&		${MAKE} beforeinstall
54726504Sjhay	cd ${.CURDIR}/lib/libz &&		${MAKE} beforeinstall
54830169Sjkh	cd ${.CURDIR}/usr.bin/f2c &&		${MAKE} beforeinstall
54930169Sjkh	cd ${.CURDIR}/usr.bin/lex &&		${MAKE} beforeinstall
5502061Sjkh
55117308Speter#
55217308Speter# lib-tools - build tools to compile and install the libraries.
55317308Speter#
55427910Sasami# XXX gperf is required for cc
55527910Sasami# XXX a new ld and tsort is required for cc
5565366Snatelib-tools:
55727910Sasami.for d in				\
55827910Sasami		gnu/usr.bin/gperf	\
55927910Sasami		gnu/usr.bin/ld		\
56027910Sasami		usr.bin/tsort		\
56127910Sasami		gnu/usr.bin/as		\
56227910Sasami		gnu/usr.bin/bison	\
56327910Sasami		gnu/usr.bin/cc		\
56427910Sasami		usr.bin/ar		\
56527910Sasami		usr.bin/lex/lib		\
56627910Sasami		usr.bin/mk_cmds		\
56727910Sasami		usr.bin/nm		\
56827910Sasami		usr.bin/ranlib		\
56927910Sasami		usr.bin/uudecode
57034509Sbde	cd ${.CURDIR}/$d && ${MAKE} ${MK_FLAGS} depend && \
57130113Sjkh		${MAKE} ${MK_FLAGS} all && \
57234623Sbde		${MAKE} ${MK_FLAGS} -B install && \
57334575Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
57427910Sasami.endfor
5755366Snate
57617308Speter#
57717308Speter# libraries - build and install the libraries
57817308Speter#
57934541Sbde
58034541Sbde# We have to know too much about botches in the lib tree:
58134541Sbde.if exists(csu/${MACHINE}.pcc)
58234541Sbde_csu=csu/${MACHINE}.pcc
58334541Sbde.else
58434541Sbde_csu=csu/${MACHINE}
58524754Sjdp.endif
58634541Sbde
58734541Sbde.if defined(WANT_CSRG_LIBM)
58834541Sbde_libm=	libm
58934541Sbde.else
59034541Sbde_libm=	msun
5918295Srgrimes.endif
59234541Sbde
59334541Sbdelibraries:
59434541Sbde#
59534541Sbde# Build csu early so that some tools get linked to the new version (too
59634541Sbde# late for the main tools, however).
59734541Sbde#
59834541Sbde# To satisfy shared library or ELF linkage when only the libraries being
59934541Sbde# built are visible:
60034541Sbde#
60134541Sbde# libcom_err must be built before libss.
60234541Sbde# libcrypt and libmd must be built before libskey.
60334541Sbde# libm must be built before libtcl.
60434541Sbde# libmytinfo must be built before libdialog and libncurses.
60534541Sbde# libncurses must be built before libdialog.
60634541Sbde# libtermcap must be built before libcurses, libedit and libreadline.
60734541Sbde#
60834541Sbde.for _lib in ${_csu} libcom_err libcrypt ${_libm} libmytinfo \
60934541Sbde	     libncurses libtermcap
61034541Sbde.if exists(${.CURDIR}/lib/${_lib})
61134541Sbde	cd ${.CURDIR}/lib/${_lib} && \
61234541Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} depend && \
61334541Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} all && \
61434541Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B install
6158489Srgrimes.endif
61634541Sbde.endfor
61734541Sbde.for _lib in gnu/lib lib usr.bin/lex/lib usr.sbin/pcvt/keycap
61834541Sbde.if exists(${.CURDIR}/${_lib})
61934541Sbde	cd ${.CURDIR}/${_lib} && \
62034541Sbde		${MAKE} ${MK_FLAGS} depend && \
62130113Sjkh		${MAKE} ${MK_FLAGS} all && \
62230113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6238489Srgrimes.endif
62434541Sbde.endfor
62534541Sbde.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
62634509Sbde	cd ${.CURDIR}/secure/lib && ${MAKE} ${MK_FLAGS} depend && \
62730113Sjkh		${MAKE} ${MK_FLAGS} all && \
62830113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6292160Scsgr.endif
63034541Sbde.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
63134541Sbde    defined(MAKE_KERBEROS4)
63234509Sbde	cd ${.CURDIR}/kerberosIV/lib && ${MAKE} ${MK_FLAGS} depend && \
63330113Sjkh		${MAKE} ${MK_FLAGS} all && \
63430113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6352626Scsgr.endif
6362061Sjkh
63717308Speter#
63817308Speter# build-tools - build and install any other tools needed to complete the
63917308Speter# compile and install.
64027910Sasami# ifdef stale
64127910Sasami# bc and cpp are required to build groff.  Otherwise, the order here is
64227910Sasami# mostly historical, i.e., bogus.
64327910Sasami# chmod is used to build gcc's tmpmultilib[2] at obscure times.
64427910Sasami# endif stale
64527910Sasami# XXX uname is a bug - the target should not depend on the host.
64617308Speter#
64711806Sphkbuild-tools:
64819175Sbde.for d in				\
64927910Sasami		bin/cat 		\
65027910Sasami		bin/chmod		\
65127910Sasami		bin/cp 			\
65227910Sasami		bin/date		\
65327910Sasami		bin/dd			\
65427910Sasami		bin/echo		\
65527910Sasami		bin/expr		\
65627910Sasami		bin/hostname		\
65727910Sasami		bin/ln			\
65827910Sasami		bin/ls			\
65927910Sasami		bin/mkdir		\
66027910Sasami		bin/mv			\
66127910Sasami		bin/rm			\
66227910Sasami		bin/sh			\
66327910Sasami		bin/test		\
66427910Sasami		gnu/usr.bin/awk		\
66527910Sasami		gnu/usr.bin/bc		\
66627910Sasami		gnu/usr.bin/grep	\
66727910Sasami		gnu/usr.bin/groff	\
66827910Sasami		gnu/usr.bin/gzip	\
66927910Sasami		gnu/usr.bin/man/makewhatis	\
67027910Sasami		gnu/usr.bin/sort	\
67134509Sbde		gnu/usr.bin/texinfo	\
67221673Sjkh		share/info		\
67327910Sasami		usr.bin/basename	\
67427910Sasami		usr.bin/cap_mkdb	\
67527910Sasami		usr.bin/chflags		\
67627910Sasami		usr.bin/cmp		\
67727910Sasami		usr.bin/col		\
67827910Sasami		usr.bin/cpp		\
67927910Sasami		usr.bin/expand		\
68027910Sasami		usr.bin/file2c		\
68127910Sasami		usr.bin/find		\
68227910Sasami		usr.bin/gencat		\
68327910Sasami		usr.bin/lorder		\
68427910Sasami		usr.bin/m4		\
68527910Sasami		usr.bin/mkdep		\
68627910Sasami		usr.bin/paste		\
68727910Sasami		usr.bin/sed		\
68827910Sasami		usr.bin/size		\
68927910Sasami		usr.bin/soelim		\
69027910Sasami		usr.bin/strip		\
69119175Sbde		usr.bin/symorder	\
69227910Sasami		usr.bin/touch		\
69327910Sasami		usr.bin/tr		\
69427910Sasami		usr.bin/true		\
69527910Sasami		usr.bin/uname		\
69627910Sasami		usr.bin/uuencode	\
69727910Sasami		usr.bin/vgrind		\
69827910Sasami		usr.bin/vi		\
69927910Sasami		usr.bin/wc		\
70034688Sbde		usr.bin/xargs		\
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