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