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