]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
This commit was generated by cvs2svn to compensate for changes in r126380,
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6 #       -DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7 #       -DNO_RESCUE do not build rescue binaries
8 #       -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9 #       -DNOCLEAN do not clean at all
10 #       -DNOCRYPT will prevent building of crypt versions
11 #       -DNOMAN do not build the manual pages
12 #       -DNOPROFILE do not build profiled libraries
13 #       -DNOGAMES do not go into games subdir
14 #       -DNOSHARE do not go into share subdir
15 #       -DNOINFO do not make or install info files
16 #       -DNOLIBC_R do not build libc_r.
17 #       -DNO_FORTRAN do not build g77 and related libraries.
18 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
19 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
20 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
21 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
22 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
23 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24 #       TARGET_ARCH="arch" to crossbuild world to a different arch
25
26 #
27 # The intended user-driven targets are:
28 # buildworld  - rebuild *everything*, including glue to help do upgrades
29 # installworld- install everything built by "buildworld"
30 # update      - convenient way to update your source tree (eg: sup/cvs)
31 #
32 # Standard targets (not defined here) are documented in the makefiles in
33 # /usr/share/mk.  These include:
34 #               obj depend all install clean cleandepend cleanobj
35
36 # We must do share/info early so that installation of info `dir'
37 # entries works correctly.  Do it first since it is less likely to
38 # grow dependencies on include and lib than vice versa.
39 #
40 # We must do lib and libexec before bin, because if installworld
41 # installs a new /bin/sh, the 'make' command will *immediately*
42 # use that new version.  And the new (dynamically-linked) /bin/sh
43 # will expect to find appropriate libraries in /lib and /libexec.
44 #
45 # We must do etc last for install/distribute to work.
46 #
47 SUBDIR= share/info include lib libexec bin
48 .if !defined(NOGAMES)
49 SUBDIR+=games
50 .endif
51 SUBDIR+=gnu
52 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
53 SUBDIR+=kerberos5
54 .endif
55 .if !defined(NO_RESCUE)
56 SUBDIR+=rescue
57 .endif
58 SUBDIR+=sbin
59 .if !defined(NOCRYPT)
60 SUBDIR+=secure
61 .endif
62 .if !defined(NOSHARE)
63 SUBDIR+=share
64 .endif
65 SUBDIR+=sys usr.bin usr.sbin etc
66
67 # These are last, since it is nice to at least get the base system
68 # rebuilt before you do them.
69 .for _DIR in ${LOCAL_DIRS}
70 .if exists(${.CURDIR}/${_DIR}/Makefile)
71 SUBDIR+= ${_DIR}
72 .endif
73 .endfor
74
75 .if defined(SUBDIR_OVERRIDE)
76 SUBDIR=         ${SUBDIR_OVERRIDE}
77 .endif
78
79 .if defined(NOCLEANDIR)
80 CLEANDIR=       clean cleandepend
81 .else
82 CLEANDIR=       cleandir
83 .endif
84
85 CVS?=           cvs
86 SUP?=           /usr/local/bin/cvsup
87 SUPFLAGS?=      -g -L 2 -P -
88 .if defined(SUPHOST)
89 SUPFLAGS+=      -h ${SUPHOST}
90 .endif
91
92 MAKEOBJDIRPREFIX?=      /usr/obj
93 .if !defined(OSRELDATE)
94 .if exists(/usr/include/osreldate.h)
95 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
96                 /usr/include/osreldate.h
97 .else
98 OSRELDATE=      0
99 .endif
100 .endif
101 TARGET_ARCH?=   ${MACHINE_ARCH}
102 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
103 TARGET?=        ${MACHINE}
104 TARGET_CPUTYPE?=${CPUTYPE}
105 .else
106 TARGET?=        ${TARGET_ARCH}
107 TARGET_CPUTYPE?=
108 .endif
109 .if !empty(TARGET_CPUTYPE)
110 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
111 .else
112 _TARGET_CPUTYPE=dummy
113 .endif
114 _CPUTYPE!=      ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
115                 CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
116 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
117 .error CPUTYPE global should be set with ?=.
118 .endif
119 .if make(buildworld)
120 BUILD_ARCH!=    sysctl -n hw.machine_arch
121 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
122 .error To cross-build, set TARGET_ARCH.
123 .endif
124 .endif
125 .if ${MACHINE} == ${TARGET}
126 OBJTREE=        ${MAKEOBJDIRPREFIX}
127 .else
128 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
129 .endif
130 WORLDTMP=       ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
131 # /usr/games added for fortune which depend on strfile
132 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
133 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
134 STRICTTMPPATH=  ${BPATH}:${XPATH}
135 TMPPATH=        ${STRICTTMPPATH}:${PATH}
136
137 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
138
139 #
140 # Building a world goes through the following stages
141 #
142 # 1. legacy stage [BMAKE]
143 #       This stage is responsible for creating compatibility
144 #       shims that are needed by the bootstrap-tools,
145 #       build-tools and cross-tools stages.
146 # 1. bootstrap-tools stage [BMAKE]
147 #       This stage is responsible for creating programs that
148 #       are needed for backward compatibility reasons. They
149 #       are not built as cross-tools.
150 # 2. build-tools stage [TMAKE]
151 #       This stage is responsible for creating the object
152 #       tree and building any tools that are needed during
153 #       the build process.
154 # 3. cross-tools stage [XMAKE]
155 #       This stage is responsible for creating any tools that
156 #       are needed for cross-builds. A cross-compiler is one
157 #       of them.
158 # 4. world stage [WMAKE]
159 #       This stage actually builds the world.
160 # 5. install stage (optional) [IMAKE]
161 #       This stage installs a previously built world.
162 #
163
164 BOOTSTRAPPING?= 0
165
166 # Common environment for world related stages
167 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
168                 MACHINE_ARCH=${TARGET_ARCH} \
169                 MACHINE=${TARGET} \
170                 CPUTYPE=${TARGET_CPUTYPE} \
171                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
172                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
173                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
174
175 # bootstrap-tools stage
176 BMAKEENV=       DESTDIR= \
177                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
178                 PATH=${BPATH}:${PATH} \
179                 WORLDTMP=${WORLDTMP} \
180                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
181 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
182                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
183                 BOOTSTRAPPING=${OSRELDATE} \
184                 -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
185                 -DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
186
187 # build-tools stage
188 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
189                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
190                 BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
191
192 # cross-tools stage
193 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
194
195 # world stage
196 WMAKEENV=       ${CROSSENV} \
197                 DESTDIR=${WORLDTMP} \
198                 _SHLIBDIRPREFIX=${WORLDTMP} \
199                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
200                 PATH=${TMPPATH}
201 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1
202
203 # install stage
204 IMAKEENV=       ${CROSSENV} \
205                 PATH=${STRICTTMPPATH}:${INSTALLTMP}
206 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
207
208 # kernel stage
209 KMAKEENV=       ${WMAKEENV}
210
211 #
212 # buildworld
213 #
214 # Attempt to rebuild the entire system, with reasonable chance of
215 # success, regardless of how old your existing system is.
216 #
217 _worldtmp:
218 .if ${.CURDIR:C/[^,]//g} != ""
219 #       The m4 build of sendmail files doesn't like it if ',' is used
220 #       anywhere in the path of it's files.
221         @echo
222         @echo "*** Error: path to source tree contains a comma ','"
223         @echo
224         @false
225 .endif
226         @echo
227         @echo "--------------------------------------------------------------"
228         @echo ">>> Rebuilding the temporary build tree"
229         @echo "--------------------------------------------------------------"
230 .if !defined(NOCLEAN)
231         rm -rf ${WORLDTMP}
232 .else
233         rm -rf ${WORLDTMP}/legacy/usr/include
234         # XXX - These two can depend on any header file.
235         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
236         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
237 .endif
238 .for _dir in \
239     usr/bin usr/games usr/include/c++/3.3 usr/include/sys usr/lib \
240     usr/libexec usr/sbin usr/share/dict \
241     usr/share/groff_font/devX100 \
242     usr/share/groff_font/devX100-12 \
243     usr/share/groff_font/devX75 \
244     usr/share/groff_font/devX75-12 \
245     usr/share/groff_font/devascii \
246     usr/share/groff_font/devcp1047 \
247     usr/share/groff_font/devdvi \
248     usr/share/groff_font/devhtml \
249     usr/share/groff_font/devkoi8-r \
250     usr/share/groff_font/devlatin1 \
251     usr/share/groff_font/devlbp \
252     usr/share/groff_font/devlj4 \
253     usr/share/groff_font/devps \
254     usr/share/groff_font/devutf8 \
255     usr/share/tmac/mdoc usr/share/tmac/mm
256         mkdir -p ${WORLDTMP}/legacy/${_dir}
257 .endfor
258 .for _dir in \
259     lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
260     usr/libexec usr/share/misc usr/share/bsnmp/defs usr/share/bsnmp/mibs
261         mkdir -p ${WORLDTMP}/${_dir}
262 .endfor
263         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
264             -p ${WORLDTMP}/usr/include
265         ln -sf ${.CURDIR}/sys ${WORLDTMP}
266 _legacy:
267         @echo
268         @echo "--------------------------------------------------------------"
269         @echo ">>> stage 1.1: legacy release compatibility shims"
270         @echo "--------------------------------------------------------------"
271         cd ${.CURDIR}; ${BMAKE} legacy
272 _bootstrap-tools:
273         @echo
274         @echo "--------------------------------------------------------------"
275         @echo ">>> stage 1.2: bootstrap tools"
276         @echo "--------------------------------------------------------------"
277         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
278 _cleanobj:
279 .if !defined(NOCLEAN)
280         @echo
281         @echo "--------------------------------------------------------------"
282         @echo ">>> stage 2.1: cleaning up the object tree"
283         @echo "--------------------------------------------------------------"
284         cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
285 .endif
286 _obj:
287         @echo
288         @echo "--------------------------------------------------------------"
289         @echo ">>> stage 2.2: rebuilding the object tree"
290         @echo "--------------------------------------------------------------"
291         cd ${.CURDIR}; ${WMAKE} par-obj
292 _build-tools:
293         @echo
294         @echo "--------------------------------------------------------------"
295         @echo ">>> stage 2.3: build tools"
296         @echo "--------------------------------------------------------------"
297         cd ${.CURDIR}; ${TMAKE} build-tools
298 _cross-tools:
299         @echo
300         @echo "--------------------------------------------------------------"
301         @echo ">>> stage 3: cross tools"
302         @echo "--------------------------------------------------------------"
303         cd ${.CURDIR}; ${XMAKE} cross-tools
304 _includes:
305         @echo
306         @echo "--------------------------------------------------------------"
307         @echo ">>> stage 4.1: building includes"
308         @echo "--------------------------------------------------------------"
309         cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
310 _libraries:
311         @echo
312         @echo "--------------------------------------------------------------"
313         @echo ">>> stage 4.2: building libraries"
314         @echo "--------------------------------------------------------------"
315         cd ${.CURDIR}; \
316             ${WMAKE} -DNOFSCHG -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPROFILE \
317             libraries
318 _depend:
319         @echo
320         @echo "--------------------------------------------------------------"
321         @echo ">>> stage 4.3: make dependencies"
322         @echo "--------------------------------------------------------------"
323         cd ${.CURDIR}; ${WMAKE} par-depend
324 everything:
325         @echo
326         @echo "--------------------------------------------------------------"
327         @echo ">>> stage 4.4: building everything.."
328         @echo "--------------------------------------------------------------"
329         cd ${.CURDIR}; ${WMAKE} par-all
330
331
332 WMAKE_TGTS=
333 .if !defined(SUBDIR_OVERRIDE)
334 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
335 .endif
336 WMAKE_TGTS+=    _cleanobj _obj _build-tools
337 .if !defined(SUBDIR_OVERRIDE)
338 WMAKE_TGTS+=    _cross-tools
339 .endif
340 WMAKE_TGTS+=    _includes _libraries _depend everything
341
342 buildworld: ${WMAKE_TGTS}
343 .ORDER: ${WMAKE_TGTS}
344
345 #
346 # installcheck
347 #
348 # Checks to be sure system is ready for installworld
349 #
350 installcheck:
351 .if !defined(NO_SENDMAIL)
352         @if ! `id -u smmsp > /dev/null`; then \
353                 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
354                 false; \
355         fi
356         @if ! `id -g smmsp > /dev/null`; then \
357                 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
358                 false; \
359         fi
360 .endif
361
362 #
363 # distributeworld
364 #
365 # Distributes everything compiled by a `buildworld'.
366 #
367 # installworld
368 #
369 # Installs everything compiled by a 'buildworld'.
370 #
371 distributeworld installworld: installcheck
372         mkdir -p ${INSTALLTMP}
373         for prog in [ awk cap_mkdb cat chflags chmod chown \
374             date echo egrep find grep \
375             ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
376             test true uname wc zic; do \
377                 cp `which $$prog` ${INSTALLTMP}; \
378         done
379         cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
380         rm -rf ${INSTALLTMP}
381
382 #
383 # reinstall
384 #
385 # If you have a build server, you can NFS mount the source and obj directories
386 # and do a 'make reinstall' on the *client* to install new binaries from the
387 # most recent server build.
388 #
389 reinstall:
390         @echo "--------------------------------------------------------------"
391         @echo ">>> Making hierarchy"
392         @echo "--------------------------------------------------------------"
393         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
394         @echo
395         @echo "--------------------------------------------------------------"
396         @echo ">>> Installing everything.."
397         @echo "--------------------------------------------------------------"
398         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
399
400 redistribute:
401         @echo "--------------------------------------------------------------"
402         @echo ">>> Distributing everything.."
403         @echo "--------------------------------------------------------------"
404         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
405
406 #
407 # buildkernel and installkernel
408 #
409 # Which kernels to build and/or install is specified by setting
410 # KERNCONF. If not defined a GENERIC kernel is built/installed.
411 # Only the existing (depending TARGET) config files are used
412 # for building kernels and only the first of these is designated
413 # as the one being installed.
414 #
415 # Note that we have to use TARGET instead of TARGET_ARCH when
416 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
417 # be set to cross-build, we have to make sure TARGET is set
418 # properly.
419
420 .if !defined(KERNCONF) && defined(KERNEL)
421 KERNCONF=       ${KERNEL}
422 KERNWARN=       yes
423 .else
424 KERNCONF?=      GENERIC
425 .endif
426 INSTKERNNAME?=  kernel
427
428 KERNSRCDIR?=    ${.CURDIR}/sys
429 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
430 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
431 KERNCONFDIR?=   ${KRNLCONFDIR}
432
433 BUILDKERNELS=
434 INSTALLKERNEL=
435 .for _kernel in ${KERNCONF}
436 .if exists(${KERNCONFDIR}/${_kernel})
437 BUILDKERNELS+=  ${_kernel}
438 .if empty(INSTALLKERNEL)
439 INSTALLKERNEL= ${_kernel}
440 .endif
441 .endif
442 .endfor
443
444 #
445 # buildkernel
446 #
447 # Builds all kernels defined by BUILDKERNELS.
448 #
449 buildkernel:
450 .if empty(BUILDKERNELS)
451         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
452         @false
453 .endif
454 .if defined(KERNWARN)
455         @echo "--------------------------------------------------------------"
456         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
457         @echo "--------------------------------------------------------------"
458         @sleep 3
459 .endif
460         @echo
461 .for _kernel in ${BUILDKERNELS}
462         @echo "--------------------------------------------------------------"
463         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
464         @echo "--------------------------------------------------------------"
465         @echo "===> ${_kernel}"
466         mkdir -p ${KRNLOBJDIR}
467 .if !defined(NO_KERNELCONFIG)
468         cd ${KRNLCONFDIR}; \
469                 PATH=${TMPPATH} \
470                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
471                         ${KERNCONFDIR}/${_kernel}
472 .endif
473 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
474         cd ${KRNLOBJDIR}/${_kernel}; \
475             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
476 .endif
477         cd ${KRNLOBJDIR}/${_kernel}; \
478             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
479             ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
480         cd ${KRNLOBJDIR}/${_kernel}; \
481             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
482 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
483 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
484 .for target in obj depend all
485         cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
486             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
487             ${MAKE} -DNO_CPU_CFLAGS ${target}
488 .endfor
489 .endif
490 .if !defined(NO_KERNELDEPEND)
491         cd ${KRNLOBJDIR}/${_kernel}; \
492             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
493 .endif
494         cd ${KRNLOBJDIR}/${_kernel}; \
495             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
496         @echo "--------------------------------------------------------------"
497         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
498         @echo "--------------------------------------------------------------"
499 .endfor
500
501 #
502 # installkernel
503 #
504 # Install the kernel defined by INSTALLKERNEL
505 #
506 installkernel reinstallkernel installkernel.debug reinstallkernel.debug:
507 .if empty(INSTALLKERNEL)
508         @echo "ERROR: No kernel \"${KERNCONF}\" to install."
509         @false
510 .endif
511         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
512             ${CROSSENV} PATH=${TMPPATH} \
513             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
514
515 #
516 # update
517 #
518 # Update the source tree, by running sup and/or running cvs to update to the
519 # latest copy.
520 #
521 update:
522 .if defined(SUP_UPDATE)
523         @echo "--------------------------------------------------------------"
524         @echo ">>> Running ${SUP}"
525         @echo "--------------------------------------------------------------"
526 .if defined(SUPFILE)
527         @${SUP} ${SUPFLAGS} ${SUPFILE}
528 .endif
529 .if defined(SUPFILE1)
530         @${SUP} ${SUPFLAGS} ${SUPFILE1}
531 .endif
532 .if defined(SUPFILE2)
533         @${SUP} ${SUPFLAGS} ${SUPFILE2}
534 .endif
535 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
536         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
537 .endif
538 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
539         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
540 .endif
541 .endif
542 .if defined(CVS_UPDATE)
543         @echo "--------------------------------------------------------------"
544         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
545         @echo "--------------------------------------------------------------"
546         cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
547 .endif
548
549 #
550 # ------------------------------------------------------------------------
551 #
552 # From here onwards are utility targets used by the 'make world' and
553 # related targets.  If your 'world' breaks, you may like to try to fix
554 # the problem and manually run the following targets to attempt to
555 # complete the build.  Beware, this is *not* guaranteed to work, you
556 # need to have a pretty good grip on the current state of the system
557 # to attempt to manually finish it.  If in doubt, 'make world' again.
558 #
559
560 #
561 # legacy: Build compatibility shims for the next three targets
562 #
563 legacy:
564 .for _tool in tools/build
565         @${ECHODIR} "===> ${_tool}"; \
566             cd ${.CURDIR}/${_tool}; \
567             ${MAKE} DIRPRFX=${_tool}/ obj; \
568             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
569             ${MAKE} DIRPRFX=${_tool}/ depend; \
570             ${MAKE} DIRPRFX=${_tool}/ all; \
571             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
572 .endfor
573
574 #
575 # bootstrap-tools: Build tools needed for compatibility
576 #
577 .if !defined(NOGAMES)
578 _strfile=       games/fortune/strfile
579 .endif
580
581 .if !defined(NO_CXX)
582 _gperf= gnu/usr.bin/gperf
583 .if ${BOOTSTRAPPING} < 500113
584 _groff=         gnu/usr.bin/groff
585 .else
586 _groff=         gnu/usr.bin/groff/tmac
587 .endif
588 .endif
589
590 .if ${BOOTSTRAPPING} < 502102
591 _lex=           usr.bin/lex
592 .endif
593
594 .if ${BOOTSTRAPPING} < 450005 || \
595     ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
596 _uudecode=      usr.bin/uudecode
597 .endif
598
599 .if ${BOOTSTRAPPING} < 430002 || \
600     ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
601 _xargs=         usr.bin/xargs
602 .endif
603
604 .if ${BOOTSTRAPPING} < 430002 || \
605     ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
606 _yacc=          usr.bin/yacc
607 .endif
608
609 .if !defined(NO_RESCUE) && \
610     ${BOOTSTRAPPING} < 501100
611 _crunchgen=     usr.sbin/crunch/crunchgen
612 .endif
613
614 .if ${BOOTSTRAPPING} < 501114
615 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
616 .endif
617
618 .if ${BOOTSTRAPPING} < 500019
619 _kbdcontrol=    usr.sbin/kbdcontrol
620 .endif
621
622 bootstrap-tools:
623 .for _tool in \
624     ${_strfile} \
625     ${_gperf} \
626     ${_groff} \
627     gnu/usr.bin/texinfo \
628     usr.bin/colldef \
629     ${_lex} \
630     usr.bin/makewhatis \
631     usr.bin/rpcgen \
632     ${_uudecode} \
633     ${_xargs} \
634     usr.bin/xinstall \
635     ${_yacc} \
636     usr.sbin/config \
637     ${_crunchgen} \
638     ${_gensnmptree} \
639     ${_kbdcontrol}
640         @${ECHODIR} "===> ${_tool}"; \
641                 cd ${.CURDIR}/${_tool}; \
642                 ${MAKE} DIRPRFX=${_tool}/ obj; \
643                 ${MAKE} DIRPRFX=${_tool}/ depend; \
644                 ${MAKE} DIRPRFX=${_tool}/ all; \
645                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
646 .endfor
647
648 #
649 # build-tools: Build special purpose build tools
650 #
651 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
652 _aicasm= sys/modules/aic7xxx/aicasm
653 .endif
654
655 .if !defined(NOSHARE)
656 _share= share/syscons/scrnmaps
657 .endif
658
659 .if !defined(NO_FORTRAN)
660 _fortran= gnu/usr.bin/cc/f771
661 .endif
662
663 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
664 _kerberos5_tools= kerberos5/tools
665 .endif
666
667 .if !defined(NO_RESCUE)
668 _rescue= rescue/rescue
669 .endif
670
671 build-tools:
672 .for _tool in \
673     bin/csh \
674     bin/sh \
675     ${_rescue} \
676     gnu/usr.bin/cc/cc_tools \
677     ${_fortran} \
678     lib/libncurses \
679     ${_share} \
680     ${_aicasm} \
681     usr.bin/awk \
682     usr.bin/file \
683     usr.sbin/sysinstall
684         @${ECHODIR} "===> ${_tool}"; \
685                 cd ${.CURDIR}/${_tool}; \
686                 ${MAKE} DIRPRFX=${_tool}/ obj; \
687                 ${MAKE} DIRPRFX=${_tool}/ build-tools
688 .endfor
689 .for _tool in \
690     ${_kerberos5_tools}
691         @${ECHODIR} "===> ${_tool}"; \
692                 cd ${.CURDIR}/${_tool}; \
693                 ${MAKE} DIRPRFX=${_tool}/ obj; \
694                 ${MAKE} DIRPRFX=${_tool}/ depend; \
695                 ${MAKE} DIRPRFX=${_tool}/ all
696 .endfor
697
698 #
699 # cross-tools: Build cross-building tools
700 #
701 .if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
702     ${BOOTSTRAPPING} < 500037
703 _elf2aout=      usr.bin/elf2aout
704 .endif
705
706 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
707 _btxld=         usr.sbin/btxld
708 .endif
709
710 .if (!defined(NO_RESCUE) || \
711     defined(RELEASEDIR)) && \
712     (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
713 _crunchide=     usr.sbin/crunch/crunchide
714 .endif
715
716 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
717 _elf2exe=       usr.sbin/elf2exe
718 .endif
719
720 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
721     defined(RELEASEDIR)
722 _kgzip=         usr.sbin/kgzip
723 .endif
724
725 cross-tools:
726 .for _tool in \
727     gnu/usr.bin/binutils \
728     gnu/usr.bin/cc \
729     ${_elf2aout} \
730     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
731     ${_btxld} \
732     ${_crunchide} \
733     ${_elf2exe} \
734     ${_kgzip}
735         @${ECHODIR} "===> ${_tool}"; \
736                 cd ${.CURDIR}/${_tool}; \
737                 ${MAKE} DIRPRFX=${_tool}/ obj; \
738                 ${MAKE} DIRPRFX=${_tool}/ depend; \
739                 ${MAKE} DIRPRFX=${_tool}/ all; \
740                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
741 .endfor
742
743 #
744 # hierarchy - ensure that all the needed directories are present
745 #
746 hierarchy:
747         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
748
749 #
750 # libraries - build all libraries, and install them under ${DESTDIR}.
751 #
752 # The list of libraries with dependents (${_prebuild_libs}) and their
753 # interdependencies (__L) are built automatically by the
754 # ${.CURDIR}/tools/make_libdeps.sh script.
755 #
756 libraries:
757         cd ${.CURDIR}; \
758             ${MAKE} -f Makefile.inc1 _startup_libs; \
759             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
760             ${MAKE} -f Makefile.inc1 _generic_libs;
761
762 # These dependencies are not automatically generated:
763 #
764 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
765 # shared libraries for ELF.
766 #
767 _startup_libs=  gnu/lib/csu gnu/lib/libgcc
768 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
769 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
770 .else
771 _startup_libs+= lib/csu/${MACHINE_ARCH}
772 .endif
773
774 _prebuild_libs=
775
776 _generic_libs=  gnu/lib
777
778 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
779 _prebuild_libs+=        kerberos5/lib/libasn1
780 _prebuild_libs+=        kerberos5/lib/libgssapi
781 _prebuild_libs+=        kerberos5/lib/libkrb5
782 _prebuild_libs+=        kerberos5/lib/libroken
783 _generic_libs+= kerberos5/lib
784 .endif
785
786 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
787                 lib/libkvm lib/libmd \
788                 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
789                 lib/libradius lib/librpcsvc \
790                 lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
791                 lib/libz lib/msun
792
793 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
794 lib/libypclnt__L: lib/librpcsvc__L
795
796 _generic_libs+= lib
797
798 .if !defined(NOCRYPT)
799 .if !defined(NO_OPENSSL)
800 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
801 .if !defined(NO_OPENSSH)
802 _prebuild_libs+=        secure/lib/libssh
803 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
804 .endif
805 .endif
806 _generic_libs+= secure/lib
807 .endif
808
809 _generic_libs+= usr.bin/lex/lib
810
811 .if ${MACHINE_ARCH} == "i386"
812 _generic_libs+= usr.sbin/pcvt/keycap
813 .endif
814
815 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
816 ${_lib}__L: .PHONY
817 .if exists(${.CURDIR}/${_lib})
818         @${ECHODIR} "===> ${_lib}"; \
819                 cd ${.CURDIR}/${_lib}; \
820                 ${MAKE} DIRPRFX=${_lib}/ depend; \
821                 ${MAKE} DIRPRFX=${_lib}/ all; \
822                 ${MAKE} DIRPRFX=${_lib}/ install
823 .endif
824 .endfor
825
826 # libpam is special: we need to build static PAM modules before
827 # static PAM library, and dynamic PAM library before dynamic PAM
828 # modules.
829 lib/libpam__L: .PHONY
830         @${ECHODIR} "===> lib/libpam"; \
831                 cd ${.CURDIR}/lib/libpam; \
832                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
833                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
834                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
835
836 _startup_libs: ${_startup_libs:S/$/__L/}
837 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
838 _generic_libs: ${_generic_libs:S/$/__L/}
839
840 .for __target in all clean cleandepend cleandir depend includes obj
841 .for entry in ${SUBDIR}
842 ${entry}.${__target}__D: .PHONY
843         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
844                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
845                 edir=${entry}.${MACHINE_ARCH}; \
846                 cd ${.CURDIR}/$${edir}; \
847         else \
848                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
849                 edir=${entry}; \
850                 cd ${.CURDIR}/$${edir}; \
851         fi; \
852         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
853 .endfor
854 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
855 .endfor
856
857 .include <bsd.subdir.mk>