Makefile revision 36397
12061Sjkh#
236397Ssos#	$Id: Makefile,v 1.180 1998/05/25 17:34:34 sos Exp $
32061Sjkh#
433611Sjb# While porting to the another architecture include the bootstrap instead
532427Sjb# of the normal build.
632427Sjb#
736111Sjb.if exists(${.CURDIR}/Makefile.${MACHINE}) && defined(BOOTSTRAP_WORLD)
833611Sjb.include "${.CURDIR}/Makefile.${MACHINE}"
932427Sjb.else
1032427Sjb#
112061Sjkh# Make command line options:
1215603Smarkm#	-DCLOBBER will remove /usr/include
1330169Sjkh#	-DMAKE_KERBEROS4 to build KerberosIV
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)
13135479SbdeCLEANDIR=	clean cleandepend
1328854Srgrimes.else
1332061SjkhCLEANDIR=	cleandir
1342061Sjkh.endif
13512483Speter.endif
1362061Sjkh
13735479Sbde.if !defined(NOCLEAN) && ${.MAKEFLAGS:M-j} == ""
13835479Sbde_NODEPEND=	true
13935479Sbde.endif
14035479Sbde.if defined(_NODEPEND)
14135479Sbde_DEPEND=	cleandepend
14235479Sbde.else
14335479Sbde_DEPEND=	depend
14435479Sbde.endif
14535479Sbde
14635462SjkhSUP?=		cvsup
14735462SjkhSUPFLAGS?=	-g -L 2 -P -
14818714Sache
14917308Speter#
15034541Sbde# While building tools for bootstrapping, we don't need to waste time on
15134575Sbde# shared or profiled libraries, shared linkage, or documentation, except
15234575Sbde# when the tools won't get cleaned we must use the defaults for shared
15334575Sbde# libraries and shared linkage (and this doesn't waste time).
15434592Sbde# XXX actually, we do need to waste time building shared libraries.
15517308Speter#
15634575Sbde.if defined(NOCLEAN)
15735427SbdeMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
15834575Sbde.else
15935427SbdeMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
16034575Sbde.endif
16115603Smarkm
16217308Speter#
16317308Speter# world
16417308Speter#
16517308Speter# Attempt to rebuild and reinstall *everything*, with reasonable chance of
16617308Speter# success, regardless of how old your existing system is.
16717308Speter#
16817308Speter# >> Beware, it overwrites the local build environment! <<
16917308Speter#
17017308Speterworld:
17118362Sjkh	@echo "--------------------------------------------------------------"
17219966Sache	@echo "make world started on `LC_TIME=C date`"
17318362Sjkh	@echo "--------------------------------------------------------------"
17417308Speter.if target(pre-world)
17527910Sasami	@echo
17617308Speter	@echo "--------------------------------------------------------------"
17717308Speter	@echo " Making 'pre-world' target"
17817308Speter	@echo "--------------------------------------------------------------"
17936074Sbde	cd ${.CURDIR}; ${MAKE} pre-world
18027910Sasami.endif
18136074Sbde	cd ${.CURDIR}; ${MAKE} buildworld
18236074Sbde	cd ${.CURDIR}; ${MAKE} -B installworld
18327910Sasami.if target(post-world)
18417308Speter	@echo
1852061Sjkh	@echo "--------------------------------------------------------------"
18627910Sasami	@echo " Making 'post-world' target"
1872061Sjkh	@echo "--------------------------------------------------------------"
18836074Sbde	cd ${.CURDIR}; ${MAKE} post-world
18927910Sasami.endif
1902061Sjkh	@echo
19117308Speter	@echo "--------------------------------------------------------------"
19227910Sasami	@echo "make world completed on `LC_TIME=C date`"
19317308Speter	@echo "--------------------------------------------------------------"
19427910Sasami
19527910Sasami.if defined(MAKEOBJDIRPREFIX)
19627910SasamiWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
19717308Speter.else
19827910SasamiWORLDTMP=	/usr/obj${.CURDIR}/tmp
19917308Speter.endif
20027910SasamiSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
20127910SasamiTMPPATH=	${STRICTTMPPATH}:${PATH}
20227910Sasami
20327910Sasami# XXX COMPILER_PATH is needed for finding cc1, ld and as
20427910Sasami# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
20527910Sasami#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
20627910Sasami#	wouldn't link *crt.o or libgcc if it were used.
20727910Sasami# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
20827910Sasami#	want that - all compile-time library paths should be resolved by gcc.
20927910Sasami#	It fails for set[ug]id executables (are any used?).
21027910SasamiCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
21127910Sasami		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
21234509Sbde		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
21327910Sasami		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
21427910Sasami		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
21527910Sasami
21627910SasamiBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
21727910SasamiXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
21835479Sbde		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
21927910Sasami
22027910Sasami# used to compile and install 'make' in temporary build tree
22134688SbdeMAKETMP=	${WORLDTMP}/make
22234688SbdeIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
22327910Sasami# bootstrap make
22435427SbdeBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
22527910Sasami# cross make used for compilation
22635427SbdeXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
22727910Sasami# cross make used for final installation
22835427SbdeIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
22927910Sasami
23027910Sasami#
23127910Sasami# buildworld
23227910Sasami#
23327910Sasami# Attempt to rebuild the entire system, with reasonable chance of
23427910Sasami# success, regardless of how old your existing system is.
23527910Sasami#
23627910Sasamibuildworld:
23727910Sasami.if !defined(NOCLEAN)
23817308Speter	@echo
23917308Speter	@echo "--------------------------------------------------------------"
24027910Sasami	@echo " Cleaning up the temporary build tree"
24117308Speter	@echo "--------------------------------------------------------------"
24227910Sasami	mkdir -p ${WORLDTMP}
24327910Sasami	chflags -R noschg ${WORLDTMP}/
24427910Sasami	rm -rf ${WORLDTMP}
24527910Sasami.endif
24633133Sadam.if !defined(NOTOOLS)
24717466Speter	@echo
24817308Speter	@echo "--------------------------------------------------------------"
24927910Sasami	@echo " Making make"
25017308Speter	@echo "--------------------------------------------------------------"
25134688Sbde	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
25234688Sbde	( \
25336074Sbde	cd ${.CURDIR}/usr.bin/make; \
25436074Sbde		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
25536074Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
25636074Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
25734688Sbde		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
25834688Sbde	)
25933133Sadam.endif
26017308Speter	@echo
26117308Speter	@echo "--------------------------------------------------------------"
26227910Sasami	@echo " Making hierarchy"
26317308Speter	@echo "--------------------------------------------------------------"
26436074Sbde	cd ${.CURDIR}; ${BMAKE} hierarchy
26527910Sasami.if !defined(NOCLEAN)
26617308Speter	@echo
26717308Speter	@echo "--------------------------------------------------------------"
26827910Sasami	@echo " Cleaning up the obj tree"
26917308Speter	@echo "--------------------------------------------------------------"
27036074Sbde	cd ${.CURDIR}; ${BMAKE} ${CLEANDIR:S/^/par-/}
27127910Sasami.endif
27227910Sasami.if !defined(NOOBJDIR)
27317308Speter	@echo
27417308Speter	@echo "--------------------------------------------------------------"
27527910Sasami	@echo " Rebuilding the obj tree"
27617308Speter	@echo "--------------------------------------------------------------"
27736074Sbde	cd ${.CURDIR}; ${BMAKE} par-${OBJDIR}
27827910Sasami.endif
27933133Sadam.if !defined(NOTOOLS)
28017308Speter	@echo
28117308Speter	@echo "--------------------------------------------------------------"
28227910Sasami	@echo " Rebuilding bootstrap tools"
28317308Speter	@echo "--------------------------------------------------------------"
28436074Sbde	cd ${.CURDIR}; ${BMAKE} bootstrap
28517308Speter	@echo
28617308Speter	@echo "--------------------------------------------------------------"
28727910Sasami	@echo " Rebuilding tools necessary to build the include files"
28817308Speter	@echo "--------------------------------------------------------------"
28936074Sbde	cd ${.CURDIR}; ${BMAKE} include-tools
29033133Sadam.endif
29117308Speter	@echo
29217308Speter	@echo "--------------------------------------------------------------"
29334509Sbde	@echo " Rebuilding ${DESTDIR}/usr/include"
29417308Speter	@echo "--------------------------------------------------------------"
29536074Sbde	cd ${.CURDIR}; SHARED=symlinks ${BMAKE} includes
29635851Sjb	@echo
29735851Sjb	@echo "--------------------------------------------------------------"
29835851Sjb	@echo " Rebuilding bootstrap libraries"
29935851Sjb	@echo "--------------------------------------------------------------"
30036074Sbde	cd ${.CURDIR}; ${BMAKE} bootstrap-libraries
30133133Sadam.if !defined(NOTOOLS)
30217962Speter	@echo
30317962Speter	@echo "--------------------------------------------------------------"
30435851Sjb	@echo " Rebuilding tools needed to build libraries"
30517962Speter	@echo "--------------------------------------------------------------"
30636074Sbde	cd ${.CURDIR}; ${BMAKE} lib-tools
30733133Sadam.endif
30833133Sadam.if !defined(NOTOOLS)
30917962Speter	@echo
31017962Speter	@echo "--------------------------------------------------------------"
31127910Sasami	@echo " Rebuilding all other tools needed to build the world"
31217962Speter	@echo "--------------------------------------------------------------"
31336074Sbde	cd ${.CURDIR}; ${BMAKE} build-tools
31433133Sadam.endif
31535479Sbde.if !defined(_NODEPEND)
31617308Speter	@echo
31717308Speter	@echo "--------------------------------------------------------------"
31827910Sasami	@echo " Rebuilding dependencies"
31917308Speter	@echo "--------------------------------------------------------------"
32036074Sbde	cd ${.CURDIR}; ${XMAKE} par-depend
32135479Sbde.endif
32217308Speter	@echo
32317308Speter	@echo "--------------------------------------------------------------"
32435427Sbde	@echo " Building libraries"
32535427Sbde	@echo "--------------------------------------------------------------"
32636074Sbde	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN libraries
32735427Sbde	@echo
32835427Sbde	@echo "--------------------------------------------------------------"
32927910Sasami	@echo " Building everything.."
33017962Speter	@echo "--------------------------------------------------------------"
33136074Sbde	cd ${.CURDIR}; ${XMAKE} all
3322061Sjkh
33317308Speter#
33427910Sasami# installworld
33527910Sasami#
33627910Sasami# Installs everything compiled by a 'buildworld'.
33727910Sasami#
33827910Sasamiinstallworld:
33936074Sbde	cd ${.CURDIR}; ${IXMAKE} reinstall
34027910Sasami
34127910Sasami#
34217308Speter# reinstall
34317308Speter#
34417308Speter# If you have a build server, you can NFS mount the source and obj directories
34517308Speter# and do a 'make reinstall' on the *client* to install new binaries from the
34617308Speter# most recent server build.
34717308Speter#
34817308Speterreinstall:
34912483Speter	@echo "--------------------------------------------------------------"
35017308Speter	@echo " Making hierarchy"
35112483Speter	@echo "--------------------------------------------------------------"
35236074Sbde	cd ${.CURDIR}; ${MAKE} hierarchy
35312483Speter	@echo
3542061Sjkh	@echo "--------------------------------------------------------------"
35517962Speter	@echo " Installing everything.."
35617962Speter	@echo "--------------------------------------------------------------"
35736074Sbde	cd ${.CURDIR}; ${MAKE} install
35817962Speter	@echo
35917962Speter	@echo "--------------------------------------------------------------"
36033595Snate	@echo " Re-scanning the shared libraries.."
36133595Snate	@echo "--------------------------------------------------------------"
36236074Sbde	cd ${.CURDIR}; ldconfig -R
36333595Snate	@echo
36433595Snate	@echo "--------------------------------------------------------------"
36517962Speter	@echo " Rebuilding man page indexes"
36617962Speter	@echo "--------------------------------------------------------------"
36736074Sbde	cd ${.CURDIR}/share/man; ${MAKE} makedb
3682061Sjkh
36917308Speter#
37017308Speter# update
37117308Speter#
37217308Speter# Update the source tree, by running sup and/or running cvs to update to the
37317308Speter# latest copy.
37417308Speter#
3752302Spaulupdate:
3762302Spaul.if defined(SUP_UPDATE)
3772302Spaul	@echo "--------------------------------------------------------------"
37835462Sjkh	@echo "Running ${SUP}"
3792302Spaul	@echo "--------------------------------------------------------------"
38018714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE}
38110760Sache.if defined(SUPFILE1)
38218714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE1}
3832302Spaul.endif
38410760Sache.if defined(SUPFILE2)
38518714Sache	@${SUP} ${SUPFLAGS} ${SUPFILE2}
38610760Sache.endif
38710760Sache.endif
3882302Spaul.if defined(CVS_UPDATE)
3892302Spaul	@echo "--------------------------------------------------------------"
3902302Spaul	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
3912302Spaul	@echo "--------------------------------------------------------------"
39236074Sbde	cd ${.CURDIR}; cvs -q update -P -d
3932302Spaul.endif
3942302Spaul
39517308Speter#
39617308Speter# most
39717308Speter#
39817308Speter# Build most of the user binaries on the existing system libs and includes.
39917308Speter#
40017308Spetermost:
4012061Sjkh	@echo "--------------------------------------------------------------"
40217308Speter	@echo " Building programs only"
4032061Sjkh	@echo "--------------------------------------------------------------"
40436074Sbde	cd ${.CURDIR}/bin;		${MAKE} all
40536074Sbde	cd ${.CURDIR}/sbin;		${MAKE} all
40636074Sbde	cd ${.CURDIR}/libexec;		${MAKE} all
40736074Sbde	cd ${.CURDIR}/usr.bin;		${MAKE} all
40836074Sbde	cd ${.CURDIR}/usr.sbin;		${MAKE} all
40936074Sbde	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
41036074Sbde	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
41136074Sbde	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
41230169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
41336074Sbde#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
41417308Speter#.endif
41517308Speter#.if !defined(NOSECURE) && !defined(NOCRYPT)
41636074Sbde#	cd ${.CURDIR}/secure;		${MAKE} most
41717308Speter#.endif
4182061Sjkh
41917308Speter#
42017308Speter# installmost
42117308Speter#
42217308Speter# Install the binaries built by the 'most' target.  This does not include
42317308Speter# libraries or include files.
42417308Speter#
4253626Swollmaninstallmost:
4263626Swollman	@echo "--------------------------------------------------------------"
4273626Swollman	@echo " Installing programs only"
4283626Swollman	@echo "--------------------------------------------------------------"
42936074Sbde	cd ${.CURDIR}/bin;		${MAKE} install
43036074Sbde	cd ${.CURDIR}/sbin;		${MAKE} install
43136074Sbde	cd ${.CURDIR}/libexec;		${MAKE} install
43236074Sbde	cd ${.CURDIR}/usr.bin;		${MAKE} install
43336074Sbde	cd ${.CURDIR}/usr.sbin;		${MAKE} install
43436074Sbde	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
43536074Sbde	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
43636074Sbde	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
43730169Sjkh#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
43836074Sbde#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
4393626Swollman#.endif
4403626Swollman#.if !defined(NOSECURE) && !defined(NOCRYPT)
44136074Sbde#	cd ${.CURDIR}/secure;		${MAKE} installmost
4423626Swollman#.endif
4433626Swollman
44417308Speter#
44517308Speter# ------------------------------------------------------------------------
44617308Speter#
44717308Speter# From here onwards are utility targets used by the 'make world' and
44817308Speter# related targets.  If your 'world' breaks, you may like to try to fix
44917308Speter# the problem and manually run the following targets to attempt to
45017308Speter# complete the build.  Beware, this is *not* guaranteed to work, you
45117308Speter# need to have a pretty good grip on the current state of the system
45217308Speter# to attempt to manually finish it.  If in doubt, 'make world' again.
45317308Speter#
4543626Swollman
45517308Speter#
45617308Speter# heirarchy - ensure that all the needed directories are present
45717308Speter#
45817308Speterhierarchy:
45936074Sbde	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
46017308Speter
46117308Speter#
46217308Speter# bootstrap - [re]build tools needed to run the actual build, this includes
46317308Speter# tools needed by 'make depend', as some tools are needed to generate source
46417308Speter# for the dependency information to be gathered from.
46517308Speter#
46617308Speterbootstrap:
46727910Sasami.if defined(DESTDIR)
46827910Sasami	rm -f ${DESTDIR}/usr/src/sys
46927910Sasami	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
47036074Sbde	cd ${.CURDIR}/include; find -dx . | cpio -dump ${DESTDIR}/usr/include
47136074Sbde	cd ${.CURDIR}/include; ${MAKE} symlinks
47227910Sasami.endif
47336074Sbde	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
47436074Sbde		${MAKE} ${MK_FLAGS} all; \
47530113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
47636074Sbde	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
47736074Sbde		${MAKE} ${MK_FLAGS} all; \
47830113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
47936074Sbde	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
48036074Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
48136074Sbde		${MAKE} ${MK_FLAGS} -DNOLIB all; \
48230113Sjkh		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
48329938Smckay.if !defined(NOOBJDIR)
48436074Sbde	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
48529938Smckay.endif
48617308Speter
48717308Speter#
48817308Speter# include-tools - generally the same as 'bootstrap', except that it's for
48917308Speter# things that are specifically needed to generate include files.
49017308Speter#
49127910Sasami# XXX should be merged with bootstrap, it's not worth keeeping them separate.
49227910Sasami# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
49327910Sasami# on cleaned away headers in ${WORLDTMP}.
49417308Speter#
49517308Speterinclude-tools:
49634520Sbde.for d in usr.bin/compile_et usr.bin/rpcgen
49736074Sbde	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
49836074Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
49936074Sbde		${MAKE} ${MK_FLAGS} all; \
50030113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
50134520Sbde.endfor
50217308Speter
50317308Speter#
50417308Speter# includes - possibly generate and install the include files.
50517308Speter#
50614119Speterincludes:
5072061Sjkh.if defined(CLOBBER)
5087130Srgrimes	rm -rf ${DESTDIR}/usr/include/*
5097130Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
5107130Srgrimes		-p ${DESTDIR}/usr/include
5112061Sjkh.endif
51236074Sbde	cd ${.CURDIR}/include;			${MAKE} -B all install
51336074Sbde	cd ${.CURDIR}/gnu/include;		${MAKE} install
51436074Sbde	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
51536074Sbde	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
51636074Sbde	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
51736074Sbde	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
51836074Sbde	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
51936074Sbde	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
52036074Sbde	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
52136074Sbde	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
52230169Sjkh.if exists(secure) && !defined(NOCRYPT)
52336074Sbde	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
5243197Scsgr.endif
52530169Sjkh.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
52636074Sbde	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
52736074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
52836074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
52936074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
53036074Sbde	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
53136074Sbde	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
53230169Sjkh.else
53336074Sbde	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
53430169Sjkh.endif
53532427Sjb.if exists(${.CURDIR}/lib/csu/${MACHINE})
53636074Sbde	cd ${.CURDIR}/lib/csu/${MACHINE};	${MAKE} beforeinstall
53732427Sjb.endif
53836074Sbde	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
53936074Sbde	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
54036074Sbde	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
54136074Sbde	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
54236074Sbde	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
54336074Sbde	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
54436074Sbde	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
54536074Sbde	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
54636074Sbde	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
54736074Sbde	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
5487281Srgrimes.if !defined(WANT_CSRG_LIBM)
54936074Sbde	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
5503242Spaul.endif
55136074Sbde	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
55236074Sbde	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
55336074Sbde	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
55436074Sbde	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
55530169Sjkh.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
55630169Sjkh	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
55736074Sbde	cd ${.CURDIR}/lib/libtcl;		${MAKE} installhdrs
55830169Sjkh.endif
55936074Sbde	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
56036074Sbde	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
56136074Sbde	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
56236074Sbde	cd ${.CURDIR}/lib/libscsi;		${MAKE} beforeinstall
56336074Sbde	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
56436074Sbde	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
56536074Sbde	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
56636074Sbde	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
56736074Sbde	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
5682061Sjkh
56917308Speter#
57017308Speter# lib-tools - build tools to compile and install the libraries.
57117308Speter#
57227910Sasami# XXX gperf is required for cc
57327910Sasami# XXX a new ld and tsort is required for cc
5745366Snatelib-tools:
57527910Sasami.for d in				\
57627910Sasami		gnu/usr.bin/gperf	\
57727910Sasami		gnu/usr.bin/ld		\
57827910Sasami		usr.bin/tsort		\
57927910Sasami		gnu/usr.bin/as		\
58027910Sasami		gnu/usr.bin/bison	\
58127910Sasami		gnu/usr.bin/cc		\
58227910Sasami		usr.bin/ar		\
58327910Sasami		usr.bin/lex/lib		\
58427910Sasami		usr.bin/mk_cmds		\
58527910Sasami		usr.bin/nm		\
58627910Sasami		usr.bin/ranlib		\
58736374Ssos		usr.bin/strip		\
58836374Ssos		usr.bin/objformat	\
58936374Ssos		usr.bin/env		\
59036374Ssos		gnu/usr.bin/binutils	\
59127910Sasami		usr.bin/uudecode
59236074Sbde	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
59336074Sbde		${MAKE} ${MK_FLAGS} all; \
59436074Sbde		${MAKE} ${MK_FLAGS} -B install; \
59534575Sbde		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
59627910Sasami.endfor
5975366Snate
59817308Speter#
59935427Sbde# We have to know too much about ordering and subdirs in the lib trees:
60017308Speter#
60135427Sbde# To satisfy shared library linkage when only the libraries being built
60235427Sbde# are visible:
60335427Sbde#
60435427Sbde# libcom_err must be built before libss.
60535427Sbde# libcrypt and libmd must be built before libskey.
60635427Sbde# libm must be built before libtcl.
60735427Sbde# libmytinfo must be built before libdialog and libncurses.
60835427Sbde# libncurses must be built before libdialog.
60935427Sbde# libtermcap must be built before libcurses, libedit and libreadline.
61035427Sbde#
61135427Sbde# Some libraries are built conditionally and/or are in inconsistently
61235427Sbde# named directories:
61335427Sbde#
61435427Sbde.if exists(lib/csu/${MACHINE}.pcc)
61535427Sbde_csu=lib/csu/${MACHINE}.pcc
61634541Sbde.else
61735427Sbde_csu=lib/csu/${MACHINE}
61824754Sjdp.endif
61934541Sbde
62035427Sbde_libcrypt=	lib/libcrypt
62135427Sbde.if !defined(NOSECURE) && !defined(NOCRYPT)
62235427Sbde_libcrypt+=	secure/lib/libcrypt
62335427Sbde.endif
62435427Sbde
62534541Sbde.if defined(WANT_CSRG_LIBM)
62635427Sbde_libm=	lib/libm
62734541Sbde.else
62835427Sbde_libm=	lib/msun
6298295Srgrimes.endif
63034541Sbde
63134541Sbde#
63235427Sbde# bootstrap-libraries - build just enough libraries for the bootstrap
63335427Sbde# tools, and install them under ${WORLDTMP}.
63434541Sbde#
63535427Sbde# Build csu and libgcc early so that some tools get linked to the new
63635427Sbde# versions (too late for the main tools, however).  Then build the
63735427Sbde# necessary prerequisite libraries (libtermcap just needs to be before
63835427Sbde# libcurses, and this only matters for the NOCLEAN case when NOPIC is
63935427Sbde# not set).
64034541Sbde#
64135427Sbde# This is mostly wrong.  The build tools must run on the host system,
64235427Sbde# so they should use host libraries.  We depend on the target being
64335427Sbde# similar enough to the host for new target libraries to work on the
64435427Sbde# host.
64534541Sbde#
64635427Sbdebootstrap-libraries:
64735427Sbde.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
64836397Ssos    gnu/lib/libregex gnu/lib/libreadline lib/libc \
64936397Ssos    lib/libcrypt lib/libcurses lib/libedit ${_libm} \
65035427Sbde    lib/libmd lib/libutil lib/libz usr.bin/lex/lib
65134541Sbde.if exists(${.CURDIR}/${_lib})
65236074Sbde	cd ${.CURDIR}/${_lib}; \
65336074Sbde		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
65436074Sbde		${MAKE} ${MK_FLAGS} all; \
65530113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
6568489Srgrimes.endif
65734541Sbde.endfor
65835427Sbde
65935427Sbde#
66035427Sbde# libraries - build all libraries, and install them under ${DESTDIR}.
66135427Sbde#
66235427Sbde# The ordering is not as special as for bootstrap-libraries.  Build
66335427Sbde# the prerequisites first, then build almost everything else in
66435427Sbde# alphabetical order.
66535427Sbde#
66635427Sbdelibraries:
66735427Sbde.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
66835427Sbde    lib/libncurses lib/libtermcap \
66935427Sbde    gnu/lib gnu/usr.bin/cc/libgcc lib usr.bin/lex/lib usr.sbin/pcvt/keycap
67035427Sbde.if exists(${.CURDIR}/${_lib})
67136074Sbde	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
67235427Sbde.endif
67335427Sbde.endfor
67434541Sbde.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
67536074Sbde	cd ${.CURDIR}/secure/lib; ${MAKE} all; ${MAKE} -B install
6762160Scsgr.endif
67734541Sbde.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
67834541Sbde    defined(MAKE_KERBEROS4)
67936074Sbde	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} all; ${MAKE} -B install
6802626Scsgr.endif
6812061Sjkh
68217308Speter#
68317308Speter# build-tools - build and install any other tools needed to complete the
68417308Speter# compile and install.
68527910Sasami# ifdef stale
68627910Sasami# bc and cpp are required to build groff.  Otherwise, the order here is
68727910Sasami# mostly historical, i.e., bogus.
68827910Sasami# chmod is used to build gcc's tmpmultilib[2] at obscure times.
68927910Sasami# endif stale
69027910Sasami# XXX uname is a bug - the target should not depend on the host.
69117308Speter#
69211806Sphkbuild-tools:
69319175Sbde.for d in				\
69427910Sasami		bin/cat 		\
69527910Sasami		bin/chmod		\
69627910Sasami		bin/cp 			\
69727910Sasami		bin/date		\
69827910Sasami		bin/dd			\
69927910Sasami		bin/echo		\
70027910Sasami		bin/expr		\
70127910Sasami		bin/hostname		\
70227910Sasami		bin/ln			\
70327910Sasami		bin/ls			\
70427910Sasami		bin/mkdir		\
70527910Sasami		bin/mv			\
70627910Sasami		bin/rm			\
70727910Sasami		bin/sh			\
70827910Sasami		bin/test		\
70927910Sasami		gnu/usr.bin/awk		\
71027910Sasami		gnu/usr.bin/bc		\
71127910Sasami		gnu/usr.bin/grep	\
71227910Sasami		gnu/usr.bin/groff	\
71327910Sasami		gnu/usr.bin/gzip	\
71427910Sasami		gnu/usr.bin/man/makewhatis	\
71535621Sbde		gnu/usr.bin/patch	\
71636142Sjb		gnu/usr.bin/perl/perl	\
71727910Sasami		gnu/usr.bin/sort	\
71834509Sbde		gnu/usr.bin/texinfo	\
71927910Sasami		usr.bin/basename	\
72027910Sasami		usr.bin/cap_mkdb	\
72127910Sasami		usr.bin/chflags		\
72227910Sasami		usr.bin/cmp		\
72327910Sasami		usr.bin/col		\
72427910Sasami		usr.bin/cpp		\
72527910Sasami		usr.bin/expand		\
72627910Sasami		usr.bin/file2c		\
72727910Sasami		usr.bin/find		\
72827910Sasami		usr.bin/gencat		\
72927910Sasami		usr.bin/lorder		\
73027910Sasami		usr.bin/m4		\
73127910Sasami		usr.bin/mkdep		\
73227910Sasami		usr.bin/paste		\
73327910Sasami		usr.bin/sed		\
73427910Sasami		usr.bin/size		\
73527910Sasami		usr.bin/soelim		\
73627910Sasami		usr.bin/strip		\
73719175Sbde		usr.bin/symorder	\
73827910Sasami		usr.bin/touch		\
73927910Sasami		usr.bin/tr		\
74027910Sasami		usr.bin/true		\
74127910Sasami		usr.bin/uname		\
74227910Sasami		usr.bin/uuencode	\
74327910Sasami		usr.bin/vgrind		\
74427910Sasami		usr.bin/vi		\
74527910Sasami		usr.bin/wc		\
74634688Sbde		usr.bin/xargs		\
74727910Sasami		usr.bin/yacc		\
74827910Sasami		usr.sbin/chown		\
74927910Sasami		usr.sbin/mtree		\
75027910Sasami		usr.sbin/zic
75136074Sbde	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
75236074Sbde		${MAKE} ${MK_FLAGS} all; \
75330113Sjkh		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
75419175Sbde.endfor
7552061Sjkh
75635479Sbde.for __target in clean cleandepend cleandir depend obj
75730113Sjkh.for entry in ${SUBDIR}
75830113Sjkh${entry}.${__target}__D: .PHONY
75935294Sdt	@if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
76030113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
76130113Sjkh		edir=${entry}.${MACHINE}; \
76230113Sjkh		cd ${.CURDIR}/$${edir}; \
76330113Sjkh	else \
76430113Sjkh		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
76530113Sjkh		edir=${entry}; \
76630113Sjkh		cd ${.CURDIR}/$${edir}; \
76730113Sjkh	fi; \
76830113Sjkh	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
76930113Sjkh.endfor
77030113Sjkhpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
77130113Sjkh.endfor
77230113Sjkh
77332427Sjb.endif
77432427Sjb
7751594Srgrimes.include <bsd.subdir.mk>
776