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