Makefile.inc1 revision 200596
1#
2# $FreeBSD: head/Makefile.inc1 200596 2009-12-16 02:54:34Z imp $
3#
4# Make command line options:
5#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6#	-DNO_CLEAN do not clean at all
7#	-DNO_SHARE do not go into share subdir
8#	-DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
9#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12#	-DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
13#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
14#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
15#	-DNO_CTF do not run the DTrace CTF conversion tools on built objects
16#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
17#	TARGET="machine" to crossbuild world for a different machine type
18
19#
20# The intended user-driven targets are:
21# buildworld  - rebuild *everything*, including glue to help do upgrades
22# installworld- install everything built by "buildworld"
23# doxygen     - build API documentation of the kernel
24# update      - convenient way to update your source tree (eg: cvsup/cvs)
25#
26# Standard targets (not defined here) are documented in the makefiles in
27# /usr/share/mk.  These include:
28#		obj depend all install clean cleandepend cleanobj
29
30.include <bsd.own.mk>
31
32.if ${MACHINE_ARCH} == "mips"
33MK_RESCUE=no	# not yet
34.endif
35
36# We must do share/info early so that installation of info `dir'
37# entries works correctly.  Do it first since it is less likely to
38# grow dependencies on include and lib than vice versa.
39#
40# We must do lib/ and libexec/ before bin/, because if installworld
41# installs a new /bin/sh, the 'make' command will *immediately*
42# use that new version.  And the new (dynamically-linked) /bin/sh
43# will expect to find appropriate libraries in /lib and /libexec.
44#
45SUBDIR=	share/info lib libexec
46SUBDIR+=bin
47.if ${MK_GAMES} != "no"
48SUBDIR+=games
49.endif
50.if ${MK_CDDL} != "no"
51SUBDIR+=cddl
52.else
53NO_CTF=1
54.endif
55SUBDIR+=gnu include
56.if ${MK_KERBEROS} != "no"
57SUBDIR+=kerberos5
58.endif
59.if ${MK_RESCUE} != "no"
60SUBDIR+=rescue
61.endif
62SUBDIR+=sbin
63.if ${MK_CRYPT} != "no"
64SUBDIR+=secure
65.endif
66.if !defined(NO_SHARE)
67SUBDIR+=share
68.endif
69SUBDIR+=sys usr.bin usr.sbin
70#
71# We must do etc/ last for install/distribute to work.
72#
73SUBDIR+=etc
74
75# These are last, since it is nice to at least get the base system
76# rebuilt before you do them.
77.for _DIR in ${LOCAL_DIRS}
78.if exists(${.CURDIR}/${_DIR}/Makefile)
79SUBDIR+= ${_DIR}
80.endif
81.endfor
82
83.if defined(SUBDIR_OVERRIDE)
84SUBDIR=		${SUBDIR_OVERRIDE}
85.endif
86
87.if defined(NOCLEAN)
88NO_CLEAN=	${NOCLEAN}
89.endif
90.if defined(NO_CLEANDIR)
91CLEANDIR=	clean cleandepend
92.else
93CLEANDIR=	cleandir
94.endif
95
96CVS?=		cvs
97CVSFLAGS?=	-A -P -d -I!
98SVN?=		svn
99SVNFLAGS?=	-r HEAD
100SUP?=		/usr/bin/csup
101SUPFLAGS?=	-g -L 2
102.if defined(SUPHOST)
103SUPFLAGS+=	-h ${SUPHOST}
104.endif
105
106MAKEOBJDIRPREFIX?=	/usr/obj
107.if !defined(OSRELDATE)
108.if exists(/usr/include/osreldate.h)
109OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
110		/usr/include/osreldate.h
111.else
112OSRELDATE=	0
113.endif
114.endif
115
116.if !defined(VERSION)
117VERSION!=	uname -srp
118VERSION+=	${OSRELDATE}
119.endif
120
121# Guess machine architecture from machine type, and vice versa.
122.if !defined(TARGET_ARCH) && defined(TARGET)
123TARGET_ARCH=	${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
124.elif !defined(TARGET) && defined(TARGET_ARCH) && \
125    ${TARGET_ARCH} != ${MACHINE_ARCH}
126TARGET=		${TARGET_ARCH}
127.endif
128# Otherwise, default to current machine type and architecture.
129TARGET?=	${MACHINE}
130TARGET_ARCH?=	${MACHINE_ARCH}
131
132KNOWN_ARCHES?=	amd64 arm i386 i386/pc98 ia64 mips powerpc sparc64 sparc64/sun4v
133.if ${TARGET} == ${TARGET_ARCH}
134_t=		${TARGET}
135.else
136_t=		${TARGET_ARCH}/${TARGET}
137.endif
138.for _t in ${_t}
139.if empty(KNOWN_ARCHES:M${_t})
140.error Unknown target ${TARGET_ARCH}:${TARGET}.
141.endif
142.endfor
143
144.if ${TARGET} == ${MACHINE}
145TARGET_CPUTYPE?=${CPUTYPE}
146.else
147TARGET_CPUTYPE?=
148.endif
149
150.if !empty(TARGET_CPUTYPE)
151_TARGET_CPUTYPE=${TARGET_CPUTYPE}
152.else
153_TARGET_CPUTYPE=dummy
154.endif
155_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
156		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
157.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
158.error CPUTYPE global should be set with ?=.
159.endif
160.if make(buildworld)
161BUILD_ARCH!=	uname -p
162.if ${MACHINE_ARCH} != ${BUILD_ARCH}
163.error To cross-build, set TARGET_ARCH.
164.endif
165.endif
166.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
167OBJTREE=	${MAKEOBJDIRPREFIX}
168.else
169OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
170.endif
171WORLDTMP=	${OBJTREE}${.CURDIR}/tmp
172# /usr/games added for fortune which depend on strfile
173BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
174XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
175STRICTTMPPATH=	${BPATH}:${XPATH}
176TMPPATH=	${STRICTTMPPATH}:${PATH}
177
178#
179# Avoid running mktemp(1) unless actually needed.
180# It may not be functional, e.g., due to new ABI
181# when in the middle of installing over this system.
182#
183.if make(distributeworld) || make(installworld)
184INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
185.endif
186
187#
188# Building a world goes through the following stages
189#
190# 1. legacy stage [BMAKE]
191#	This stage is responsible for creating compatibility
192#	shims that are needed by the bootstrap-tools,
193#	build-tools and cross-tools stages.
194# 1. bootstrap-tools stage [BMAKE]
195#	This stage is responsible for creating programs that
196#	are needed for backward compatibility reasons. They
197#	are not built as cross-tools.
198# 2. build-tools stage [TMAKE]
199#	This stage is responsible for creating the object
200#	tree and building any tools that are needed during
201#	the build process.
202# 3. cross-tools stage [XMAKE]
203#	This stage is responsible for creating any tools that
204#	are needed for cross-builds. A cross-compiler is one
205#	of them.
206# 4. world stage [WMAKE]
207#	This stage actually builds the world.
208# 5. install stage (optional) [IMAKE]
209#	This stage installs a previously built world.
210#
211
212BOOTSTRAPPING?=	0
213
214# Common environment for world related stages
215CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
216		MACHINE_ARCH=${TARGET_ARCH} \
217		MACHINE=${TARGET} \
218		CPUTYPE=${TARGET_CPUTYPE} \
219		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
220		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
221		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
222.if ${OSRELDATE} < 700044
223CROSSENV+=	AR=gnu-ar RANLIB=gnu-ranlib
224.endif
225
226# bootstrap-tools stage
227BMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
228		PATH=${BPATH}:${PATH} \
229		WORLDTMP=${WORLDTMP} \
230		VERSION="${VERSION}" \
231		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
232BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
233		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
234		DESTDIR= \
235		BOOTSTRAPPING=${OSRELDATE} \
236		SSP_CFLAGS= \
237		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
238		-DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
239		-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
240
241# build-tools stage
242TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
243		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
244		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
245		DESTDIR= \
246		SSP_CFLAGS= \
247		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
248		-DNO_WARNS -DNO_CTF
249
250# cross-tools stage
251XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
252		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
253		-DWITHOUT_GDB
254
255# world stage
256WMAKEENV=	${CROSSENV} \
257		_SHLIBDIRPREFIX=${WORLDTMP} \
258		VERSION="${VERSION}" \
259		INSTALL="sh ${.CURDIR}/tools/install.sh" \
260		PATH=${TMPPATH}
261.if ${MK_CDDL} == "no" || defined(NO_CTF)
262WMAKEENV+=	NO_CTF=1
263.endif
264WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
265
266.if ${TARGET_ARCH} == "amd64"
267# 32 bit world
268LIB32TMP=	${OBJTREE}${.CURDIR}/lib32
269
270.if empty(TARGET_CPUTYPE)
271LIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
272.else
273LIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
274.endif
275LIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -mfancy-math-387 -DCOMPAT_32BIT \
276		-isystem ${LIB32TMP}/usr/include/ \
277		-L${LIB32TMP}/usr/lib32 \
278		-B${LIB32TMP}/usr/lib32
279
280# Yes, the flags are redundant.
281LIB32WMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
282		_SHLIBDIRPREFIX=${LIB32TMP} \
283		VERSION="${VERSION}" \
284		MACHINE=i386 \
285		MACHINE_ARCH=i386 \
286		INSTALL="sh ${.CURDIR}/tools/install.sh" \
287		PATH=${TMPPATH} \
288		CC="${CC} ${LIB32FLAGS}" \
289		CXX="${CXX} ${LIB32FLAGS}" \
290		OBJC="${OBJC} ${LIB32FLAGS}" \
291		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
292		AS="${AS} --32" \
293		LIBDIR=/usr/lib32 \
294		SHLIBDIR=/usr/lib32
295
296LIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
297		-DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
298		-DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
299LIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
300.endif
301
302# install stage
303IMAKEENV=	${CROSSENV}
304IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
305.if empty(.MAKEFLAGS:M-n)
306IMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMP} \
307		LD_LIBRARY_PATH=${INSTALLTMP} \
308		PATH_LOCALE=${INSTALLTMP}/locale
309IMAKE+=		__MAKE_SHELL=${INSTALLTMP}/sh
310.else
311IMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMP}
312.endif
313
314# kernel stage
315KMAKEENV=	${WMAKEENV}
316KMAKE=		${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
317
318#
319# buildworld
320#
321# Attempt to rebuild the entire system, with reasonable chance of
322# success, regardless of how old your existing system is.
323#
324_worldtmp:
325.if ${.CURDIR:C/[^,]//g} != ""
326#	The m4 build of sendmail files doesn't like it if ',' is used
327#	anywhere in the path of it's files.
328	@echo
329	@echo "*** Error: path to source tree contains a comma ','"
330	@echo
331	false
332.endif
333	@echo
334	@echo "--------------------------------------------------------------"
335	@echo ">>> Rebuilding the temporary build tree"
336	@echo "--------------------------------------------------------------"
337.if !defined(NO_CLEAN)
338	rm -rf ${WORLDTMP}
339.if ${TARGET_ARCH} == "amd64"
340	rm -rf ${LIB32TMP}
341.endif
342.else
343	rm -rf ${WORLDTMP}/legacy/usr/include
344#	XXX - These three can depend on any header file.
345	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
346	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
347	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
348.endif
349.for _dir in \
350    lib usr legacy/usr
351	mkdir -p ${WORLDTMP}/${_dir}
352.endfor
353	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
354	    -p ${WORLDTMP}/legacy/usr >/dev/null
355	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
356	    -p ${WORLDTMP}/usr >/dev/null
357	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
358	    -p ${WORLDTMP}/usr/include >/dev/null
359	ln -sf ${.CURDIR}/sys ${WORLDTMP}
360.if ${MK_BIND_LIBS} != "no"
361	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
362	    -p ${WORLDTMP}/usr/include >/dev/null
363.endif
364_legacy:
365	@echo
366	@echo "--------------------------------------------------------------"
367	@echo ">>> stage 1.1: legacy release compatibility shims"
368	@echo "--------------------------------------------------------------"
369	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
370_bootstrap-tools:
371	@echo
372	@echo "--------------------------------------------------------------"
373	@echo ">>> stage 1.2: bootstrap tools"
374	@echo "--------------------------------------------------------------"
375	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
376_cleanobj:
377.if !defined(NO_CLEAN)
378	@echo
379	@echo "--------------------------------------------------------------"
380	@echo ">>> stage 2.1: cleaning up the object tree"
381	@echo "--------------------------------------------------------------"
382	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
383.if ${TARGET_ARCH} == "amd64"
384	${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
385.endif
386.endif
387_obj:
388	@echo
389	@echo "--------------------------------------------------------------"
390	@echo ">>> stage 2.2: rebuilding the object tree"
391	@echo "--------------------------------------------------------------"
392	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
393_build-tools:
394	@echo
395	@echo "--------------------------------------------------------------"
396	@echo ">>> stage 2.3: build tools"
397	@echo "--------------------------------------------------------------"
398	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
399_cross-tools:
400	@echo
401	@echo "--------------------------------------------------------------"
402	@echo ">>> stage 3: cross tools"
403	@echo "--------------------------------------------------------------"
404	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
405_includes:
406	@echo
407	@echo "--------------------------------------------------------------"
408	@echo ">>> stage 4.1: building includes"
409	@echo "--------------------------------------------------------------"
410	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
411_libraries:
412	@echo
413	@echo "--------------------------------------------------------------"
414	@echo ">>> stage 4.2: building libraries"
415	@echo "--------------------------------------------------------------"
416	${_+_}cd ${.CURDIR}; \
417	    ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
418	    -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
419_depend:
420	@echo
421	@echo "--------------------------------------------------------------"
422	@echo ">>> stage 4.3: make dependencies"
423	@echo "--------------------------------------------------------------"
424	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
425everything:
426	@echo
427	@echo "--------------------------------------------------------------"
428	@echo ">>> stage 4.4: building everything"
429	@echo "--------------------------------------------------------------"
430	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
431.if ${TARGET_ARCH} == "amd64"
432build32:
433	@echo
434	@echo "--------------------------------------------------------------"
435	@echo ">>> stage 5.1: building 32 bit shim libraries"
436	@echo "--------------------------------------------------------------"
437	mkdir -p ${LIB32TMP}/usr/lib32
438	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
439	    -p ${LIB32TMP}/usr >/dev/null
440	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
441	    -p ${LIB32TMP}/usr/include >/dev/null
442	mkdir -p ${WORLDTMP}
443	ln -sf ${.CURDIR}/sys ${WORLDTMP}
444.if ${MK_KERBEROS} != "no"
445.for _t in obj depend all
446	cd ${.CURDIR}/kerberos5/tools; \
447	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
448	    ${_t}
449.endfor
450.endif
451.for _t in obj includes
452	cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
453	cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
454.if ${MK_CDDL} != "no"
455	cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
456.endif
457	cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
458.if ${MK_CRYPT} != "no"
459	cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
460.endif
461.if ${MK_KERBEROS} != "no"
462	cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
463.endif
464.endfor
465.for _dir in usr.bin/lex/lib
466	cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
467.endfor
468.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
469	cd ${.CURDIR}/${_dir}; \
470	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
471	    build-tools
472.endfor
473	cd ${.CURDIR}; \
474	    ${LIB32WMAKE} -f Makefile.inc1 libraries
475.for _t in obj depend all
476	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
477	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
478.endfor
479
480distribute32 install32:
481.if make(distribute32)
482	mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32	# XXX add to mtree
483	mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace	# XXX add to mtree
484.else
485	mkdir -p ${DESTDIR}/usr/lib32			# XXX add to mtree
486	mkdir -p ${DESTDIR}/usr/lib32/dtrace		# XXX add to mtree
487.endif
488	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
489.if ${MK_CDDL} != "no"
490	cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
491.endif
492	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
493.if ${MK_CRYPT} != "no"
494	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
495.endif
496.if ${MK_KERBEROS} != "no"
497	cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
498.endif
499	cd ${.CURDIR}/libexec/rtld-elf; \
500	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
501	cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
502.endif
503
504WMAKE_TGTS=
505.if !defined(SUBDIR_OVERRIDE)
506WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
507.endif
508WMAKE_TGTS+=	_cleanobj _obj _build-tools
509.if !defined(SUBDIR_OVERRIDE)
510WMAKE_TGTS+=	_cross-tools
511.endif
512WMAKE_TGTS+=	_includes _libraries _depend everything
513.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
514WMAKE_TGTS+=	build32
515.endif
516
517buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
518.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
519
520buildworld_prologue:
521	@echo "--------------------------------------------------------------"
522	@echo ">>> World build started on `LC_ALL=C date`"
523	@echo "--------------------------------------------------------------"
524
525buildworld_epilogue:
526	@echo
527	@echo "--------------------------------------------------------------"
528	@echo ">>> World build completed on `LC_ALL=C date`"
529	@echo "--------------------------------------------------------------"
530
531#
532# We need to have this as a target because the indirection between Makefile
533# and Makefile.inc1 causes the correct PATH to be used, rather than a
534# modification of the current environment's PATH.  In addition, we need
535# to quote multiword values.
536#
537buildenvvars:
538	@echo ${WMAKEENV:Q}
539
540buildenv:
541	@echo Entering world for ${TARGET_ARCH}:${TARGET}
542	@cd ${.CURDIR} && env ${WMAKEENV} sh || true
543
544TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
545toolchain: ${TOOLCHAIN_TGTS}
546kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
547
548#
549# installcheck
550#
551# Checks to be sure system is ready for installworld/installkernel.
552#
553installcheck:
554
555#
556# Require DESTDIR to be set if installing for a different architecture.
557#
558.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
559.if !make(distributeworld)
560installcheck: installcheck_DESTDIR
561installcheck_DESTDIR:
562.if !defined(DESTDIR) || empty(DESTDIR)
563	@echo "ERROR: Please set DESTDIR!"; \
564	false
565.endif
566.endif
567.endif
568
569#
570# Check for missing UIDs/GIDs.
571#
572CHECK_UIDS=
573CHECK_GIDS=	audit
574.if ${MK_SENDMAIL} != "no"
575CHECK_UIDS+=	smmsp
576CHECK_GIDS+=	smmsp
577.endif
578.if ${MK_PF} != "no"
579CHECK_UIDS+=	proxy
580CHECK_GIDS+=	proxy authpf
581.endif
582installcheck: installcheck_UGID
583installcheck_UGID:
584.for uid in ${CHECK_UIDS}
585	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
586		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
587		false; \
588	fi
589.endfor
590.for gid in ${CHECK_GIDS}
591	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
592		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
593		false; \
594	fi
595.endfor
596
597#
598# Required install tools to be saved in a scratch dir for safety.
599#
600.if ${MK_INFO} != "no"
601_install-info=	install-info
602.endif
603.if ${MK_ZONEINFO} != "no"
604_zoneinfo=	zic tzsetup
605.endif
606
607ITOOLS=	[ awk cap_mkdb cat chflags chmod chown \
608	date echo egrep find grep ${_install-info} \
609	ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
610	test true uname wc ${_zoneinfo}
611
612#
613# distributeworld
614#
615# Distributes everything compiled by a `buildworld'.
616#
617# installworld
618#
619# Installs everything compiled by a 'buildworld'.
620#
621distributeworld installworld: installcheck
622	mkdir -p ${INSTALLTMP}
623	progs=$$(for prog in ${ITOOLS}; do \
624		if progpath=`which $$prog`; then \
625			echo $$progpath; \
626		else \
627			echo "Required tool $$prog not found in PATH." >&2; \
628			exit 1; \
629		fi; \
630	    done); \
631	libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
632	    while read line; do \
633		set -- $$line; \
634		if [ "$$2 $$3" != "not found" ]; then \
635			echo $$2; \
636		else \
637			echo "Required library $$1 not found." >&2; \
638			exit 1; \
639		fi; \
640	    done); \
641	cp $$libs $$progs ${INSTALLTMP}
642	cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
643	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
644	    ${IMAKEENV} rm -rf ${INSTALLTMP}
645
646#
647# reinstall
648#
649# If you have a build server, you can NFS mount the source and obj directories
650# and do a 'make reinstall' on the *client* to install new binaries from the
651# most recent server build.
652#
653reinstall:
654	@echo "--------------------------------------------------------------"
655	@echo ">>> Making hierarchy"
656	@echo "--------------------------------------------------------------"
657	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
658	@echo
659	@echo "--------------------------------------------------------------"
660	@echo ">>> Installing everything"
661	@echo "--------------------------------------------------------------"
662	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
663.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
664	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
665.endif
666
667redistribute:
668	@echo "--------------------------------------------------------------"
669	@echo ">>> Distributing everything"
670	@echo "--------------------------------------------------------------"
671	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
672.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
673	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
674	    DISTRIBUTION=lib32
675.endif
676
677distrib-dirs distribution:
678	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
679
680#
681# buildkernel and installkernel
682#
683# Which kernels to build and/or install is specified by setting
684# KERNCONF. If not defined a GENERIC kernel is built/installed.
685# Only the existing (depending TARGET) config files are used
686# for building kernels and only the first of these is designated
687# as the one being installed.
688#
689# Note that we have to use TARGET instead of TARGET_ARCH when
690# we're in kernel-land. Since only TARGET_ARCH is (expected) to
691# be set to cross-build, we have to make sure TARGET is set
692# properly.
693
694.if defined(KERNFAST)
695NO_KERNELCLEAN=	t
696NO_KERNELCONFIG=	t
697NO_KERNELDEPEND=	t
698NO_KERNELOBJ=		t
699# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
700.if !defined(KERNCONF) && ${KERNFAST} != "1"
701KERNCONF=${KERNFAST}
702.endif
703.endif
704.if !defined(KERNCONF) && defined(KERNEL)
705KERNCONF=	${KERNEL}
706KERNWARN=
707.else
708KERNCONF?=	GENERIC
709.endif
710INSTKERNNAME?=	kernel
711
712KERNSRCDIR?=	${.CURDIR}/sys
713KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
714KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
715KERNCONFDIR?=	${KRNLCONFDIR}
716
717BUILDKERNELS=
718INSTALLKERNEL=
719.for _kernel in ${KERNCONF}
720.if exists(${KERNCONFDIR}/${_kernel})
721BUILDKERNELS+=	${_kernel}
722.if empty(INSTALLKERNEL)
723INSTALLKERNEL= ${_kernel}
724.endif
725.endif
726.endfor
727
728#
729# buildkernel
730#
731# Builds all kernels defined by BUILDKERNELS.
732#
733buildkernel:
734.if empty(BUILDKERNELS)
735	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
736	false
737.endif
738.if defined(KERNWARN)
739	@echo "--------------------------------------------------------------"
740	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
741	@echo "--------------------------------------------------------------"
742	@sleep 3
743.endif
744	@echo
745.for _kernel in ${BUILDKERNELS}
746	@echo "--------------------------------------------------------------"
747	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
748	@echo "--------------------------------------------------------------"
749	@echo "===> ${_kernel}"
750	mkdir -p ${KRNLOBJDIR}
751.if !defined(NO_KERNELCONFIG)
752	@echo
753	@echo "--------------------------------------------------------------"
754	@echo ">>> stage 1: configuring the kernel"
755	@echo "--------------------------------------------------------------"
756	cd ${KRNLCONFDIR}; \
757		PATH=${TMPPATH} \
758		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
759			${KERNCONFDIR}/${_kernel}
760.endif
761.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
762	@echo
763	@echo "--------------------------------------------------------------"
764	@echo ">>> stage 2.1: cleaning up the object tree"
765	@echo "--------------------------------------------------------------"
766	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
767.endif
768.if !defined(NO_KERNELOBJ)
769	@echo
770	@echo "--------------------------------------------------------------"
771	@echo ">>> stage 2.2: rebuilding the object tree"
772	@echo "--------------------------------------------------------------"
773	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
774.endif
775	@echo
776	@echo "--------------------------------------------------------------"
777	@echo ">>> stage 2.3: build tools"
778	@echo "--------------------------------------------------------------"
779	cd ${KRNLOBJDIR}/${_kernel}; \
780	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
781	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \
782	    -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
783# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
784.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
785.for target in obj depend all
786	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
787	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
788	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
789.endfor
790.endif
791.if !defined(NO_KERNELDEPEND)
792	@echo
793	@echo "--------------------------------------------------------------"
794	@echo ">>> stage 3.1: making dependencies"
795	@echo "--------------------------------------------------------------"
796	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
797.endif
798	@echo
799	@echo "--------------------------------------------------------------"
800	@echo ">>> stage 3.2: building everything"
801	@echo "--------------------------------------------------------------"
802	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
803	@echo "--------------------------------------------------------------"
804	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
805	@echo "--------------------------------------------------------------"
806.endfor
807
808#
809# installkernel, etc.
810#
811# Install the kernel defined by INSTALLKERNEL
812#
813installkernel installkernel.debug \
814reinstallkernel reinstallkernel.debug: installcheck
815.if empty(INSTALLKERNEL)
816	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
817	false
818.endif
819	@echo "--------------------------------------------------------------"
820	@echo ">>> Installing kernel"
821	@echo "--------------------------------------------------------------"
822	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
823	    ${CROSSENV} PATH=${TMPPATH} \
824	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
825
826#
827# doxygen
828#
829# Build the API documentation with doxygen
830#
831doxygen:
832	@if [ ! -x `/usr/bin/which doxygen` ]; then \
833		echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
834		exit 1; \
835	fi
836	cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
837
838#
839# update
840#
841# Update the source tree, by running cvsup and/or running cvs to update to the
842# latest copy.
843#
844update:
845.if defined(SUP_UPDATE)
846	@echo "--------------------------------------------------------------"
847	@echo ">>> Running ${SUP}"
848	@echo "--------------------------------------------------------------"
849.if defined(SUPFILE)
850	@${SUP} ${SUPFLAGS} ${SUPFILE}
851.endif
852.if defined(SUPFILE1)
853	@${SUP} ${SUPFLAGS} ${SUPFILE1}
854.endif
855.if defined(SUPFILE2)
856	@${SUP} ${SUPFLAGS} ${SUPFILE2}
857.endif
858.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
859	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
860.endif
861.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
862	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
863.endif
864.endif
865.if defined(CVS_UPDATE)
866	@cd ${.CURDIR} ; \
867	if [ -d CVS ] ; then \
868		echo "--------------------------------------------------------------" ; \
869		echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
870		echo "--------------------------------------------------------------" ; \
871		echo ${CVS} -R -q update ${CVSFLAGS} ; \
872		${CVS} -R -q update ${CVSFLAGS} ; \
873	fi
874.endif
875.if defined(SVN_UPDATE)
876	@cd ${.CURDIR} ; \
877	if [ -d .svn ] ; then \
878		echo "--------------------------------------------------------------" ; \
879		echo ">>> Updating ${.CURDIR} using Subversion" ; \
880		echo "--------------------------------------------------------------" ; \
881		echo ${SVN} update ${SVNFLAGS} ; \
882		${SVN} update ${SVNFLAGS} ; \
883	fi
884.endif
885
886#
887# ------------------------------------------------------------------------
888#
889# From here onwards are utility targets used by the 'make world' and
890# related targets.  If your 'world' breaks, you may like to try to fix
891# the problem and manually run the following targets to attempt to
892# complete the build.  Beware, this is *not* guaranteed to work, you
893# need to have a pretty good grip on the current state of the system
894# to attempt to manually finish it.  If in doubt, 'make world' again.
895#
896
897#
898# legacy: Build compatibility shims for the next three targets
899#
900legacy:
901.if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
902	@echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
903	false
904.endif
905.for _tool in tools/build
906	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
907	    cd ${.CURDIR}/${_tool}; \
908	    ${MAKE} DIRPRFX=${_tool}/ obj; \
909	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
910	    ${MAKE} DIRPRFX=${_tool}/ depend; \
911	    ${MAKE} DIRPRFX=${_tool}/ all; \
912	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
913.endfor
914
915#
916# bootstrap-tools: Build tools needed for compatibility
917#
918.if ${MK_GAMES} != "no"
919_strfile=	games/fortune/strfile
920.endif
921
922.if ${MK_CXX} != "no"
923_gperf=		gnu/usr.bin/gperf
924.if ${BOOTSTRAPPING} < 700004
925_groff=		gnu/usr.bin/groff
926.else
927_groff=		gnu/usr.bin/groff/tmac
928.endif
929.endif
930
931.if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
932_ar=		usr.bin/ar
933.endif
934
935.if ${BOOTSTRAPPING} < 800013
936_mklocale=	usr.bin/mklocale
937.endif
938
939.if ${BOOTSTRAPPING} < 900002
940_sed=		usr.bin/sed
941.endif
942
943.if ${BOOTSTRAPPING} < 700018
944_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
945.endif
946
947.if ${MK_RESCUE} != "no" && \
948    ${BOOTSTRAPPING} < 700026
949_crunchgen=	usr.sbin/crunch/crunchgen
950.endif
951
952.if ${MK_CDDL} != "no"
953_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
954    lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
955.endif
956
957bootstrap-tools:
958.for _tool in \
959    ${_dtrace_tools} \
960    ${_strfile} \
961    ${_gperf} \
962    ${_groff} \
963    ${_ar} \
964    usr.bin/lorder \
965    usr.bin/makewhatis \
966    ${_mklocale} \
967    usr.bin/rpcgen \
968    ${_sed} \
969    usr.bin/xinstall \
970    ${_gensnmptree} \
971    usr.sbin/config \
972    ${_crunchgen}
973	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
974		cd ${.CURDIR}/${_tool}; \
975		${MAKE} DIRPRFX=${_tool}/ obj; \
976		${MAKE} DIRPRFX=${_tool}/ depend; \
977		${MAKE} DIRPRFX=${_tool}/ all; \
978		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
979.endfor
980
981#
982# build-tools: Build special purpose build tools
983#
984.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
985_aicasm= sys/modules/aic7xxx/aicasm
986.endif
987
988.if !defined(NO_SHARE)
989_share=	share/syscons/scrnmaps
990.endif
991
992.if ${MK_KERBEROS} != "no"
993_kerberos5_tools= kerberos5/tools
994.endif
995
996.if ${MK_RESCUE} != "no"
997_rescue= rescue/rescue
998.endif
999
1000build-tools:
1001.for _tool in \
1002    bin/csh \
1003    bin/sh \
1004    ${_rescue} \
1005    lib/ncurses/ncurses \
1006    lib/ncurses/ncursesw \
1007    ${_share} \
1008    ${_aicasm} \
1009    usr.bin/awk \
1010    lib/libmagic \
1011    usr.sbin/sysinstall
1012	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1013		cd ${.CURDIR}/${_tool}; \
1014		${MAKE} DIRPRFX=${_tool}/ obj; \
1015		${MAKE} DIRPRFX=${_tool}/ build-tools
1016.endfor
1017.for _tool in \
1018    gnu/usr.bin/cc/cc_tools \
1019    ${_kerberos5_tools}
1020	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1021		cd ${.CURDIR}/${_tool}; \
1022		${MAKE} DIRPRFX=${_tool}/ obj; \
1023		${MAKE} DIRPRFX=${_tool}/ depend; \
1024		${MAKE} DIRPRFX=${_tool}/ all
1025.endfor
1026
1027#
1028# cross-tools: Build cross-building tools
1029#
1030.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1031.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1032_btxld=		usr.sbin/btxld
1033.endif
1034.endif
1035.if ${TARGET_ARCH} != ${MACHINE_ARCH}
1036.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1037_crunchide=	usr.sbin/crunch/crunchide
1038.endif
1039.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1040_kgzip=		usr.sbin/kgzip
1041.endif
1042.endif
1043
1044cross-tools:
1045.for _tool in \
1046    gnu/usr.bin/binutils \
1047    gnu/usr.bin/cc \
1048    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1049    ${_btxld} \
1050    ${_crunchide} \
1051    ${_kgzip}
1052	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1053		cd ${.CURDIR}/${_tool}; \
1054		${MAKE} DIRPRFX=${_tool}/ obj; \
1055		${MAKE} DIRPRFX=${_tool}/ depend; \
1056		${MAKE} DIRPRFX=${_tool}/ all; \
1057		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1058.endfor
1059
1060#
1061# hierarchy - ensure that all the needed directories are present
1062#
1063hierarchy:
1064	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
1065
1066#
1067# libraries - build all libraries, and install them under ${DESTDIR}.
1068#
1069# The list of libraries with dependents (${_prebuild_libs}) and their
1070# interdependencies (__L) are built automatically by the
1071# ${.CURDIR}/tools/make_libdeps.sh script.
1072#
1073libraries:
1074	cd ${.CURDIR}; \
1075	    ${MAKE} -f Makefile.inc1 _prereq_libs; \
1076	    ${MAKE} -f Makefile.inc1 _startup_libs; \
1077	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1078	    ${MAKE} -f Makefile.inc1 _generic_libs;
1079
1080#
1081# static libgcc.a prerequisite for shared libc
1082#
1083_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc
1084
1085# These dependencies are not automatically generated:
1086#
1087# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1088# all shared libraries for ELF.
1089#
1090_startup_libs=	gnu/lib/csu
1091.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1092_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
1093.else
1094_startup_libs+=	lib/csu/${MACHINE_ARCH}
1095.endif
1096_startup_libs+=	gnu/lib/libgcc
1097_startup_libs+=	lib/libc
1098
1099gnu/lib/libgcc__L: lib/libc__L
1100
1101_prebuild_libs=	${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1102		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libroken} \
1103		${_kerberos5_lib_libheimntlm} ${_kerberos5_lib_libgssapi_krb5} \
1104		lib/libbz2 lib/libcom_err lib/libcrypt lib/libelf \
1105		lib/libexpat \
1106		${_lib_cddl} ${_lib_libgssapi} ${_lib_libipx} \
1107		lib/libkiconv lib/libkvm lib/libmd \
1108		lib/ncurses/ncurses lib/ncurses/ncursesw \
1109		lib/libopie lib/libpam ${_lib_libthr} \
1110		lib/libradius lib/libsbuf lib/libtacplus lib/libulog \
1111		lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1112		${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1113		${_secure_lib_libssl} lib/libdwarf lib/libproc
1114
1115.if ${MK_LIBTHR} != "no"
1116_lib_libthr=	lib/libthr
1117.endif
1118
1119_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1120
1121lib/libopie__L lib/libtacplus__L: lib/libmd__L
1122
1123.if ${MK_CDDL} != "no"
1124_cddl_lib= cddl/lib
1125.endif
1126
1127.if ${MK_CRYPT} != "no"
1128.if ${MK_OPENSSL} != "no"
1129_secure_lib_libcrypto= secure/lib/libcrypto
1130_secure_lib_libssl= secure/lib/libssl
1131lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1132.if ${MK_OPENSSH} != "no"
1133_secure_lib_libssh= secure/lib/libssh
1134secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1135.if ${MK_KERBEROS} != "no"
1136kerberos5/lib/libgssapi_krb5__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1137    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1138    lib/libmd__L kerberos5/lib/libroken__L secure/lib/libcrypto__L \
1139    lib/libcrypt__L
1140secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libgssapi_krb5__L
1141.endif
1142.endif
1143.endif
1144_secure_lib=	secure/lib
1145.endif
1146
1147.if ${MK_IPX} != "no"
1148_lib_libipx=	lib/libipx
1149.endif
1150
1151.if ${MK_KERBEROS} != "no"
1152_kerberos5_lib=	kerberos5/lib
1153_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1154_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1155_kerberos5_lib_libhx509= kerberos5/lib/libhx509
1156_kerberos5_lib_libroken= kerberos5/lib/libroken
1157_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1158_kerberos5_lib_libgssapi_krb5= kerberos5/lib/libgssapi_krb5
1159_lib_libgssapi=	lib/libgssapi
1160.endif
1161
1162.if ${MK_NIS} != "no"
1163_lib_libypclnt=	lib/libypclnt
1164.endif
1165
1166.if ${MK_OPENSSL} == "no"
1167lib/libradius__L: lib/libmd__L
1168.endif
1169
1170.for _lib in ${_prereq_libs}
1171${_lib}__PL: .PHONY
1172.if exists(${.CURDIR}/${_lib})
1173	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1174		cd ${.CURDIR}/${_lib}; \
1175		${MAKE} DIRPRFX=${_lib}/ obj; \
1176		${MAKE} DIRPRFX=${_lib}/ depend; \
1177		${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1178		${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1179.endif
1180.endfor
1181
1182.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1183${_lib}__L: .PHONY
1184.if exists(${.CURDIR}/${_lib})
1185	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1186		cd ${.CURDIR}/${_lib}; \
1187		${MAKE} DIRPRFX=${_lib}/ obj; \
1188		${MAKE} DIRPRFX=${_lib}/ depend; \
1189		${MAKE} DIRPRFX=${_lib}/ all; \
1190		${MAKE} DIRPRFX=${_lib}/ install
1191.endif
1192.endfor
1193
1194# libpam is special: we need to build static PAM modules before
1195# static PAM library, and dynamic PAM library before dynamic PAM
1196# modules.
1197lib/libpam__L: .PHONY
1198	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1199		cd ${.CURDIR}/lib/libpam; \
1200		${MAKE} DIRPRFX=lib/libpam/ obj; \
1201		${MAKE} DIRPRFX=lib/libpam/ depend; \
1202		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1203		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1204
1205_prereq_libs: ${_prereq_libs:S/$/__PL/}
1206_startup_libs: ${_startup_libs:S/$/__L/}
1207_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1208_generic_libs: ${_generic_libs:S/$/__L/}
1209
1210.for __target in all clean cleandepend cleandir depend includes obj
1211.for entry in ${SUBDIR}
1212${entry}.${__target}__D: .PHONY
1213	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1214		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1215		edir=${entry}.${MACHINE_ARCH}; \
1216		cd ${.CURDIR}/$${edir}; \
1217	else \
1218		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1219		edir=${entry}; \
1220		cd ${.CURDIR}/$${edir}; \
1221	fi; \
1222	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1223.endfor
1224par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1225.endfor
1226
1227.include <bsd.subdir.mk>
1228
1229.if make(check-old) || make(check-old-dirs) || \
1230    make(check-old-files) || make(check-old-libs) || \
1231    make(delete-old) || make(delete-old-dirs) || \
1232    make(delete-old-files) || make(delete-old-libs)
1233
1234#
1235# check for / delete old files section
1236#
1237
1238.include "ObsoleteFiles.inc"
1239
1240OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1241else you can not start such an application. Consult UPDATING for more \
1242information regarding how to cope with the removal/revision bump of a \
1243specific library."
1244
1245.if !defined(BATCH_DELETE_OLD_FILES)
1246RM_I=-i
1247.else
1248RM_I=-v
1249.endif
1250
1251delete-old-files:
1252	@echo ">>> Removing old files (only deletes safe to delete libs)"
1253# Ask for every old file if the user really wants to remove it.
1254# It's annoying, but better safe than sorry.
1255	@for file in ${OLD_FILES}; do \
1256		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1257			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1258			rm ${RM_I} "${DESTDIR}/$${file}"; \
1259		fi; \
1260	done
1261# Remove catpages without corresponding manpages.
1262	@3<&0; \
1263	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1264	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1265	while read catpage; do \
1266		read manpage; \
1267		if [ ! -e "$${manpage}" ]; then \
1268			rm ${RM_I} $${catpage} <&3 ; \
1269	        fi; \
1270	done
1271	@echo ">>> Old files removed"
1272
1273check-old-files:
1274	@echo ">>> Checking for old files"
1275	@for file in ${OLD_FILES}; do \
1276		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1277		 	echo "${DESTDIR}/$${file}"; \
1278		fi; \
1279	done
1280# Check for catpages without corresponding manpages.
1281	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1282	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1283	while read catpage; do \
1284		read manpage; \
1285		if [ ! -e "$${manpage}" ]; then \
1286			echo $${catpage} ; \
1287	        fi; \
1288	done
1289
1290delete-old-libs:
1291	@echo ">>> Removing old libraries"
1292	@echo "${OLD_LIBS_MESSAGE}" | fmt
1293	@for file in ${OLD_LIBS}; do \
1294		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1295			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1296			rm ${RM_I} "${DESTDIR}/$${file}"; \
1297		fi; \
1298	done
1299	@echo ">>> Old libraries removed"
1300
1301check-old-libs:
1302	@echo ">>> Checking for old libraries"
1303	@for file in ${OLD_LIBS}; do \
1304		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1305			echo "${DESTDIR}/$${file}"; \
1306		fi; \
1307	done
1308
1309delete-old-dirs:
1310	@echo ">>> Removing old directories"
1311	@for dir in ${OLD_DIRS}; do \
1312		if [ -d "${DESTDIR}/$${dir}" ]; then \
1313			rmdir -v "${DESTDIR}/$${dir}" || true; \
1314		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1315			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1316		fi; \
1317	done
1318	@echo ">>> Old directories removed"
1319
1320check-old-dirs:
1321	@echo ">>> Checking for old directories"
1322	@for dir in ${OLD_DIRS}; do \
1323		if [ -d "${DESTDIR}/$${dir}" ]; then \
1324			echo "${DESTDIR}/$${dir}"; \
1325		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1326			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1327		fi; \
1328	done
1329
1330delete-old: delete-old-files delete-old-dirs
1331	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1332
1333check-old: check-old-files check-old-libs check-old-dirs
1334	@echo "To remove old files and directories run '${MAKE} delete-old'."
1335	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1336
1337.endif
1338
1339#
1340# showconfig - show build configuration.
1341#
1342showconfig:
1343	@${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1344
1345
1346###############
1347
1348.if defined(XDEV) && defined(XDEV_ARCH)
1349
1350NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1351	-DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1352	-DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS
1353
1354XDDIR=${XDEV}-freebsd
1355XDTP=/usr/${XDDIR}
1356CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1357	TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH}
1358CDENV= ${CDBENV} \
1359	_SHLIBDIRPREFIX=${XDTP} \
1360	TOOLS_PREFIX=${XDTP}
1361CD2ENV=${CDENV} \
1362	MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1363
1364CDTMP=	${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1365CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1366CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1367XDDESTDIR=${DESTDIR}${XDTP}
1368.if !defined(OSREL)
1369OSREL!= uname -r | sed -e 's/[-(].*//'
1370.endif
1371
1372.ORDER: xdev-build xdev-install
1373xdev: xdev-build xdev-install
1374
1375.ORDER: _xb-build-tools _xb-cross-tools
1376xdev-build: _xb-build-tools _xb-cross-tools
1377
1378_xb-build-tools:
1379	${_+_}cd ${.CURDIR}; \
1380	${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1381
1382_xb-cross-tools:
1383.for _tool in \
1384    gnu/usr.bin/binutils \
1385    gnu/usr.bin/cc
1386	${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1387	cd ${.CURDIR}/${_tool}; \
1388	${CDMAKE} DIRPRFX=${_tool}/ obj; \
1389	${CDMAKE} DIRPRFX=${_tool}/ depend; \
1390	${CDMAKE} DIRPRFX=${_tool}/ all
1391.endfor
1392
1393_xi-mtree:
1394	${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1395	mkdir -p ${XDDESTDIR}
1396	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1397	    -p ${XDDESTDIR} >/dev/null
1398	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1399	    -p ${XDDESTDIR}/usr >/dev/null
1400	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1401	    -p ${XDDESTDIR}/usr/include >/dev/null
1402
1403.ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1404xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1405
1406_xi-cross-tools:
1407	@echo "_xi-cross-tools"
1408.for _tool in \
1409    gnu/usr.bin/binutils \
1410    gnu/usr.bin/cc
1411	${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1412	cd ${.CURDIR}/${_tool}; \
1413	${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1414.endfor
1415
1416_xi-includes:
1417	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1418		DESTDIR=${XDDESTDIR}
1419
1420_xi-libraries:
1421	${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1422		DESTDIR=${XDDESTDIR}
1423
1424_xi-links:
1425	${_+_}cd ${XDDESTDIR}/usr/bin; \
1426		for i in *; do \
1427			ln -sf ../../${XDTP}/usr/bin/$$i \
1428			    ../../../../usr/bin/${XDDIR}-$$i; \
1429			ln -sf ../../${XDTP}/usr/bin/$$i \
1430			    ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1431		done
1432.endif
1433