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