Makefile.inc1 revision 113439
1#
2# $FreeBSD: head/Makefile.inc1 113439 2003-04-13 14:34:17Z ru $
3#
4# Make command line options:
5#	-DMAKE_KERBEROS5 to build Kerberos5
6#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
7#	-DNOCLEAN do not clean at all
8#	-DNOCRYPT will prevent building of crypt versions
9#	-DNOMAN do not build the manual pages
10#	-DNOPROFILE do not build profiled libraries
11#	-DNOSECURE do not go into secure subdir
12#	-DNOGAMES do not go into games subdir
13#	-DNOSHARE do not go into share subdir
14#	-DNOINFO do not make or install info files
15#	-DNOLIBC_R do not build libc_r.
16#	-DNO_FORTRAN do not build g77 and related libraries.
17#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
18#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
19#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
20#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
21#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
22#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
23#	TARGET_ARCH="arch" to crossbuild world to a different arch
24
25#
26# The intended user-driven targets are:
27# buildworld  - rebuild *everything*, including glue to help do upgrades
28# installworld- install everything built by "buildworld"
29# update      - convenient way to update your source tree (eg: sup/cvs)
30# most        - build user commands, no libraries or include files
31# installmost - install user commands, no libraries or include files
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# Put initial settings here.
38SUBDIR=
39
40# We must do share/info early so that installation of info `dir'
41# entries works correctly.  Do it first since it is less likely to
42# grow dependencies on include and lib than vice versa.
43.if exists(${.CURDIR}/share/info)
44SUBDIR+= share/info
45.endif
46
47.if exists(${.CURDIR}/include)
48SUBDIR+= include
49.endif
50.if exists(${.CURDIR}/lib)
51SUBDIR+= lib
52.endif
53
54.if exists(${.CURDIR}/bin)
55SUBDIR+= bin
56.endif
57.if exists(${.CURDIR}/games) && !defined(NOGAMES)
58SUBDIR+= games
59.endif
60.if exists(${.CURDIR}/gnu)
61SUBDIR+= gnu
62.endif
63.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
64    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
65SUBDIR+= kerberos5
66.endif
67.if exists(${.CURDIR}/libexec)
68SUBDIR+= libexec
69.endif
70.if exists(${.CURDIR}/sbin)
71SUBDIR+= sbin
72.endif
73.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
74SUBDIR+= secure
75.endif
76.if exists(${.CURDIR}/share) && !defined(NOSHARE)
77SUBDIR+= share
78.endif
79.if exists(${.CURDIR}/sys)
80SUBDIR+= sys
81.endif
82.if exists(${.CURDIR}/usr.bin)
83SUBDIR+= usr.bin
84.endif
85.if exists(${.CURDIR}/usr.sbin)
86SUBDIR+= usr.sbin
87.endif
88
89# etc must be last for "distribute" to work
90.if exists(${.CURDIR}/etc)
91SUBDIR+= etc
92.endif
93
94# These are last, since it is nice to at least get the base system
95# rebuilt before you do them.
96.if defined(LOCAL_DIRS)
97.for _DIR in ${LOCAL_DIRS}
98.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
99SUBDIR+= ${_DIR}
100.endif
101.endfor
102.endif
103
104.if defined(SUBDIR_OVERRIDE)
105SUBDIR=		${SUBDIR_OVERRIDE}
106.endif
107
108.if defined(NOCLEANDIR)
109CLEANDIR=	clean cleandepend
110.else
111CLEANDIR=	cleandir
112.endif
113
114CVS?=		cvs
115SUP?=		/usr/local/bin/cvsup
116SUPFLAGS?=	-g -L 2 -P -
117.if defined(SUPHOST)
118SUPFLAGS+=	-h ${SUPHOST}
119.endif
120
121MAKEOBJDIRPREFIX?=	/usr/obj
122OSRELDATE!=	sysctl -n kern.osreldate
123TARGET_ARCH?=	${MACHINE_ARCH}
124.if ${TARGET_ARCH} == ${MACHINE_ARCH}
125TARGET?=	${MACHINE}
126TARGET_CPUTYPE?=${CPUTYPE}
127.else
128TARGET?=	${TARGET_ARCH}
129TARGET_CPUTYPE?=
130.endif
131.if !empty(TARGET_CPUTYPE)
132_TARGET_CPUTYPE=${TARGET_CPUTYPE}
133.else
134_TARGET_CPUTYPE=dummy
135.endif
136_CPUTYPE!=	${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
137		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
138.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
139.error CPUTYPE global should be set with ?=.
140.endif
141.if make(buildworld)
142BUILD_ARCH!=	sysctl -n hw.machine_arch
143.if ${MACHINE_ARCH} != ${BUILD_ARCH}
144.error To cross-build, set TARGET_ARCH.
145.endif
146.endif
147.if ${MACHINE} == ${TARGET}
148OBJTREE=	${MAKEOBJDIRPREFIX}
149.else
150OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
151.endif
152WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
153# /usr/games added for fortune which depend on strfile
154BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
155XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
156STRICTTMPPATH=	${BPATH}:${XPATH}
157TMPPATH=	${STRICTTMPPATH}:${PATH}
158
159INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
160
161#
162# Building a world goes through the following stages
163#
164# 1. legacy stage [BMAKE]
165#	This stage is responsible for creating compatibility
166#	shims that are needed by the bootstrap-tools,
167#	build-tools and cross-tools stages.
168# 1. bootstrap-tools stage [BMAKE]
169#	This stage is responsible for creating programs that
170#	are needed for backward compatibility reasons. They
171#	are not built as cross-tools.
172# 2. build-tools stage [TMAKE]
173#	This stage is responsible for creating the object
174#	tree and building any tools that are needed during
175#	the build process.
176# 3. cross-tools stage [XMAKE]
177#	This stage is responsible for creating any tools that
178#	are needed for cross-builds. A cross-compiler is one
179#	of them.
180# 4. world stage [WMAKE]
181#	This stage actually builds the world.
182# 5. install stage (optional) [IMAKE]
183#	This stage installs a previously built world.
184#
185
186# Common environment for world related stages
187CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
188		MACHINE_ARCH=${TARGET_ARCH} \
189		MACHINE=${TARGET} \
190		CPUTYPE=${TARGET_CPUTYPE} \
191		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
192		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
193		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
194
195# bootstrap-tools stage
196BMAKEENV=	DESTDIR= \
197		INSTALL="sh ${.CURDIR}/tools/install.sh" \
198		PATH=${BPATH}:${PATH} \
199		WORLDTMP=${WORLDTMP} \
200		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
201BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
202		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
203		BOOTSTRAPPING=${OSRELDATE} \
204		-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
205		-DNO_CPU_CFLAGS -DNO_WARNS
206
207# build-tools stage
208TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
209		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
210		BOOTSTRAPPING=${OSRELDATE} -DNO_CPU_CFLAGS -DNO_WARNS
211
212# cross-tools stage
213XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
214
215# world stage
216WMAKEENV=	${CROSSENV} \
217		DESTDIR=${WORLDTMP} \
218		INSTALL="sh ${.CURDIR}/tools/install.sh" \
219		PATH=${TMPPATH}
220WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
221
222# install stage
223IMAKEENV=	${CROSSENV} \
224		PATH=${STRICTTMPPATH}:${INSTALLTMP}
225IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
226
227# kernel stage
228KMAKEENV=	${WMAKEENV}
229
230#
231# buildworld
232#
233# Attempt to rebuild the entire system, with reasonable chance of
234# success, regardless of how old your existing system is.
235#
236_worldtmp:
237.if ${.CURDIR:C/[^,]//g} != ""
238#	The m4 build of sendmail files doesn't like it if ',' is used
239#	anywhere in the path of it's files.
240	@echo
241	@echo "*** Error: path to source tree contains a comma ','"
242	@echo
243	@false
244.endif
245	@echo
246	@echo "--------------------------------------------------------------"
247	@echo ">>> Rebuilding the temporary build tree"
248	@echo "--------------------------------------------------------------"
249.if !defined(NOCLEAN)
250	rm -rf ${WORLDTMP}
251.else
252	rm -rf ${WORLDTMP}/legacy/usr/include
253	# XXX - These two can depend on any header file.
254	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
255	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
256.endif
257.for _dir in \
258    usr/bin usr/games usr/include/sys usr/lib \
259    usr/libexec usr/sbin usr/share/dict \
260    usr/share/groff_font/devX100 \
261    usr/share/groff_font/devX100-12 \
262    usr/share/groff_font/devX75 \
263    usr/share/groff_font/devX75-12 \
264    usr/share/groff_font/devascii \
265    usr/share/groff_font/devcp1047 \
266    usr/share/groff_font/devdvi \
267    usr/share/groff_font/devhtml \
268    usr/share/groff_font/devkoi8-r \
269    usr/share/groff_font/devlatin1 \
270    usr/share/groff_font/devlbp \
271    usr/share/groff_font/devlj4 \
272    usr/share/groff_font/devps \
273    usr/share/groff_font/devutf8 \
274    usr/share/tmac/mdoc usr/share/tmac/mm
275	mkdir -p ${WORLDTMP}/legacy/${_dir}
276.endfor
277.for _dir in \
278    usr/bin usr/lib/compat/aout usr/libdata/ldscripts usr/libexec usr/share/misc
279	mkdir -p ${WORLDTMP}/${_dir}
280.endfor
281.for _dir in \
282    arpa dev fs g++/backward g++/bits g++/ext isc isofs libmilter \
283    objc openssl protocols readline rpc rpcsvc security ufs
284	mkdir -p ${WORLDTMP}/usr/include/${_dir}
285.endfor
286	ln -sf ${.CURDIR}/sys ${WORLDTMP}
287_legacy:
288	@echo
289	@echo "--------------------------------------------------------------"
290	@echo ">>> stage 1: legacy release compatibility shims"
291	@echo "--------------------------------------------------------------"
292	cd ${.CURDIR}; ${BMAKE} legacy
293_bootstrap-tools:
294	@echo
295	@echo "--------------------------------------------------------------"
296	@echo ">>> stage 1: bootstrap tools"
297	@echo "--------------------------------------------------------------"
298	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
299_cleanobj:
300.if !defined(NOCLEAN)
301	@echo
302	@echo "--------------------------------------------------------------"
303	@echo ">>> stage 2: cleaning up the object tree"
304	@echo "--------------------------------------------------------------"
305	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
306.endif
307_obj:
308	@echo
309	@echo "--------------------------------------------------------------"
310	@echo ">>> stage 2: rebuilding the object tree"
311	@echo "--------------------------------------------------------------"
312	cd ${.CURDIR}; ${WMAKE} par-obj
313_build-tools:
314	@echo
315	@echo "--------------------------------------------------------------"
316	@echo ">>> stage 2: build tools"
317	@echo "--------------------------------------------------------------"
318	cd ${.CURDIR}; ${TMAKE} build-tools
319_cross-tools:
320	@echo
321	@echo "--------------------------------------------------------------"
322	@echo ">>> stage 3: cross tools"
323	@echo "--------------------------------------------------------------"
324	cd ${.CURDIR}; ${XMAKE} cross-tools
325_includes:
326	@echo
327	@echo "--------------------------------------------------------------"
328	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
329	@echo "--------------------------------------------------------------"
330	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
331_libraries:
332	@echo
333	@echo "--------------------------------------------------------------"
334	@echo ">>> stage 4: building libraries"
335	@echo "--------------------------------------------------------------"
336	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
337_depend:
338	@echo
339	@echo "--------------------------------------------------------------"
340	@echo ">>> stage 4: make dependencies"
341	@echo "--------------------------------------------------------------"
342	cd ${.CURDIR}; ${WMAKE} par-depend
343everything:
344	@echo
345	@echo "--------------------------------------------------------------"
346	@echo ">>> stage 4: building everything.."
347	@echo "--------------------------------------------------------------"
348	cd ${.CURDIR}; ${WMAKE} par-all
349
350
351WMAKE_TGTS=
352.if !defined(SUBDIR_OVERRIDE)
353WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
354.endif
355WMAKE_TGTS+=	_cleanobj _obj _build-tools
356.if !defined(SUBDIR_OVERRIDE)
357WMAKE_TGTS+=	_cross-tools
358.endif
359WMAKE_TGTS+=	_includes _libraries _depend everything
360
361buildworld: ${WMAKE_TGTS}
362.ORDER: ${WMAKE_TGTS}
363
364#
365# installcheck
366#
367# Checks to be sure system is ready for installworld
368#
369installcheck:
370.if !defined(NO_SENDMAIL)
371	@if ! `grep -q '^smmsp:' /etc/passwd`; then \
372		echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
373		false; \
374	fi
375	@if ! `grep -q '^smmsp:' /etc/group`; then \
376		echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
377		false; \
378	fi
379.endif
380.if ${TARGET_ARCH} == ${MACHINE_ARCH} && !defined(DISTDIR) && \
381    (!defined(DESTDIR) || empty(DESTDIR) || ${DESTDIR} == "/")
382	@echo "Checking to see if your booted kernel is fresh enough.."
383	${.OBJDIR}/bin/sh/sh -c \
384	    'echo "Testing installed kernel for new sigaction(2) syscall"'
385	@echo "Seems ok.."
386.endif
387
388#
389# distributeworld
390#
391# Distributes everything compiled by a `buildworld'.
392#
393# installworld
394#
395# Installs everything compiled by a 'buildworld'.
396#
397distributeworld installworld: installcheck
398	mkdir -p ${INSTALLTMP}
399	for prog in [ awk cap_mkdb cat chflags chmod chown \
400	    date echo egrep find grep \
401	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
402	    test true uname wc zic; do \
403		cp `which $$prog` ${INSTALLTMP}; \
404	done
405	cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
406	rm -rf ${INSTALLTMP}
407
408#
409# reinstall
410#
411# If you have a build server, you can NFS mount the source and obj directories
412# and do a 'make reinstall' on the *client* to install new binaries from the
413# most recent server build.
414#
415reinstall:
416	@echo "--------------------------------------------------------------"
417	@echo ">>> Making hierarchy"
418	@echo "--------------------------------------------------------------"
419	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
420	@echo
421	@echo "--------------------------------------------------------------"
422	@echo ">>> Installing everything.."
423	@echo "--------------------------------------------------------------"
424	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
425.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
426	@echo
427	@echo "--------------------------------------------------------------"
428	@echo ">>> Rebuilding man page indices"
429	@echo "--------------------------------------------------------------"
430	cd ${.CURDIR}/share/man; ${MAKE} makedb
431.endif
432
433redistribute:
434	@echo "--------------------------------------------------------------"
435	@echo ">>> Distributing everything.."
436	@echo "--------------------------------------------------------------"
437	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
438
439#
440# buildkernel and installkernel
441#
442# Which kernels to build and/or install is specified by setting
443# KERNCONF. If not defined a GENERIC kernel is built/installed.
444# Only the existing (depending TARGET) config files are used
445# for building kernels and only the first of these is designated
446# as the one being installed.
447#
448# Note that we have to use TARGET instead of TARGET_ARCH when
449# we're in kernel-land. Since only TARGET_ARCH is (expected) to
450# be set to cross-build, we have to make sure TARGET is set
451# properly.
452
453.if !defined(KERNCONF) && defined(KERNEL)
454KERNCONF=	${KERNEL}
455KERNWARN=	yes
456.else
457KERNCONF?=	GENERIC
458.endif
459INSTKERNNAME?=	kernel
460
461KRNLSRCDIR=	${.CURDIR}/sys
462KRNLCONFDIR=	${KRNLSRCDIR}/${TARGET}/conf
463KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
464KERNCONFDIR?=	${KRNLCONFDIR}
465
466BUILDKERNELS=
467INSTALLKERNEL=
468.for _kernel in ${KERNCONF}
469.if exists(${KERNCONFDIR}/${_kernel})
470BUILDKERNELS+=	${_kernel}
471.if empty(INSTALLKERNEL)
472INSTALLKERNEL= ${_kernel}
473.endif
474.endif
475.endfor
476
477#
478# buildkernel
479#
480# Builds all kernels defined by BUILDKERNELS.
481#
482buildkernel:
483.if empty(BUILDKERNELS)
484	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
485	@false
486.endif
487.if defined(KERNWARN)
488	@echo "--------------------------------------------------------------"
489	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
490	@echo "--------------------------------------------------------------"
491	@sleep 3
492.endif
493	@echo
494.for _kernel in ${BUILDKERNELS}
495	@echo "--------------------------------------------------------------"
496	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
497	@echo "--------------------------------------------------------------"
498	@echo "===> ${_kernel}"
499	mkdir -p ${KRNLOBJDIR}
500.if !defined(NO_KERNELCONFIG)
501	cd ${KRNLCONFDIR}; \
502		PATH=${TMPPATH} \
503		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
504			${KERNCONFDIR}/${_kernel}
505.endif
506.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
507	cd ${KRNLOBJDIR}/${_kernel}; \
508	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
509.endif
510	cd ${KRNLOBJDIR}/${_kernel}; \
511	    MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
512	    ${MAKE} -DNO_CPU_CFLAGS -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
513	cd ${KRNLOBJDIR}/${_kernel}; \
514	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
515# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
516.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
517.for target in obj depend all
518	cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
519	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
520	    ${MAKE} -DNO_CPU_CFLAGS ${target}
521.endfor
522.endif
523.if !defined(NO_KERNELDEPEND)
524	cd ${KRNLOBJDIR}/${_kernel}; \
525	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
526.endif
527	cd ${KRNLOBJDIR}/${_kernel}; \
528	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
529	@echo "--------------------------------------------------------------"
530	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
531	@echo "--------------------------------------------------------------"
532.endfor
533
534#
535# installkernel
536#
537# Install the kernel defined by INSTALLKERNEL
538#
539installkernel reinstallkernel:
540.if empty(INSTALLKERNEL)
541	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
542	@false
543.endif
544	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
545	    ${CROSSENV} PATH=${TMPPATH} \
546	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
547
548#
549# update
550#
551# Update the source tree, by running sup and/or running cvs to update to the
552# latest copy.
553#
554update:
555.if defined(SUP_UPDATE)
556	@echo "--------------------------------------------------------------"
557	@echo ">>> Running ${SUP}"
558	@echo "--------------------------------------------------------------"
559.if defined(SUPFILE)
560	@${SUP} ${SUPFLAGS} ${SUPFILE}
561.endif
562.if defined(SUPFILE1)
563	@${SUP} ${SUPFLAGS} ${SUPFILE1}
564.endif
565.if defined(SUPFILE2)
566	@${SUP} ${SUPFLAGS} ${SUPFILE2}
567.endif
568.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
569	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
570.endif
571.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
572	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
573.endif
574.endif
575.if defined(CVS_UPDATE)
576	@echo "--------------------------------------------------------------"
577	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
578	@echo "--------------------------------------------------------------"
579	cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
580.endif
581
582#
583# most
584#
585# Build most of the user binaries on the existing system libs and includes.
586#
587most:
588	@echo "--------------------------------------------------------------"
589	@echo ">>> Building programs only"
590	@echo "--------------------------------------------------------------"
591.for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
592	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ all
593.endfor
594
595#
596# installmost
597#
598# Install the binaries built by the 'most' target.  This does not include
599# libraries or include files.
600#
601installmost:
602	@echo "--------------------------------------------------------------"
603	@echo ">>> Installing programs only"
604	@echo "--------------------------------------------------------------"
605.for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
606	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ install
607.endfor
608
609#
610# ------------------------------------------------------------------------
611#
612# From here onwards are utility targets used by the 'make world' and
613# related targets.  If your 'world' breaks, you may like to try to fix
614# the problem and manually run the following targets to attempt to
615# complete the build.  Beware, this is *not* guaranteed to work, you
616# need to have a pretty good grip on the current state of the system
617# to attempt to manually finish it.  If in doubt, 'make world' again.
618#
619
620#
621# legacy: Build compatibility shims for the next three targets
622#
623legacy:
624.for _tool in tools/build
625	@${ECHODIR} "===> ${_tool}"; \
626	    cd ${.CURDIR}/${_tool}; \
627	    ${MAKE} DIRPRFX=${_tool}/ obj; \
628	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
629	    ${MAKE} DIRPRFX=${_tool}/ depend; \
630	    ${MAKE} DIRPRFX=${_tool}/ all; \
631	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
632.endfor
633
634#
635# bootstrap-tools: Build tools needed for compatibility
636#
637.if exists(${.CURDIR}/games) && !defined(NOGAMES)
638_strfile=	games/fortune/strfile
639.endif
640
641bootstrap-tools:
642.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
643    usr.bin/makewhatis usr.bin/rpcgen usr.bin/uudecode \
644    usr.bin/xargs usr.bin/xinstall \
645    usr.sbin/config usr.sbin/kbdcontrol \
646    gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
647	@${ECHODIR} "===> ${_tool}"; \
648		cd ${.CURDIR}/${_tool}; \
649		${MAKE} DIRPRFX=${_tool}/ obj; \
650		${MAKE} DIRPRFX=${_tool}/ depend; \
651		${MAKE} DIRPRFX=${_tool}/ all; \
652		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
653.endfor
654
655#
656# build-tools: Build special purpose build tools
657#
658.if defined(MODULES_WITH_WORLD) && exists(${KRNLSRCDIR}/modules)
659_aicasm= sys/modules/aic7xxx/aicasm
660.endif
661
662.if exists(${.CURDIR}/share) && !defined(NOSHARE)
663_share=	share/syscons/scrnmaps
664.endif
665
666.if !defined(NO_FORTRAN)
667_fortran= gnu/usr.bin/cc/f771
668.endif
669
670.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
671    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
672_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
673    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
674.endif
675
676build-tools:
677.for _tool in bin/csh bin/sh gnu/usr.bin/cc/cc_tools ${_fortran} \
678    ${_libkrb5} lib/libncurses ${_share} \
679    ${_aicasm} usr.bin/awk usr.bin/file usr.sbin/sysinstall
680	@${ECHODIR} "===> ${_tool}"; \
681		cd ${.CURDIR}/${_tool}; \
682		${MAKE} DIRPRFX=${_tool}/ obj; \
683		${MAKE} DIRPRFX=${_tool}/ build-tools
684.endfor
685
686#
687# cross-tools: Build cross-building tools
688#
689.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
690_elf2exe=	usr.sbin/elf2exe
691.endif
692
693.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
694_btxld=	usr.sbin/btxld
695.if defined(RELEASEDIR)
696_kgzip=	usr.sbin/kgzip
697.endif
698.endif
699
700.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH}
701_elf2aout=	usr.bin/elf2aout
702.endif
703
704.if defined(RELEASEDIR)
705_crunchide=	usr.sbin/crunch/crunchide
706.endif
707
708_xlint=	usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
709
710cross-tools:
711.for _tool in ${_btxld} ${_elf2aout} ${_elf2exe} \
712    gnu/usr.bin/binutils ${_crunchide} \
713    gnu/usr.bin/cc ${_xlint} ${_kgzip}
714	@${ECHODIR} "===> ${_tool}"; \
715		cd ${.CURDIR}/${_tool}; \
716		${MAKE} DIRPRFX=${_tool}/ obj; \
717		${MAKE} DIRPRFX=${_tool}/ depend; \
718		${MAKE} DIRPRFX=${_tool}/ all; \
719		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
720.endfor
721
722#
723# hierarchy - ensure that all the needed directories are present
724#
725hierarchy:
726	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
727
728#
729# libraries - build all libraries, and install them under ${DESTDIR}.
730#
731# The list of libraries with dependents (${_prebuild_libs}) and their
732# interdependencies (__L) are built automatically by the
733# ${.CURDIR}/tools/make_libdeps.sh script.
734#
735libraries:
736	cd ${.CURDIR}; \
737	    ${MAKE} -f Makefile.inc1 _startup_libs; \
738	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
739	    ${MAKE} -f Makefile.inc1 _generic_libs;
740
741# These dependencies are not automatically generated:
742#
743# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
744# shared libraries for ELF.
745#
746_startup_libs=	gnu/lib/csu gnu/lib/libgcc
747.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
748_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
749.else
750_startup_libs+=	lib/csu/${MACHINE_ARCH}
751.endif
752
753_prebuild_libs=
754
755_generic_libs=	gnu/lib
756
757.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
758_prebuild_libs+=	kerberos5/lib/libasn1
759_prebuild_libs+=	kerberos5/lib/libgssapi
760_prebuild_libs+=	kerberos5/lib/libkrb5
761_prebuild_libs+=	kerberos5/lib/libroken
762_generic_libs+=	kerberos5/lib
763.endif
764
765_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libkvm lib/libmd \
766		lib/libncurses lib/libopie lib/libpam lib/libradius \
767		lib/librpcsvc \
768		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
769		lib/libz lib/msun
770
771lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
772lib/libypclnt__L: lib/librpcsvc__L
773
774_generic_libs+=	lib
775
776.if !defined(NOCRYPT) && !defined(NOSECURE)
777.if !defined(NO_OPENSSL)
778_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
779.if !defined(NO_OPENSSH)
780_prebuild_libs+=	secure/lib/libssh
781secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
782.endif
783.endif
784_generic_libs+=	secure/lib
785.endif
786
787_generic_libs+=	usr.bin/lex/lib
788
789.if ${MACHINE_ARCH} == "i386"
790_generic_libs+=	usr.sbin/pcvt/keycap
791.endif
792
793.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
794${_lib}__L: .PHONY
795.if exists(${.CURDIR}/${_lib})
796	@${ECHODIR} "===> ${_lib}"; \
797		cd ${.CURDIR}/${_lib}; \
798		${MAKE} DIRPRFX=${_lib}/ depend; \
799		${MAKE} DIRPRFX=${_lib}/ all; \
800		${MAKE} DIRPRFX=${_lib}/ install
801.endif
802.endfor
803
804# libpam is special: we need to build static PAM modules before
805# static PAM library, and dynamic PAM library before dynamic PAM
806# modules.
807lib/libpam__L: .PHONY
808	@${ECHODIR} "===> lib/libpam"; \
809		cd ${.CURDIR}/lib/libpam; \
810		${MAKE} DIRPRFX=lib/libpam/ depend; \
811		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
812		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
813
814_startup_libs: ${_startup_libs:S/$/__L/}
815_prebuild_libs: ${_prebuild_libs:S/$/__L/}
816_generic_libs: ${_generic_libs:S/$/__L/}
817
818.for __target in all clean cleandepend cleandir depend includes obj
819.for entry in ${SUBDIR}
820${entry}.${__target}__D: .PHONY
821	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
822		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
823		edir=${entry}.${MACHINE_ARCH}; \
824		cd ${.CURDIR}/$${edir}; \
825	else \
826		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
827		edir=${entry}; \
828		cd ${.CURDIR}/$${edir}; \
829	fi; \
830	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
831.endfor
832par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
833.endfor
834
835.include <bsd.subdir.mk>
836