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