xref: /dragonfly/Makefile.inc1 (revision 113f6df6)
1#
2# $FreeBSD: src/Makefile.inc1,v 1.141.2.62 2003/04/06 19:54:00 dwmalone Exp $
3# $DragonFly: src/Makefile.inc1,v 1.40 2004/10/20 23:02:59 dillon Exp $
4#
5# Make command line options:
6#	-DMAKE_KERBEROS5 to build Kerberos5
7#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8#	-DNOCLEAN do not clean at all
9#	-DNOCRYPT will prevent building of crypt versions
10#	-DNOMAN do not build the manual pages
11#	-DNOPROFILE do not build profiled libraries
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# The intended user-driven targets are:
26#
27# buildworld  - rebuild *everything*, including glue to help do upgrades
28# quickworld  - skip the glue and do a depend+build on the meat
29# realquickworld - skip the glue and depend stages and just build the meat
30# crossworld  - only build the glue (particularly the cross-build environment)
31# installworld- install everything built by "buildworld"
32# update      - convenient way to update your source tree (eg: sup/cvs)
33# most        - build user commands, no libraries or include files
34# installmost - install user commands, no libraries or include files
35#
36# Standard targets (not defined here) are documented in the makefiles in
37# /usr/share/mk.  These include:
38#		obj depend all install clean cleandepend cleanobj
39
40# Put initial settings here.
41SUBDIR=
42
43# We must do share/info early so that installation of info `dir'
44# entries works correctly.  Do it first since it is less likely to
45# grow dependencies on include and lib than vice versa.
46.if exists(${.CURDIR}/share/info)
47SUBDIR+= share/info
48.endif
49
50# We must do include and lib early so that the perl *.ph generation
51# works correctly as it uses the header files installed by this.
52.if exists(${.CURDIR}/include)
53SUBDIR+= include
54.endif
55.if exists(${.CURDIR}/lib)
56SUBDIR+= lib
57.endif
58# This exists simply to ensure that the obj dir hierarchy is
59# intact for nrelease, allowing the nrelease Makefile's to
60# reference ${.OBJDIR}.
61#
62.if exists(${.CURDIR}/nrelease)
63SUBDIR+= nrelease
64.endif
65
66.if exists(${.CURDIR}/bin)
67SUBDIR+= bin
68.endif
69.if exists(${.CURDIR}/games) && !defined(NOGAMES)
70SUBDIR+= games
71.endif
72.if exists(${.CURDIR}/gnu)
73SUBDIR+= gnu
74.endif
75.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
76    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
77SUBDIR+= kerberos5
78.endif
79.if exists(${.CURDIR}/libexec)
80SUBDIR+= libexec
81.endif
82.if exists(${.CURDIR}/sbin)
83SUBDIR+= sbin
84.endif
85.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
86SUBDIR+= secure
87.endif
88.if exists(${.CURDIR}/share) && !defined(NOSHARE)
89SUBDIR+= share
90.endif
91.if exists(${.CURDIR}/sys)
92SUBDIR+= sys
93.endif
94.if exists(${.CURDIR}/usr.bin)
95SUBDIR+= usr.bin
96.endif
97.if exists(${.CURDIR}/usr.sbin)
98SUBDIR+= usr.sbin
99.endif
100
101# etc must be last for "distribute" to work
102.if exists(${.CURDIR}/etc)
103SUBDIR+= etc
104.endif
105
106# These are last, since it is nice to at least get the base system
107# rebuilt before you do them.
108.if defined(LOCAL_DIRS)
109.for _DIR in ${LOCAL_DIRS}
110.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
111SUBDIR+= ${_DIR}
112.endif
113.endfor
114.endif
115
116.if defined(SUBDIR_OVERRIDE)
117SUBDIR=		${SUBDIR_OVERRIDE}
118.endif
119
120.if defined(NOCLEANDIR)
121CLEANDIR=	clean cleandepend
122.else
123CLEANDIR=	cleandir
124.endif
125
126SUP?=		/usr/local/bin/cvsup
127SUPFLAGS?=	-g -L 2 -P -
128.if defined(SUPHOST)
129SUPFLAGS+=	-h ${SUPHOST}
130.endif
131
132# Object directory base in primary make.  Note that when we rerun make
133# from inside this file we change MAKEOBJDIRPREFIX to the appropriate
134# subdirectory because the rest of the build system needs it that way.
135# The original object directory base is saved in OBJTREE.
136#
137MAKEOBJDIRPREFIX?=	/usr/obj
138OBJTREE?=		${MAKEOBJDIRPREFIX}
139
140# Used for stage installs and pathing
141#
142DESTDIRBASE?=		${OBJTREE}${.CURDIR}
143
144TARGET_ARCH?=	${MACHINE_ARCH}
145.if ${TARGET_ARCH} == ${MACHINE_ARCH}
146TARGET?=	${MACHINE}
147.else
148TARGET?=	${TARGET_ARCH}
149.endif
150.if make(buildworld)
151BUILD_ARCH!=	sysctl -n hw.machine_arch
152.if ${MACHINE_ARCH} != ${BUILD_ARCH}
153.error To cross-build, set TARGET_ARCH.
154.endif
155.endif
156
157# BTOOLS	(Natively built) All non-cross-development tools that the
158#		main build needs.  This includes things like 'mkdir' and 'rm'.
159#		We will not use the native system's exec path once we start
160#		on WORLD.  (bootstrap-tools and build-tools or BTOOLS)
161#
162# CTOOLS	(Natively built) Cross development tools which are specific
163#		to the target architecture.
164#
165# WORLD		(Cross built) Our ultimate buildworld, using only BTOOLS and
166#		CTOOLS.
167#
168# MACHINE_ARCH	Architecture we are building on
169# TARGET_ARCH	Architecture we are building for
170#
171BTOOLSDEST=	${DESTDIRBASE}/btools_${MACHINE_ARCH}
172CTOOLSDEST=	${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH}
173WORLDDEST=	${DESTDIRBASE}/world_${TARGET_ARCH}
174
175# The bootstrap-tools path is used by the bootstrap-tools, build-tools, and
176# cross-tools stages to augment the existing command path to access newer
177# versions of certain utilities such as 'patch' that the cross-tools stage
178# might expect.
179#
180BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
181
182# The strict temporary command path contains all binaries required
183# by the buildworld system after the cross-tools stage.
184#
185STRICTTMPPATH=	${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
186
187TMPDIR?=	/tmp
188TMPPID!=	echo $$$$
189
190#
191# Building a world goes through the following stages
192#
193# 1. bootstrap-tool stage [BMAKE]
194#	This stage is responsible for creating programs that
195#	are needed for backward compatibility reasons. They
196#	are not built as cross-tools.
197# 2. build-tool stage [TMAKE]
198#	This stage is responsible for creating the object
199#	tree and building any tools that are needed during
200#	the build process.
201# 3. cross-tool stage [XMAKE]
202#	This stage is responsible for creating any tools that
203#	are needed for cross-builds. A cross-compiler is one
204#	of them.
205# 4. world stage [WMAKE]
206#	This stage actually builds the world.
207# 5. install stage (optional) [IMAKE]
208#	This stage installs a previously built world.
209#
210
211# bootstrap-tool stage
212#
213BMAKEENV=	MAKEOBJDIRPREFIX=${BTOOLSDEST} \
214		OBJTREE=${OBJTREE} \
215		DESTDIR=${BTOOLSDEST} \
216		PATH=${BTOOLSPATH}:${PATH} \
217		INSTALL="sh ${.CURDIR}/tools/install.sh"
218
219BMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
220		-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
221		-DNO_WERROR
222
223# build-tool stage
224#
225TMAKEENV=	MAKEOBJDIRPREFIX=${BTOOLSDEST} \
226		OBJTREE=${OBJTREE} \
227		DESTDIR= \
228		PATH=${BTOOLSPATH}:${PATH} \
229		INSTALL="sh ${.CURDIR}/tools/install.sh"
230
231TMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
232		-DNO_FORTRAN
233
234# cross-tool stage
235#
236# note: TOOLS_PREFIX points to the obj root holding the cross
237#	compiler binaries, while USRDATA_PREFIX points to the obj root
238#	holding the target environment (and also determines where cross-built
239#	libraries, crt*.o, and include files are installed).
240#
241XMAKEENV=	MAKEOBJDIRPREFIX=${CTOOLSDEST} \
242		OBJTREE=${OBJTREE} \
243		DESTDIR=${CTOOLSDEST} \
244		INSTALL="sh ${.CURDIR}/tools/install.sh" \
245		TOOLS_PREFIX=${CTOOLSDEST} \
246		USRDATA_PREFIX=${WORLDDEST} \
247		PATH=${BTOOLSPATH}:${PATH}
248
249XMAKE=		${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
250		-DBOOTSTRAPPING
251
252# world stage, note the strict path and note that TOOLS_PREFIX is left
253# unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
254# which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
255# for both binary and library paths, even though it is being compiled to
256# WORLDDEST.  None of the programs in the world stage are ever actually
257# executed during the buildworld/installworld.
258#
259CROSSENV=	MAKEOBJDIRPREFIX=${WORLDDEST} \
260		OBJTREE=${OBJTREE} \
261		MACHINE_ARCH=${TARGET_ARCH} \
262		MACHINE=${TARGET} \
263		OBJFORMAT_PATH=${CTOOLSDEST} \
264		PERL5LIB=${WORLDDEST}/usr/libdata/perl/5.00503 \
265		GROFF_BIN_PATH=${BTOOLSDEST}/usr/bin \
266		GROFF_FONT_PATH=${BTOOLSDEST}/usr/share/groff_font \
267		GROFF_TMAC_PATH=${BTOOLSDEST}/usr/share/tmac
268
269WMAKEENV=	${CROSSENV} \
270		DESTDIR=${WORLDDEST} \
271		INSTALL="sh ${.CURDIR}/tools/install.sh" \
272		PATH=${STRICTTMPPATH}
273
274WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
275
276# install stage
277#
278IMAKEENV=	${CROSSENV} \
279		PATH=${STRICTTMPPATH}
280IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
281
282# kernel stage
283#
284KMAKEENV=	${WMAKEENV}
285
286# buildworld
287#
288# Attempt to rebuild the entire system, with reasonable chance of
289# success, regardless of how old your existing system is.
290#
291_worldtmp:
292	@echo
293	@echo "--------------------------------------------------------------"
294	@echo ">>> Rebuilding the temporary build tree"
295	@echo "--------------------------------------------------------------"
296.if !defined(NOCLEAN)
297	rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
298.else
299	# XXX - These two can depend on any header file.
300	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
301	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
302.endif
303	mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
304.for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
305	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist	\
306		-p ${_dir}/  > /dev/null
307	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist		\
308		-p ${_dir}/usr > /dev/null
309.endfor
310	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist	\
311		-p ${WORLDDEST}/usr/include > /dev/null
312	ln -sf ${.CURDIR}/sys ${WORLDDEST}
313
314_bootstrap-tools:
315	@echo
316	@echo "--------------------------------------------------------------"
317	@echo ">>> stage 1: bootstrap tools"
318	@echo "--------------------------------------------------------------"
319	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
320_cleanobj:
321	@echo
322	@echo "--------------------------------------------------------------"
323	@echo ">>> stage 2a: cleaning up the object tree"
324	@echo "--------------------------------------------------------------"
325	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
326_obj:
327	@echo
328	@echo "--------------------------------------------------------------"
329	@echo ">>> stage 2b: rebuilding the object tree"
330	@echo "--------------------------------------------------------------"
331	cd ${.CURDIR}; ${WMAKE} par-obj
332_build-tools:
333	@echo
334	@echo "--------------------------------------------------------------"
335	@echo ">>> stage 2c: build tools"
336	@echo "--------------------------------------------------------------"
337	cd ${.CURDIR}; ${TMAKE} build-tools
338_cross-tools:
339	@echo
340	@echo "--------------------------------------------------------------"
341	@echo ">>> stage 3: cross tools"
342	@echo "--------------------------------------------------------------"
343	cd ${.CURDIR}; ${XMAKE} cross-tools
344_includes:
345	@echo
346	@echo "--------------------------------------------------------------"
347	@echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
348	@echo "--------------------------------------------------------------"
349	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
350_libraries:
351	@echo
352	@echo "--------------------------------------------------------------"
353	@echo ">>> stage 4b: building libraries"
354	@echo "--------------------------------------------------------------"
355	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
356_depend:
357	@echo
358	@echo "--------------------------------------------------------------"
359	@echo ">>> stage 4c: make dependencies"
360	@echo "--------------------------------------------------------------"
361	cd ${.CURDIR}; ${WMAKE} par-depend
362everything:
363	@echo
364	@echo "--------------------------------------------------------------"
365	@echo ">>> stage 4d: building everything.."
366	@echo "--------------------------------------------------------------"
367	cd ${.CURDIR}; ${WMAKE} all
368
369# note: buildworld no longer depends on _cleanobj because we rm -rf the
370# entire object tree and built the bootstrap tools in a different location.
371#
372# buildworld	- build everything from scratch
373# quickworld	- skip the bootstrap, build, and cross-build steps
374# realquickworld - skip the bootstrap, build, crossbuild, and depend step.
375#
376# note: we include _obj in realquickworld to prevent accidental creation
377# of files in /usr/src.
378
379WMAKE_TGTS=
380.if !defined(SUBDIR_OVERRIDE)
381WMAKE_TGTS+=	_worldtmp _bootstrap-tools
382.endif
383WMAKE_TGTS+=	_obj _build-tools
384.if !defined(SUBDIR_OVERRIDE)
385WMAKE_TGTS+=	_cross-tools
386.endif
387WMAKE_TGTS+=	_includes _libraries _depend everything
388
389buildworld: ${WMAKE_TGTS}
390
391quickworld: _obj _includes _libraries _depend everything
392
393realquickworld: _obj _includes _libraries everything
394
395crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
396
397.ORDER: ${WMAKE_TGTS}
398
399#
400# installcheck
401#
402# Checks to be sure system is ready for installworld
403#
404installcheck:
405.if !defined(NO_SENDMAIL)
406	@if ! `id -u smmsp > /dev/null`; then \
407		echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
408		false; \
409	fi
410	@if ! `id -g smmsp > /dev/null`; then \
411		echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
412		false; \
413	fi
414.endif
415
416#
417# distributeworld
418#
419# Distributes everything compiled by a `buildworld'.
420#
421# installworld
422#
423# Installs everything compiled by a 'buildworld'.
424#
425distributeworld installworld: installcheck
426	cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
427
428#
429# reinstall
430#
431# If you have a build server, you can NFS mount the source and obj directories
432# and do a 'make reinstall' on the *client* to install new binaries from the
433# most recent server build.
434#
435reinstall:
436	@echo "--------------------------------------------------------------"
437	@echo ">>> Making hierarchy"
438	@echo "--------------------------------------------------------------"
439	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
440	@echo
441	@echo "--------------------------------------------------------------"
442	@echo ">>> Installing everything.."
443	@echo "--------------------------------------------------------------"
444	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
445.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
446	@echo
447	@echo "--------------------------------------------------------------"
448	@echo ">>> Rebuilding man page indices"
449	@echo "--------------------------------------------------------------"
450	cd ${.CURDIR}/share/man; ${MAKE} makedb
451.endif
452
453redistribute:
454	@echo "--------------------------------------------------------------"
455	@echo ">>> Distributing everything.."
456	@echo "--------------------------------------------------------------"
457	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
458
459#
460# buildkernel, nativekernel, quickkernel, and installkernel
461#
462# Which kernels to build and/or install is specified by setting
463# KERNCONF. If not defined a GENERIC kernel is built/installed.
464# Only the existing (depending TARGET) config files are used
465# for building kernels and only the first of these is designated
466# as the one being installed.
467#
468# You can specify INSTALLSTRIPPED=1 if you wish the installed
469# kernel and modules to be stripped of its debug info (required
470# symbols are left intact).  You can specify INSTALLSTRIPPEDMODULES
471# if you only want to strip the modules of their debug info.  These
472# only apply if you have DEBUG=-g in your kernel config or make line.
473#
474# Note that we have to use TARGET instead of TARGET_ARCH when
475# we're in kernel-land. Since only TARGET_ARCH is (expected) to
476# be set to cross-build, we have to make sure TARGET is set
477# properly.
478
479.if !defined(KERNCONF) && defined(KERNEL)
480KERNCONF=	${KERNEL}
481KERNWARN=	yes
482.else
483KERNCONF?=	GENERIC
484.endif
485INSTKERNNAME?=	kernel
486
487KRNLSRCDIR=	${.CURDIR}/sys
488KRNLCONFDIR=	${KRNLSRCDIR}/${TARGET}/conf
489KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
490KERNCONFDIR?=	${KRNLCONFDIR}
491
492BUILDKERNELS=
493INSTALLKERNEL=
494.for _kernel in ${KERNCONF}
495.if exists(${KERNCONFDIR}/${_kernel})
496BUILDKERNELS+=	${_kernel}
497.if empty(INSTALLKERNEL)
498INSTALLKERNEL= ${_kernel}
499.endif
500.endif
501.endfor
502
503#
504# buildkernel
505#
506# Builds all kernels defined by BUILDKERNELS.
507#
508bk_tools:
509	@if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
510	    echo "You must buildworld before buildkernel.  If you wish"; \
511	    echo "to build a kernel using native tools, config it manually"; \
512	    echo "or use the nativekernel target if you are in a rush"; \
513	    exit 1; \
514	fi
515
516maybe_bk_tools:
517.for _kernel in ${BUILDKERNELS}
518	@if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
519	    if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
520		echo "The kernel was build using buildworld tools which no" ; \
521		echo "longer appear to exist, quickkernel failed!" ; \
522		exit 1; \
523	    fi; \
524	fi
525.endfor
526
527bk_build_list:
528.if empty(BUILDKERNELS)
529	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
530	@false
531.endif
532
533bk_kernwarn:
534.if defined(KERNWARN)
535	@echo "--------------------------------------------------------------"
536	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
537	@echo "--------------------------------------------------------------"
538	@sleep 3
539.endif
540	@echo
541
542# The buildkernel target rebuilds the specified kernels from scratch
543# using the crossbuild tools generated by the last buildworld.  It is
544# the safest (but also the most time consuming) way to build a new kernel.
545#
546buildkernel:	bk_tools bk_build_list bk_kernwarn
547.for _kernel in ${BUILDKERNELS}
548	@echo "--------------------------------------------------------------"
549	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
550	@echo "--------------------------------------------------------------"
551	@echo "===> ${_kernel}"
552.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
553	rm -rf ${KRNLOBJDIR}/${_kernel}
554.else
555	@if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
556		echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
557		rm -rf ${KRNLOBJDIR}/${_kernel}; fi
558.endif
559	mkdir -p ${KRNLOBJDIR}
560.if !defined(NO_KERNELCONFIG)
561	cd ${KRNLCONFDIR}; \
562		PATH=${STRICTTMPPATH} \
563		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
564			${KERNCONFDIR}/${_kernel}
565.endif
566	touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
567	cd ${KRNLOBJDIR}/${_kernel}; \
568	    MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
569	    ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
570.if !defined(NO_KERNELDEPEND)
571	cd ${KRNLOBJDIR}/${_kernel}; \
572	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
573.endif
574	cd ${KRNLOBJDIR}/${_kernel}; \
575	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
576	@echo "--------------------------------------------------------------"
577	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
578	@echo "--------------------------------------------------------------"
579.endfor
580
581# The nativekernel target rebuilds the specified kernels from scratch
582# using the systems standard compiler rather then using the crossbuild
583# tools generated by the last buildworld.  This is fairly safe if your
584# system is reasonable up-to-date.
585#
586nativekernel:	bk_build_list bk_kernwarn
587.for _kernel in ${BUILDKERNELS}
588	@echo "--------------------------------------------------------------"
589	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
590	@echo "--------------------------------------------------------------"
591	@echo "===> ${_kernel}"
592.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
593	rm -rf ${KRNLOBJDIR}/${_kernel}
594.else
595	@if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
596		echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
597		rm -rf ${KRNLOBJDIR}/${_kernel}; fi
598.endif
599	mkdir -p ${KRNLOBJDIR}
600.if !defined(NO_KERNELCONFIG)
601	cd ${KRNLCONFDIR}; \
602		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
603			${KERNCONFDIR}/${_kernel}
604.endif
605	touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
606	cd ${KRNLOBJDIR}/${_kernel}; \
607	    MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
608	    ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
609.if !defined(NO_KERNELDEPEND)
610	cd ${KRNLOBJDIR}/${_kernel}; \
611	    ${MAKE} KERNEL=${INSTKERNNAME} depend
612.endif
613	cd ${KRNLOBJDIR}/${_kernel}; \
614	    ${MAKE} KERNEL=${INSTKERNNAME} all
615	@echo "--------------------------------------------------------------"
616	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
617	@echo "--------------------------------------------------------------"
618.endfor
619
620# The quickkernel target rebuilds the specified kernels as quickly
621# as possible.  It will use the native tools or the buildworld cross tools
622# based on whether the kernel was originally generated via buildkernel or
623# nativekernel.  Config is rerun but the object hierarchy is not rebuilt,
624# nor is the make depend step run.
625#
626quickkernel:	maybe_bk_tools bk_build_list bk_kernwarn
627.for _kernel in ${BUILDKERNELS}
628	@echo "--------------------------------------------------------------"
629	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
630	@echo "--------------------------------------------------------------"
631	@echo "===> ${_kernel}"
632.if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
633.if !defined(NO_KERNELCONFIG)
634	cd ${KRNLCONFDIR}; \
635		PATH=${STRICTTMPPATH} \
636		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
637			${KERNCONFDIR}/${_kernel}
638.endif
639	cd ${KRNLOBJDIR}/${_kernel}; \
640	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
641.else
642.if !defined(NO_KERNELCONFIG)
643	cd ${KRNLCONFDIR}; \
644	    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
645		${KERNCONFDIR}/${_kernel}
646.endif
647	cd ${KRNLOBJDIR}/${_kernel}; \
648	    ${MAKE} KERNEL=${INSTKERNNAME} all
649.endif
650	@echo "--------------------------------------------------------------"
651	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
652	@echo "--------------------------------------------------------------"
653.endfor
654
655
656# installkernel
657#
658# Install the kernel defined by INSTALLKERNEL
659#
660installkernel reinstallkernel:
661.if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
662	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
663	    ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
664.else
665	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
666	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
667.endif
668
669#
670# update
671#
672# Update the source tree, by running sup and/or running cvs to update to the
673# latest copy.
674#
675update:
676.if defined(SUP_UPDATE)
677	@echo "--------------------------------------------------------------"
678	@echo ">>> Running ${SUP}"
679	@echo "--------------------------------------------------------------"
680.if defined(SUPFILE)
681	@${SUP} ${SUPFLAGS} ${SUPFILE}
682.endif
683.if defined(SUPFILE1)
684	@${SUP} ${SUPFLAGS} ${SUPFILE1}
685.endif
686.if defined(SUPFILE2)
687	@${SUP} ${SUPFLAGS} ${SUPFILE2}
688.endif
689.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
690	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
691.endif
692.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
693	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
694.endif
695.endif
696.if defined(CVS_UPDATE)
697	@echo "--------------------------------------------------------------"
698	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
699	@echo "--------------------------------------------------------------"
700	cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
701.endif
702
703#
704# most
705#
706# Build most of the user binaries on the existing system libs and includes.
707#
708most:
709	@echo "--------------------------------------------------------------"
710	@echo ">>> Building programs only"
711	@echo "--------------------------------------------------------------"
712.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
713	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ all
714.endfor
715
716#
717# installmost
718#
719# Install the binaries built by the 'most' target.  This does not include
720# libraries or include files.
721#
722installmost:
723	@echo "--------------------------------------------------------------"
724	@echo ">>> Installing programs only"
725	@echo "--------------------------------------------------------------"
726.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
727	cd ${.CURDIR}/${_dir};		${MAKE} DIRPRFX=${_dir}/ install
728.endfor
729
730#
731# ------------------------------------------------------------------------
732#
733# From here onwards are utility targets used by the 'make world' and
734# related targets.  If your 'world' breaks, you may like to try to fix
735# the problem and manually run the following targets to attempt to
736# complete the build.  Beware, this is *not* guaranteed to work, you
737# need to have a pretty good grip on the current state of the system
738# to attempt to manually finish it.  If in doubt, 'make world' again.
739#
740
741# bootstrap-tools: Build all tools required to build all tools.  Note that
742# order is important in a number of cases and also note that the bootstrap
743# and build tools stages have access to earlier binaries they themselves
744# had generated.
745#
746# patch:	older patch's do not have -i.  This program must be built
747#		first so other bootstrap tools that need to apply patches
748#		can use it.
749# [x]install:	dependancies on various new install features
750# rpcgen:	old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
751#		envs are not compatible with older objformat binaries.
752#
753.if exists(${.CURDIR}/games) && !defined(NOGAMES)
754_strfile=	games/fortune/strfile
755.endif
756
757bootstrap-tools:
758.for _tool in ${_strfile} \
759    usr.bin/patch \
760    bin/chmod bin/cp bin/dd bin/mkdir bin/rm bin/echo bin/test \
761    bin/cat bin/date bin/ln bin/mv bin/csh bin/expr bin/sh bin/ls \
762    bin/hostname bin/kill \
763    sbin/sysctl \
764    usr.bin/yacc usr.bin/colldef usr.bin/uudecode usr.bin/xinstall \
765    usr.bin/m4 usr.bin/rpcgen usr.bin/make usr.bin/awk usr.bin/file \
766    usr.bin/find usr.bin/lex usr.bin/sed usr.bin/uname usr.bin/touch \
767    usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
768    usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
769    usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
770    usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
771    usr.bin/vi usr.bin/cap_mkdb usr.bin/vgrind usr.bin/true usr.bin/false \
772    usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
773    usr.sbin/chown usr.sbin/mtree usr.sbin/config \
774    usr.sbin/btxld usr.sbin/pwd_mkdb usr.sbin/zic usr.sbin/makewhatis \
775    gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo \
776    gnu/usr.bin/grep gnu/usr.bin/sort \
777    gnu/usr.bin/gzip usr.bin/bzip2
778	${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
779		cd ${.CURDIR}/${_tool}; \
780		${MAKE} DIRPRFX=${_tool}/ obj; \
781		${MAKE} DIRPRFX=${_tool}/ depend; \
782		${MAKE} DIRPRFX=${_tool}/ all; \
783		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
784.endfor
785	touch ${BTOOLSDEST}/.bootstrap_done
786
787# build-tools: Build special purpose build tools.  gcc2 related tools are
788# only built under the i386 architecture.  Other architectures are
789# gcc3-only.
790#
791# XXX we may be able to remove or consolidate this into bootstrap-tools
792# now that we have the native helper (.nx/.no) infrastructure.
793#
794.if exists(${.CURDIR}/games) && !defined(NOGAMES)
795_games=	games/adventure games/hack games/phantasia
796.endif
797
798.if exists(${.CURDIR}/share) && !defined(NOSHARE)
799_share=	share/syscons/scrnmaps
800.endif
801
802_gcc34_cross= gnu/usr.bin/cc34
803_gcc34_tools= gnu/usr.bin/cc34/cc_prep gnu/usr.bin/cc34/cc_tools
804.if ${MACHINE_ARCH} == "i386" && ${TARGET_ARCH} == "i386"
805_gcc2_cross= gnu/usr.bin/cc
806_gcc2_tools= gnu/usr.bin/cc/cc_tools
807_binutils= gnu/usr.bin/binutils gnu/usr.bin/binutils214
808.else
809_binutils= gnu/usr.bin/binutils214
810.endif
811
812.if !defined(NO_FORTRAN)
813.if ${TARGET_ARCH} == "i386"
814_fortran= gnu/usr.bin/cc/f771
815.else
816_fortran= gnu/usr.bin/cc34/f771
817.endif
818.endif
819
820.if !defined(NOPERL)
821_perl=	gnu/usr.bin/perl/miniperl
822.endif
823
824.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
825    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
826_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
827    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
828.endif
829
830.if defined(RELEASEDIR)
831_sysinstall= release/sysinstall
832.endif
833
834build-tools:
835.for _tool in ${_gcc2_tools} ${_gcc34_tools} \
836	      ${_fortran} ${_perl} ${_libroken4} ${_libkrb5} \
837	      ${_share} ${_sysinstall}
838	${ECHODIR} "===> ${_tool} (build-tools)"; \
839		cd ${.CURDIR}/${_tool}; \
840		${MAKE} DIRPRFX=${_tool}/ obj; \
841		${MAKE} DIRPRFX=${_tool}/ depend; \
842		${MAKE} DIRPRFX=${_tool}/ all; \
843		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
844.endfor
845	touch ${BTOOLSDEST}/.build_done
846
847#
848# cross-tools: Build cross-building tools
849#
850.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
851_elf2exe=	usr.sbin/elf2exe
852.endif
853
854.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
855_btxld=	usr.sbin/btxld
856.endif
857
858cross-tools:
859.for _tool in ${_btxld} ${_elf2exe} ${_binutils} \
860	      usr.bin/objformat usr.sbin/crunch/crunchide \
861	      ${_gcc2_cross} ${_gcc34_cross}
862	${ECHODIR} "===> ${_tool} (cross-tools)"; \
863		cd ${.CURDIR}/${_tool}; \
864		${MAKE} DIRPRFX=${_tool}/ obj; \
865		${MAKE} DIRPRFX=${_tool}/ depend; \
866		${MAKE} DIRPRFX=${_tool}/ all; \
867		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
868.endfor
869	touch ${CTOOLSDEST}/.cross_done
870
871#
872# hierarchy - ensure that all the needed directories are present
873#
874hierarchy:
875	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
876
877#
878# libraries - build all libraries, and install them under ${DESTDIR}.
879#
880# The list of libraries with dependents (${_prebuild_libs}) and their
881# interdependencies (__L) are built automatically by the
882# ${.CURDIR}/tools/make_libdeps.sh script.
883#
884# .makeenv does not work when bootstrapping from 4.x, so we must be sure
885# to specify the correct CCVER or 'cc' will not exec the correct compiler.
886#
887libraries:
888	cd ${.CURDIR}; \
889	    HOST_CCVER=${HOST_CCVER} CCVER=gcc2 \
890		${MAKE} -f Makefile.inc1 _startup_libs2; \
891	    HOST_CCVER=${HOST_CCVER} CCVER=gcc34 \
892		${MAKE} -f Makefile.inc1 _startup_libs34; \
893	    ${MAKE} -f Makefile.inc1 _startup_libs; \
894	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
895	    ${MAKE} -f Makefile.inc1 _generic_libs;
896	touch ${WORLDDEST}/.libraries_done
897
898# These dependencies are not automatically generated:
899#
900# gnu/lib/libgcc and lib/csu must be built before all
901# shared libraries for ELF.  The targets for _startup_libs{2,3} are
902# specifically built using gcc{2,3}.
903#
904_startup_libs2=	gnu/lib/gcc2/libgcc
905_startup_libs34=	gnu/lib/gcc34/libgcc
906.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
907_startup_libs=	lib/csu/${MACHINE_ARCH}-elf
908.else
909_startup_libs=	lib/csu/${MACHINE_ARCH}
910.endif
911_startup_libs+=	lib/csu/common lib/libc
912
913_prebuild_libs=
914
915_generic_libs=	gnu/lib
916
917.if !defined(NOPERL)
918_generic_libs+=	gnu/usr.bin/perl/libperl
919.endif
920
921.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
922_prebuild_libs+=	kerberos5/lib/libasn1
923_prebuild_libs+=	kerberos5/lib/libgssapi
924_prebuild_libs+=	kerberos5/lib/libkrb5
925_prebuild_libs+=	kerberos5/lib/libroken
926_generic_libs+=	kerberos5/lib
927.endif
928
929_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
930		lib/libncurses lib/libopie lib/libradius lib/libskey \
931		lib/libtacplus lib/libutil \
932		lib/libz lib/msun
933
934lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
935lib/libskey__L: lib/libcrypt__L lib/libmd__L
936
937_generic_libs+=	lib
938
939.if !defined(NOCRYPT)
940.if !defined(NO_OPENSSL)
941_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
942.if !defined(NO_OPENSSH)
943_prebuild_libs+=	secure/lib/libssh
944secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
945.endif
946.endif
947_generic_libs+=	secure/lib
948.endif
949
950_generic_libs+=	usr.bin/lex/lib
951
952.if ${MACHINE_ARCH} == "i386"
953_generic_libs+=	usr.sbin/pcvt/keycap
954.endif
955
956.for _lib in ${_startup_libs2} ${_startup_libs3} ${_startup_libs34} \
957		${_startup_libs} ${_prebuild_libs} ${_generic_libs}
958${_lib}__L: .PHONY
959.if exists(${.CURDIR}/${_lib})
960	${ECHODIR} "===> ${_lib}"; \
961		cd ${.CURDIR}/${_lib}; \
962		${MAKE} DIRPRFX=${_lib}/ depend; \
963		${MAKE} DIRPRFX=${_lib}/ all; \
964		${MAKE} DIRPRFX=${_lib}/ install
965.endif
966.endfor
967
968# only mess with gcc2 for i386 architectures.
969#
970_startup_libs: ${_startup_libs:S/$/__L/}
971.if ${TARGET_ARCH} == "i386"
972_startup_libs2: ${_startup_libs2:S/$/__L/}
973.else
974_startup_libs2:
975.endif
976_startup_libs3: ${_startup_libs3:S/$/__L/}
977_startup_libs34: ${_startup_libs34:S/$/__L/}
978_prebuild_libs: ${_prebuild_libs:S/$/__L/}
979_generic_libs: ${_generic_libs:S/$/__L/}
980
981# library targets must be ordered because there are inter-library
982# races (e.g. generation of tconfig.h)
983#
984.ORDER: ${_startup_libs2:S/$/__L/}
985.ORDER: ${_startup_libs3:S/$/__L/}
986.ORDER: ${_startup_libs34:S/$/__L/}
987.ORDER: ${_startup_libs:S/$/__L/}
988.ORDER: ${_prebuild_libs:S/$/__L/}
989.ORDER: ${_generic_libs:S/$/__L/}
990
991.for __target in clean cleandepend cleandir obj depend includes
992.for entry in ${SUBDIR}
993${entry}.${__target}__D: .PHONY
994	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
995		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
996		edir=${entry}.${MACHINE_ARCH}; \
997		cd ${.CURDIR}/$${edir}; \
998	else \
999		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
1000		edir=${entry}; \
1001		cd ${.CURDIR}/$${edir}; \
1002	fi; \
1003	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1004.endfor
1005par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1006.ORDER: ${SUBDIR:S/$/.${__target}__D/}
1007.endfor
1008.ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
1009
1010# The wmake target is used by /usr/bin/wmake to run make in a
1011# world build environment.
1012#
1013wmake:
1014	@echo '${WMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${WMAKE_ARGS}'
1015
1016wmakeenv:
1017	@echo '${WMAKEENV} /bin/sh'
1018
1019bmake:
1020	@echo '${BMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${BMAKE_ARGS}'
1021
1022bmakeenv:
1023	@echo '${BMAKEENV} /bin/sh'
1024
1025tmake:
1026	@echo '${TMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${TMAKE_ARGS}'
1027
1028tmakeenv:
1029	@echo '${TMAKEENV} /bin/sh'
1030
1031.include <bsd.subdir.mk>
1032
1033