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