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