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