Makefile.inc1 revision 152693
11590Srgrimes#
21590Srgrimes# $FreeBSD: head/Makefile.inc1 152693 2005-11-22 20:47:43Z ru $
31590Srgrimes#
41590Srgrimes# Make command line options:
51590Srgrimes#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
61590Srgrimes#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
71590Srgrimes#	-DNO_RESCUE do not build rescue binaries
81590Srgrimes#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
91590Srgrimes#	-DNO_CLEAN do not clean at all
101590Srgrimes#	-DNO_CRYPT will prevent building of crypt versions
111590Srgrimes#	-DNO_MAN do not build the manual pages
121590Srgrimes#	-DNO_NLS do not build Native Language Support files
131590Srgrimes#	-DNO_PROFILE do not build profiled libraries
141590Srgrimes#	-DNO_GAMES do not go into games subdir
151590Srgrimes#	-DNO_SHARE do not go into share subdir
161590Srgrimes#	-DNO_INFO do not make or install info files
171590Srgrimes#	-DNO_LIBC_R do not build libc_r.
181590Srgrimes#	-DNO_FORTRAN do not build g77 and related libraries.
191590Srgrimes#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
201590Srgrimes#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
211590Srgrimes#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
221590Srgrimes#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
231590Srgrimes#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
241590Srgrimes#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
251590Srgrimes#	TARGET_ARCH="arch" to crossbuild world to a different arch
261590Srgrimes
271590Srgrimes#
281590Srgrimes# The intended user-driven targets are:
291590Srgrimes# buildworld  - rebuild *everything*, including glue to help do upgrades
301590Srgrimes# installworld- install everything built by "buildworld"
311590Srgrimes# update      - convenient way to update your source tree (eg: cvsup/cvs)
321590Srgrimes#
3387628Sdwmalone# Standard targets (not defined here) are documented in the makefiles in
3487628Sdwmalone# /usr/share/mk.  These include:
3587628Sdwmalone#		obj depend all install clean cleandepend cleanobj
3687628Sdwmalone
3787628Sdwmalone# We must do share/info early so that installation of info `dir'
3887628Sdwmalone# entries works correctly.  Do it first since it is less likely to
3987229Smarkm# grow dependencies on include and lib than vice versa.
4087229Smarkm#
4187229Smarkm# We must do lib and libexec before bin, because if installworld
4291226Sbde# installs a new /bin/sh, the 'make' command will *immediately*
43102944Sdwmalone# use that new version.  And the new (dynamically-linked) /bin/sh
441590Srgrimes# will expect to find appropriate libraries in /lib and /libexec.
4591226Sbde#
4672109Scharnier# We must do etc last for install/distribute to work.
471590Srgrimes#
4823693SpeterSUBDIR=	share/info include lib libexec bin
4972109Scharnier.if !defined(NO_GAMES)
5074586SacheSUBDIR+=games
5172109Scharnier.endif
521590SrgrimesSUBDIR+=gnu
531590Srgrimes.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
541590SrgrimesSUBDIR+=kerberos5
5572109Scharnier.endif
56202191Sed.if !defined(NO_RESCUE)
571590SrgrimesSUBDIR+=rescue
5865064Sbrian.endif
591590SrgrimesSUBDIR+=sbin
601590Srgrimes.if !defined(NO_CRYPT)
611590SrgrimesSUBDIR+=secure
621590Srgrimes.endif
6392920Simp.if !defined(NO_SHARE)
6492920SimpSUBDIR+=share
6592920Simp.endif
661590SrgrimesSUBDIR+=sys usr.bin usr.sbin etc
671590Srgrimes
68102944Sdwmalone# These are last, since it is nice to at least get the base system
691590Srgrimes# rebuilt before you do them.
7087229Smarkm.for _DIR in ${LOCAL_DIRS}
7187229Smarkm.if exists(${.CURDIR}/${_DIR}/Makefile)
7223693SpeterSUBDIR+= ${_DIR}
731590Srgrimes.endif
741590Srgrimes.endfor
751590Srgrimes
761590Srgrimes.if defined(SUBDIR_OVERRIDE)
771590SrgrimesSUBDIR=		${SUBDIR_OVERRIDE}
7823693Speter.endif
791590Srgrimes
801590Srgrimes.if defined(NOCLEAN)
8123693SpeterNO_CLEAN=	${NOCLEAN}
8223693Speter.endif
831590Srgrimes.if defined(NO_CLEANDIR)
841590SrgrimesCLEANDIR=	clean cleandepend
851590Srgrimes.else
861590SrgrimesCLEANDIR=	cleandir
871590Srgrimes.endif
881590Srgrimes
891590SrgrimesCVS?=		cvs
901590SrgrimesCVSFLAGS?=	-A -P -d -I!
911590SrgrimesSUP?=		/usr/local/bin/cvsup
9270474SdesSUPFLAGS?=	-g -L 2 -P -
9370655Sdes.if defined(SUPHOST)
941590SrgrimesSUPFLAGS+=	-h ${SUPHOST}
951590Srgrimes.endif
961590Srgrimes
971590SrgrimesMAKEOBJDIRPREFIX?=	/usr/obj
981590Srgrimes.if !defined(OSRELDATE)
99102944Sdwmalone.if exists(/usr/include/osreldate.h)
1001590SrgrimesOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
10187229Smarkm		/usr/include/osreldate.h
10287229Smarkm.else
10387229SmarkmOSRELDATE=	0
1041590Srgrimes.endif
1051590Srgrimes.endif
1069993SacheTARGET_ARCH?=	${MACHINE_ARCH}
1071590Srgrimes.if ${TARGET_ARCH} == ${MACHINE_ARCH}
10874586SacheTARGET?=	${MACHINE}
10974586SacheTARGET_CPUTYPE?=${CPUTYPE}
1101590Srgrimes.else
1111590SrgrimesTARGET?=	${TARGET_ARCH}
1121590SrgrimesTARGET_CPUTYPE?=
1131590Srgrimes.endif
1141590Srgrimes.if !empty(TARGET_CPUTYPE)
1151590Srgrimes_TARGET_CPUTYPE=${TARGET_CPUTYPE}
1161590Srgrimes.else
1172537Spst_TARGET_CPUTYPE=dummy
1181590Srgrimes.endif
1191590Srgrimes_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
1201590Srgrimes		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
1211590Srgrimes.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
1221590Srgrimes.error CPUTYPE global should be set with ?=.
12399249Smini.endif
12499249Smini.if make(buildworld)
1251590SrgrimesBUILD_ARCH!=	sysctl -n hw.machine_arch
1261590Srgrimes.if ${MACHINE_ARCH} != ${BUILD_ARCH}
1271590Srgrimes.error To cross-build, set TARGET_ARCH.
1281590Srgrimes.endif
1291590Srgrimes.endif
1301590Srgrimes.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
1311590SrgrimesOBJTREE=	${MAKEOBJDIRPREFIX}
1321590Srgrimes.else
1331590SrgrimesOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
1341590Srgrimes.endif
1351590SrgrimesWORLDTMP=	${OBJTREE}${.CURDIR}/tmp
1361590Srgrimes# /usr/games added for fortune which depend on strfile
1371590SrgrimesBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
1381590SrgrimesXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
1391590SrgrimesSTRICTTMPPATH=	${BPATH}:${XPATH}
1401590SrgrimesTMPPATH=	${STRICTTMPPATH}:${PATH}
1411590Srgrimes
1421590SrgrimesINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
1431590Srgrimes
1441590Srgrimes#
1451590Srgrimes# Building a world goes through the following stages
1461590Srgrimes#
1471590Srgrimes# 1. legacy stage [BMAKE]
1481590Srgrimes#	This stage is responsible for creating compatibility
1491590Srgrimes#	shims that are needed by the bootstrap-tools,
1501590Srgrimes#	build-tools and cross-tools stages.
1511590Srgrimes# 1. bootstrap-tools stage [BMAKE]
1521590Srgrimes#	This stage is responsible for creating programs that
1531590Srgrimes#	are needed for backward compatibility reasons. They
1541590Srgrimes#	are not built as cross-tools.
1551590Srgrimes# 2. build-tools stage [TMAKE]
1561590Srgrimes#	This stage is responsible for creating the object
1571590Srgrimes#	tree and building any tools that are needed during
15899249Smini#	the build process.
1591590Srgrimes# 3. cross-tools stage [XMAKE]
1602537Spst#	This stage is responsible for creating any tools that
1612537Spst#	are needed for cross-builds. A cross-compiler is one
1621590Srgrimes#	of them.
1631590Srgrimes# 4. world stage [WMAKE]
1641590Srgrimes#	This stage actually builds the world.
1651590Srgrimes# 5. install stage (optional) [IMAKE]
1661590Srgrimes#	This stage installs a previously built world.
1671590Srgrimes#
1681590Srgrimes
1691590SrgrimesBOOTSTRAPPING?=	0
1701590Srgrimes
1711590Srgrimes# Common environment for world related stages
1721590SrgrimesCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
1731590Srgrimes		MACHINE_ARCH=${TARGET_ARCH} \
1741590Srgrimes		MACHINE=${TARGET} \
17567467Sru		CPUTYPE=${TARGET_CPUTYPE} \
1761590Srgrimes		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
17774586Sache		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
17874586Sache		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
17974586Sache
18074586Sache# bootstrap-tools stage
1811590SrgrimesBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
1821590Srgrimes		PATH=${BPATH}:${PATH} \
1831590Srgrimes		WORLDTMP=${WORLDTMP} \
1841590Srgrimes		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
1851590SrgrimesBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
1861590Srgrimes		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
187112987Srwatson		DESTDIR= \
188112987Srwatson		BOOTSTRAPPING=${OSRELDATE} \
1891590Srgrimes		-DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
19090390Speter		-DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
1911590Srgrimes
1921590Srgrimes# build-tools stage
1931590SrgrimesTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
1941590Srgrimes		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
1951590Srgrimes		DESTDIR= \
1961590Srgrimes		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
1971590Srgrimes
1981590Srgrimes# cross-tools stage
1991590SrgrimesXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
2001590Srgrimes
2011590Srgrimes# world stage
2021590SrgrimesWMAKEENV=	${CROSSENV} \
2031590Srgrimes		_SHLIBDIRPREFIX=${WORLDTMP} \
2041590Srgrimes		INSTALL="sh ${.CURDIR}/tools/install.sh" \
20567467Sru		PATH=${TMPPATH}
20667467SruWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
20767467Sru
2081590Srgrimes.if ${TARGET_ARCH} == "amd64"
20974586Sache# 32 bit world
21074586SacheLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
21174586Sache
21274586SacheLIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
21374586SacheLIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
21474586Sache		-L${LIB32TMP}/usr/lib32 \
21574586Sache		-B${LIB32TMP}/usr/lib32
21674586SacheLIB32CC=	${LIB32PREFLAGS} \
21774586Sache		${LIB32POSTFLAGS}
21874586SacheLIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
21974586Sache		${LIB32POSTFLAGS}
22074586SacheLIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
2211590Srgrimes		${LIB32POSTFLAGS}
2221590Srgrimes
2231590Srgrimes# Yes, the flags are redundant.
2241590SrgrimesLIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
2251590Srgrimes		_SHLIBDIRPREFIX=${LIB32TMP} \
2261590Srgrimes		MACHINE=i386 \
2271590Srgrimes		MACHINE_ARCH=i386 \
2281590Srgrimes		INSTALL="sh ${.CURDIR}/tools/install.sh" \
2292537Spst		PATH=${TMPPATH} \
2302537Spst		CC="${CC} ${LIB32CC}" \
2312537Spst		CXX="${CXX} ${LIB32CXX}" \
2322537Spst		OBJC="${OBJC} ${LIB32OBJC}" \
23374586Sache		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
23474586Sache		AS="${AS} --32" \
23574586Sache		LIBDIR=/usr/lib32 \
23674586Sache		SHLIBDIR=/usr/lib32
23774586Sache
2382537SpstLIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
23974586Sache		-DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
24074586SacheLIB32IMAKE=	${LIB32MAKE:NINSTALL=*} -DNO_INCS
24174586Sache.endif
24274586Sache
24374586Sache# install stage
2442537Spst.if empty(.MAKEFLAGS:M-n)
2452537SpstIMAKEENV=	${CROSSENV} \
24674586Sache		PATH=${STRICTTMPPATH}:${INSTALLTMP}
24774586Sache.else
24874586SacheIMAKEENV=	${CROSSENV} \
24974586Sache		PATH=${TMPPATH}:${INSTALLTMP}
25074586Sache.endif
2512537SpstIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
2521590Srgrimes
2531590Srgrimes# kernel stage
2541590SrgrimesKMAKEENV=	${WMAKEENV}
255102944SdwmaloneKMAKE=		${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
2561590Srgrimes
2571590Srgrimes#
2581590Srgrimes# buildworld
2591590Srgrimes#
2601590Srgrimes# Attempt to rebuild the entire system, with reasonable chance of
2611590Srgrimes# success, regardless of how old your existing system is.
2621590Srgrimes#
2631590Srgrimes_worldtmp:
2641590Srgrimes.if ${.CURDIR:C/[^,]//g} != ""
2651590Srgrimes#	The m4 build of sendmail files doesn't like it if ',' is used
2661590Srgrimes#	anywhere in the path of it's files.
2671590Srgrimes	@echo
2681590Srgrimes	@echo "*** Error: path to source tree contains a comma ','"
2691590Srgrimes	@echo
2701590Srgrimes	false
2711590Srgrimes.endif
2721590Srgrimes	@echo
2731590Srgrimes	@echo "--------------------------------------------------------------"
2741590Srgrimes	@echo ">>> Rebuilding the temporary build tree"
2751590Srgrimes	@echo "--------------------------------------------------------------"
2761590Srgrimes.if !defined(NO_CLEAN)
2771590Srgrimes	rm -rf ${WORLDTMP}
2781590Srgrimes.if ${TARGET_ARCH} == "amd64"
2791590Srgrimes	rm -rf ${LIB32TMP}
2801590Srgrimes.endif
2811590Srgrimes.else
2821590Srgrimes	rm -rf ${WORLDTMP}/legacy/usr/include
2831590Srgrimes	# XXX - These two can depend on any header file.
2841590Srgrimes	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
2851590Srgrimes	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
2861590Srgrimes.endif
2871590Srgrimes.for _dir in \
2881590Srgrimes    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
2891590Srgrimes    usr/libexec usr/sbin usr/share/dict \
2901590Srgrimes    usr/share/groff_font/devX100 \
2911590Srgrimes    usr/share/groff_font/devX100-12 \
29265064Sbrian    usr/share/groff_font/devX75 \
293102944Sdwmalone    usr/share/groff_font/devX75-12 \
2941590Srgrimes    usr/share/groff_font/devascii \
2951590Srgrimes    usr/share/groff_font/devcp1047 \
29687229Smarkm    usr/share/groff_font/devdvi \
29787229Smarkm    usr/share/groff_font/devhtml \
29887229Smarkm    usr/share/groff_font/devkoi8-r \
2991590Srgrimes    usr/share/groff_font/devlatin1 \
3001590Srgrimes    usr/share/groff_font/devlbp \
30167467Sru    usr/share/groff_font/devlj4 \
30267467Sru    usr/share/groff_font/devps \
3031590Srgrimes    usr/share/groff_font/devutf8 \
3041590Srgrimes    usr/share/tmac/mdoc usr/share/tmac/mm
3051590Srgrimes	mkdir -p ${WORLDTMP}/legacy/${_dir}
3061590Srgrimes.endfor
3071590Srgrimes.for _dir in \
3081590Srgrimes    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
309200462Sdelphij    usr/libexec usr/sbin usr/share/misc \
3101590Srgrimes    usr/share/snmp/defs usr/share/snmp/mibs
3111590Srgrimes	mkdir -p ${WORLDTMP}/${_dir}
3121590Srgrimes.endfor
3131590Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3141590Srgrimes	    -p ${WORLDTMP}/usr/include >/dev/null
3151590Srgrimes	ln -sf ${.CURDIR}/sys ${WORLDTMP}
3161590Srgrimes.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
3171590Srgrimes	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
3181590Srgrimes	    -p ${WORLDTMP}/usr/include >/dev/null
31965064Sbrian.endif
32065064Sbrian_legacy:
3211590Srgrimes	@echo
32223971Sache	@echo "--------------------------------------------------------------"
32323971Sache	@echo ">>> stage 1.1: legacy release compatibility shims"
3241590Srgrimes	@echo "--------------------------------------------------------------"
3251590Srgrimes	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
3261590Srgrimes_bootstrap-tools:
3271590Srgrimes	@echo
3281590Srgrimes	@echo "--------------------------------------------------------------"
3291590Srgrimes	@echo ">>> stage 1.2: bootstrap tools"
3301590Srgrimes	@echo "--------------------------------------------------------------"
3311590Srgrimes	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
3321590Srgrimes_cleanobj:
3331590Srgrimes.if !defined(NO_CLEAN)
33465064Sbrian	@echo
33565064Sbrian	@echo "--------------------------------------------------------------"
3361590Srgrimes	@echo ">>> stage 2.1: cleaning up the object tree"
33723971Sache	@echo "--------------------------------------------------------------"
33823971Sache	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
3391590Srgrimes.if ${TARGET_ARCH} == "amd64"
3401590Srgrimes	rm -rf ${OBJTREE}/lib32
3411590Srgrimes.endif
3421590Srgrimes.endif
3431590Srgrimes_obj:
3441590Srgrimes	@echo
3451590Srgrimes	@echo "--------------------------------------------------------------"
346102944Sdwmalone	@echo ">>> stage 2.2: rebuilding the object tree"
3471590Srgrimes	@echo "--------------------------------------------------------------"
3481590Srgrimes	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
3491590Srgrimes_build-tools:
3509994Sache	@echo
3511590Srgrimes	@echo "--------------------------------------------------------------"
3521590Srgrimes	@echo ">>> stage 2.3: build tools"
3531590Srgrimes	@echo "--------------------------------------------------------------"
3541590Srgrimes	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
3551590Srgrimes_cross-tools:
3561590Srgrimes	@echo
35767467Sru	@echo "--------------------------------------------------------------"
3581590Srgrimes	@echo ">>> stage 3: cross tools"
3591590Srgrimes	@echo "--------------------------------------------------------------"
3601590Srgrimes	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
3611590Srgrimes_includes:
3621590Srgrimes	@echo
3631590Srgrimes	@echo "--------------------------------------------------------------"
364	@echo ">>> stage 4.1: building includes"
365	@echo "--------------------------------------------------------------"
366	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
367_libraries:
368	@echo
369	@echo "--------------------------------------------------------------"
370	@echo ">>> stage 4.2: building libraries"
371	@echo "--------------------------------------------------------------"
372	${_+_}cd ${.CURDIR}; \
373	    ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
374	    -DNO_NLS -DNO_PROFILE libraries
375_depend:
376	@echo
377	@echo "--------------------------------------------------------------"
378	@echo ">>> stage 4.3: make dependencies"
379	@echo "--------------------------------------------------------------"
380	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
381everything:
382	@echo
383	@echo "--------------------------------------------------------------"
384	@echo ">>> stage 4.4: building everything"
385	@echo "--------------------------------------------------------------"
386	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
387.if ${TARGET_ARCH} == "amd64"
388build32:
389	@echo
390	@echo "--------------------------------------------------------------"
391	@echo ">>> stage 5.1: building 32 bit shim libraries"
392	@echo "--------------------------------------------------------------"
393.for _dir in \
394    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
395    usr/libexec usr/sbin usr/share/misc \
396    usr/share/snmp/defs usr/share/snmp/mibs
397	mkdir -p ${LIB32TMP}/${_dir}
398.endfor
399	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
400	    -p ${LIB32TMP}/usr/include >/dev/null
401	mkdir -p ${WORLDTMP}
402	ln -sf ${.CURDIR}/sys ${WORLDTMP}
403.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
404.for _t in obj depend all
405	cd ${.CURDIR}/kerberos5/tools; \
406	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
407.endfor
408.endif
409.for _t in obj includes
410	cd ${.CURDIR}/include; \
411	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412	cd ${.CURDIR}/lib; \
413	    ${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} sh || 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 ">>> Making hierarchy"
709	@echo "--------------------------------------------------------------"
710	cd ${.CURDIR}; \
711	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
712	@echo
713	@echo "--------------------------------------------------------------"
714	@echo ">>> Installing kernel"
715	@echo "--------------------------------------------------------------"
716	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
717	    ${CROSSENV} PATH=${TMPPATH} \
718	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
719
720#
721# update
722#
723# Update the source tree, by running cvsup and/or running cvs to update to the
724# latest copy.
725#
726update:
727.if defined(SUP_UPDATE)
728	@echo "--------------------------------------------------------------"
729	@echo ">>> Running ${SUP}"
730	@echo "--------------------------------------------------------------"
731.if defined(SUPFILE)
732	@${SUP} ${SUPFLAGS} ${SUPFILE}
733.endif
734.if defined(SUPFILE1)
735	@${SUP} ${SUPFLAGS} ${SUPFILE1}
736.endif
737.if defined(SUPFILE2)
738	@${SUP} ${SUPFLAGS} ${SUPFILE2}
739.endif
740.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
741	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
742.endif
743.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
744	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
745.endif
746.endif
747.if defined(CVS_UPDATE)
748	@echo "--------------------------------------------------------------"
749	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
750	@echo "--------------------------------------------------------------"
751	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
752.endif
753
754#
755# ------------------------------------------------------------------------
756#
757# From here onwards are utility targets used by the 'make world' and
758# related targets.  If your 'world' breaks, you may like to try to fix
759# the problem and manually run the following targets to attempt to
760# complete the build.  Beware, this is *not* guaranteed to work, you
761# need to have a pretty good grip on the current state of the system
762# to attempt to manually finish it.  If in doubt, 'make world' again.
763#
764
765#
766# legacy: Build compatibility shims for the next three targets
767#
768legacy:
769.if ${BOOTSTRAPPING} < 503000
770	@echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
771	false
772.endif
773.for _tool in tools/build
774	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
775	    cd ${.CURDIR}/${_tool}; \
776	    ${MAKE} DIRPRFX=${_tool}/ obj; \
777	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
778	    ${MAKE} DIRPRFX=${_tool}/ depend; \
779	    ${MAKE} DIRPRFX=${_tool}/ all; \
780	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
781.endfor
782
783#
784# bootstrap-tools: Build tools needed for compatibility
785#
786.if !defined(NO_GAMES)
787_strfile=	games/fortune/strfile
788.endif
789
790.if !defined(NO_CXX)
791_gperf=		gnu/usr.bin/gperf
792.if ${BOOTSTRAPPING} < 700004
793_groff=		gnu/usr.bin/groff
794.else
795_groff=		gnu/usr.bin/groff/tmac
796.endif
797.endif
798
799.if ${BOOTSTRAPPING} < 600029
800_texinfo=	gnu/usr.bin/texinfo
801.endif
802
803.if ${BOOTSTRAPPING} < 600015
804_cap_mkdb=	usr.bin/cap_mkdb
805.endif
806
807.if ${BOOTSTRAPPING} < 600018
808_colldef=	usr.bin/colldef
809.endif
810
811.if ${BOOTSTRAPPING} < 600017
812_gencat=	usr.bin/gencat
813.endif
814
815.if ${BOOTSTRAPPING} < 600016
816_mklocale=	usr.bin/mklocale
817.endif
818
819.if !defined(NO_RESCUE) && \
820    ${BOOTSTRAPPING} < 600008
821_crunchgen=	usr.sbin/crunch/crunchgen
822.endif
823
824.if ${BOOTSTRAPPING} < 600020
825_pwd_mkdb=	usr.sbin/pwd_mkdb
826.endif
827
828bootstrap-tools:
829.for _tool in \
830    ${_strfile} \
831    ${_gperf} \
832    ${_groff} \
833    ${_texinfo} \
834    ${_cap_mkdb} \
835    ${_colldef} \
836    ${_gencat} \
837    usr.bin/lorder \
838    usr.bin/makewhatis \
839    ${_mklocale} \
840    usr.bin/rpcgen \
841    usr.bin/xinstall \
842    usr.sbin/config \
843    ${_crunchgen} \
844    ${_pwd_mkdb}
845	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
846		cd ${.CURDIR}/${_tool}; \
847		${MAKE} DIRPRFX=${_tool}/ obj; \
848		${MAKE} DIRPRFX=${_tool}/ depend; \
849		${MAKE} DIRPRFX=${_tool}/ all; \
850		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
851.endfor
852
853#
854# build-tools: Build special purpose build tools
855#
856.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
857_aicasm= sys/modules/aic7xxx/aicasm
858.endif
859
860.if !defined(NO_SHARE)
861_share=	share/syscons/scrnmaps
862.endif
863
864.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
865_kerberos5_tools= kerberos5/tools
866.endif
867
868.if !defined(NO_RESCUE)
869_rescue= rescue/rescue
870.endif
871
872build-tools:
873.for _tool in \
874    bin/csh \
875    bin/sh \
876    ${_rescue} \
877    lib/libncurses \
878    ${_share} \
879    ${_aicasm} \
880    usr.bin/awk \
881    lib/libmagic \
882    usr.sbin/sysinstall
883	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
884		cd ${.CURDIR}/${_tool}; \
885		${MAKE} DIRPRFX=${_tool}/ obj; \
886		${MAKE} DIRPRFX=${_tool}/ build-tools
887.endfor
888.for _tool in \
889    gnu/usr.bin/cc/cc_tools \
890    ${_kerberos5_tools}
891	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
892		cd ${.CURDIR}/${_tool}; \
893		${MAKE} DIRPRFX=${_tool}/ obj; \
894		${MAKE} DIRPRFX=${_tool}/ depend; \
895		${MAKE} DIRPRFX=${_tool}/ all
896.endfor
897
898#
899# cross-tools: Build cross-building tools
900#
901.if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
902    ${TARGET_ARCH} != ${MACHINE_ARCH}
903_btxld=		usr.sbin/btxld
904.endif
905
906.if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
907    ${TARGET_ARCH} != ${MACHINE_ARCH}
908_crunchide=	usr.sbin/crunch/crunchide
909.endif
910
911.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
912_elf2exe=	usr.sbin/elf2exe
913.endif
914
915.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
916    defined(RELEASEDIR)
917_kgzip=		usr.sbin/kgzip
918.endif
919
920cross-tools:
921.for _tool in \
922    gnu/usr.bin/binutils \
923    gnu/usr.bin/cc \
924    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
925    ${_btxld} \
926    ${_crunchide} \
927    ${_elf2exe} \
928    ${_kgzip}
929	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
930		cd ${.CURDIR}/${_tool}; \
931		${MAKE} DIRPRFX=${_tool}/ obj; \
932		${MAKE} DIRPRFX=${_tool}/ depend; \
933		${MAKE} DIRPRFX=${_tool}/ all; \
934		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
935.endfor
936
937#
938# hierarchy - ensure that all the needed directories are present
939#
940hierarchy:
941	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
942
943#
944# libraries - build all libraries, and install them under ${DESTDIR}.
945#
946# The list of libraries with dependents (${_prebuild_libs}) and their
947# interdependencies (__L) are built automatically by the
948# ${.CURDIR}/tools/make_libdeps.sh script.
949#
950libraries:
951	cd ${.CURDIR}; \
952	    ${MAKE} -f Makefile.inc1 _startup_libs; \
953	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
954	    ${MAKE} -f Makefile.inc1 _generic_libs;
955
956# These dependencies are not automatically generated:
957#
958# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
959# shared libraries for ELF.
960#
961_startup_libs=	gnu/lib/csu gnu/lib/libgcc
962.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
963_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
964.else
965_startup_libs+=	lib/csu/${MACHINE_ARCH}
966.endif
967
968_prebuild_libs=
969
970_generic_libs=	gnu/lib
971
972.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
973_prebuild_libs+=	kerberos5/lib/libasn1
974_prebuild_libs+=	kerberos5/lib/libgssapi
975_prebuild_libs+=	kerberos5/lib/libkrb5
976_prebuild_libs+=	kerberos5/lib/libroken
977_generic_libs+=	kerberos5/lib
978.endif
979
980_prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
981		lib/libipx lib/libkiconv lib/libkvm lib/libmd \
982		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
983		lib/libradius \
984		lib/libsbuf lib/libtacplus lib/libutil \
985		lib/libz lib/msun
986
987lib/libopie__L lib/libtacplus__L: lib/libmd__L
988
989_generic_libs+=	lib
990
991.if !defined(NO_CRYPT)
992.if !defined(NO_OPENSSL)
993_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
994lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
995.if !defined(NO_OPENSSH)
996_prebuild_libs+=	secure/lib/libssh
997secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
998.if !defined(NO_KERBEROS)
999secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1000    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1001    kerberos5/lib/libroken__L
1002.endif
1003.endif
1004.endif
1005_generic_libs+=	secure/lib
1006.endif
1007
1008.if defined(NO_CRYPT) || defined(NO_OPENSSL)
1009lib/libradius__L: lib/libmd__L
1010.endif
1011
1012.if !defined(NO_NIS)
1013_prebuild_libs+=	lib/libypclnt
1014.endif
1015
1016_generic_libs+=	usr.bin/lex/lib
1017
1018.if ${MACHINE_ARCH} == "i386"
1019_generic_libs+=	usr.sbin/pcvt/keycap
1020.endif
1021
1022.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1023${_lib}__L: .PHONY
1024.if exists(${.CURDIR}/${_lib})
1025	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1026		cd ${.CURDIR}/${_lib}; \
1027		${MAKE} DIRPRFX=${_lib}/ depend; \
1028		${MAKE} DIRPRFX=${_lib}/ all; \
1029		${MAKE} DIRPRFX=${_lib}/ install
1030.endif
1031.endfor
1032
1033# libpam is special: we need to build static PAM modules before
1034# static PAM library, and dynamic PAM library before dynamic PAM
1035# modules.
1036lib/libpam__L: .PHONY
1037	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1038		cd ${.CURDIR}/lib/libpam; \
1039		${MAKE} DIRPRFX=lib/libpam/ depend; \
1040		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1041		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1042
1043_startup_libs: ${_startup_libs:S/$/__L/}
1044_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1045_generic_libs: ${_generic_libs:S/$/__L/}
1046
1047.for __target in all clean cleandepend cleandir depend includes obj
1048.for entry in ${SUBDIR}
1049${entry}.${__target}__D: .PHONY
1050	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1051		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1052		edir=${entry}.${MACHINE_ARCH}; \
1053		cd ${.CURDIR}/$${edir}; \
1054	else \
1055		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1056		edir=${entry}; \
1057		cd ${.CURDIR}/$${edir}; \
1058	fi; \
1059	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1060.endfor
1061par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1062.endfor
1063
1064.include <bsd.subdir.mk>
1065
1066.if make(delete-old) || make(delete-old-libs) || make(check-old)
1067
1068#
1069# check for / delete old files section
1070#
1071
1072.include "ObsoleteFiles.inc"
1073
1074OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1075else you can not start such an application. Consult UPDATING for more \
1076information regarding how to cope with the removal/revision bump of a \
1077specific library."
1078
1079.if !defined(BATCH_DELETE_OLD_FILES)
1080RM_I=-i
1081.else
1082RM_I=-v
1083.endif
1084
1085delete-old-files:
1086	@echo ">>> Removing old files (only deletes safe to delete libs)"
1087.for file in ${OLD_FILES}
1088# Ask for every old file if the user really wants to remove it.
1089# It's annoying, but better safe than sorry.
1090	@[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1091                ||  ([ -f "${DESTDIR}/${file}" ] \
1092                        && echo "Removing schg flag on ${DESTDIR}/${file}" \
1093                        && chflags noschg "${DESTDIR}/${file}" \
1094                        && rm ${RM_I} "${DESTDIR}/${file}"))
1095.endfor
1096# Remove catpages without corresponding manpages.
1097	@3<&0; \
1098	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1099	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1100	while read catpage; do \
1101		read manpage; \
1102		if [ ! -e "$${manpage}" ]; then \
1103			rm ${RM_I} $${catpage} <&3 ; \
1104	        fi; \
1105	done
1106	@echo ">>> Old files removed"
1107
1108check-old-files:
1109	@echo ">>> Checking for old files"
1110.for file in ${OLD_FILES}
1111	@[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1112.endfor
1113# Check for catpages without corresponding manpages.
1114	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1115	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1116	while read catpage; do \
1117		read manpage; \
1118		if [ ! -e "$${manpage}" ]; then \
1119			echo $${catpage} ; \
1120	        fi; \
1121	done
1122
1123delete-old-libs:
1124	@echo ">>> Removing old libraries"
1125	@echo "${OLD_LIBS_MESSAGE}" | fmt
1126.for file in ${OLD_LIBS}
1127	@[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1128		||  ([ -f "${DESTDIR}/${file}" ] \
1129			&& echo "Removing schg flag on ${DESTDIR}/${file}" \
1130			&& chflags noschg "${DESTDIR}/${file}" \
1131			&& rm ${RM_I} "${DESTDIR}/${file}"))
1132.endfor
1133	@echo ">>> Old libraries removed"
1134
1135check-old-libs:
1136	@echo ">>> Checking for old libraries"
1137.for file in ${OLD_LIBS}
1138	@[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1139.endfor
1140
1141delete-old-dirs:
1142	@echo ">>> Removing old directories"
1143.for dir in ${OLD_DIRS}
1144# Don't fail if an old directory isn't empty.
1145	@[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1146.endfor
1147	@echo ">>> Old directories removed"
1148
1149check-old-dirs:
1150	@echo ">>> Checking for old directories"
1151.for dir in ${OLD_DIRS}
1152	@[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1153.endfor
1154
1155delete-old: delete-old-files delete-old-dirs
1156	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1157
1158check-old: check-old-files check-old-libs check-old-dirs
1159	@echo "To remove old files and directories run '${MAKE} delete-old'."
1160	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1161
1162.endif
1163
1164