Makefile.inc1 revision 153002
117683Spst#
239291Sfenner# $FreeBSD: head/Makefile.inc1 153002 2005-12-02 00:50:30Z ambrisko $
317683Spst#
417683Spst# Make command line options:
517683Spst#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
617683Spst#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
717683Spst#	-DNO_RESCUE do not build rescue binaries
817683Spst#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
917683Spst#	-DNO_CLEAN do not clean at all
1017683Spst#	-DNO_CRYPT will prevent building of crypt versions
1117683Spst#	-DNO_MAN do not build the manual pages
1217683Spst#	-DNO_NLS do not build Native Language Support files
1317683Spst#	-DNO_PROFILE do not build profiled libraries
1417683Spst#	-DNO_GAMES do not go into games subdir
1517683Spst#	-DNO_SHARE do not go into share subdir
1617683Spst#	-DNO_INFO do not make or install info files
1717683Spst#	-DNO_LIBC_R do not build libc_r.
1817683Spst#	-DNO_FORTRAN do not build g77 and related libraries.
1917683Spst#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
2017683Spst#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
2117683Spst#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
22127664Sbms#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
23214518Srpaulo#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2417683Spst#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2517683Spst#	TARGET_ARCH="arch" to crossbuild world to a different arch
2675107Sfenner
2775107Sfenner#
2875107Sfenner# The intended user-driven targets are:
2975107Sfenner# buildworld  - rebuild *everything*, including glue to help do upgrades
3017683Spst# installworld- install everything built by "buildworld"
3117683Spst# update      - convenient way to update your source tree (eg: cvsup/cvs)
3217683Spst#
3317683Spst# Standard targets (not defined here) are documented in the makefiles in
3417683Spst# /usr/share/mk.  These include:
3517683Spst#		obj depend all install clean cleandepend cleanobj
3617683Spst
3717683Spst# We must do share/info early so that installation of info `dir'
3817683Spst# entries works correctly.  Do it first since it is less likely to
3917683Spst# grow dependencies on include and lib than vice versa.
4017683Spst#
4117683Spst# We must do lib and libexec before bin, because if installworld
4217683Spst# installs a new /bin/sh, the 'make' command will *immediately*
4317683Spst# use that new version.  And the new (dynamically-linked) /bin/sh
4417683Spst# will expect to find appropriate libraries in /lib and /libexec.
4517683Spst#
4617683Spst# We must do etc last for install/distribute to work.
4717683Spst#
4817683SpstSUBDIR=	share/info include lib libexec bin
4917683Spst.if !defined(NO_GAMES)
5017683SpstSUBDIR+=games
5117683Spst.endif
5217683SpstSUBDIR+=gnu
5317683Spst.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
5417683SpstSUBDIR+=kerberos5
5517683Spst.endif
5617683Spst.if !defined(NO_RESCUE)
5717683SpstSUBDIR+=rescue
5817683Spst.endif
5917683SpstSUBDIR+=sbin
6017683Spst.if !defined(NO_CRYPT)
61127664SbmsSUBDIR+=secure
62127664Sbms.endif
6317683Spst.if !defined(NO_SHARE)
6417683SpstSUBDIR+=share
6517683Spst.endif
66146768SsamSUBDIR+=sys usr.bin usr.sbin etc
67146768Ssam
6817683Spst# These are last, since it is nice to at least get the base system
6917683Spst# rebuilt before you do them.
7017683Spst.for _DIR in ${LOCAL_DIRS}
71127664Sbms.if exists(${.CURDIR}/${_DIR}/Makefile)
72127664SbmsSUBDIR+= ${_DIR}
73127664Sbms.endif
74127664Sbms.endfor
75127664Sbms
76127664Sbms.if defined(SUBDIR_OVERRIDE)
77127664SbmsSUBDIR=		${SUBDIR_OVERRIDE}
78127664Sbms.endif
79127664Sbms
80127664Sbms.if defined(NOCLEAN)
81127664SbmsNO_CLEAN=	${NOCLEAN}
82127664Sbms.endif
8317683Spst.if defined(NO_CLEANDIR)
8417683SpstCLEANDIR=	clean cleandepend
8517683Spst.else
8617683SpstCLEANDIR=	cleandir
8717683Spst.endif
8817683Spst
89127664SbmsCVS?=		cvs
9017683SpstCVSFLAGS?=	-A -P -d -I!
9117683SpstSUP?=		/usr/local/bin/cvsup
9217683SpstSUPFLAGS?=	-g -L 2 -P -
9317683Spst.if defined(SUPHOST)
9475107SfennerSUPFLAGS+=	-h ${SUPHOST}
9575107Sfenner.endif
9617683Spst
9717683SpstMAKEOBJDIRPREFIX?=	/usr/obj
9817683Spst.if !defined(OSRELDATE)
9917683Spst.if exists(/usr/include/osreldate.h)
100146768SsamOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
101146768Ssam		/usr/include/osreldate.h
102146768Ssam.else
103240725SkevloOSRELDATE=	0
104146768Ssam.endif
105146768Ssam.endif
106146768SsamTARGET_ARCH?=	${MACHINE_ARCH}
107146768Ssam.if ${TARGET_ARCH} == ${MACHINE_ARCH}
108146768SsamTARGET?=	${MACHINE}
109146768SsamTARGET_CPUTYPE?=${CPUTYPE}
11017683Spst.else
11117683SpstTARGET?=	${TARGET_ARCH}
11217683SpstTARGET_CPUTYPE?=
113127664Sbms.endif
114127664Sbms.if !empty(TARGET_CPUTYPE)
115127664Sbms_TARGET_CPUTYPE=${TARGET_CPUTYPE}
116127664Sbms.else
117127664Sbms_TARGET_CPUTYPE=dummy
118127664Sbms.endif
119127664Sbms_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
120127664Sbms		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
121127664Sbms.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
122127664Sbms.error CPUTYPE global should be set with ?=.
123127664Sbms.endif
12417683Spst.if make(buildworld)
12517683SpstBUILD_ARCH!=	uname -m
12617683Spst.if ${MACHINE_ARCH} != ${BUILD_ARCH}
12717683Spst.error To cross-build, set TARGET_ARCH.
128127664Sbms.endif
129127664Sbms.endif
13017683Spst.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
13117683SpstOBJTREE=	${MAKEOBJDIRPREFIX}
13217683Spst.else
13317683SpstOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
13417683Spst.endif
13517683SpstWORLDTMP=	${OBJTREE}${.CURDIR}/tmp
13617683Spst# /usr/games added for fortune which depend on strfile
13717683SpstBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
138127664SbmsXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
139146768SsamSTRICTTMPPATH=	${BPATH}:${XPATH}
140146768SsamTMPPATH=	${STRICTTMPPATH}:${PATH}
141146768Ssam
142146768SsamINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
143146768Ssam
144146768Ssam#
145146768Ssam# Building a world goes through the following stages
146146768Ssam#
147146768Ssam# 1. legacy stage [BMAKE]
148146768Ssam#	This stage is responsible for creating compatibility
149146768Ssam#	shims that are needed by the bootstrap-tools,
150146768Ssam#	build-tools and cross-tools stages.
151146768Ssam# 1. bootstrap-tools stage [BMAKE]
152146768Ssam#	This stage is responsible for creating programs that
153146768Ssam#	are needed for backward compatibility reasons. They
154146768Ssam#	are not built as cross-tools.
155146768Ssam# 2. build-tools stage [TMAKE]
156146768Ssam#	This stage is responsible for creating the object
157127664Sbms#	tree and building any tools that are needed during
15817683Spst#	the build process.
15917683Spst# 3. cross-tools stage [XMAKE]
16017683Spst#	This stage is responsible for creating any tools that
16117683Spst#	are needed for cross-builds. A cross-compiler is one
16217683Spst#	of them.
16375107Sfenner# 4. world stage [WMAKE]
16417683Spst#	This stage actually builds the world.
16575107Sfenner# 5. install stage (optional) [IMAKE]
16675107Sfenner#	This stage installs a previously built world.
16717683Spst#
16817683Spst
16917683SpstBOOTSTRAPPING?=	0
17098530Sfenner
17198530Sfenner# Common environment for world related stages
17298530SfennerCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
17398530Sfenner		MACHINE_ARCH=${TARGET_ARCH} \
17498530Sfenner		MACHINE=${TARGET} \
17598530Sfenner		CPUTYPE=${TARGET_CPUTYPE} \
17698530Sfenner		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
17798530Sfenner		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
17898530Sfenner		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
17998530Sfenner
18098530Sfenner# bootstrap-tools stage
18198530SfennerBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
18298530Sfenner		PATH=${BPATH}:${PATH} \
18317683Spst		WORLDTMP=${WORLDTMP} \
18417683Spst		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
18517683SpstBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
18617683Spst		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
18798530Sfenner		DESTDIR= \
18898530Sfenner		BOOTSTRAPPING=${OSRELDATE} \
18998530Sfenner		-DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
19098530Sfenner		-DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
19198530Sfenner
19217683Spst# build-tools stage
19317683SpstTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
19417683Spst		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
19517683Spst		DESTDIR= \
19617683Spst		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
197190225Srpaulo
198190225Srpaulo# cross-tools stage
19917683SpstXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
20017683Spst
20117683Spst# world stage
20217683SpstWMAKEENV=	${CROSSENV} \
20317683Spst		_SHLIBDIRPREFIX=${WORLDTMP} \
20475107Sfenner		INSTALL="sh ${.CURDIR}/tools/install.sh" \
20575107Sfenner		PATH=${TMPPATH}
20675107SfennerWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
20717683Spst
20817683Spst.if ${TARGET_ARCH} == "amd64"
20917683Spst# 32 bit world
210190225SrpauloLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
21175107Sfenner
21217683SpstLIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
21317683SpstLIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
21417683Spst		-L${LIB32TMP}/usr/lib32 \
21575107Sfenner		-B${LIB32TMP}/usr/lib32
21617683SpstLIB32CC=	${LIB32PREFLAGS} \
217190225Srpaulo		${LIB32POSTFLAGS}
21817683SpstLIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
219190225Srpaulo		${LIB32POSTFLAGS}
22075107SfennerLIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
22117683Spst		${LIB32POSTFLAGS}
22217683Spst
22375107Sfenner# Yes, the flags are redundant.
22417683SpstLIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
225190225Srpaulo		_SHLIBDIRPREFIX=${LIB32TMP} \
22675107Sfenner		MACHINE=i386 \
22717683Spst		MACHINE_ARCH=i386 \
22817683Spst		INSTALL="sh ${.CURDIR}/tools/install.sh" \
229214518Srpaulo		PATH=${TMPPATH} \
230214518Srpaulo		CC="${CC} ${LIB32CC}" \
231190225Srpaulo		CXX="${CXX} ${LIB32CXX}" \
232190225Srpaulo		OBJC="${OBJC} ${LIB32OBJC}" \
23317683Spst		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
23417683Spst		AS="${AS} --32" \
23517683Spst		LIBDIR=/usr/lib32 \
23617683Spst		SHLIBDIR=/usr/lib32
237190225Srpaulo
238190225SrpauloLIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
239190225Srpaulo		-DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
240190225SrpauloLIB32IMAKE=	${LIB32MAKE:NINSTALL=*} -DNO_INCS
241190225Srpaulo.endif
242190225Srpaulo
243190225Srpaulo# install stage
244190225Srpaulo.if empty(.MAKEFLAGS:M-n)
245190225SrpauloIMAKEENV=	${CROSSENV} \
246190225Srpaulo		PATH=${STRICTTMPPATH}:${INSTALLTMP}
247190225Srpaulo.else
248190225SrpauloIMAKEENV=	${CROSSENV} \
249190225Srpaulo		PATH=${TMPPATH}:${INSTALLTMP}
25017683Spst.endif
25117683SpstIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
25275107Sfenner
253146768Ssam# kernel stage
254146768SsamKMAKEENV=	${WMAKEENV}
255146768SsamKMAKE=		${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
256146768Ssam
257146768Ssam#
258146768Ssam# buildworld
259146768Ssam#
260146768Ssam# Attempt to rebuild the entire system, with reasonable chance of
261146768Ssam# success, regardless of how old your existing system is.
262146768Ssam#
263146768Ssam_worldtmp:
264146768Ssam.if ${.CURDIR:C/[^,]//g} != ""
265146768Ssam#	The m4 build of sendmail files doesn't like it if ',' is used
266146768Ssam#	anywhere in the path of it's files.
267146768Ssam	@echo
268146768Ssam	@echo "*** Error: path to source tree contains a comma ','"
269146768Ssam	@echo
270146768Ssam	false
271146768Ssam.endif
272146768Ssam	@echo
273146768Ssam	@echo "--------------------------------------------------------------"
274146768Ssam	@echo ">>> Rebuilding the temporary build tree"
275146768Ssam	@echo "--------------------------------------------------------------"
276146768Ssam.if !defined(NO_CLEAN)
277146768Ssam	rm -rf ${WORLDTMP}
278146768Ssam.if ${TARGET_ARCH} == "amd64"
279146768Ssam	rm -rf ${LIB32TMP}
280146768Ssam.endif
281146768Ssam.else
282190225Srpaulo	rm -rf ${WORLDTMP}/legacy/usr/include
283190225Srpaulo	# XXX - These two can depend on any header file.
284190225Srpaulo	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
28517683Spst	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
28617683Spst.endif
28775107Sfenner.for _dir in \
288190225Srpaulo    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
28939291Sfenner    usr/libexec usr/sbin usr/share/dict \
29075107Sfenner    usr/share/groff_font/devX100 \
291190225Srpaulo    usr/share/groff_font/devX100-12 \
292127664Sbms    usr/share/groff_font/devX75 \
293127664Sbms    usr/share/groff_font/devX75-12 \
294190225Srpaulo    usr/share/groff_font/devascii \
295127664Sbms    usr/share/groff_font/devcp1047 \
296127664Sbms    usr/share/groff_font/devdvi \
297190225Srpaulo    usr/share/groff_font/devhtml \
29817683Spst    usr/share/groff_font/devkoi8-r \
299127664Sbms    usr/share/groff_font/devlatin1 \
30017683Spst    usr/share/groff_font/devlbp \
301190225Srpaulo    usr/share/groff_font/devlj4 \
30275107Sfenner    usr/share/groff_font/devps \
30317683Spst    usr/share/groff_font/devutf8 \
30417683Spst    usr/share/tmac/mdoc usr/share/tmac/mm
305190225Srpaulo	mkdir -p ${WORLDTMP}/legacy/${_dir}
306190225Srpaulo.endfor
307190225Srpaulo.for _dir in \
308190225Srpaulo    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
309190225Srpaulo    usr/libexec usr/sbin usr/share/misc \
310190225Srpaulo    usr/share/snmp/defs usr/share/snmp/mibs
311190225Srpaulo	mkdir -p ${WORLDTMP}/${_dir}
312190225Srpaulo.endfor
313190225Srpaulo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
31475107Sfenner	    -p ${WORLDTMP}/usr/include >/dev/null
31575107Sfenner	ln -sf ${.CURDIR}/sys ${WORLDTMP}
31675107Sfenner.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
31775107Sfenner	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
31875107Sfenner	    -p ${WORLDTMP}/usr/include >/dev/null
31975107Sfenner.endif
32075107Sfenner_legacy:
321190225Srpaulo	@echo
32275107Sfenner	@echo "--------------------------------------------------------------"
323190225Srpaulo	@echo ">>> stage 1.1: legacy release compatibility shims"
32475107Sfenner	@echo "--------------------------------------------------------------"
32575107Sfenner	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
32675107Sfenner_bootstrap-tools:
32775107Sfenner	@echo
32875107Sfenner	@echo "--------------------------------------------------------------"
32975107Sfenner	@echo ">>> stage 1.2: bootstrap tools"
33075107Sfenner	@echo "--------------------------------------------------------------"
33175107Sfenner	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
33275107Sfenner_cleanobj:
33375107Sfenner.if !defined(NO_CLEAN)
33475107Sfenner	@echo
33575107Sfenner	@echo "--------------------------------------------------------------"
33675107Sfenner	@echo ">>> stage 2.1: cleaning up the object tree"
33775107Sfenner	@echo "--------------------------------------------------------------"
33875107Sfenner	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
33975107Sfenner.if ${TARGET_ARCH} == "amd64"
34075107Sfenner	rm -rf ${OBJTREE}/lib32
34175107Sfenner.endif
34275107Sfenner.endif
34375107Sfenner_obj:
344190225Srpaulo	@echo
345190225Srpaulo	@echo "--------------------------------------------------------------"
34675107Sfenner	@echo ">>> stage 2.2: rebuilding the object tree"
34717683Spst	@echo "--------------------------------------------------------------"
34875107Sfenner	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
34975107Sfenner_build-tools:
35075107Sfenner	@echo
35175107Sfenner	@echo "--------------------------------------------------------------"
35275107Sfenner	@echo ">>> stage 2.3: build tools"
353190225Srpaulo	@echo "--------------------------------------------------------------"
35475107Sfenner	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
35575107Sfenner_cross-tools:
35675107Sfenner	@echo
357190225Srpaulo	@echo "--------------------------------------------------------------"
35875107Sfenner	@echo ">>> stage 3: cross tools"
35975107Sfenner	@echo "--------------------------------------------------------------"
36075107Sfenner	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
36175107Sfenner_includes:
36275107Sfenner	@echo
363190225Srpaulo	@echo "--------------------------------------------------------------"
36475107Sfenner	@echo ">>> stage 4.1: building includes"
36575107Sfenner	@echo "--------------------------------------------------------------"
36675107Sfenner	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
36775107Sfenner_libraries:
36817683Spst	@echo
36917683Spst	@echo "--------------------------------------------------------------"
37017683Spst	@echo ">>> stage 4.2: building libraries"
371190225Srpaulo	@echo "--------------------------------------------------------------"
37275107Sfenner	${_+_}cd ${.CURDIR}; \
37317683Spst	    ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
37417683Spst	    -DNO_NLS -DNO_PROFILE libraries
37517683Spst_depend:
376127664Sbms	@echo
377127664Sbms	@echo "--------------------------------------------------------------"
378127664Sbms	@echo ">>> stage 4.3: make dependencies"
379127664Sbms	@echo "--------------------------------------------------------------"
380127664Sbms	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
381127664Sbmseverything:
382146768Ssam	@echo
383127664Sbms	@echo "--------------------------------------------------------------"
384147894Ssam	@echo ">>> stage 4.4: building everything"
385127664Sbms	@echo "--------------------------------------------------------------"
386127664Sbms	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
387127664Sbms.if ${TARGET_ARCH} == "amd64"
388127664Sbmsbuild32:
389127664Sbms	@echo
390190225Srpaulo	@echo "--------------------------------------------------------------"
39117683Spst	@echo ">>> stage 5.1: building 32 bit shim libraries"
392214518Srpaulo	@echo "--------------------------------------------------------------"
393190225Srpaulo.for _dir in \
39417683Spst    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
39517683Spst    usr/libexec usr/sbin usr/share/misc \
396190225Srpaulo    usr/share/snmp/defs usr/share/snmp/mibs
397251129Sdelphij	mkdir -p ${LIB32TMP}/${_dir}
398190225Srpaulo.endfor
399190225Srpaulo	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
400190225Srpaulo	    -p ${LIB32TMP}/usr/include >/dev/null
401190225Srpaulo	mkdir -p ${WORLDTMP}
402190225Srpaulo	ln -sf ${.CURDIR}/sys ${WORLDTMP}
403190225Srpaulo.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
404190225Srpaulo.for _t in obj depend all
405190225Srpaulo	cd ${.CURDIR}/kerberos5/tools; \
406190225Srpaulo	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
407190225Srpaulo.endfor
408190225Srpaulo.endif
40917683Spst.for _t in obj includes
410127664Sbms	cd ${.CURDIR}/include; \
41117683Spst	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
41217683Spst	cd ${.CURDIR}/lib; \
41317683Spst	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
414	cd ${.CURDIR}/gnu/lib; \
415	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416.if !defined(NO_CRYPT)
417	cd ${.CURDIR}/secure/lib; \
418	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419.endif
420.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
421	cd ${.CURDIR}/kerberos5/lib; \
422	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
423.endif
424.endfor
425.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
426	cd ${.CURDIR}/${_dir}; \
427	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
428.endfor
429.for _dir in lib/libncurses lib/libmagic
430	cd ${.CURDIR}/${_dir}; \
431	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
432.endfor
433	cd ${.CURDIR}; \
434	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
435.for _t in obj depend all
436	cd ${.CURDIR}/libexec/rtld-elf; \
437	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
438.endfor
439
440distribute32 install32:
441.if make(distribute32)
442	mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32	# XXX add to mtree
443.else
444	mkdir -p ${DESTDIR}/usr/lib32			# XXX add to mtree
445.endif
446	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
447	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
448.if !defined(NO_CRYPT)
449	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
450.endif
451	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
452.endif
453
454
455WMAKE_TGTS=
456.if !defined(SUBDIR_OVERRIDE)
457WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
458.endif
459WMAKE_TGTS+=	_cleanobj _obj _build-tools
460.if !defined(SUBDIR_OVERRIDE)
461WMAKE_TGTS+=	_cross-tools
462.endif
463WMAKE_TGTS+=	_includes _libraries _depend everything
464.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
465WMAKE_TGTS+=	build32
466.endif
467
468buildworld: ${WMAKE_TGTS}
469.ORDER: ${WMAKE_TGTS}
470
471buildenv:
472	@echo Entering world for ${TARGET_ARCH}:${TARGET}
473	@cd ${.CURDIR} && env ${WMAKEENV} ${SHELL} || true
474
475TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
476toolchain: ${TOOLCHAIN_TGTS}
477kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
478
479#
480# installcheck
481#
482# Checks to be sure system is ready for installworld/installkernel.
483#
484installcheck:
485
486#
487# Require DESTDIR to be set if installing for a different architecture.
488#
489.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
490.if !make(distributeworld)
491installcheck: installcheck_DESTDIR
492installcheck_DESTDIR:
493.if !defined(DESTDIR) || empty(DESTDIR)
494	@echo "ERROR: Please set DESTDIR!"; \
495	false
496.endif
497.endif
498.endif
499
500#
501# Check for missing UIDs/GIDs.
502#
503CHECK_UIDS=
504CHECK_GIDS=
505.if !defined(NO_SENDMAIL)
506CHECK_UIDS+=	smmsp
507CHECK_GIDS+=	smmsp
508.endif
509.if !defined(NO_PF)
510CHECK_UIDS+=	proxy
511CHECK_GIDS+=	proxy authpf
512.endif
513installcheck: installcheck_UGID
514installcheck_UGID:
515.for uid in ${CHECK_UIDS}
516	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
517		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
518		false; \
519	fi
520.endfor
521.for gid in ${CHECK_GIDS}
522	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
523		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
524		false; \
525	fi
526.endfor
527
528#
529# distributeworld
530#
531# Distributes everything compiled by a `buildworld'.
532#
533# installworld
534#
535# Installs everything compiled by a 'buildworld'.
536#
537distributeworld installworld: installcheck
538	mkdir -p ${INSTALLTMP}
539	for prog in [ awk cap_mkdb cat chflags chmod chown \
540	    date echo egrep find grep install-info \
541	    ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
542	    test true uname wc zic; do \
543		cp `which $$prog` ${INSTALLTMP}; \
544	done
545	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
546	rm -rf ${INSTALLTMP}
547
548#
549# reinstall
550#
551# If you have a build server, you can NFS mount the source and obj directories
552# and do a 'make reinstall' on the *client* to install new binaries from the
553# most recent server build.
554#
555reinstall:
556	@echo "--------------------------------------------------------------"
557	@echo ">>> Making hierarchy"
558	@echo "--------------------------------------------------------------"
559	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
560	@echo
561	@echo "--------------------------------------------------------------"
562	@echo ">>> Installing everything"
563	@echo "--------------------------------------------------------------"
564	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
565.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
566	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
567.endif
568
569redistribute:
570	@echo "--------------------------------------------------------------"
571	@echo ">>> Distributing everything"
572	@echo "--------------------------------------------------------------"
573	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
574.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
575	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
576.endif
577
578distrib-dirs distribution:
579	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
580
581#
582# buildkernel and installkernel
583#
584# Which kernels to build and/or install is specified by setting
585# KERNCONF. If not defined a GENERIC kernel is built/installed.
586# Only the existing (depending TARGET) config files are used
587# for building kernels and only the first of these is designated
588# as the one being installed.
589#
590# Note that we have to use TARGET instead of TARGET_ARCH when
591# we're in kernel-land. Since only TARGET_ARCH is (expected) to
592# be set to cross-build, we have to make sure TARGET is set
593# properly.
594
595.if !defined(KERNCONF) && defined(KERNEL)
596KERNCONF=	${KERNEL}
597KERNWARN=
598.else
599KERNCONF?=	GENERIC
600.endif
601INSTKERNNAME?=	kernel
602
603KERNSRCDIR?=	${.CURDIR}/sys
604KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
605KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
606KERNCONFDIR?=	${KRNLCONFDIR}
607
608BUILDKERNELS=
609INSTALLKERNEL=
610.for _kernel in ${KERNCONF}
611.if exists(${KERNCONFDIR}/${_kernel})
612BUILDKERNELS+=	${_kernel}
613.if empty(INSTALLKERNEL)
614INSTALLKERNEL= ${_kernel}
615.endif
616.endif
617.endfor
618
619#
620# buildkernel
621#
622# Builds all kernels defined by BUILDKERNELS.
623#
624buildkernel:
625.if empty(BUILDKERNELS)
626	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
627	false
628.endif
629.if defined(KERNWARN)
630	@echo "--------------------------------------------------------------"
631	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
632	@echo "--------------------------------------------------------------"
633	@sleep 3
634.endif
635	@echo
636.for _kernel in ${BUILDKERNELS}
637	@echo "--------------------------------------------------------------"
638	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
639	@echo "--------------------------------------------------------------"
640	@echo "===> ${_kernel}"
641	mkdir -p ${KRNLOBJDIR}
642.if !defined(NO_KERNELCONFIG)
643	@echo
644	@echo "--------------------------------------------------------------"
645	@echo ">>> stage 1: configuring the kernel"
646	@echo "--------------------------------------------------------------"
647	cd ${KRNLCONFDIR}; \
648		PATH=${TMPPATH} \
649		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
650			${KERNCONFDIR}/${_kernel}
651.endif
652.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
653	@echo
654	@echo "--------------------------------------------------------------"
655	@echo ">>> stage 2.1: cleaning up the object tree"
656	@echo "--------------------------------------------------------------"
657	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
658.endif
659	@echo
660	@echo "--------------------------------------------------------------"
661	@echo ">>> stage 2.2: rebuilding the object tree"
662	@echo "--------------------------------------------------------------"
663	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
664	@echo
665	@echo "--------------------------------------------------------------"
666	@echo ">>> stage 2.3: build tools"
667	@echo "--------------------------------------------------------------"
668	cd ${KRNLOBJDIR}/${_kernel}; \
669	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
670	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
671# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
672.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
673.for target in obj depend all
674	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
675	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
676	    ${MAKE} -DNO_CPU_CFLAGS ${target}
677.endfor
678.endif
679.if !defined(NO_KERNELDEPEND)
680	@echo
681	@echo "--------------------------------------------------------------"
682	@echo ">>> stage 3.1: making dependencies"
683	@echo "--------------------------------------------------------------"
684	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
685.endif
686	@echo
687	@echo "--------------------------------------------------------------"
688	@echo ">>> stage 3.2: building everything"
689	@echo "--------------------------------------------------------------"
690	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
691	@echo "--------------------------------------------------------------"
692	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
693	@echo "--------------------------------------------------------------"
694.endfor
695
696#
697# installkernel, etc.
698#
699# Install the kernel defined by INSTALLKERNEL
700#
701installkernel installkernel.debug \
702reinstallkernel reinstallkernel.debug: installcheck
703.if empty(INSTALLKERNEL)
704	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
705	false
706.endif
707	@echo "--------------------------------------------------------------"
708	@echo ">>> Installing kernel"
709	@echo "--------------------------------------------------------------"
710	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
711	    ${CROSSENV} PATH=${TMPPATH} \
712	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
713
714#
715# update
716#
717# Update the source tree, by running cvsup and/or running cvs to update to the
718# latest copy.
719#
720update:
721.if defined(SUP_UPDATE)
722	@echo "--------------------------------------------------------------"
723	@echo ">>> Running ${SUP}"
724	@echo "--------------------------------------------------------------"
725.if defined(SUPFILE)
726	@${SUP} ${SUPFLAGS} ${SUPFILE}
727.endif
728.if defined(SUPFILE1)
729	@${SUP} ${SUPFLAGS} ${SUPFILE1}
730.endif
731.if defined(SUPFILE2)
732	@${SUP} ${SUPFLAGS} ${SUPFILE2}
733.endif
734.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
735	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
736.endif
737.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
738	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
739.endif
740.endif
741.if defined(CVS_UPDATE)
742	@echo "--------------------------------------------------------------"
743	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
744	@echo "--------------------------------------------------------------"
745	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
746.endif
747
748#
749# ------------------------------------------------------------------------
750#
751# From here onwards are utility targets used by the 'make world' and
752# related targets.  If your 'world' breaks, you may like to try to fix
753# the problem and manually run the following targets to attempt to
754# complete the build.  Beware, this is *not* guaranteed to work, you
755# need to have a pretty good grip on the current state of the system
756# to attempt to manually finish it.  If in doubt, 'make world' again.
757#
758
759#
760# legacy: Build compatibility shims for the next three targets
761#
762legacy:
763.if ${BOOTSTRAPPING} < 503000
764	@echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
765	false
766.endif
767.for _tool in tools/build
768	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
769	    cd ${.CURDIR}/${_tool}; \
770	    ${MAKE} DIRPRFX=${_tool}/ obj; \
771	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
772	    ${MAKE} DIRPRFX=${_tool}/ depend; \
773	    ${MAKE} DIRPRFX=${_tool}/ all; \
774	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
775.endfor
776
777#
778# bootstrap-tools: Build tools needed for compatibility
779#
780.if !defined(NO_GAMES)
781_strfile=	games/fortune/strfile
782.endif
783
784.if !defined(NO_CXX)
785_gperf=		gnu/usr.bin/gperf
786.if ${BOOTSTRAPPING} < 700004
787_groff=		gnu/usr.bin/groff
788.else
789_groff=		gnu/usr.bin/groff/tmac
790.endif
791.endif
792
793.if ${BOOTSTRAPPING} < 600029
794_texinfo=	gnu/usr.bin/texinfo
795.endif
796
797.if ${BOOTSTRAPPING} < 600015
798_cap_mkdb=	usr.bin/cap_mkdb
799.endif
800
801.if ${BOOTSTRAPPING} < 600018
802_colldef=	usr.bin/colldef
803.endif
804
805.if ${BOOTSTRAPPING} < 600017
806_gencat=	usr.bin/gencat
807.endif
808
809.if ${BOOTSTRAPPING} < 600016
810_mklocale=	usr.bin/mklocale
811.endif
812
813.if !defined(NO_RESCUE) && \
814    ${BOOTSTRAPPING} < 600008
815_crunchgen=	usr.sbin/crunch/crunchgen
816.endif
817
818.if ${BOOTSTRAPPING} < 600020
819_pwd_mkdb=	usr.sbin/pwd_mkdb
820.endif
821
822bootstrap-tools:
823.for _tool in \
824    ${_strfile} \
825    ${_gperf} \
826    ${_groff} \
827    ${_texinfo} \
828    ${_cap_mkdb} \
829    ${_colldef} \
830    ${_gencat} \
831    usr.bin/lorder \
832    usr.bin/makewhatis \
833    ${_mklocale} \
834    usr.bin/rpcgen \
835    usr.bin/xinstall \
836    usr.sbin/config \
837    ${_crunchgen} \
838    ${_pwd_mkdb}
839	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
840		cd ${.CURDIR}/${_tool}; \
841		${MAKE} DIRPRFX=${_tool}/ obj; \
842		${MAKE} DIRPRFX=${_tool}/ depend; \
843		${MAKE} DIRPRFX=${_tool}/ all; \
844		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
845.endfor
846
847#
848# build-tools: Build special purpose build tools
849#
850.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
851_aicasm= sys/modules/aic7xxx/aicasm
852.endif
853
854.if !defined(NO_SHARE)
855_share=	share/syscons/scrnmaps
856.endif
857
858.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
859_kerberos5_tools= kerberos5/tools
860.endif
861
862.if !defined(NO_RESCUE)
863_rescue= rescue/rescue
864.endif
865
866build-tools:
867.for _tool in \
868    bin/csh \
869    bin/sh \
870    ${_rescue} \
871    lib/libncurses \
872    ${_share} \
873    ${_aicasm} \
874    usr.bin/awk \
875    lib/libmagic \
876    usr.sbin/sysinstall
877	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
878		cd ${.CURDIR}/${_tool}; \
879		${MAKE} DIRPRFX=${_tool}/ obj; \
880		${MAKE} DIRPRFX=${_tool}/ build-tools
881.endfor
882.for _tool in \
883    gnu/usr.bin/cc/cc_tools \
884    ${_kerberos5_tools}
885	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
886		cd ${.CURDIR}/${_tool}; \
887		${MAKE} DIRPRFX=${_tool}/ obj; \
888		${MAKE} DIRPRFX=${_tool}/ depend; \
889		${MAKE} DIRPRFX=${_tool}/ all
890.endfor
891
892#
893# cross-tools: Build cross-building tools
894#
895.if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
896    ${TARGET_ARCH} != ${MACHINE_ARCH}
897_btxld=		usr.sbin/btxld
898.endif
899
900.if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
901    ${TARGET_ARCH} != ${MACHINE_ARCH}
902_crunchide=	usr.sbin/crunch/crunchide
903.endif
904
905.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
906_elf2exe=	usr.sbin/elf2exe
907.endif
908
909.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
910    defined(RELEASEDIR)
911_kgzip=		usr.sbin/kgzip
912.endif
913
914cross-tools:
915.for _tool in \
916    gnu/usr.bin/binutils \
917    gnu/usr.bin/cc \
918    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
919    ${_btxld} \
920    ${_crunchide} \
921    ${_elf2exe} \
922    ${_kgzip}
923	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
924		cd ${.CURDIR}/${_tool}; \
925		${MAKE} DIRPRFX=${_tool}/ obj; \
926		${MAKE} DIRPRFX=${_tool}/ depend; \
927		${MAKE} DIRPRFX=${_tool}/ all; \
928		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
929.endfor
930
931#
932# hierarchy - ensure that all the needed directories are present
933#
934hierarchy:
935	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
936
937#
938# libraries - build all libraries, and install them under ${DESTDIR}.
939#
940# The list of libraries with dependents (${_prebuild_libs}) and their
941# interdependencies (__L) are built automatically by the
942# ${.CURDIR}/tools/make_libdeps.sh script.
943#
944libraries:
945	cd ${.CURDIR}; \
946	    ${MAKE} -f Makefile.inc1 _startup_libs; \
947	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
948	    ${MAKE} -f Makefile.inc1 _generic_libs;
949
950# These dependencies are not automatically generated:
951#
952# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
953# shared libraries for ELF.
954#
955_startup_libs=	gnu/lib/csu gnu/lib/libgcc
956.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
957_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
958.else
959_startup_libs+=	lib/csu/${MACHINE_ARCH}
960.endif
961
962_prebuild_libs=
963
964_generic_libs=	gnu/lib
965
966.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
967_prebuild_libs+=	kerberos5/lib/libasn1
968_prebuild_libs+=	kerberos5/lib/libgssapi
969_prebuild_libs+=	kerberos5/lib/libkrb5
970_prebuild_libs+=	kerberos5/lib/libroken
971_generic_libs+=	kerberos5/lib
972.endif
973
974_prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
975		lib/libipx lib/libkiconv lib/libkvm lib/libmd \
976		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
977		lib/libradius \
978		lib/libsbuf lib/libtacplus lib/libutil \
979		lib/libz lib/msun
980
981lib/libopie__L lib/libtacplus__L: lib/libmd__L
982
983_generic_libs+=	lib
984
985.if !defined(NO_CRYPT)
986.if !defined(NO_OPENSSL)
987_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
988lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
989.if !defined(NO_OPENSSH)
990_prebuild_libs+=	secure/lib/libssh
991secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
992.if !defined(NO_KERBEROS)
993secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
994    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
995    kerberos5/lib/libroken__L
996.endif
997.endif
998.endif
999_generic_libs+=	secure/lib
1000.endif
1001
1002.if defined(NO_CRYPT) || defined(NO_OPENSSL)
1003lib/libradius__L: lib/libmd__L
1004.endif
1005
1006.if !defined(NO_NIS)
1007_prebuild_libs+=	lib/libypclnt
1008.endif
1009
1010_generic_libs+=	usr.bin/lex/lib
1011
1012.if ${MACHINE_ARCH} == "i386"
1013_generic_libs+=	usr.sbin/pcvt/keycap
1014.endif
1015
1016.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1017${_lib}__L: .PHONY
1018.if exists(${.CURDIR}/${_lib})
1019	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1020		cd ${.CURDIR}/${_lib}; \
1021		${MAKE} DIRPRFX=${_lib}/ depend; \
1022		${MAKE} DIRPRFX=${_lib}/ all; \
1023		${MAKE} DIRPRFX=${_lib}/ install
1024.endif
1025.endfor
1026
1027# libpam is special: we need to build static PAM modules before
1028# static PAM library, and dynamic PAM library before dynamic PAM
1029# modules.
1030lib/libpam__L: .PHONY
1031	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1032		cd ${.CURDIR}/lib/libpam; \
1033		${MAKE} DIRPRFX=lib/libpam/ depend; \
1034		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1035		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1036
1037_startup_libs: ${_startup_libs:S/$/__L/}
1038_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1039_generic_libs: ${_generic_libs:S/$/__L/}
1040
1041.for __target in all clean cleandepend cleandir depend includes obj
1042.for entry in ${SUBDIR}
1043${entry}.${__target}__D: .PHONY
1044	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1045		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1046		edir=${entry}.${MACHINE_ARCH}; \
1047		cd ${.CURDIR}/$${edir}; \
1048	else \
1049		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1050		edir=${entry}; \
1051		cd ${.CURDIR}/$${edir}; \
1052	fi; \
1053	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1054.endfor
1055par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1056.endfor
1057
1058.include <bsd.subdir.mk>
1059
1060.if make(delete-old) || make(delete-old-libs) || make(check-old)
1061
1062#
1063# check for / delete old files section
1064#
1065
1066.include "ObsoleteFiles.inc"
1067
1068OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1069else you can not start such an application. Consult UPDATING for more \
1070information regarding how to cope with the removal/revision bump of a \
1071specific library."
1072
1073.if !defined(BATCH_DELETE_OLD_FILES)
1074RM_I=-i
1075.else
1076RM_I=-v
1077.endif
1078
1079delete-old-files:
1080	@echo ">>> Removing old files (only deletes safe to delete libs)"
1081.for file in ${OLD_FILES}
1082# Ask for every old file if the user really wants to remove it.
1083# It's annoying, but better safe than sorry.
1084	@[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1085                ||  ([ -f "${DESTDIR}/${file}" ] \
1086                        && echo "Removing schg flag on ${DESTDIR}/${file}" \
1087                        && chflags noschg "${DESTDIR}/${file}" \
1088                        && rm ${RM_I} "${DESTDIR}/${file}"))
1089.endfor
1090# Remove catpages without corresponding manpages.
1091	@3<&0; \
1092	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1093	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1094	while read catpage; do \
1095		read manpage; \
1096		if [ ! -e "$${manpage}" ]; then \
1097			rm ${RM_I} $${catpage} <&3 ; \
1098	        fi; \
1099	done
1100	@echo ">>> Old files removed"
1101
1102check-old-files:
1103	@echo ">>> Checking for old files"
1104.for file in ${OLD_FILES}
1105	@[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1106.endfor
1107# Check for catpages without corresponding manpages.
1108	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1109	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1110	while read catpage; do \
1111		read manpage; \
1112		if [ ! -e "$${manpage}" ]; then \
1113			echo $${catpage} ; \
1114	        fi; \
1115	done
1116
1117delete-old-libs:
1118	@echo ">>> Removing old libraries"
1119	@echo "${OLD_LIBS_MESSAGE}" | fmt
1120.for file in ${OLD_LIBS}
1121	@[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1122		||  ([ -f "${DESTDIR}/${file}" ] \
1123			&& echo "Removing schg flag on ${DESTDIR}/${file}" \
1124			&& chflags noschg "${DESTDIR}/${file}" \
1125			&& rm ${RM_I} "${DESTDIR}/${file}"))
1126.endfor
1127	@echo ">>> Old libraries removed"
1128
1129check-old-libs:
1130	@echo ">>> Checking for old libraries"
1131.for file in ${OLD_LIBS}
1132	@[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1133.endfor
1134
1135delete-old-dirs:
1136	@echo ">>> Removing old directories"
1137.for dir in ${OLD_DIRS}
1138# Don't fail if an old directory isn't empty.
1139	@[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1140.endfor
1141	@echo ">>> Old directories removed"
1142
1143check-old-dirs:
1144	@echo ">>> Checking for old directories"
1145.for dir in ${OLD_DIRS}
1146	@[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1147.endfor
1148
1149delete-old: delete-old-files delete-old-dirs
1150	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1151
1152check-old: check-old-files check-old-libs check-old-dirs
1153	@echo "To remove old files and directories run '${MAKE} delete-old'."
1154	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1155
1156.endif
1157
1158