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