Check that the authpf user and group are installed before starting the
[dragonfly.git] / Makefile.inc1
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.41 2004/10/26 16:14:55 drhodus 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.
41 SUBDIR=
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)
47 SUBDIR+= 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)
53 SUBDIR+= include
54 .endif
55 .if exists(${.CURDIR}/lib)
56 SUBDIR+= 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)
63 SUBDIR+= nrelease
64 .endif
65
66 .if exists(${.CURDIR}/bin)
67 SUBDIR+= bin
68 .endif
69 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
70 SUBDIR+= games
71 .endif
72 .if exists(${.CURDIR}/gnu)
73 SUBDIR+= gnu
74 .endif
75 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
76     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
77 SUBDIR+= kerberos5
78 .endif
79 .if exists(${.CURDIR}/libexec)
80 SUBDIR+= libexec
81 .endif
82 .if exists(${.CURDIR}/sbin)
83 SUBDIR+= sbin
84 .endif
85 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
86 SUBDIR+= secure
87 .endif
88 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
89 SUBDIR+= share
90 .endif
91 .if exists(${.CURDIR}/sys)
92 SUBDIR+= sys
93 .endif
94 .if exists(${.CURDIR}/usr.bin)
95 SUBDIR+= usr.bin
96 .endif
97 .if exists(${.CURDIR}/usr.sbin)
98 SUBDIR+= usr.sbin
99 .endif
100
101 # etc must be last for "distribute" to work
102 .if exists(${.CURDIR}/etc)
103 SUBDIR+= 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)
111 SUBDIR+= ${_DIR}
112 .endif
113 .endfor
114 .endif
115
116 .if defined(SUBDIR_OVERRIDE)
117 SUBDIR=         ${SUBDIR_OVERRIDE}
118 .endif
119
120 .if defined(NOCLEANDIR)
121 CLEANDIR=       clean cleandepend
122 .else
123 CLEANDIR=       cleandir
124 .endif
125
126 SUP?=           /usr/local/bin/cvsup
127 SUPFLAGS?=      -g -L 2 -P -
128 .if defined(SUPHOST)
129 SUPFLAGS+=      -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 #
137 MAKEOBJDIRPREFIX?=      /usr/obj
138 OBJTREE?=               ${MAKEOBJDIRPREFIX}
139
140 # Used for stage installs and pathing
141 #
142 DESTDIRBASE?=           ${OBJTREE}${.CURDIR}
143
144 TARGET_ARCH?=   ${MACHINE_ARCH}
145 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
146 TARGET?=        ${MACHINE}
147 .else
148 TARGET?=        ${TARGET_ARCH}
149 .endif
150 .if make(buildworld)
151 BUILD_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 #
171 BTOOLSDEST=     ${DESTDIRBASE}/btools_${MACHINE_ARCH}
172 CTOOLSDEST=     ${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH}
173 WORLDDEST=      ${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 #
180 BTOOLSPATH= ${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 #
185 STRICTTMPPATH=  ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
186
187 TMPDIR?=        /tmp
188 TMPPID!=        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 #
213 BMAKEENV=       MAKEOBJDIRPREFIX=${BTOOLSDEST} \
214                 OBJTREE=${OBJTREE} \
215                 DESTDIR=${BTOOLSDEST} \
216                 PATH=${BTOOLSPATH}:${PATH} \
217                 INSTALL="sh ${.CURDIR}/tools/install.sh"
218
219 BMAKE=          ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
220                 -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
221                 -DNO_WERROR
222
223 # build-tool stage
224 #
225 TMAKEENV=       MAKEOBJDIRPREFIX=${BTOOLSDEST} \
226                 OBJTREE=${OBJTREE} \
227                 DESTDIR= \
228                 PATH=${BTOOLSPATH}:${PATH} \
229                 INSTALL="sh ${.CURDIR}/tools/install.sh"
230
231 TMAKE=          ${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 #
241 XMAKEENV=       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
249 XMAKE=          ${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 #
259 CROSSENV=       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
269 WMAKEENV=       ${CROSSENV} \
270                 DESTDIR=${WORLDDEST} \
271                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
272                 PATH=${STRICTTMPPATH}
273
274 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1
275
276 # install stage
277 #
278 IMAKEENV=       ${CROSSENV} \
279                 PATH=${STRICTTMPPATH}
280 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
281
282 # kernel stage
283 #
284 KMAKEENV=       ${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
362 everything:
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
379 WMAKE_TGTS=
380 .if !defined(SUBDIR_OVERRIDE)
381 WMAKE_TGTS+=    _worldtmp _bootstrap-tools
382 .endif
383 WMAKE_TGTS+=    _obj _build-tools
384 .if !defined(SUBDIR_OVERRIDE)
385 WMAKE_TGTS+=    _cross-tools
386 .endif
387 WMAKE_TGTS+=    _includes _libraries _depend everything
388
389 buildworld: ${WMAKE_TGTS}
390
391 quickworld: _obj _includes _libraries _depend everything
392
393 realquickworld: _obj _includes _libraries everything
394
395 crossworld: _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 #
404 installcheck:
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 #Check that authpf user and group is installed
417 #
418         @if ! `id -u authpf > /dev/null`; then \
419                 echo "ERROR: Required authpf user is missing, see /usr/src/UPDATING."; \
420                 false; \
421         fi
422         @if ! `id -g authpf > /dev/null`; then \
423                 echo "ERROR: Required authpf group is missing, see /usr/src/UPDATING."; \
424                 false; \
425         fi
426 #
427 # distributeworld
428 #
429 # Distributes everything compiled by a `buildworld'.
430 #
431 # installworld
432 #
433 # Installs everything compiled by a 'buildworld'.
434 #
435 distributeworld installworld: installcheck
436         cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
437
438 #
439 # reinstall
440 #
441 # If you have a build server, you can NFS mount the source and obj directories
442 # and do a 'make reinstall' on the *client* to install new binaries from the
443 # most recent server build.
444 #
445 reinstall:
446         @echo "--------------------------------------------------------------"
447         @echo ">>> Making hierarchy"
448         @echo "--------------------------------------------------------------"
449         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
450         @echo
451         @echo "--------------------------------------------------------------"
452         @echo ">>> Installing everything.."
453         @echo "--------------------------------------------------------------"
454         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
455 .if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
456         @echo
457         @echo "--------------------------------------------------------------"
458         @echo ">>> Rebuilding man page indices"
459         @echo "--------------------------------------------------------------"
460         cd ${.CURDIR}/share/man; ${MAKE} makedb
461 .endif
462
463 redistribute:
464         @echo "--------------------------------------------------------------"
465         @echo ">>> Distributing everything.."
466         @echo "--------------------------------------------------------------"
467         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
468
469 #
470 # buildkernel, nativekernel, quickkernel, and installkernel
471 #
472 # Which kernels to build and/or install is specified by setting
473 # KERNCONF. If not defined a GENERIC kernel is built/installed.
474 # Only the existing (depending TARGET) config files are used
475 # for building kernels and only the first of these is designated
476 # as the one being installed.
477 #
478 # You can specify INSTALLSTRIPPED=1 if you wish the installed 
479 # kernel and modules to be stripped of its debug info (required
480 # symbols are left intact).  You can specify INSTALLSTRIPPEDMODULES
481 # if you only want to strip the modules of their debug info.  These
482 # only apply if you have DEBUG=-g in your kernel config or make line.
483 #
484 # Note that we have to use TARGET instead of TARGET_ARCH when
485 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
486 # be set to cross-build, we have to make sure TARGET is set
487 # properly.
488
489 .if !defined(KERNCONF) && defined(KERNEL)
490 KERNCONF=       ${KERNEL}
491 KERNWARN=       yes
492 .else
493 KERNCONF?=      GENERIC
494 .endif
495 INSTKERNNAME?=  kernel
496
497 KRNLSRCDIR=     ${.CURDIR}/sys
498 KRNLCONFDIR=    ${KRNLSRCDIR}/${TARGET}/conf
499 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
500 KERNCONFDIR?=   ${KRNLCONFDIR}
501
502 BUILDKERNELS=
503 INSTALLKERNEL=
504 .for _kernel in ${KERNCONF}
505 .if exists(${KERNCONFDIR}/${_kernel})
506 BUILDKERNELS+=  ${_kernel}
507 .if empty(INSTALLKERNEL)
508 INSTALLKERNEL= ${_kernel}
509 .endif
510 .endif
511 .endfor
512
513 #
514 # buildkernel
515 #
516 # Builds all kernels defined by BUILDKERNELS.
517 #
518 bk_tools:
519         @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
520             echo "You must buildworld before buildkernel.  If you wish"; \
521             echo "to build a kernel using native tools, config it manually"; \
522             echo "or use the nativekernel target if you are in a rush"; \
523             exit 1; \
524         fi
525
526 maybe_bk_tools:
527 .for _kernel in ${BUILDKERNELS}
528         @if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
529             if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
530                 echo "The kernel was build using buildworld tools which no" ; \
531                 echo "longer appear to exist, quickkernel failed!" ; \
532                 exit 1; \
533             fi; \
534         fi
535 .endfor
536
537 bk_build_list:
538 .if empty(BUILDKERNELS)
539         @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
540         @false
541 .endif
542
543 bk_kernwarn:
544 .if defined(KERNWARN)
545         @echo "--------------------------------------------------------------"
546         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
547         @echo "--------------------------------------------------------------"
548         @sleep 3
549 .endif
550         @echo
551
552 # The buildkernel target rebuilds the specified kernels from scratch
553 # using the crossbuild tools generated by the last buildworld.  It is
554 # the safest (but also the most time consuming) way to build a new kernel.
555 #
556 buildkernel:    bk_tools bk_build_list bk_kernwarn
557 .for _kernel in ${BUILDKERNELS}
558         @echo "--------------------------------------------------------------"
559         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
560         @echo "--------------------------------------------------------------"
561         @echo "===> ${_kernel}"
562 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
563         rm -rf ${KRNLOBJDIR}/${_kernel}
564 .else
565         @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
566                 echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
567                 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
568 .endif
569         mkdir -p ${KRNLOBJDIR}
570 .if !defined(NO_KERNELCONFIG)
571         cd ${KRNLCONFDIR}; \
572                 PATH=${STRICTTMPPATH} \
573                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
574                         ${KERNCONFDIR}/${_kernel}
575 .endif
576         touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
577         cd ${KRNLOBJDIR}/${_kernel}; \
578             MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
579             ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
580 .if !defined(NO_KERNELDEPEND)
581         cd ${KRNLOBJDIR}/${_kernel}; \
582             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
583 .endif
584         cd ${KRNLOBJDIR}/${_kernel}; \
585             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
586         @echo "--------------------------------------------------------------"
587         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
588         @echo "--------------------------------------------------------------"
589 .endfor
590
591 # The nativekernel target rebuilds the specified kernels from scratch
592 # using the systems standard compiler rather then using the crossbuild
593 # tools generated by the last buildworld.  This is fairly safe if your
594 # system is reasonable up-to-date.
595 #
596 nativekernel:   bk_build_list bk_kernwarn
597 .for _kernel in ${BUILDKERNELS}
598         @echo "--------------------------------------------------------------"
599         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
600         @echo "--------------------------------------------------------------"
601         @echo "===> ${_kernel}"
602 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
603         rm -rf ${KRNLOBJDIR}/${_kernel}
604 .else
605         @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
606                 echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
607                 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
608 .endif
609         mkdir -p ${KRNLOBJDIR}
610 .if !defined(NO_KERNELCONFIG)
611         cd ${KRNLCONFDIR}; \
612                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
613                         ${KERNCONFDIR}/${_kernel}
614 .endif
615         touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
616         cd ${KRNLOBJDIR}/${_kernel}; \
617             MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
618             ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
619 .if !defined(NO_KERNELDEPEND)
620         cd ${KRNLOBJDIR}/${_kernel}; \
621             ${MAKE} KERNEL=${INSTKERNNAME} depend
622 .endif
623         cd ${KRNLOBJDIR}/${_kernel}; \
624             ${MAKE} KERNEL=${INSTKERNNAME} all
625         @echo "--------------------------------------------------------------"
626         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
627         @echo "--------------------------------------------------------------"
628 .endfor
629
630 # The quickkernel target rebuilds the specified kernels as quickly
631 # as possible.  It will use the native tools or the buildworld cross tools
632 # based on whether the kernel was originally generated via buildkernel or
633 # nativekernel.  Config is rerun but the object hierarchy is not rebuilt,
634 # nor is the make depend step run.
635 #
636 quickkernel:    maybe_bk_tools bk_build_list bk_kernwarn
637 .for _kernel in ${BUILDKERNELS}
638         @echo "--------------------------------------------------------------"
639         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
640         @echo "--------------------------------------------------------------"
641         @echo "===> ${_kernel}"
642 .if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
643 .if !defined(NO_KERNELCONFIG)
644         cd ${KRNLCONFDIR}; \
645                 PATH=${STRICTTMPPATH} \
646                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
647                         ${KERNCONFDIR}/${_kernel}
648 .endif
649         cd ${KRNLOBJDIR}/${_kernel}; \
650             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
651 .else
652 .if !defined(NO_KERNELCONFIG)
653         cd ${KRNLCONFDIR}; \
654             config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
655                 ${KERNCONFDIR}/${_kernel}
656 .endif
657         cd ${KRNLOBJDIR}/${_kernel}; \
658             ${MAKE} KERNEL=${INSTKERNNAME} all
659 .endif
660         @echo "--------------------------------------------------------------"
661         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
662         @echo "--------------------------------------------------------------"
663 .endfor
664
665
666 # installkernel
667 #
668 # Install the kernel defined by INSTALLKERNEL
669 #
670 installkernel reinstallkernel:
671 .if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
672         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
673             ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
674 .else
675         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
676             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
677 .endif
678
679 #
680 # update
681 #
682 # Update the source tree, by running sup and/or running cvs to update to the
683 # latest copy.
684 #
685 update:
686 .if defined(SUP_UPDATE)
687         @echo "--------------------------------------------------------------"
688         @echo ">>> Running ${SUP}"
689         @echo "--------------------------------------------------------------"
690 .if defined(SUPFILE)
691         @${SUP} ${SUPFLAGS} ${SUPFILE}
692 .endif
693 .if defined(SUPFILE1)
694         @${SUP} ${SUPFLAGS} ${SUPFILE1}
695 .endif
696 .if defined(SUPFILE2)
697         @${SUP} ${SUPFLAGS} ${SUPFILE2}
698 .endif
699 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
700         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
701 .endif
702 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
703         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
704 .endif
705 .endif
706 .if defined(CVS_UPDATE)
707         @echo "--------------------------------------------------------------"
708         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
709         @echo "--------------------------------------------------------------"
710         cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
711 .endif
712
713 #
714 # most
715 #
716 # Build most of the user binaries on the existing system libs and includes.
717 #
718 most:
719         @echo "--------------------------------------------------------------"
720         @echo ">>> Building programs only"
721         @echo "--------------------------------------------------------------"
722 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
723         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ all
724 .endfor
725
726 #
727 # installmost
728 #
729 # Install the binaries built by the 'most' target.  This does not include
730 # libraries or include files.
731 #
732 installmost:
733         @echo "--------------------------------------------------------------"
734         @echo ">>> Installing programs only"
735         @echo "--------------------------------------------------------------"
736 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
737         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ install
738 .endfor
739
740 #
741 # ------------------------------------------------------------------------
742 #
743 # From here onwards are utility targets used by the 'make world' and
744 # related targets.  If your 'world' breaks, you may like to try to fix
745 # the problem and manually run the following targets to attempt to
746 # complete the build.  Beware, this is *not* guaranteed to work, you
747 # need to have a pretty good grip on the current state of the system
748 # to attempt to manually finish it.  If in doubt, 'make world' again.
749 #
750
751 # bootstrap-tools: Build all tools required to build all tools.  Note that
752 # order is important in a number of cases and also note that the bootstrap
753 # and build tools stages have access to earlier binaries they themselves
754 # had generated.
755 #
756 # patch:        older patch's do not have -i.  This program must be built
757 #               first so other bootstrap tools that need to apply patches
758 #               can use it.
759 # [x]install:   dependancies on various new install features
760 # rpcgen:       old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
761 #               envs are not compatible with older objformat binaries.
762 #
763 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
764 _strfile=       games/fortune/strfile
765 .endif
766
767 bootstrap-tools:
768 .for _tool in ${_strfile} \
769     usr.bin/patch \
770     bin/chmod bin/cp bin/dd bin/mkdir bin/rm bin/echo bin/test \
771     bin/cat bin/date bin/ln bin/mv bin/csh bin/expr bin/sh bin/ls \
772     bin/hostname bin/kill \
773     sbin/sysctl \
774     usr.bin/yacc usr.bin/colldef usr.bin/uudecode usr.bin/xinstall \
775     usr.bin/m4 usr.bin/rpcgen usr.bin/make usr.bin/awk usr.bin/file \
776     usr.bin/find usr.bin/lex usr.bin/sed usr.bin/uname usr.bin/touch \
777     usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
778     usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
779     usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
780     usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
781     usr.bin/vi usr.bin/cap_mkdb usr.bin/vgrind usr.bin/true usr.bin/false \
782     usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
783     usr.sbin/chown usr.sbin/mtree usr.sbin/config \
784     usr.sbin/btxld usr.sbin/pwd_mkdb usr.sbin/zic usr.sbin/makewhatis \
785     gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo \
786     gnu/usr.bin/grep gnu/usr.bin/sort \
787     gnu/usr.bin/gzip usr.bin/bzip2
788         ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
789                 cd ${.CURDIR}/${_tool}; \
790                 ${MAKE} DIRPRFX=${_tool}/ obj; \
791                 ${MAKE} DIRPRFX=${_tool}/ depend; \
792                 ${MAKE} DIRPRFX=${_tool}/ all; \
793                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
794 .endfor
795         touch ${BTOOLSDEST}/.bootstrap_done
796
797 # build-tools: Build special purpose build tools.  gcc2 related tools are
798 # only built under the i386 architecture.  Other architectures are
799 # gcc3-only.
800 #
801 # XXX we may be able to remove or consolidate this into bootstrap-tools
802 # now that we have the native helper (.nx/.no) infrastructure.
803 #
804 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
805 _games= games/adventure games/hack games/phantasia
806 .endif
807
808 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
809 _share= share/syscons/scrnmaps
810 .endif
811
812 _gcc34_cross= gnu/usr.bin/cc34
813 _gcc34_tools= gnu/usr.bin/cc34/cc_prep gnu/usr.bin/cc34/cc_tools
814 .if ${MACHINE_ARCH} == "i386" && ${TARGET_ARCH} == "i386"
815 _gcc2_cross= gnu/usr.bin/cc
816 _gcc2_tools= gnu/usr.bin/cc/cc_tools
817 _binutils= gnu/usr.bin/binutils gnu/usr.bin/binutils214
818 .else
819 _binutils= gnu/usr.bin/binutils214
820 .endif
821
822 .if !defined(NO_FORTRAN)
823 .if ${TARGET_ARCH} == "i386"
824 _fortran= gnu/usr.bin/cc/f771
825 .else
826 _fortran= gnu/usr.bin/cc34/f771
827 .endif
828 .endif
829
830 .if !defined(NOPERL)
831 _perl=  gnu/usr.bin/perl/miniperl
832 .endif
833
834 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
835     !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
836 _libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
837     kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
838 .endif
839
840 .if defined(RELEASEDIR)
841 _sysinstall= release/sysinstall
842 .endif
843
844 build-tools:
845 .for _tool in ${_gcc2_tools} ${_gcc34_tools} \
846               ${_fortran} ${_perl} ${_libroken4} ${_libkrb5} \
847               ${_share} ${_sysinstall}
848         ${ECHODIR} "===> ${_tool} (build-tools)"; \
849                 cd ${.CURDIR}/${_tool}; \
850                 ${MAKE} DIRPRFX=${_tool}/ obj; \
851                 ${MAKE} DIRPRFX=${_tool}/ depend; \
852                 ${MAKE} DIRPRFX=${_tool}/ all; \
853                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
854 .endfor
855         touch ${BTOOLSDEST}/.build_done
856
857 #
858 # cross-tools: Build cross-building tools
859 #
860 .if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
861 _elf2exe=       usr.sbin/elf2exe
862 .endif
863
864 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
865 _btxld= usr.sbin/btxld
866 .endif
867
868 cross-tools:
869 .for _tool in ${_btxld} ${_elf2exe} ${_binutils} \
870               usr.bin/objformat usr.sbin/crunch/crunchide \
871               ${_gcc2_cross} ${_gcc34_cross}
872         ${ECHODIR} "===> ${_tool} (cross-tools)"; \
873                 cd ${.CURDIR}/${_tool}; \
874                 ${MAKE} DIRPRFX=${_tool}/ obj; \
875                 ${MAKE} DIRPRFX=${_tool}/ depend; \
876                 ${MAKE} DIRPRFX=${_tool}/ all; \
877                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
878 .endfor
879         touch ${CTOOLSDEST}/.cross_done
880
881 #
882 # hierarchy - ensure that all the needed directories are present
883 #
884 hierarchy:
885         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
886
887 #
888 # libraries - build all libraries, and install them under ${DESTDIR}.
889 #
890 # The list of libraries with dependents (${_prebuild_libs}) and their
891 # interdependencies (__L) are built automatically by the
892 # ${.CURDIR}/tools/make_libdeps.sh script.
893 #
894 # .makeenv does not work when bootstrapping from 4.x, so we must be sure
895 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
896 #
897 libraries:
898         cd ${.CURDIR}; \
899             HOST_CCVER=${HOST_CCVER} CCVER=gcc2 \
900                 ${MAKE} -f Makefile.inc1 _startup_libs2; \
901             HOST_CCVER=${HOST_CCVER} CCVER=gcc34 \
902                 ${MAKE} -f Makefile.inc1 _startup_libs34; \
903             ${MAKE} -f Makefile.inc1 _startup_libs; \
904             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
905             ${MAKE} -f Makefile.inc1 _generic_libs;
906         touch ${WORLDDEST}/.libraries_done
907
908 # These dependencies are not automatically generated:
909 #
910 # gnu/lib/libgcc and lib/csu must be built before all
911 # shared libraries for ELF.  The targets for _startup_libs{2,3} are
912 # specifically built using gcc{2,3}.
913 #
914 _startup_libs2= gnu/lib/gcc2/libgcc
915 _startup_libs34=        gnu/lib/gcc34/libgcc
916 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
917 _startup_libs=  lib/csu/${MACHINE_ARCH}-elf
918 .else
919 _startup_libs=  lib/csu/${MACHINE_ARCH}
920 .endif
921 _startup_libs+= lib/csu/common lib/libc
922
923 _prebuild_libs=
924
925 _generic_libs=  gnu/lib
926
927 .if !defined(NOPERL)
928 _generic_libs+= gnu/usr.bin/perl/libperl
929 .endif
930
931 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
932 _prebuild_libs+=        kerberos5/lib/libasn1
933 _prebuild_libs+=        kerberos5/lib/libgssapi
934 _prebuild_libs+=        kerberos5/lib/libkrb5
935 _prebuild_libs+=        kerberos5/lib/libroken
936 _generic_libs+= kerberos5/lib
937 .endif
938
939 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
940                 lib/libncurses lib/libopie lib/libradius lib/libskey \
941                 lib/libtacplus lib/libutil \
942                 lib/libz lib/msun
943
944 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
945 lib/libskey__L: lib/libcrypt__L lib/libmd__L
946
947 _generic_libs+= lib
948
949 .if !defined(NOCRYPT)
950 .if !defined(NO_OPENSSL)
951 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
952 .if !defined(NO_OPENSSH)
953 _prebuild_libs+=        secure/lib/libssh
954 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
955 .endif
956 .endif
957 _generic_libs+= secure/lib
958 .endif
959
960 _generic_libs+= usr.bin/lex/lib
961
962 .if ${MACHINE_ARCH} == "i386"
963 _generic_libs+= usr.sbin/pcvt/keycap
964 .endif
965
966 .for _lib in ${_startup_libs2} ${_startup_libs3} ${_startup_libs34} \
967                 ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
968 ${_lib}__L: .PHONY
969 .if exists(${.CURDIR}/${_lib})
970         ${ECHODIR} "===> ${_lib}"; \
971                 cd ${.CURDIR}/${_lib}; \
972                 ${MAKE} DIRPRFX=${_lib}/ depend; \
973                 ${MAKE} DIRPRFX=${_lib}/ all; \
974                 ${MAKE} DIRPRFX=${_lib}/ install
975 .endif
976 .endfor
977
978 # only mess with gcc2 for i386 architectures.
979 #
980 _startup_libs: ${_startup_libs:S/$/__L/}
981 .if ${TARGET_ARCH} == "i386"
982 _startup_libs2: ${_startup_libs2:S/$/__L/}
983 .else
984 _startup_libs2:
985 .endif
986 _startup_libs3: ${_startup_libs3:S/$/__L/}
987 _startup_libs34: ${_startup_libs34:S/$/__L/}
988 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
989 _generic_libs: ${_generic_libs:S/$/__L/}
990
991 # library targets must be ordered because there are inter-library
992 # races (e.g. generation of tconfig.h)
993 #
994 .ORDER: ${_startup_libs2:S/$/__L/}
995 .ORDER: ${_startup_libs3:S/$/__L/}
996 .ORDER: ${_startup_libs34:S/$/__L/}
997 .ORDER: ${_startup_libs:S/$/__L/}
998 .ORDER: ${_prebuild_libs:S/$/__L/}
999 .ORDER: ${_generic_libs:S/$/__L/}
1000
1001 .for __target in clean cleandepend cleandir obj depend includes
1002 .for entry in ${SUBDIR}
1003 ${entry}.${__target}__D: .PHONY
1004         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1005                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
1006                 edir=${entry}.${MACHINE_ARCH}; \
1007                 cd ${.CURDIR}/$${edir}; \
1008         else \
1009                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
1010                 edir=${entry}; \
1011                 cd ${.CURDIR}/$${edir}; \
1012         fi; \
1013         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1014 .endfor
1015 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1016 .ORDER: ${SUBDIR:S/$/.${__target}__D/}
1017 .endfor
1018 .ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
1019
1020 # The wmake target is used by /usr/bin/wmake to run make in a
1021 # world build environment.
1022 #
1023 wmake:
1024         @echo '${WMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${WMAKE_ARGS}'
1025
1026 wmakeenv:
1027         @echo '${WMAKEENV} /bin/sh'
1028
1029 bmake:
1030         @echo '${BMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${BMAKE_ARGS}'
1031
1032 bmakeenv:
1033         @echo '${BMAKEENV} /bin/sh'
1034
1035 tmake:
1036         @echo '${TMAKEENV} ${MAKE} -m ${.CURDIR}/share/mk ${TMAKE_ARGS}'
1037
1038 tmakeenv:
1039         @echo '${TMAKEENV} /bin/sh'
1040
1041 .include <bsd.subdir.mk>
1042