Makefile.inc1 revision 142757
1#
2# $FreeBSD: head/Makefile.inc1 142757 2005-02-28 07:16:39Z ru $
3#
4# Make command line options:
5#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7#	-DNO_RESCUE do not build rescue binaries
8#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9#	-DNO_CLEAN do not clean at all
10#	-DNO_CRYPT will prevent building of crypt versions
11#	-DNO_MAN do not build the manual pages
12#	-DNO_NLS do not build Native Language Support files
13#	-DNO_PROFILE do not build profiled libraries
14#	-DNO_GAMES do not go into games subdir
15#	-DNO_SHARE do not go into share subdir
16#	-DNO_INFO do not make or install info files
17#	-DNO_LIBC_R do not build libc_r.
18#	-DNO_FORTRAN do not build g77 and related libraries.
19#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
20#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
21#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
22#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
23#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
24#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
25#	TARGET_ARCH="arch" to crossbuild world to a different arch
26
27#
28# The intended user-driven targets are:
29# buildworld  - rebuild *everything*, including glue to help do upgrades
30# installworld- install everything built by "buildworld"
31# update      - convenient way to update your source tree (eg: cvsup/cvs)
32#
33# Standard targets (not defined here) are documented in the makefiles in
34# /usr/share/mk.  These include:
35#		obj depend all install clean cleandepend cleanobj
36
37# We must do share/info early so that installation of info `dir'
38# entries works correctly.  Do it first since it is less likely to
39# grow dependencies on include and lib than vice versa.
40#
41# We must do lib and libexec before bin, because if installworld
42# installs a new /bin/sh, the 'make' command will *immediately*
43# use that new version.  And the new (dynamically-linked) /bin/sh
44# will expect to find appropriate libraries in /lib and /libexec.
45#
46# We must do etc last for install/distribute to work.
47#
48SUBDIR=	share/info include lib libexec bin
49.if !defined(NO_GAMES)
50SUBDIR+=games
51.endif
52SUBDIR+=gnu
53.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
54SUBDIR+=kerberos5
55.endif
56.if !defined(NO_RESCUE)
57SUBDIR+=rescue
58.endif
59SUBDIR+=sbin
60.if !defined(NO_CRYPT)
61SUBDIR+=secure
62.endif
63.if !defined(NO_SHARE)
64SUBDIR+=share
65.endif
66SUBDIR+=sys usr.bin usr.sbin etc
67
68# These are last, since it is nice to at least get the base system
69# rebuilt before you do them.
70.for _DIR in ${LOCAL_DIRS}
71.if exists(${.CURDIR}/${_DIR}/Makefile)
72SUBDIR+= ${_DIR}
73.endif
74.endfor
75
76.if defined(SUBDIR_OVERRIDE)
77SUBDIR=		${SUBDIR_OVERRIDE}
78.endif
79
80.if defined(NO_CLEANDIR)
81CLEANDIR=	clean cleandepend
82.else
83CLEANDIR=	cleandir
84.endif
85
86CVS?=		cvs
87CVSFLAGS?=	-A -P -d -I!
88SUP?=		/usr/local/bin/cvsup
89SUPFLAGS?=	-g -L 2 -P -
90.if defined(SUPHOST)
91SUPFLAGS+=	-h ${SUPHOST}
92.endif
93
94MAKEOBJDIRPREFIX?=	/usr/obj
95.if !defined(OSRELDATE)
96.if exists(/usr/include/osreldate.h)
97OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
98		/usr/include/osreldate.h
99.else
100OSRELDATE=	0
101.endif
102.endif
103TARGET_ARCH?=	${MACHINE_ARCH}
104.if ${TARGET_ARCH} == ${MACHINE_ARCH}
105TARGET?=	${MACHINE}
106TARGET_CPUTYPE?=${CPUTYPE}
107.else
108TARGET?=	${TARGET_ARCH}
109TARGET_CPUTYPE?=
110.endif
111.if !empty(TARGET_CPUTYPE)
112_TARGET_CPUTYPE=${TARGET_CPUTYPE}
113.else
114_TARGET_CPUTYPE=dummy
115.endif
116_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
117		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
118.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
119.error CPUTYPE global should be set with ?=.
120.endif
121.if make(buildworld)
122BUILD_ARCH!=	sysctl -n hw.machine_arch
123.if ${MACHINE_ARCH} != ${BUILD_ARCH}
124.error To cross-build, set TARGET_ARCH.
125.endif
126.endif
127.if ${MACHINE} == ${TARGET}
128OBJTREE=	${MAKEOBJDIRPREFIX}
129.else
130OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
131.endif
132WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
133# /usr/games added for fortune which depend on strfile
134BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
135XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
136STRICTTMPPATH=	${BPATH}:${XPATH}
137TMPPATH=	${STRICTTMPPATH}:${PATH}
138
139INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
140
141#
142# Building a world goes through the following stages
143#
144# 1. legacy stage [BMAKE]
145#	This stage is responsible for creating compatibility
146#	shims that are needed by the bootstrap-tools,
147#	build-tools and cross-tools stages.
148# 1. bootstrap-tools stage [BMAKE]
149#	This stage is responsible for creating programs that
150#	are needed for backward compatibility reasons. They
151#	are not built as cross-tools.
152# 2. build-tools stage [TMAKE]
153#	This stage is responsible for creating the object
154#	tree and building any tools that are needed during
155#	the build process.
156# 3. cross-tools stage [XMAKE]
157#	This stage is responsible for creating any tools that
158#	are needed for cross-builds. A cross-compiler is one
159#	of them.
160# 4. world stage [WMAKE]
161#	This stage actually builds the world.
162# 5. install stage (optional) [IMAKE]
163#	This stage installs a previously built world.
164#
165
166BOOTSTRAPPING?=	0
167
168# Common environment for world related stages
169CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
170		MACHINE_ARCH=${TARGET_ARCH} \
171		MACHINE=${TARGET} \
172		CPUTYPE=${TARGET_CPUTYPE} \
173		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
174		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
175		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
176
177# bootstrap-tools stage
178BMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
179		PATH=${BPATH}:${PATH} \
180		WORLDTMP=${WORLDTMP} \
181		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
182BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
183		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
184		DESTDIR= \
185		BOOTSTRAPPING=${OSRELDATE} \
186		-DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
187		-DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
188
189# build-tools stage
190TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
191		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
192		DESTDIR= \
193		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
194
195# cross-tools stage
196XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
197
198# world stage
199WMAKEENV=	${CROSSENV} \
200		_SHLIBDIRPREFIX=${WORLDTMP} \
201		INSTALL="sh ${.CURDIR}/tools/install.sh" \
202		PATH=${TMPPATH}
203WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
204
205.if ${MACHINE_ARCH} == "amd64"
206# 32 bit world
207LIB32TMP=	${OBJTREE}${.CURDIR}/lib32
208
209LIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
210LIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
211		-L${LIB32TMP}/usr/lib32 \
212		-B${LIB32TMP}/usr/lib32
213LIB32CC=	${LIB32PREFLAGS} \
214		${LIB32POSTFLAGS}
215LIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
216		${LIB32POSTFLAGS}
217LIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
218		${LIB32POSTFLAGS}
219
220# Yes, the flags are redundant.
221LIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
222		_SHLIBDIRPREFIX=${LIB32TMP} \
223		MACHINE_ARCH=i386 \
224		INSTALL="sh ${.CURDIR}/tools/install.sh" \
225		PATH=${TMPPATH} \
226		CC="cc ${LIB32CC}" \
227		CXX="c++ ${LIB32CXX}" \
228		OBJC="cc ${LIB32OBJC}" \
229		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
230		AS="as --32" \
231		LIBDIR=/usr/lib32 \
232		SHLIBDIR=/usr/lib32
233
234LIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
235		-DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML \
236		CC="cc ${LIB32CC}" \
237		CXX="c++ ${LIB32CXX}" \
238		OBJC="cc ${LIB32OBJC}" \
239		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
240		AS="as --32" \
241		LIBDIR=/usr/lib32 \
242		SHLIBDIR=/usr/lib32
243.endif
244
245# install stage
246.if empty(.MAKEFLAGS:M-n)
247IMAKEENV=	${CROSSENV} \
248		PATH=${STRICTTMPPATH}:${INSTALLTMP}
249.else
250IMAKEENV=	${CROSSENV} \
251		PATH=${TMPPATH}:${INSTALLTMP}
252.endif
253IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
254
255# kernel stage
256KMAKEENV=	${WMAKEENV}
257
258#
259# buildworld
260#
261# Attempt to rebuild the entire system, with reasonable chance of
262# success, regardless of how old your existing system is.
263#
264_worldtmp:
265.if ${.CURDIR:C/[^,]//g} != ""
266#	The m4 build of sendmail files doesn't like it if ',' is used
267#	anywhere in the path of it's files.
268	@echo
269	@echo "*** Error: path to source tree contains a comma ','"
270	@echo
271	false
272.endif
273	@echo
274	@echo "--------------------------------------------------------------"
275	@echo ">>> Rebuilding the temporary build tree"
276	@echo "--------------------------------------------------------------"
277.if !defined(NO_CLEAN)
278	rm -rf ${WORLDTMP}
279.else
280	rm -rf ${WORLDTMP}/legacy/usr/include
281	# XXX - These two can depend on any header file.
282	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
283	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
284.endif
285.for _dir in \
286    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
287    usr/libexec usr/sbin usr/share/dict \
288    usr/share/groff_font/devX100 \
289    usr/share/groff_font/devX100-12 \
290    usr/share/groff_font/devX75 \
291    usr/share/groff_font/devX75-12 \
292    usr/share/groff_font/devascii \
293    usr/share/groff_font/devcp1047 \
294    usr/share/groff_font/devdvi \
295    usr/share/groff_font/devhtml \
296    usr/share/groff_font/devkoi8-r \
297    usr/share/groff_font/devlatin1 \
298    usr/share/groff_font/devlbp \
299    usr/share/groff_font/devlj4 \
300    usr/share/groff_font/devps \
301    usr/share/groff_font/devutf8 \
302    usr/share/tmac/mdoc usr/share/tmac/mm
303	mkdir -p ${WORLDTMP}/legacy/${_dir}
304.endfor
305.for _dir in \
306    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
307    usr/libexec usr/sbin usr/share/misc \
308    usr/share/snmp/defs usr/share/snmp/mibs
309	mkdir -p ${WORLDTMP}/${_dir}
310.endfor
311	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
312	    -p ${WORLDTMP}/usr/include >/dev/null
313	ln -sf ${.CURDIR}/sys ${WORLDTMP}
314.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
315	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
316	    -p ${WORLDTMP}/usr/include >/dev/null
317.endif
318_legacy:
319	@echo
320	@echo "--------------------------------------------------------------"
321	@echo ">>> stage 1.1: legacy release compatibility shims"
322	@echo "--------------------------------------------------------------"
323	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
324_bootstrap-tools:
325	@echo
326	@echo "--------------------------------------------------------------"
327	@echo ">>> stage 1.2: bootstrap tools"
328	@echo "--------------------------------------------------------------"
329	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
330_cleanobj:
331.if !defined(NO_CLEAN)
332	@echo
333	@echo "--------------------------------------------------------------"
334	@echo ">>> stage 2.1: cleaning up the object tree"
335	@echo "--------------------------------------------------------------"
336	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
337.endif
338_obj:
339	@echo
340	@echo "--------------------------------------------------------------"
341	@echo ">>> stage 2.2: rebuilding the object tree"
342	@echo "--------------------------------------------------------------"
343	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
344_build-tools:
345	@echo
346	@echo "--------------------------------------------------------------"
347	@echo ">>> stage 2.3: build tools"
348	@echo "--------------------------------------------------------------"
349	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
350_cross-tools:
351	@echo
352	@echo "--------------------------------------------------------------"
353	@echo ">>> stage 3: cross tools"
354	@echo "--------------------------------------------------------------"
355	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
356_includes:
357	@echo
358	@echo "--------------------------------------------------------------"
359	@echo ">>> stage 4.1: building includes"
360	@echo "--------------------------------------------------------------"
361	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
362_libraries:
363	@echo
364	@echo "--------------------------------------------------------------"
365	@echo ">>> stage 4.2: building libraries"
366	@echo "--------------------------------------------------------------"
367	${_+_}cd ${.CURDIR}; \
368	    ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
369	    -DNO_NLS -DNO_PROFILE libraries
370_depend:
371	@echo
372	@echo "--------------------------------------------------------------"
373	@echo ">>> stage 4.3: make dependencies"
374	@echo "--------------------------------------------------------------"
375	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
376everything:
377	@echo
378	@echo "--------------------------------------------------------------"
379	@echo ">>> stage 4.4: building everything"
380	@echo "--------------------------------------------------------------"
381	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
382.if ${MACHINE_ARCH} == "amd64"
383build32:
384	@echo
385	@echo "--------------------------------------------------------------"
386	@echo ">>> stage 5.1: building 32 bit shim libraries"
387	@echo "--------------------------------------------------------------"
388.for _dir in \
389    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
390    usr/libexec usr/sbin usr/share/misc \
391    usr/share/snmp/defs usr/share/snmp/mibs
392	mkdir -p ${LIB32TMP}/${_dir}
393.endfor
394	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
395	    -p ${LIB32TMP}/usr/include >/dev/null
396	ln -sf ${.CURDIR}/sys ${WORLDTMP}
397.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
398.for _t in obj depend all
399	cd ${.CURDIR}/kerberos5/tools; \
400	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
401.endfor
402.endif
403.for _t in obj includes
404	cd ${.CURDIR}/include; \
405	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
406	cd ${.CURDIR}/lib; \
407	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
408	cd ${.CURDIR}/gnu/lib; \
409	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
410.if !defined(NO_CRYPT)
411	cd ${.CURDIR}/secure/lib; \
412	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
413.endif
414.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
415	cd ${.CURDIR}/kerberos5/lib; \
416	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
417.endif
418.endfor
419.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
420	cd ${.CURDIR}/${_dir}; \
421	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
422.endfor
423.for _dir in lib/libncurses lib/libmagic
424	cd ${.CURDIR}/${_dir}; \
425	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
426.endfor
427	cd ${.CURDIR}; \
428	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
429.for _t in obj depend all
430	cd ${.CURDIR}/libexec/rtld-elf; \
431	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
432.endfor
433
434install32:
435	mkdir -p ${DESTDIR}/usr/lib32	# XXX add to mtree
436	cd ${.CURDIR}/lib; ${LIB32MAKE} install
437	cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
438.if !defined(NO_CRYPT)
439	cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
440.endif
441	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
442.endif
443
444
445WMAKE_TGTS=
446.if !defined(SUBDIR_OVERRIDE)
447WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
448.endif
449WMAKE_TGTS+=	_cleanobj _obj _build-tools
450.if !defined(SUBDIR_OVERRIDE)
451WMAKE_TGTS+=	_cross-tools
452.endif
453WMAKE_TGTS+=	_includes _libraries _depend everything
454.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
455WMAKE_TGTS+=	build32
456.endif
457
458buildworld: ${WMAKE_TGTS}
459.ORDER: ${WMAKE_TGTS}
460
461buildenv:
462	@echo Entering world for ${TARGET_ARCH}:${TARGET}
463	@cd ${.CURDIR} && env ${WMAKEENV} sh || true
464
465TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
466toolchain: ${TOOLCHAIN_TGTS}
467kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
468
469#
470# Use this to add checks to installworld/installkernel targets.
471#
472SPECIAL_INSTALLCHECKS=
473
474#
475# installcheck
476#
477# Checks to be sure system is ready for installworld
478#
479CHECK_UIDS=
480CHECK_GIDS=
481.if !defined(NO_SENDMAIL)
482CHECK_UIDS+=	smmsp
483CHECK_GIDS+=	smmsp
484.endif
485.if !defined(NO_PF)
486CHECK_UIDS+=	proxy
487CHECK_GIDS+=	proxy authpf
488.endif
489installcheck: ${SPECIAL_INSTALLCHECKS}
490.for uid in ${CHECK_UIDS}
491	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
492		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
493		false; \
494	fi
495.endfor
496.for gid in ${CHECK_GIDS}
497	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
498		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
499		false; \
500	fi
501.endfor
502
503#
504# distributeworld
505#
506# Distributes everything compiled by a `buildworld'.
507#
508# installworld
509#
510# Installs everything compiled by a 'buildworld'.
511#
512distributeworld installworld: installcheck
513	mkdir -p ${INSTALLTMP}
514	for prog in [ awk cap_mkdb cat chflags chmod chown \
515	    date echo egrep find grep \
516	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
517	    test true uname wc zic; do \
518		cp `which $$prog` ${INSTALLTMP}; \
519	done
520	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
521	rm -rf ${INSTALLTMP}
522
523#
524# reinstall
525#
526# If you have a build server, you can NFS mount the source and obj directories
527# and do a 'make reinstall' on the *client* to install new binaries from the
528# most recent server build.
529#
530reinstall: ${SPECIAL_INSTALLCHECKS}
531	@echo "--------------------------------------------------------------"
532	@echo ">>> Making hierarchy"
533	@echo "--------------------------------------------------------------"
534	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
535	@echo
536	@echo "--------------------------------------------------------------"
537	@echo ">>> Installing everything"
538	@echo "--------------------------------------------------------------"
539	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
540.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
541	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
542.endif
543
544redistribute:
545	@echo "--------------------------------------------------------------"
546	@echo ">>> Distributing everything"
547	@echo "--------------------------------------------------------------"
548	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
549
550distribution:
551	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} distribution
552
553#
554# buildkernel and installkernel
555#
556# Which kernels to build and/or install is specified by setting
557# KERNCONF. If not defined a GENERIC kernel is built/installed.
558# Only the existing (depending TARGET) config files are used
559# for building kernels and only the first of these is designated
560# as the one being installed.
561#
562# Note that we have to use TARGET instead of TARGET_ARCH when
563# we're in kernel-land. Since only TARGET_ARCH is (expected) to
564# be set to cross-build, we have to make sure TARGET is set
565# properly.
566
567.if !defined(KERNCONF) && defined(KERNEL)
568KERNCONF=	${KERNEL}
569KERNWARN=
570.else
571KERNCONF?=	GENERIC
572.endif
573INSTKERNNAME?=	kernel
574
575KERNSRCDIR?=	${.CURDIR}/sys
576KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
577KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
578KERNCONFDIR?=	${KRNLCONFDIR}
579
580BUILDKERNELS=
581INSTALLKERNEL=
582.for _kernel in ${KERNCONF}
583.if exists(${KERNCONFDIR}/${_kernel})
584BUILDKERNELS+=	${_kernel}
585.if empty(INSTALLKERNEL)
586INSTALLKERNEL= ${_kernel}
587.endif
588.endif
589.endfor
590
591#
592# buildkernel
593#
594# Builds all kernels defined by BUILDKERNELS.
595#
596buildkernel:
597.if empty(BUILDKERNELS)
598	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
599	false
600.endif
601.if defined(KERNWARN)
602	@echo "--------------------------------------------------------------"
603	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
604	@echo "--------------------------------------------------------------"
605	@sleep 3
606.endif
607	@echo
608.for _kernel in ${BUILDKERNELS}
609	@echo "--------------------------------------------------------------"
610	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
611	@echo "--------------------------------------------------------------"
612	@echo "===> ${_kernel}"
613	mkdir -p ${KRNLOBJDIR}
614.if !defined(NO_KERNELCONFIG)
615	@echo
616	@echo "--------------------------------------------------------------"
617	@echo ">>> stage 1: configuring the kernel"
618	@echo "--------------------------------------------------------------"
619	cd ${KRNLCONFDIR}; \
620		PATH=${TMPPATH} \
621		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
622			${KERNCONFDIR}/${_kernel}
623.endif
624.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
625	@echo
626	@echo "--------------------------------------------------------------"
627	@echo ">>> stage 2.1: cleaning up the object tree"
628	@echo "--------------------------------------------------------------"
629	cd ${KRNLOBJDIR}/${_kernel}; \
630	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
631.endif
632	@echo
633	@echo "--------------------------------------------------------------"
634	@echo ">>> stage 2.2: rebuilding the object tree"
635	@echo "--------------------------------------------------------------"
636	cd ${KRNLOBJDIR}/${_kernel}; \
637	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
638	@echo
639	@echo "--------------------------------------------------------------"
640	@echo ">>> stage 2.3: build tools"
641	@echo "--------------------------------------------------------------"
642	cd ${KRNLOBJDIR}/${_kernel}; \
643	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
644	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
645# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
646.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
647.for target in obj depend all
648	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
649	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
650	    ${MAKE} -DNO_CPU_CFLAGS ${target}
651.endfor
652.endif
653.if !defined(NO_KERNELDEPEND)
654	@echo
655	@echo "--------------------------------------------------------------"
656	@echo ">>> stage 3.1: making dependencies"
657	@echo "--------------------------------------------------------------"
658	cd ${KRNLOBJDIR}/${_kernel}; \
659	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
660.endif
661	@echo
662	@echo "--------------------------------------------------------------"
663	@echo ">>> stage 3.2: building everything"
664	@echo "--------------------------------------------------------------"
665	cd ${KRNLOBJDIR}/${_kernel}; \
666	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
667	@echo "--------------------------------------------------------------"
668	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
669	@echo "--------------------------------------------------------------"
670.endfor
671
672#
673# installkernel, etc.
674#
675# Install the kernel defined by INSTALLKERNEL
676#
677installkernel installkernel.debug \
678reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
679.if empty(INSTALLKERNEL)
680	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
681	false
682.endif
683	@echo "--------------------------------------------------------------"
684	@echo ">>> Making hierarchy"
685	@echo "--------------------------------------------------------------"
686	cd ${.CURDIR}; \
687	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
688	@echo
689	@echo "--------------------------------------------------------------"
690	@echo ">>> Installing kernel"
691	@echo "--------------------------------------------------------------"
692	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
693	    ${CROSSENV} PATH=${TMPPATH} \
694	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
695
696#
697# update
698#
699# Update the source tree, by running cvsup and/or running cvs to update to the
700# latest copy.
701#
702update:
703.if defined(SUP_UPDATE)
704	@echo "--------------------------------------------------------------"
705	@echo ">>> Running ${SUP}"
706	@echo "--------------------------------------------------------------"
707.if defined(SUPFILE)
708	@${SUP} ${SUPFLAGS} ${SUPFILE}
709.endif
710.if defined(SUPFILE1)
711	@${SUP} ${SUPFLAGS} ${SUPFILE1}
712.endif
713.if defined(SUPFILE2)
714	@${SUP} ${SUPFLAGS} ${SUPFILE2}
715.endif
716.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
717	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
718.endif
719.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
720	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
721.endif
722.endif
723.if defined(CVS_UPDATE)
724	@echo "--------------------------------------------------------------"
725	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
726	@echo "--------------------------------------------------------------"
727	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
728.endif
729
730#
731# ------------------------------------------------------------------------
732#
733# From here onwards are utility targets used by the 'make world' and
734# related targets.  If your 'world' breaks, you may like to try to fix
735# the problem and manually run the following targets to attempt to
736# complete the build.  Beware, this is *not* guaranteed to work, you
737# need to have a pretty good grip on the current state of the system
738# to attempt to manually finish it.  If in doubt, 'make world' again.
739#
740
741#
742# legacy: Build compatibility shims for the next three targets
743#
744legacy:
745.if ${BOOTSTRAPPING} < 503000
746	@echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
747	false
748.endif
749.for _tool in tools/build
750	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
751	    cd ${.CURDIR}/${_tool}; \
752	    ${MAKE} DIRPRFX=${_tool}/ obj; \
753	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
754	    ${MAKE} DIRPRFX=${_tool}/ depend; \
755	    ${MAKE} DIRPRFX=${_tool}/ all; \
756	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
757.endfor
758
759#
760# bootstrap-tools: Build tools needed for compatibility
761#
762.if !defined(NO_GAMES)
763_strfile=	games/fortune/strfile
764.endif
765
766.if !defined(NO_CXX)
767_gperf=		gnu/usr.bin/gperf
768.if ${BOOTSTRAPPING} < 500113
769_groff=		gnu/usr.bin/groff
770.else
771_groff=		gnu/usr.bin/groff/tmac
772.endif
773.endif
774
775.if ${BOOTSTRAPPING} < 600015
776_cap_mkdb=	usr.bin/cap_mkdb
777.endif
778
779.if ${BOOTSTRAPPING} < 600018
780_colldef=	usr.bin/colldef
781.endif
782
783.if ${BOOTSTRAPPING} < 600017
784_gencat=	usr.bin/gencat
785.endif
786
787.if ${BOOTSTRAPPING} < 600016
788_mklocale=	usr.bin/mklocale
789.endif
790
791.if !defined(NO_RESCUE) && \
792    ${BOOTSTRAPPING} < 600008
793_crunchgen=	usr.sbin/crunch/crunchgen
794.endif
795
796bootstrap-tools:
797.for _tool in \
798    ${_strfile} \
799    ${_gperf} \
800    ${_groff} \
801    gnu/usr.bin/texinfo \
802    ${_cap_mkdb} \
803    ${_colldef} \
804    ${_gencat} \
805    usr.bin/lorder \
806    usr.bin/makewhatis \
807    ${_mklocale} \
808    usr.bin/rpcgen \
809    usr.bin/xinstall \
810    usr.sbin/config \
811    ${_crunchgen}
812	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
813		cd ${.CURDIR}/${_tool}; \
814		${MAKE} DIRPRFX=${_tool}/ obj; \
815		${MAKE} DIRPRFX=${_tool}/ depend; \
816		${MAKE} DIRPRFX=${_tool}/ all; \
817		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
818.endfor
819
820#
821# build-tools: Build special purpose build tools
822#
823.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
824_aicasm= sys/modules/aic7xxx/aicasm
825.endif
826
827.if !defined(NO_SHARE)
828_share=	share/syscons/scrnmaps
829.endif
830
831.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
832_kerberos5_tools= kerberos5/tools
833.endif
834
835.if !defined(NO_RESCUE)
836_rescue= rescue/rescue
837.endif
838
839build-tools:
840.for _tool in \
841    bin/csh \
842    bin/sh \
843    ${_rescue} \
844    lib/libncurses \
845    ${_share} \
846    ${_aicasm} \
847    usr.bin/awk \
848    lib/libmagic \
849    usr.sbin/sysinstall
850	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
851		cd ${.CURDIR}/${_tool}; \
852		${MAKE} DIRPRFX=${_tool}/ obj; \
853		${MAKE} DIRPRFX=${_tool}/ build-tools
854.endfor
855.for _tool in \
856    gnu/usr.bin/cc/cc_tools \
857    ${_kerberos5_tools}
858	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
859		cd ${.CURDIR}/${_tool}; \
860		${MAKE} DIRPRFX=${_tool}/ obj; \
861		${MAKE} DIRPRFX=${_tool}/ depend; \
862		${MAKE} DIRPRFX=${_tool}/ all
863.endfor
864
865#
866# cross-tools: Build cross-building tools
867#
868.if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
869    ${TARGET_ARCH} != ${MACHINE_ARCH}
870_btxld=		usr.sbin/btxld
871.endif
872
873.if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
874    ${TARGET_ARCH} != ${MACHINE_ARCH}
875_crunchide=	usr.sbin/crunch/crunchide
876.endif
877
878.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
879_elf2exe=	usr.sbin/elf2exe
880.endif
881
882.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
883    defined(RELEASEDIR)
884_kgzip=		usr.sbin/kgzip
885.endif
886
887cross-tools:
888.for _tool in \
889    gnu/usr.bin/binutils \
890    gnu/usr.bin/cc \
891    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
892    ${_btxld} \
893    ${_crunchide} \
894    ${_elf2exe} \
895    ${_kgzip}
896	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
897		cd ${.CURDIR}/${_tool}; \
898		${MAKE} DIRPRFX=${_tool}/ obj; \
899		${MAKE} DIRPRFX=${_tool}/ depend; \
900		${MAKE} DIRPRFX=${_tool}/ all; \
901		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
902.endfor
903
904#
905# hierarchy - ensure that all the needed directories are present
906#
907hierarchy:
908	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
909
910#
911# libraries - build all libraries, and install them under ${DESTDIR}.
912#
913# The list of libraries with dependents (${_prebuild_libs}) and their
914# interdependencies (__L) are built automatically by the
915# ${.CURDIR}/tools/make_libdeps.sh script.
916#
917libraries:
918	cd ${.CURDIR}; \
919	    ${MAKE} -f Makefile.inc1 _startup_libs; \
920	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
921	    ${MAKE} -f Makefile.inc1 _generic_libs;
922
923# These dependencies are not automatically generated:
924#
925# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
926# shared libraries for ELF.
927#
928_startup_libs=	gnu/lib/csu gnu/lib/libgcc
929.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
930_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
931.else
932_startup_libs+=	lib/csu/${MACHINE_ARCH}
933.endif
934
935_prebuild_libs=
936
937_generic_libs=	gnu/lib
938
939.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
940_prebuild_libs+=	kerberos5/lib/libasn1
941_prebuild_libs+=	kerberos5/lib/libgssapi
942_prebuild_libs+=	kerberos5/lib/libkrb5
943_prebuild_libs+=	kerberos5/lib/libroken
944_generic_libs+=	kerberos5/lib
945.endif
946
947_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
948		lib/libkvm lib/libmd \
949		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
950		lib/libradius \
951		lib/libsbuf lib/libtacplus lib/libutil \
952		lib/libz lib/msun
953
954lib/libopie__L lib/libtacplus__L: lib/libmd__L
955
956.if !defined(NO_BIND)
957.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
958_prebuild_libs+= lib/libc_r
959.else
960_prebuild_libs+= lib/libpthread
961.endif
962.endif
963
964_generic_libs+=	lib
965
966.if !defined(NO_CRYPT)
967.if !defined(NO_OPENSSL)
968_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
969lib/libradius__L: secure/lib/libssl__L
970secure/lib/libssl__L: secure/lib/libcrypto__L
971.if !defined(NO_OPENSSH)
972_prebuild_libs+=	secure/lib/libssh
973secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
974.if !defined(NO_KERBEROS)
975secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
976    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
977    kerberos5/lib/libroken__L
978.endif
979.endif
980.endif
981_generic_libs+=	secure/lib
982.endif
983
984.if defined(NO_CRYPT) || defined(NO_OPENSSL)
985lib/libradius__L: lib/libmd__L
986.endif
987
988.if !defined(NO_NIS)
989_prebuild_libs+=	lib/libypclnt
990.endif
991
992_generic_libs+=	usr.bin/lex/lib
993
994.if ${MACHINE_ARCH} == "i386"
995_generic_libs+=	usr.sbin/pcvt/keycap
996.endif
997
998.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
999${_lib}__L: .PHONY
1000.if exists(${.CURDIR}/${_lib})
1001	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1002		cd ${.CURDIR}/${_lib}; \
1003		${MAKE} DIRPRFX=${_lib}/ depend; \
1004		${MAKE} DIRPRFX=${_lib}/ all; \
1005		${MAKE} DIRPRFX=${_lib}/ install
1006.endif
1007.endfor
1008
1009# libpam is special: we need to build static PAM modules before
1010# static PAM library, and dynamic PAM library before dynamic PAM
1011# modules.
1012lib/libpam__L: .PHONY
1013	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1014		cd ${.CURDIR}/lib/libpam; \
1015		${MAKE} DIRPRFX=lib/libpam/ depend; \
1016		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1017		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1018
1019_startup_libs: ${_startup_libs:S/$/__L/}
1020_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1021_generic_libs: ${_generic_libs:S/$/__L/}
1022
1023.for __target in all clean cleandepend cleandir depend includes obj
1024.for entry in ${SUBDIR}
1025${entry}.${__target}__D: .PHONY
1026	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1027		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1028		edir=${entry}.${MACHINE_ARCH}; \
1029		cd ${.CURDIR}/$${edir}; \
1030	else \
1031		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1032		edir=${entry}; \
1033		cd ${.CURDIR}/$${edir}; \
1034	fi; \
1035	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1036.endfor
1037par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1038.endfor
1039
1040.include <bsd.subdir.mk>
1041