Makefile.inc1 revision 114719
1195609Smp#
259243Sobrien# $FreeBSD: head/Makefile.inc1 114719 2003-05-05 08:44:40Z markm $
359243Sobrien#
459243Sobrien# Make command line options:
559243Sobrien#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
659243Sobrien#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
759243Sobrien#	-DNOCLEAN do not clean at all
859243Sobrien#	-DNOCRYPT will prevent building of crypt versions
959243Sobrien#	-DNOMAN do not build the manual pages
1059243Sobrien#	-DNOPROFILE do not build profiled libraries
1159243Sobrien#	-DNOSECURE do not go into secure subdir
1259243Sobrien#	-DNOGAMES do not go into games subdir
1359243Sobrien#	-DNOSHARE do not go into share subdir
1459243Sobrien#	-DNOINFO do not make or install info files
1559243Sobrien#	-DNOLIBC_R do not build libc_r.
1659243Sobrien#	-DNO_FORTRAN do not build g77 and related libraries.
17100616Smp#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1859243Sobrien#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
1959243Sobrien#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
2059243Sobrien#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
2159243Sobrien#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2259243Sobrien#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2359243Sobrien#	TARGET_ARCH="arch" to crossbuild world to a different arch
2459243Sobrien
2559243Sobrien#
2659243Sobrien# The intended user-driven targets are:
2759243Sobrien# buildworld  - rebuild *everything*, including glue to help do upgrades
2859243Sobrien# installworld- install everything built by "buildworld"
2959243Sobrien# update      - convenient way to update your source tree (eg: sup/cvs)
3059243Sobrien# most        - build user commands, no libraries or include files
3159243Sobrien# installmost - install user commands, no libraries or include files
3259243Sobrien#
3359243Sobrien# Standard targets (not defined here) are documented in the makefiles in
3459243Sobrien# /usr/share/mk.  These include:
3559243Sobrien#		obj depend all install clean cleandepend cleanobj
3659243Sobrien
3759243Sobrien# Put initial settings here.
3859243SobrienSUBDIR=
3959243Sobrien
4059243Sobrien# We must do share/info early so that installation of info `dir'
4159243Sobrien# entries works correctly.  Do it first since it is less likely to
4259243Sobrien# grow dependencies on include and lib than vice versa.
4359243Sobrien.if exists(${.CURDIR}/share/info)
4459243SobrienSUBDIR+= share/info
4559243Sobrien.endif
4659243Sobrien
4759243Sobrien.if exists(${.CURDIR}/include)
4859243SobrienSUBDIR+= include
4959243Sobrien.endif
5059243Sobrien.if exists(${.CURDIR}/lib)
5159243SobrienSUBDIR+= lib
5259243Sobrien.endif
5359243Sobrien
5459243Sobrien.if exists(${.CURDIR}/bin)
5559243SobrienSUBDIR+= bin
5659243Sobrien.endif
5759243Sobrien.if exists(${.CURDIR}/games) && !defined(NOGAMES)
5859243SobrienSUBDIR+= games
5959243Sobrien.endif
6059243Sobrien.if exists(${.CURDIR}/gnu)
6159243SobrienSUBDIR+= gnu
6259243Sobrien.endif
6359243Sobrien.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
6459243Sobrien    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
6559243SobrienSUBDIR+= kerberos5
6659243Sobrien.endif
6759243Sobrien.if exists(${.CURDIR}/libexec)
6859243SobrienSUBDIR+= libexec
6959243Sobrien.endif
7059243Sobrien.if exists(${.CURDIR}/sbin)
7159243SobrienSUBDIR+= sbin
7259243Sobrien.endif
7359243Sobrien.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
7459243SobrienSUBDIR+= secure
7559243Sobrien.endif
7659243Sobrien.if exists(${.CURDIR}/share) && !defined(NOSHARE)
7759243SobrienSUBDIR+= share
7859243Sobrien.endif
7959243Sobrien.if exists(${.CURDIR}/sys)
8059243SobrienSUBDIR+= sys
8159243Sobrien.endif
8259243Sobrien.if exists(${.CURDIR}/usr.bin)
8359243SobrienSUBDIR+= usr.bin
8459243Sobrien.endif
8559243Sobrien.if exists(${.CURDIR}/usr.sbin)
8659243SobrienSUBDIR+= usr.sbin
8759243Sobrien.endif
8859243Sobrien
8959243Sobrien# etc must be last for "distribute" to work
9059243Sobrien.if exists(${.CURDIR}/etc)
9159243SobrienSUBDIR+= etc
9259243Sobrien.endif
9359243Sobrien
9459243Sobrien# These are last, since it is nice to at least get the base system
9559243Sobrien# rebuilt before you do them.
9659243Sobrien.if defined(LOCAL_DIRS)
9759243Sobrien.for _DIR in ${LOCAL_DIRS}
9859243Sobrien.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
9959243SobrienSUBDIR+= ${_DIR}
10059243Sobrien.endif
10159243Sobrien.endfor
10259243Sobrien.endif
10359243Sobrien
10459243Sobrien.if defined(SUBDIR_OVERRIDE)
10559243SobrienSUBDIR=		${SUBDIR_OVERRIDE}
10659243Sobrien.endif
10759243Sobrien
10859243Sobrien.if defined(NOCLEANDIR)
10959243SobrienCLEANDIR=	clean cleandepend
11059243Sobrien.else
11159243SobrienCLEANDIR=	cleandir
11259243Sobrien.endif
11359243Sobrien
11459243SobrienCVS?=		cvs
11559243SobrienSUP?=		/usr/local/bin/cvsup
11659243SobrienSUPFLAGS?=	-g -L 2 -P -
11759243Sobrien.if defined(SUPHOST)
11859243SobrienSUPFLAGS+=	-h ${SUPHOST}
11959243Sobrien.endif
12059243Sobrien
12159243SobrienMAKEOBJDIRPREFIX?=	/usr/obj
12259243Sobrien.if !defined(OSRELDATE)
12359243SobrienOSRELDATE!=	sysctl -n kern.osreldate
12459243Sobrien.endif
12559243SobrienTARGET_ARCH?=	${MACHINE_ARCH}
12659243Sobrien.if ${TARGET_ARCH} == ${MACHINE_ARCH}
12759243SobrienTARGET?=	${MACHINE}
12859243SobrienTARGET_CPUTYPE?=${CPUTYPE}
12959243Sobrien.else
13059243SobrienTARGET?=	${TARGET_ARCH}
13159243SobrienTARGET_CPUTYPE?=
13259243Sobrien.endif
13359243Sobrien.if !empty(TARGET_CPUTYPE)
13459243Sobrien_TARGET_CPUTYPE=${TARGET_CPUTYPE}
13559243Sobrien.else
13659243Sobrien_TARGET_CPUTYPE=dummy
13759243Sobrien.endif
13859243Sobrien_CPUTYPE!=	${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
13959243Sobrien		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
14059243Sobrien.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
14159243Sobrien.error CPUTYPE global should be set with ?=.
14259243Sobrien.endif
14359243Sobrien.if make(buildworld)
14459243SobrienBUILD_ARCH!=	sysctl -n hw.machine_arch
14559243Sobrien.if ${MACHINE_ARCH} != ${BUILD_ARCH}
14659243Sobrien.error To cross-build, set TARGET_ARCH.
14759243Sobrien.endif
14859243Sobrien.endif
14959243Sobrien.if ${MACHINE} == ${TARGET}
15059243SobrienOBJTREE=	${MAKEOBJDIRPREFIX}
15159243Sobrien.else
15259243SobrienOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
15359243Sobrien.endif
15459243SobrienWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
15559243Sobrien# /usr/games added for fortune which depend on strfile
15659243SobrienBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
15759243SobrienXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
15859243SobrienSTRICTTMPPATH=	${BPATH}:${XPATH}
15959243SobrienTMPPATH=	${STRICTTMPPATH}:${PATH}
16059243Sobrien
16159243SobrienINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
16259243Sobrien
16359243Sobrien#
16459243Sobrien# Building a world goes through the following stages
16559243Sobrien#
16659243Sobrien# 1. legacy stage [BMAKE]
16759243Sobrien#	This stage is responsible for creating compatibility
16859243Sobrien#	shims that are needed by the bootstrap-tools,
16959243Sobrien#	build-tools and cross-tools stages.
17059243Sobrien# 1. bootstrap-tools stage [BMAKE]
17159243Sobrien#	This stage is responsible for creating programs that
17259243Sobrien#	are needed for backward compatibility reasons. They
17359243Sobrien#	are not built as cross-tools.
17459243Sobrien# 2. build-tools stage [TMAKE]
17559243Sobrien#	This stage is responsible for creating the object
17659243Sobrien#	tree and building any tools that are needed during
17759243Sobrien#	the build process.
17859243Sobrien# 3. cross-tools stage [XMAKE]
17959243Sobrien#	This stage is responsible for creating any tools that
18059243Sobrien#	are needed for cross-builds. A cross-compiler is one
18159243Sobrien#	of them.
18259243Sobrien# 4. world stage [WMAKE]
18359243Sobrien#	This stage actually builds the world.
18459243Sobrien# 5. install stage (optional) [IMAKE]
18559243Sobrien#	This stage installs a previously built world.
18659243Sobrien#
18759243Sobrien
18859243SobrienBOOTSTRAPPING?=	0
18959243Sobrien
19059243Sobrien# Common environment for world related stages
19159243SobrienCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
19259243Sobrien		MACHINE_ARCH=${TARGET_ARCH} \
19359243Sobrien		MACHINE=${TARGET} \
19459243Sobrien		CPUTYPE=${TARGET_CPUTYPE} \
19559243Sobrien		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
19659243Sobrien		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
19759243Sobrien		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
19859243Sobrien
19959243Sobrien# bootstrap-tools stage
20059243SobrienBMAKEENV=	DESTDIR= \
20159243Sobrien		INSTALL="sh ${.CURDIR}/tools/install.sh" \
20259243Sobrien		PATH=${BPATH}:${PATH} \
20359243Sobrien		WORLDTMP=${WORLDTMP} \
20459243Sobrien		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
20559243SobrienBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
20659243Sobrien		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
20759243Sobrien		BOOTSTRAPPING=${OSRELDATE} \
20859243Sobrien		-DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
20959243Sobrien		-DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
21059243Sobrien
21159243Sobrien# build-tools stage
21259243SobrienTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
21359243Sobrien		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
21459243Sobrien		BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
21559243Sobrien
21659243Sobrien# cross-tools stage
21759243SobrienXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
21859243Sobrien
21959243Sobrien# world stage
22059243SobrienWMAKEENV=	${CROSSENV} \
22159243Sobrien		DESTDIR=${WORLDTMP} \
22259243Sobrien		INSTALL="sh ${.CURDIR}/tools/install.sh" \
22359243Sobrien		PATH=${TMPPATH}
22459243SobrienWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
22559243Sobrien
22659243Sobrien# install stage
22759243SobrienIMAKEENV=	${CROSSENV} \
22859243Sobrien		PATH=${STRICTTMPPATH}:${INSTALLTMP}
22959243SobrienIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
23059243Sobrien
23159243Sobrien# kernel stage
23259243SobrienKMAKEENV=	${WMAKEENV}
23359243Sobrien
23459243Sobrien#
23559243Sobrien# buildworld
23659243Sobrien#
23759243Sobrien# Attempt to rebuild the entire system, with reasonable chance of
23859243Sobrien# success, regardless of how old your existing system is.
23959243Sobrien#
24059243Sobrien_worldtmp:
24159243Sobrien.if ${.CURDIR:C/[^,]//g} != ""
24259243Sobrien#	The m4 build of sendmail files doesn't like it if ',' is used
24359243Sobrien#	anywhere in the path of it's files.
24459243Sobrien	@echo
24559243Sobrien	@echo "*** Error: path to source tree contains a comma ','"
24659243Sobrien	@echo
24759243Sobrien	@false
24859243Sobrien.endif
24959243Sobrien	@echo
25059243Sobrien	@echo "--------------------------------------------------------------"
25159243Sobrien	@echo ">>> Rebuilding the temporary build tree"
25259243Sobrien	@echo "--------------------------------------------------------------"
25359243Sobrien.if !defined(NOCLEAN)
25459243Sobrien	rm -rf ${WORLDTMP}
25559243Sobrien.else
25659243Sobrien	rm -rf ${WORLDTMP}/legacy/usr/include
25759243Sobrien	# XXX - These two can depend on any header file.
25859243Sobrien	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
25959243Sobrien	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
26059243Sobrien.endif
26159243Sobrien.for _dir in \
26259243Sobrien    usr/bin usr/games usr/include/sys usr/lib \
26359243Sobrien    usr/libexec usr/sbin usr/share/dict \
26459243Sobrien    usr/share/groff_font/devX100 \
26559243Sobrien    usr/share/groff_font/devX100-12 \
26659243Sobrien    usr/share/groff_font/devX75 \
26759243Sobrien    usr/share/groff_font/devX75-12 \
26859243Sobrien    usr/share/groff_font/devascii \
26959243Sobrien    usr/share/groff_font/devcp1047 \
27059243Sobrien    usr/share/groff_font/devdvi \
27159243Sobrien    usr/share/groff_font/devhtml \
27259243Sobrien    usr/share/groff_font/devkoi8-r \
27359243Sobrien    usr/share/groff_font/devlatin1 \
27459243Sobrien    usr/share/groff_font/devlbp \
27559243Sobrien    usr/share/groff_font/devlj4 \
27659243Sobrien    usr/share/groff_font/devps \
27759243Sobrien    usr/share/groff_font/devutf8 \
27859243Sobrien    usr/share/tmac/mdoc usr/share/tmac/mm
27959243Sobrien	mkdir -p ${WORLDTMP}/legacy/${_dir}
28059243Sobrien.endfor
28159243Sobrien.for _dir in \
28259243Sobrien    usr/bin usr/lib/compat/aout usr/libdata/ldscripts usr/libexec usr/share/misc
28359243Sobrien	mkdir -p ${WORLDTMP}/${_dir}
28459243Sobrien.endfor
28559243Sobrien.for _dir in \
28659243Sobrien    arpa dev fs g++/backward g++/bits g++/ext isc isofs libmilter \
28759243Sobrien    objc openssl protocols readline rpc rpcsvc security ufs
28859243Sobrien	mkdir -p ${WORLDTMP}/usr/include/${_dir}
28959243Sobrien.endfor
29059243Sobrien	ln -sf ${.CURDIR}/sys ${WORLDTMP}
29159243Sobrien_legacy:
29259243Sobrien	@echo
29359243Sobrien	@echo "--------------------------------------------------------------"
29459243Sobrien	@echo ">>> stage 1: legacy release compatibility shims"
29559243Sobrien	@echo "--------------------------------------------------------------"
29659243Sobrien	cd ${.CURDIR}; ${BMAKE} legacy
29759243Sobrien_bootstrap-tools:
29859243Sobrien	@echo
29959243Sobrien	@echo "--------------------------------------------------------------"
30059243Sobrien	@echo ">>> stage 1: bootstrap tools"
30159243Sobrien	@echo "--------------------------------------------------------------"
30259243Sobrien	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
30359243Sobrien_cleanobj:
30459243Sobrien.if !defined(NOCLEAN)
30559243Sobrien	@echo
30659243Sobrien	@echo "--------------------------------------------------------------"
30759243Sobrien	@echo ">>> stage 2: cleaning up the object tree"
30859243Sobrien	@echo "--------------------------------------------------------------"
30959243Sobrien	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
31059243Sobrien.endif
31159243Sobrien_obj:
31259243Sobrien	@echo
31359243Sobrien	@echo "--------------------------------------------------------------"
31459243Sobrien	@echo ">>> stage 2: rebuilding the object tree"
31559243Sobrien	@echo "--------------------------------------------------------------"
31659243Sobrien	cd ${.CURDIR}; ${WMAKE} par-obj
31759243Sobrien_build-tools:
31859243Sobrien	@echo
31959243Sobrien	@echo "--------------------------------------------------------------"
32059243Sobrien	@echo ">>> stage 2: build tools"
32159243Sobrien	@echo "--------------------------------------------------------------"
32259243Sobrien	cd ${.CURDIR}; ${TMAKE} build-tools
32359243Sobrien_cross-tools:
32459243Sobrien	@echo
32559243Sobrien	@echo "--------------------------------------------------------------"
32659243Sobrien	@echo ">>> stage 3: cross tools"
32759243Sobrien	@echo "--------------------------------------------------------------"
32859243Sobrien	cd ${.CURDIR}; ${XMAKE} cross-tools
32959243Sobrien_includes:
33059243Sobrien	@echo
33159243Sobrien	@echo "--------------------------------------------------------------"
33259243Sobrien	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
33359243Sobrien	@echo "--------------------------------------------------------------"
33459243Sobrien	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
33559243Sobrien_libraries:
33659243Sobrien	@echo
33759243Sobrien	@echo "--------------------------------------------------------------"
33859243Sobrien	@echo ">>> stage 4: building libraries"
33959243Sobrien	@echo "--------------------------------------------------------------"
34059243Sobrien	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
34159243Sobrien_depend:
34259243Sobrien	@echo
34359243Sobrien	@echo "--------------------------------------------------------------"
34459243Sobrien	@echo ">>> stage 4: make dependencies"
34559243Sobrien	@echo "--------------------------------------------------------------"
34659243Sobrien	cd ${.CURDIR}; ${WMAKE} par-depend
34759243Sobrieneverything:
34859243Sobrien	@echo
34959243Sobrien	@echo "--------------------------------------------------------------"
35059243Sobrien	@echo ">>> stage 4: building everything.."
35159243Sobrien	@echo "--------------------------------------------------------------"
35259243Sobrien	cd ${.CURDIR}; ${WMAKE} par-all
35359243Sobrien
35459243Sobrien
35559243SobrienWMAKE_TGTS=
35659243Sobrien.if !defined(SUBDIR_OVERRIDE)
35759243SobrienWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
35859243Sobrien.endif
35959243SobrienWMAKE_TGTS+=	_cleanobj _obj _build-tools
36059243Sobrien.if !defined(SUBDIR_OVERRIDE)
36159243SobrienWMAKE_TGTS+=	_cross-tools
36259243Sobrien.endif
36359243SobrienWMAKE_TGTS+=	_includes _libraries _depend everything
36459243Sobrien
36559243Sobrienbuildworld: ${WMAKE_TGTS}
36659243Sobrien.ORDER: ${WMAKE_TGTS}
36759243Sobrien
36859243Sobrien#
36959243Sobrien# installcheck
37059243Sobrien#
37159243Sobrien# Checks to be sure system is ready for installworld
37259243Sobrien#
37359243Sobrieninstallcheck:
37459243Sobrien.if !defined(NO_SENDMAIL)
37559243Sobrien	@if ! `grep -q '^smmsp:' /etc/passwd`; then \
37659243Sobrien		echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
37759243Sobrien		false; \
37859243Sobrien	fi
37959243Sobrien	@if ! `grep -q '^smmsp:' /etc/group`; then \
38059243Sobrien		echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
38159243Sobrien		false; \
38259243Sobrien	fi
38359243Sobrien.endif
38459243Sobrien.if ${TARGET_ARCH} == ${MACHINE_ARCH} && !defined(DISTDIR) && \
38559243Sobrien    (!defined(DESTDIR) || empty(DESTDIR) || ${DESTDIR} == "/")
38659243Sobrien	@echo "Checking to see if your booted kernel is fresh enough.."
38759243Sobrien	${.OBJDIR}/bin/sh/sh -c \
38859243Sobrien	    'echo "Testing installed kernel for new sigaction(2) syscall"'
38959243Sobrien	@echo "Seems ok.."
39059243Sobrien.endif
39159243Sobrien
39259243Sobrien#
39359243Sobrien# distributeworld
39459243Sobrien#
39559243Sobrien# Distributes everything compiled by a `buildworld'.
39659243Sobrien#
39759243Sobrien# installworld
39859243Sobrien#
39959243Sobrien# Installs everything compiled by a 'buildworld'.
40059243Sobrien#
40159243Sobriendistributeworld installworld: installcheck
40259243Sobrien	mkdir -p ${INSTALLTMP}
40359243Sobrien	for prog in [ awk cap_mkdb cat chflags chmod chown \
40459243Sobrien	    date echo egrep find grep \
40559243Sobrien	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
40659243Sobrien	    test true uname wc zic; do \
40759243Sobrien		cp `which $$prog` ${INSTALLTMP}; \
40859243Sobrien	done
40959243Sobrien	cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
41059243Sobrien	rm -rf ${INSTALLTMP}
41159243Sobrien
41259243Sobrien#
41359243Sobrien# reinstall
41459243Sobrien#
41559243Sobrien# If you have a build server, you can NFS mount the source and obj directories
41659243Sobrien# and do a 'make reinstall' on the *client* to install new binaries from the
41759243Sobrien# most recent server build.
41859243Sobrien#
41959243Sobrienreinstall:
42059243Sobrien	@echo "--------------------------------------------------------------"
42159243Sobrien	@echo ">>> Making hierarchy"
42259243Sobrien	@echo "--------------------------------------------------------------"
42359243Sobrien	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
42459243Sobrien	@echo
42559243Sobrien	@echo "--------------------------------------------------------------"
42659243Sobrien	@echo ">>> Installing everything.."
42759243Sobrien	@echo "--------------------------------------------------------------"
42859243Sobrien	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
42959243Sobrien.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
43059243Sobrien	@echo
43159243Sobrien	@echo "--------------------------------------------------------------"
43259243Sobrien	@echo ">>> Rebuilding man page indices"
43359243Sobrien	@echo "--------------------------------------------------------------"
43459243Sobrien	cd ${.CURDIR}/share/man; ${MAKE} makedb
43559243Sobrien.endif
43659243Sobrien
43759243Sobrienredistribute:
43859243Sobrien	@echo "--------------------------------------------------------------"
43959243Sobrien	@echo ">>> Distributing everything.."
44059243Sobrien	@echo "--------------------------------------------------------------"
44159243Sobrien	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
44259243Sobrien
44359243Sobrien#
44459243Sobrien# buildkernel and installkernel
44559243Sobrien#
44659243Sobrien# Which kernels to build and/or install is specified by setting
44759243Sobrien# KERNCONF. If not defined a GENERIC kernel is built/installed.
44859243Sobrien# Only the existing (depending TARGET) config files are used
44959243Sobrien# for building kernels and only the first of these is designated
45059243Sobrien# as the one being installed.
45159243Sobrien#
45259243Sobrien# Note that we have to use TARGET instead of TARGET_ARCH when
453100616Smp# we're in kernel-land. Since only TARGET_ARCH is (expected) to
454100616Smp# be set to cross-build, we have to make sure TARGET is set
45559243Sobrien# properly.
456195609Smp
45759243Sobrien.if !defined(KERNCONF) && defined(KERNEL)
45859243SobrienKERNCONF=	${KERNEL}
45959243SobrienKERNWARN=	yes
46059243Sobrien.else
46159243SobrienKERNCONF?=	GENERIC
46259243Sobrien.endif
46359243SobrienINSTKERNNAME?=	kernel
46459243Sobrien
46559243SobrienKERNSRCDIR?=	${.CURDIR}/sys
46659243SobrienKRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
46759243SobrienKRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
46859243SobrienKERNCONFDIR?=	${KRNLCONFDIR}
46959243Sobrien
47059243SobrienBUILDKERNELS=
47159243SobrienINSTALLKERNEL=
47259243Sobrien.for _kernel in ${KERNCONF}
47359243Sobrien.if exists(${KERNCONFDIR}/${_kernel})
47459243SobrienBUILDKERNELS+=	${_kernel}
47559243Sobrien.if empty(INSTALLKERNEL)
47659243SobrienINSTALLKERNEL= ${_kernel}
47759243Sobrien.endif
47859243Sobrien.endif
47959243Sobrien.endfor
48059243Sobrien
48159243Sobrien#
48259243Sobrien# buildkernel
48359243Sobrien#
48459243Sobrien# Builds all kernels defined by BUILDKERNELS.
48559243Sobrien#
48659243Sobrienbuildkernel:
48759243Sobrien.if empty(BUILDKERNELS)
48859243Sobrien	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
489100616Smp	@false
490100616Smp.endif
491100616Smp.if defined(KERNWARN)
492100616Smp	@echo "--------------------------------------------------------------"
493100616Smp	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
494100616Smp	@echo "--------------------------------------------------------------"
495100616Smp	@sleep 3
496100616Smp.endif
497100616Smp	@echo
498100616Smp.for _kernel in ${BUILDKERNELS}
499100616Smp	@echo "--------------------------------------------------------------"
500100616Smp	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
501100616Smp	@echo "--------------------------------------------------------------"
502100616Smp	@echo "===> ${_kernel}"
503100616Smp	mkdir -p ${KRNLOBJDIR}
504100616Smp.if !defined(NO_KERNELCONFIG)
505100616Smp	cd ${KRNLCONFDIR}; \
506100616Smp		PATH=${TMPPATH} \
507100616Smp		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
508100616Smp			${KERNCONFDIR}/${_kernel}
509100616Smp.endif
510100616Smp.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
511100616Smp	cd ${KRNLOBJDIR}/${_kernel}; \
512100616Smp	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
513100616Smp.endif
514100616Smp	cd ${KRNLOBJDIR}/${_kernel}; \
515100616Smp	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
516100616Smp	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
517100616Smp	cd ${KRNLOBJDIR}/${_kernel}; \
518100616Smp	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
519100616Smp# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
520100616Smp.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
521100616Smp.for target in obj depend all
52259243Sobrien	cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
523	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
524	    ${MAKE} -DNO_CPU_CFLAGS ${target}
525.endfor
526.endif
527.if !defined(NO_KERNELDEPEND)
528	cd ${KRNLOBJDIR}/${_kernel}; \
529	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
530.endif
531	cd ${KRNLOBJDIR}/${_kernel}; \
532	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
533	@echo "--------------------------------------------------------------"
534	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
535	@echo "--------------------------------------------------------------"
536.endfor
537
538#
539# installkernel
540#
541# Install the kernel defined by INSTALLKERNEL
542#
543installkernel reinstallkernel:
544.if empty(INSTALLKERNEL)
545	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
546	@false
547.endif
548	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
549	    ${CROSSENV} PATH=${TMPPATH} \
550	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
551
552#
553# update
554#
555# Update the source tree, by running sup and/or running cvs to update to the
556# latest copy.
557#
558update:
559.if defined(SUP_UPDATE)
560	@echo "--------------------------------------------------------------"
561	@echo ">>> Running ${SUP}"
562	@echo "--------------------------------------------------------------"
563.if defined(SUPFILE)
564	@${SUP} ${SUPFLAGS} ${SUPFILE}
565.endif
566.if defined(SUPFILE1)
567	@${SUP} ${SUPFLAGS} ${SUPFILE1}
568.endif
569.if defined(SUPFILE2)
570	@${SUP} ${SUPFLAGS} ${SUPFILE2}
571.endif
572.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
573	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
574.endif
575.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
576	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
577.endif
578.endif
579.if defined(CVS_UPDATE)
580	@echo "--------------------------------------------------------------"
581	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
582	@echo "--------------------------------------------------------------"
583	cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
584.endif
585
586#
587# most
588#
589# Build most of the user binaries on the existing system libs and includes.
590#
591most:
592	@echo "--------------------------------------------------------------"
593	@echo ">>> Building programs only"
594	@echo "--------------------------------------------------------------"
595.for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
596	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ all
597.endfor
598
599#
600# installmost
601#
602# Install the binaries built by the 'most' target.  This does not include
603# libraries or include files.
604#
605installmost:
606	@echo "--------------------------------------------------------------"
607	@echo ">>> Installing programs only"
608	@echo "--------------------------------------------------------------"
609.for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
610	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ install
611.endfor
612
613#
614# ------------------------------------------------------------------------
615#
616# From here onwards are utility targets used by the 'make world' and
617# related targets.  If your 'world' breaks, you may like to try to fix
618# the problem and manually run the following targets to attempt to
619# complete the build.  Beware, this is *not* guaranteed to work, you
620# need to have a pretty good grip on the current state of the system
621# to attempt to manually finish it.  If in doubt, 'make world' again.
622#
623
624#
625# legacy: Build compatibility shims for the next three targets
626#
627legacy:
628.for _tool in tools/build
629	@${ECHODIR} "===> ${_tool}"; \
630	    cd ${.CURDIR}/${_tool}; \
631	    ${MAKE} DIRPRFX=${_tool}/ obj; \
632	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
633	    ${MAKE} DIRPRFX=${_tool}/ depend; \
634	    ${MAKE} DIRPRFX=${_tool}/ all; \
635	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
636.endfor
637
638#
639# bootstrap-tools: Build tools needed for compatibility
640#
641.if exists(${.CURDIR}/games) && !defined(NOGAMES)
642_strfile=	games/fortune/strfile
643.endif
644
645.if ${BOOTSTRAPPING} < 500113
646_groff=		gnu/usr.bin/groff
647.else
648_groff=		gnu/usr.bin/groff/tmac
649.endif
650
651.if ( ${BOOTSTRAPPING} < 450005 || \
652    ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034 ))
653_uudecode=	usr.bin/uudecode
654.endif
655
656.if ( ${BOOTSTRAPPING} < 430002 || \
657    ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019 ))
658_xargs=		usr.bin/xargs
659.endif
660
661.if ( ${BOOTSTRAPPING} < 430002 || \
662    ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018 ))
663_yacc=		usr.bin/yacc
664.endif
665
666.if ${BOOTSTRAPPING} < 500019
667_kbdcontrol=	usr.sbin/kbdcontrol
668.endif
669
670bootstrap-tools:
671.for _tool in ${_strfile} usr.bin/colldef \
672    usr.bin/makewhatis usr.bin/rpcgen ${_uudecode} \
673    ${_xargs} usr.bin/xinstall ${_yacc} \
674    usr.sbin/config ${_kbdcontrol} \
675    gnu/usr.bin/gperf ${_groff} gnu/usr.bin/texinfo
676	@${ECHODIR} "===> ${_tool}"; \
677		cd ${.CURDIR}/${_tool}; \
678		${MAKE} DIRPRFX=${_tool}/ obj; \
679		${MAKE} DIRPRFX=${_tool}/ depend; \
680		${MAKE} DIRPRFX=${_tool}/ all; \
681		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
682.endfor
683
684#
685# build-tools: Build special purpose build tools
686#
687.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
688_aicasm= sys/modules/aic7xxx/aicasm
689.endif
690
691.if exists(${.CURDIR}/share) && !defined(NOSHARE)
692_share=	share/syscons/scrnmaps
693.endif
694
695.if !defined(NO_FORTRAN)
696_fortran= gnu/usr.bin/cc/f771
697.endif
698
699.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
700    !defined(NOCRYPT) && !defined(NO_KERBEROS)
701_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
702    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
703.endif
704
705build-tools:
706.for _tool in bin/csh bin/sh gnu/usr.bin/cc/cc_tools ${_fortran} \
707    ${_libkrb5} lib/libncurses ${_share} \
708    ${_aicasm} usr.bin/awk usr.bin/file usr.sbin/sysinstall
709	@${ECHODIR} "===> ${_tool}"; \
710		cd ${.CURDIR}/${_tool}; \
711		${MAKE} DIRPRFX=${_tool}/ obj; \
712		${MAKE} DIRPRFX=${_tool}/ build-tools
713.endfor
714
715#
716# cross-tools: Build cross-building tools
717#
718.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
719_elf2exe=	usr.sbin/elf2exe
720.endif
721
722.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
723_btxld=	usr.sbin/btxld
724.if defined(RELEASEDIR)
725_kgzip=	usr.sbin/kgzip
726.endif
727.endif
728
729.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
730    ${BOOTSTRAPPING} < 500037
731_elf2aout=	usr.bin/elf2aout
732.endif
733
734.if defined(RELEASEDIR)
735_crunchide=	usr.sbin/crunch/crunchide
736.endif
737
738_xlint=	usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
739
740cross-tools:
741.for _tool in ${_btxld} ${_elf2aout} ${_elf2exe} \
742    gnu/usr.bin/binutils ${_crunchide} \
743    gnu/usr.bin/cc ${_xlint} ${_kgzip}
744	@${ECHODIR} "===> ${_tool}"; \
745		cd ${.CURDIR}/${_tool}; \
746		${MAKE} DIRPRFX=${_tool}/ obj; \
747		${MAKE} DIRPRFX=${_tool}/ depend; \
748		${MAKE} DIRPRFX=${_tool}/ all; \
749		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
750.endfor
751
752#
753# hierarchy - ensure that all the needed directories are present
754#
755hierarchy:
756	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
757
758#
759# libraries - build all libraries, and install them under ${DESTDIR}.
760#
761# The list of libraries with dependents (${_prebuild_libs}) and their
762# interdependencies (__L) are built automatically by the
763# ${.CURDIR}/tools/make_libdeps.sh script.
764#
765libraries:
766	cd ${.CURDIR}; \
767	    ${MAKE} -f Makefile.inc1 _startup_libs; \
768	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
769	    ${MAKE} -f Makefile.inc1 _generic_libs;
770
771# These dependencies are not automatically generated:
772#
773# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
774# shared libraries for ELF.
775#
776_startup_libs=	gnu/lib/csu gnu/lib/libgcc
777.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
778_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
779.else
780_startup_libs+=	lib/csu/${MACHINE_ARCH}
781.endif
782
783_prebuild_libs=
784
785_generic_libs=	gnu/lib
786
787.if !defined(NOCRYPT) && !defined(NO_KERBEROS)
788_prebuild_libs+=	kerberos5/lib/libasn1
789_prebuild_libs+=	kerberos5/lib/libgssapi
790_prebuild_libs+=	kerberos5/lib/libkrb5
791_prebuild_libs+=	kerberos5/lib/libroken
792_generic_libs+=	kerberos5/lib
793.endif
794
795_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libkvm lib/libmd \
796		lib/libncurses lib/libopie lib/libpam lib/libradius \
797		lib/librpcsvc \
798		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
799		lib/libz lib/msun
800
801lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
802lib/libypclnt__L: lib/librpcsvc__L
803
804_generic_libs+=	lib
805
806.if !defined(NOCRYPT) && !defined(NOSECURE)
807.if !defined(NO_OPENSSL)
808_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
809.if !defined(NO_OPENSSH)
810_prebuild_libs+=	secure/lib/libssh
811secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
812.endif
813.endif
814_generic_libs+=	secure/lib
815.endif
816
817_generic_libs+=	usr.bin/lex/lib
818
819.if ${MACHINE_ARCH} == "i386"
820_generic_libs+=	usr.sbin/pcvt/keycap
821.endif
822
823.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
824${_lib}__L: .PHONY
825.if exists(${.CURDIR}/${_lib})
826	@${ECHODIR} "===> ${_lib}"; \
827		cd ${.CURDIR}/${_lib}; \
828		${MAKE} DIRPRFX=${_lib}/ depend; \
829		${MAKE} DIRPRFX=${_lib}/ all; \
830		${MAKE} DIRPRFX=${_lib}/ install
831.endif
832.endfor
833
834# libpam is special: we need to build static PAM modules before
835# static PAM library, and dynamic PAM library before dynamic PAM
836# modules.
837lib/libpam__L: .PHONY
838	@${ECHODIR} "===> lib/libpam"; \
839		cd ${.CURDIR}/lib/libpam; \
840		${MAKE} DIRPRFX=lib/libpam/ depend; \
841		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
842		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
843
844_startup_libs: ${_startup_libs:S/$/__L/}
845_prebuild_libs: ${_prebuild_libs:S/$/__L/}
846_generic_libs: ${_generic_libs:S/$/__L/}
847
848.for __target in all clean cleandepend cleandir depend includes obj
849.for entry in ${SUBDIR}
850${entry}.${__target}__D: .PHONY
851	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
852		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
853		edir=${entry}.${MACHINE_ARCH}; \
854		cd ${.CURDIR}/$${edir}; \
855	else \
856		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
857		edir=${entry}; \
858		cd ${.CURDIR}/$${edir}; \
859	fi; \
860	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
861.endfor
862par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
863.endfor
864
865.include <bsd.subdir.mk>
866