Undo the last commit. Utility programs which install c++ includes have no
[dragonfly.git] / Makefile.inc1
CommitLineData
984263bc
MD
1#
2# $FreeBSD: src/Makefile.inc1,v 1.141.2.62 2003/04/06 19:54:00 dwmalone Exp $
f0f3e4e6 3# $DragonFly: src/Makefile.inc1,v 1.28 2004/04/04 01:08:18 dillon Exp $
984263bc
MD
4#
5# Make command line options:
984263bc
MD
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
984263bc
MD
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
984263bc
MD
24#
25# The intended user-driven targets are:
1397f94a 26#
984263bc 27# buildworld - rebuild *everything*, including glue to help do upgrades
1397f94a
MD
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)
984263bc
MD
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
17d0fefe
MD
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
984263bc
MD
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
984263bc
MD
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
de347b31 85.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
984263bc
MD
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
1397f94a
MD
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#
984263bc 137MAKEOBJDIRPREFIX?= /usr/obj
1397f94a
MD
138OBJTREE?= ${MAKEOBJDIRPREFIX}
139
140# Used for stage installs and pathing
141#
142DESTDIRBASE?= ${OBJTREE}${.CURDIR}
143
984263bc
MD
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
1397f94a
MD
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 strict temporary command path contains all binaries required
176# by the buildworld system after the cross-tools stage.
177#
178STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
984263bc
MD
179
180TMPDIR?= /tmp
181TMPPID!= echo $$$$
984263bc
MD
182
183#
184# Building a world goes through the following stages
185#
186# 1. bootstrap-tool stage [BMAKE]
187# This stage is responsible for creating programs that
188# are needed for backward compatibility reasons. They
189# are not built as cross-tools.
190# 2. build-tool stage [TMAKE]
191# This stage is responsible for creating the object
192# tree and building any tools that are needed during
193# the build process.
194# 3. cross-tool stage [XMAKE]
195# This stage is responsible for creating any tools that
196# are needed for cross-builds. A cross-compiler is one
197# of them.
198# 4. world stage [WMAKE]
199# This stage actually builds the world.
200# 5. install stage (optional) [IMAKE]
201# This stage installs a previously built world.
202#
203
984263bc 204# bootstrap-tool stage
1397f94a
MD
205#
206BMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
207 OBJTREE=${OBJTREE} \
984263bc
MD
208 DESTDIR= \
209 INSTALL="sh ${.CURDIR}/tools/install.sh"
1397f94a 210
984263bc
MD
211BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
212 -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
213 -DNO_WERROR
214
215# build-tool stage
1397f94a
MD
216#
217TMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
218 OBJTREE=${OBJTREE} \
984263bc
MD
219 DESTDIR= \
220 INSTALL="sh ${.CURDIR}/tools/install.sh"
1397f94a
MD
221
222TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
223 -DNO_FORTRAN
984263bc
MD
224
225# cross-tool stage
1397f94a
MD
226#
227# note: TOOLS_PREFIX points to the obj root holding the cross
228# compiler binaries, while INCS_PREFIX points to the obj root holding
229# the target environment (and also determines where cross-built
230# libraries and crt*.o are installed).
231#
232XMAKEENV= MAKEOBJDIRPREFIX=${CTOOLSDEST} \
233 OBJTREE=${OBJTREE} \
234 DESTDIR=${CTOOLSDEST} \
235 INSTALL="sh ${.CURDIR}/tools/install.sh" \
236 TOOLS_PREFIX=${CTOOLSDEST} \
237 USRDATA_PREFIX=${WORLDDEST}
238
239XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB
240
241# world stage, note the strict path and note that TOOLS_PREFIX is left
242# unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
243# which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
244# for both binary and library paths, even though it is being compiled to
245# WORLDDEST. None of the programs in the world stage are ever actually
246# executed during the buildworld/installworld.
247#
248CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \
249 OBJTREE=${OBJTREE} \
250 MACHINE_ARCH=${TARGET_ARCH} \
251 MACHINE=${TARGET} \
252 OBJFORMAT_PATH=${CTOOLSDEST} \
253 PERL5LIB=${WORLDDEST}/usr/libdata/perl/5.00503 \
c02263c2
MD
254 GROFF_BIN_PATH=${BTOOLSDEST}/usr/bin \
255 GROFF_FONT_PATH=${BTOOLSDEST}/usr/share/groff_font \
256 GROFF_TMAC_PATH=${BTOOLSDEST}/usr/share/tmac
984263bc 257
984263bc 258WMAKEENV= ${CROSSENV} \
1397f94a 259 DESTDIR=${WORLDDEST} \
984263bc 260 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1397f94a
MD
261 PATH=${STRICTTMPPATH}
262
984263bc
MD
263WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1
264
265# install stage
b07b69cc 266#
984263bc 267IMAKEENV= ${CROSSENV} \
1397f94a 268 PATH=${STRICTTMPPATH}
984263bc
MD
269IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
270
271# kernel stage
b07b69cc
MD
272#
273KMAKEENV= ${WMAKEENV}
984263bc 274
984263bc
MD
275# buildworld
276#
277# Attempt to rebuild the entire system, with reasonable chance of
278# success, regardless of how old your existing system is.
279#
280_worldtmp:
281 @echo
282 @echo "--------------------------------------------------------------"
283 @echo ">>> Rebuilding the temporary build tree"
284 @echo "--------------------------------------------------------------"
285.if !defined(NOCLEAN)
1397f94a 286 rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
984263bc
MD
287.else
288 # XXX - These two can depend on any header file.
289 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
290 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
291.endif
1397f94a
MD
292 mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
293.for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
294 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
295 -p ${_dir}/ > /dev/null
296 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
297 -p ${_dir}/usr > /dev/null
984263bc 298.endfor
1397f94a
MD
299 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
300 -p ${WORLDDEST}/usr/include > /dev/null
301 ln -sf ${.CURDIR}/sys ${WORLDDEST}
302
984263bc
MD
303_bootstrap-tools:
304 @echo
305 @echo "--------------------------------------------------------------"
306 @echo ">>> stage 1: bootstrap tools"
307 @echo "--------------------------------------------------------------"
308 cd ${.CURDIR}; ${BMAKE} bootstrap-tools
309_cleanobj:
984263bc
MD
310 @echo
311 @echo "--------------------------------------------------------------"
1397f94a 312 @echo ">>> stage 2a: cleaning up the object tree"
984263bc
MD
313 @echo "--------------------------------------------------------------"
314 cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
984263bc
MD
315_obj:
316 @echo
317 @echo "--------------------------------------------------------------"
1397f94a 318 @echo ">>> stage 2b: rebuilding the object tree"
984263bc
MD
319 @echo "--------------------------------------------------------------"
320 cd ${.CURDIR}; ${WMAKE} par-obj
321_build-tools:
322 @echo
323 @echo "--------------------------------------------------------------"
1397f94a 324 @echo ">>> stage 2c: build tools"
984263bc
MD
325 @echo "--------------------------------------------------------------"
326 cd ${.CURDIR}; ${TMAKE} build-tools
327_cross-tools:
328 @echo
329 @echo "--------------------------------------------------------------"
330 @echo ">>> stage 3: cross tools"
331 @echo "--------------------------------------------------------------"
332 cd ${.CURDIR}; ${XMAKE} cross-tools
333_includes:
334 @echo
335 @echo "--------------------------------------------------------------"
1397f94a 336 @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
984263bc
MD
337 @echo "--------------------------------------------------------------"
338 cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
339_libraries:
340 @echo
341 @echo "--------------------------------------------------------------"
1397f94a 342 @echo ">>> stage 4b: building libraries"
984263bc
MD
343 @echo "--------------------------------------------------------------"
344 cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
345_depend:
346 @echo
347 @echo "--------------------------------------------------------------"
1397f94a 348 @echo ">>> stage 4c: make dependencies"
984263bc
MD
349 @echo "--------------------------------------------------------------"
350 cd ${.CURDIR}; ${WMAKE} par-depend
351everything:
352 @echo
353 @echo "--------------------------------------------------------------"
1397f94a 354 @echo ">>> stage 4d: building everything.."
984263bc
MD
355 @echo "--------------------------------------------------------------"
356 cd ${.CURDIR}; ${WMAKE} all
357
1397f94a
MD
358# note: buildworld no longer depends on _cleanobj because we rm -rf the
359# entire object tree and built the bootstrap tools in a different location.
360#
361# buildworld - build everything from scratch
362# quickworld - skip the bootstrap, build, and cross-build steps
363# realquickworld - skip the bootstrap, build, crossbuild, and depend step.
364#
365# note: we include _obj in realquickworld to prevent accidental creation
366# of files in /usr/src.
984263bc
MD
367
368WMAKE_TGTS=
369.if !defined(SUBDIR_OVERRIDE)
370WMAKE_TGTS+= _worldtmp _bootstrap-tools
371.endif
1397f94a 372WMAKE_TGTS+= _obj _build-tools
984263bc
MD
373.if !defined(SUBDIR_OVERRIDE)
374WMAKE_TGTS+= _cross-tools
375.endif
376WMAKE_TGTS+= _includes _libraries _depend everything
377
378buildworld: ${WMAKE_TGTS}
1397f94a
MD
379
380quickworld: _obj _includes _libraries _depend everything
381
382realquickworld: _obj _includes _libraries everything
383
384crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
385
984263bc
MD
386.ORDER: ${WMAKE_TGTS}
387
388#
389# installcheck
390#
391# Checks to be sure system is ready for installworld
392#
393installcheck:
394.if !defined(NO_SENDMAIL)
72ac4ef4 395 @if ! `id -u smmsp > /dev/null`; then \
984263bc
MD
396 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
397 false; \
398 fi
72ac4ef4 399 @if ! `id -g smmsp > /dev/null`; then \
984263bc
MD
400 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
401 false; \
402 fi
403.endif
404
405#
406# distributeworld
407#
408# Distributes everything compiled by a `buildworld'.
409#
410# installworld
411#
412# Installs everything compiled by a 'buildworld'.
413#
414distributeworld installworld: installcheck
984263bc 415 cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
984263bc
MD
416
417#
418# reinstall
419#
420# If you have a build server, you can NFS mount the source and obj directories
421# and do a 'make reinstall' on the *client* to install new binaries from the
422# most recent server build.
423#
424reinstall:
425 @echo "--------------------------------------------------------------"
426 @echo ">>> Making hierarchy"
427 @echo "--------------------------------------------------------------"
428 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
429 @echo
430 @echo "--------------------------------------------------------------"
431 @echo ">>> Installing everything.."
432 @echo "--------------------------------------------------------------"
433 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
434.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
435 @echo
436 @echo "--------------------------------------------------------------"
437 @echo ">>> Rebuilding man page indices"
438 @echo "--------------------------------------------------------------"
439 cd ${.CURDIR}/share/man; ${MAKE} makedb
440.endif
441
442redistribute:
443 @echo "--------------------------------------------------------------"
444 @echo ">>> Distributing everything.."
445 @echo "--------------------------------------------------------------"
446 cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
447
448#
449# buildkernel and installkernel
450#
451# Which kernels to build and/or install is specified by setting
452# KERNCONF. If not defined a GENERIC kernel is built/installed.
453# Only the existing (depending TARGET) config files are used
454# for building kernels and only the first of these is designated
455# as the one being installed.
456#
457# Note that we have to use TARGET instead of TARGET_ARCH when
458# we're in kernel-land. Since only TARGET_ARCH is (expected) to
459# be set to cross-build, we have to make sure TARGET is set
460# properly.
461
462.if !defined(KERNCONF) && defined(KERNEL)
463KERNCONF= ${KERNEL}
464KERNWARN= yes
465.else
466KERNCONF?= GENERIC
467.endif
468INSTKERNNAME?= kernel
469
470KRNLSRCDIR= ${.CURDIR}/sys
471KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
472KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
473KERNCONFDIR?= ${KRNLCONFDIR}
474
475BUILDKERNELS=
476INSTALLKERNEL=
477.for _kernel in ${KERNCONF}
478.if exists(${KERNCONFDIR}/${_kernel})
479BUILDKERNELS+= ${_kernel}
480.if empty(INSTALLKERNEL)
481INSTALLKERNEL= ${_kernel}
482.endif
483.endif
484.endfor
485
486#
487# buildkernel
488#
489# Builds all kernels defined by BUILDKERNELS.
490#
e05c8c84
MD
491check_buildworld_tools:
492 @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
493 echo "You must buildworld before buildkernel. If you wish"; \
494 echo "to build a kernel using native tools, config it manually"; \
495 echo "or use the nativekernel target if you are in a rush"; \
496 exit 1; \
497 fi
498
499buildkernel: check_buildworld_tools
984263bc
MD
500.if empty(BUILDKERNELS)
501 @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
502 @false
503.endif
504.if defined(KERNWARN)
505 @echo "--------------------------------------------------------------"
506 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
507 @echo "--------------------------------------------------------------"
508 @sleep 3
509.endif
510 @echo
511.for _kernel in ${BUILDKERNELS}
512 @echo "--------------------------------------------------------------"
513 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
514 @echo "--------------------------------------------------------------"
515 @echo "===> ${_kernel}"
e05c8c84
MD
516 @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
517 echo "REMOVING OLD NATIVEKERNEL BUILD"; \
518 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
984263bc
MD
519 mkdir -p ${KRNLOBJDIR}
520.if !defined(NO_KERNELCONFIG)
521 cd ${KRNLCONFDIR}; \
1397f94a 522 PATH=${STRICTTMPPATH} \
984263bc
MD
523 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
524 ${KERNCONFDIR}/${_kernel}
525.endif
e05c8c84 526 touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
984263bc
MD
527.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
528 cd ${KRNLOBJDIR}/${_kernel}; \
529 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
530.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
531 cd ${KRNLOBJDIR}/${_kernel}; \
532 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
533.endif
534.endif
535 cd ${KRNLOBJDIR}/${_kernel}; \
9f3906fd
MD
536 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
537 ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
984263bc
MD
538.if !defined(NO_KERNELDEPEND)
539 cd ${KRNLOBJDIR}/${_kernel}; \
540 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
541.endif
542 cd ${KRNLOBJDIR}/${_kernel}; \
543 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
544 @echo "--------------------------------------------------------------"
545 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
546 @echo "--------------------------------------------------------------"
547.endfor
548
e05c8c84
MD
549# The nativekernel target is for when you are impatient and want to
550# build a kernel without building the world first.
551#
552nativekernel:
553.if empty(BUILDKERNELS)
554 @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
555 @false
556.endif
557.if defined(KERNWARN)
558 @echo "--------------------------------------------------------------"
559 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
560 @echo "--------------------------------------------------------------"
561 @sleep 3
562.endif
563 @echo
564.for _kernel in ${BUILDKERNELS}
565 @echo "--------------------------------------------------------------"
566 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
567 @echo "--------------------------------------------------------------"
568 @echo "===> ${_kernel}"
569 @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
570 echo "REMOVING OLD BUILDKERNEL BUILD"; \
571 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
572 mkdir -p ${KRNLOBJDIR}
573.if !defined(NO_KERNELCONFIG)
574 cd ${KRNLCONFDIR}; \
575 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
576 ${KERNCONFDIR}/${_kernel}
577.endif
578 touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
579.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
580 cd ${KRNLOBJDIR}/${_kernel}; \
581 ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
582.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
583 cd ${KRNLOBJDIR}/${_kernel}; \
584 ${MAKE} KERNEL=${INSTKERNNAME} cleandir
585.endif
586.endif
587 cd ${KRNLOBJDIR}/${_kernel}; \
588 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
589 ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
590.if !defined(NO_KERNELDEPEND)
591 cd ${KRNLOBJDIR}/${_kernel}; \
592 ${MAKE} KERNEL=${INSTKERNNAME} depend
593.endif
594 cd ${KRNLOBJDIR}/${_kernel}; \
595 ${MAKE} KERNEL=${INSTKERNNAME} all
596 @echo "--------------------------------------------------------------"
597 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
598 @echo "--------------------------------------------------------------"
599.endfor
600
984263bc
MD
601#
602# installkernel
603#
604# Install the kernel defined by INSTALLKERNEL
605#
606installkernel reinstallkernel:
607 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
608 ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
609
610#
611# update
612#
613# Update the source tree, by running sup and/or running cvs to update to the
614# latest copy.
615#
616update:
617.if defined(SUP_UPDATE)
618 @echo "--------------------------------------------------------------"
619 @echo ">>> Running ${SUP}"
620 @echo "--------------------------------------------------------------"
621.if defined(SUPFILE)
622 @${SUP} ${SUPFLAGS} ${SUPFILE}
623.endif
624.if defined(SUPFILE1)
625 @${SUP} ${SUPFLAGS} ${SUPFILE1}
626.endif
627.if defined(SUPFILE2)
628 @${SUP} ${SUPFLAGS} ${SUPFILE2}
629.endif
630.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
631 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
632.endif
633.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
634 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
635.endif
636.endif
637.if defined(CVS_UPDATE)
638 @echo "--------------------------------------------------------------"
639 @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
640 @echo "--------------------------------------------------------------"
641 cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
642.endif
643
644#
645# most
646#
647# Build most of the user binaries on the existing system libs and includes.
648#
649most:
650 @echo "--------------------------------------------------------------"
651 @echo ">>> Building programs only"
652 @echo "--------------------------------------------------------------"
653.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
654 cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ all
655.endfor
656
657#
658# installmost
659#
660# Install the binaries built by the 'most' target. This does not include
661# libraries or include files.
662#
663installmost:
664 @echo "--------------------------------------------------------------"
665 @echo ">>> Installing programs only"
666 @echo "--------------------------------------------------------------"
667.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
668 cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ install
669.endfor
670
671#
672# ------------------------------------------------------------------------
673#
674# From here onwards are utility targets used by the 'make world' and
675# related targets. If your 'world' breaks, you may like to try to fix
676# the problem and manually run the following targets to attempt to
677# complete the build. Beware, this is *not* guaranteed to work, you
678# need to have a pretty good grip on the current state of the system
679# to attempt to manually finish it. If in doubt, 'make world' again.
680#
681
1397f94a 682# bootstrap-tools: Build all tools required to build all tools.
984263bc 683#
17030342
MD
684# [x]install: dependancies on various new install features
685# rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
686# envs are not compatible with older objformat binaries.
687#
984263bc
MD
688.if exists(${.CURDIR}/games) && !defined(NOGAMES)
689_strfile= games/fortune/strfile
690.endif
691
692bootstrap-tools:
1397f94a
MD
693.for _tool in ${_strfile} \
694 bin/chmod bin/cp bin/dd bin/mkdir bin/rm bin/echo bin/test \
695 bin/cat bin/date bin/ln bin/mv bin/csh bin/expr bin/sh bin/ls \
b07b69cc 696 bin/hostname bin/kill \
1397f94a
MD
697 sbin/sysctl \
698 usr.bin/yacc usr.bin/colldef usr.bin/uudecode usr.bin/xinstall \
699 usr.bin/m4 usr.bin/rpcgen usr.bin/make gnu/usr.bin/awk usr.bin/file \
700 usr.bin/find usr.bin/lex usr.bin/sed usr.bin/uname usr.bin/touch \
701 usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
702 usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
703 usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
b07b69cc 704 usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
1397f94a 705 usr.bin/vi usr.bin/cap_mkdb usr.bin/vgrind usr.bin/true usr.bin/false \
c02263c2 706 usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
1397f94a 707 usr.sbin/chown usr.sbin/mtree usr.sbin/config \
8a48ec64 708 usr.sbin/btxld usr.sbin/pwd_mkdb usr.sbin/zic usr.sbin/makewhatis \
1397f94a
MD
709 gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo \
710 gnu/usr.bin/grep gnu/usr.bin/sort gnu/usr.bin/patch \
f0f3e4e6 711 gnu/usr.bin/gzip
1397f94a 712 ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
984263bc
MD
713 cd ${.CURDIR}/${_tool}; \
714 ${MAKE} DIRPRFX=${_tool}/ obj; \
715 ${MAKE} DIRPRFX=${_tool}/ depend; \
716 ${MAKE} DIRPRFX=${_tool}/ all; \
1397f94a 717 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
984263bc 718.endfor
e05c8c84 719 touch ${BTOOLSDEST}/.bootstrap_done
984263bc 720
17030342
MD
721# build-tools: Build special purpose build tools. gcc2 related tools are
722# only built under the i386 architecture. Other architectures are
723# gcc3-only.
984263bc 724#
1397f94a
MD
725# XXX we may be able to remove or consolidate this into bootstrap-tools
726# now that we have the native helper (.nx/.no) infrastructure.
727#
984263bc
MD
728.if exists(${.CURDIR}/games) && !defined(NOGAMES)
729_games= games/adventure games/hack games/phantasia
730.endif
731
732.if exists(${.CURDIR}/share) && !defined(NOSHARE)
733_share= share/syscons/scrnmaps
734.endif
735
17030342
MD
736_gcc3_cross= gnu/usr.bin/cc3
737_gcc3_tools= gnu/usr.bin/cc3/cc_tools
738.if ${MACHINE_ARCH} == "i386" && ${TARGET_ARCH} == "i386"
739_gcc2_cross= gnu/usr.bin/cc
740_gcc2_tools= gnu/usr.bin/cc/cc_tools
741_binutils= gnu/usr.bin/binutils gnu/usr.bin/binutils214
742.else
743_binutils= gnu/usr.bin/binutils214
744.endif
745
984263bc 746.if !defined(NO_FORTRAN)
17030342 747.if ${TARGET_ARCH} == "i386"
984263bc 748_fortran= gnu/usr.bin/cc/f771
17030342
MD
749.else
750_fortran= gnu/usr.bin/cc3/f771
751.endif
984263bc
MD
752.endif
753
754.if !defined(NOPERL)
755_perl= gnu/usr.bin/perl/miniperl
756.endif
757
984263bc
MD
758.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
759 !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
760_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
761 kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
762.endif
763
764.if defined(RELEASEDIR)
765_sysinstall= release/sysinstall
766.endif
767
768build-tools:
1397f94a 769.for _tool in ${_gcc2_tools} ${_gcc3_tools} \
17030342 770 ${_fortran} ${_perl} ${_libroken4} ${_libkrb5} \
1397f94a
MD
771 ${_share} ${_sysinstall}
772 ${ECHODIR} "===> ${_tool} (build-tools)"; \
984263bc
MD
773 cd ${.CURDIR}/${_tool}; \
774 ${MAKE} DIRPRFX=${_tool}/ obj; \
1397f94a
MD
775 ${MAKE} DIRPRFX=${_tool}/ depend; \
776 ${MAKE} DIRPRFX=${_tool}/ all; \
777 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
984263bc 778.endfor
e05c8c84 779 touch ${BTOOLSDEST}/.build_done
984263bc
MD
780
781#
782# cross-tools: Build cross-building tools
783#
784.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
785_elf2exe= usr.sbin/elf2exe
786.endif
787
788.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
789_btxld= usr.sbin/btxld
790.endif
791
792cross-tools:
17030342
MD
793.for _tool in ${_btxld} ${_elf2exe} ${_binutils} \
794 usr.bin/objformat usr.sbin/crunch/crunchide \
795 ${_gcc2_cross} ${_gcc3_cross}
1397f94a 796 ${ECHODIR} "===> ${_tool} (cross-tools)"; \
984263bc
MD
797 cd ${.CURDIR}/${_tool}; \
798 ${MAKE} DIRPRFX=${_tool}/ obj; \
799 ${MAKE} DIRPRFX=${_tool}/ depend; \
800 ${MAKE} DIRPRFX=${_tool}/ all; \
1397f94a 801 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
984263bc 802.endfor
e05c8c84 803 touch ${CTOOLSDEST}/.cross_done
984263bc
MD
804
805#
806# hierarchy - ensure that all the needed directories are present
807#
808hierarchy:
809 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
810
811#
812# libraries - build all libraries, and install them under ${DESTDIR}.
813#
814# The list of libraries with dependents (${_prebuild_libs}) and their
815# interdependencies (__L) are built automatically by the
816# ${.CURDIR}/tools/make_libdeps.sh script.
817#
5228fe46
MD
818# .makeenv does not work when bootstrapping from 4.x, so we must be sure
819# to specify the correct CCVER or 'cc' will not exec the correct compiler.
820#
984263bc
MD
821libraries:
822 cd ${.CURDIR}; \
5228fe46
MD
823 CCVER=gcc2 ${MAKE} -f Makefile.inc1 _startup_libs2; \
824 CCVER=gcc3 ${MAKE} -f Makefile.inc1 _startup_libs3; \
984263bc
MD
825 ${MAKE} -f Makefile.inc1 _startup_libs; \
826 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
827 ${MAKE} -f Makefile.inc1 _generic_libs;
e05c8c84 828 touch ${WORLDDEST}/.libraries_done
984263bc
MD
829
830# These dependencies are not automatically generated:
831#
832# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
5228fe46
MD
833# shared libraries for ELF. The targets for _startup_libs{2,3} are
834# specifically built using gcc{2,3}.
984263bc 835#
5228fe46
MD
836_startup_libs2= gnu/lib/gcc2/csu gnu/lib/gcc2/libgcc
837_startup_libs3= gnu/lib/gcc3/csu gnu/lib/gcc3/libgcc
aa8d5dcb
DR
838.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
839_startup_libs= lib/csu/${MACHINE_ARCH}-elf
984263bc 840.else
5228fe46 841_startup_libs= lib/csu/${MACHINE_ARCH}
984263bc 842.endif
1397f94a 843_startup_libs+= lib/libc
984263bc
MD
844
845_prebuild_libs=
846
847_generic_libs= gnu/lib
848
849.if !defined(NOPERL)
850_generic_libs+= gnu/usr.bin/perl/libperl
851.endif
852
853.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
854_prebuild_libs+= kerberos5/lib/libasn1
855_prebuild_libs+= kerberos5/lib/libgssapi
856_prebuild_libs+= kerberos5/lib/libkrb5
857_prebuild_libs+= kerberos5/lib/libroken
858_generic_libs+= kerberos5/lib
859.endif
860
984263bc
MD
861_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
862 lib/libncurses lib/libopie lib/libradius lib/libskey \
863 lib/libtacplus lib/libutil \
864 lib/libz lib/msun
865
866lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
867lib/libskey__L: lib/libcrypt__L lib/libmd__L
868
869_generic_libs+= lib
870
de347b31 871.if !defined(NOCRYPT)
984263bc
MD
872.if !defined(NO_OPENSSL)
873_prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
874.if !defined(NO_OPENSSH)
875_prebuild_libs+= secure/lib/libssh
876secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
877.endif
878.endif
879_generic_libs+= secure/lib
880.endif
881
882_generic_libs+= usr.bin/lex/lib
883
884.if ${MACHINE_ARCH} == "i386"
885_generic_libs+= usr.sbin/pcvt/keycap
886.endif
887
5228fe46
MD
888.for _lib in ${_startup_libs2} ${_startup_libs3} ${_startup_libs} \
889 ${_prebuild_libs} ${_generic_libs}
984263bc
MD
890${_lib}__L: .PHONY
891.if exists(${.CURDIR}/${_lib})
892 ${ECHODIR} "===> ${_lib}"; \
893 cd ${.CURDIR}/${_lib}; \
894 ${MAKE} DIRPRFX=${_lib}/ depend; \
895 ${MAKE} DIRPRFX=${_lib}/ all; \
896 ${MAKE} DIRPRFX=${_lib}/ install
897.endif
898.endfor
899
17030342
MD
900# only mess with gcc2 for i386 architectures.
901#
984263bc 902_startup_libs: ${_startup_libs:S/$/__L/}
17030342 903.if ${TARGET_ARCH} == "i386"
5228fe46 904_startup_libs2: ${_startup_libs2:S/$/__L/}
17030342
MD
905.else
906_startup_libs2:
907.endif
5228fe46 908_startup_libs3: ${_startup_libs3:S/$/__L/}
984263bc
MD
909_prebuild_libs: ${_prebuild_libs:S/$/__L/}
910_generic_libs: ${_generic_libs:S/$/__L/}
911
1397f94a
MD
912# library targets must be ordered because there are inter-library
913# races (e.g. generation of tconfig.h)
914#
915.ORDER: ${_startup_libs2:S/$/__L/}
916.ORDER: ${_startup_libs3:S/$/__L/}
917.ORDER: ${_startup_libs:S/$/__L/}
918.ORDER: ${_prebuild_libs:S/$/__L/}
919.ORDER: ${_generic_libs:S/$/__L/}
920
921.for __target in clean cleandepend cleandir obj depend includes
984263bc
MD
922.for entry in ${SUBDIR}
923${entry}.${__target}__D: .PHONY
924 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
925 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
926 edir=${entry}.${MACHINE_ARCH}; \
927 cd ${.CURDIR}/$${edir}; \
928 else \
929 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
930 edir=${entry}; \
931 cd ${.CURDIR}/$${edir}; \
932 fi; \
933 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
934.endfor
935par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1397f94a 936.ORDER: ${SUBDIR:S/$/.${__target}__D/}
984263bc 937.endfor
1397f94a 938.ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
984263bc 939
cb0f1574
MD
940# The wmake target is used by /usr/bin/wmake to run make in a
941# world build environment.
942#
943wmake:
1397f94a 944 @echo '${WMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${WMAKE_ARGS}'
cb0f1574 945
5c7da0d7
MD
946wmakeenv:
947 @echo '${WMAKEENV} /bin/sh'
948
1397f94a
MD
949bmake:
950 @echo '${BMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${BMAKE_ARGS}'
951
17030342
MD
952bmakeenv:
953 @echo '${BMAKEENV} /bin/sh'
954
1397f94a
MD
955tmake:
956 @echo '${TMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${TMAKE_ARGS}'
957
17030342
MD
958tmakeenv:
959 @echo '${TMAKEENV} /bin/sh'
960
984263bc 961.include <bsd.subdir.mk>
cb0f1574 962