]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Fix an include for NetBSD
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DMAKE_KERBEROS4 to build KerberosIV
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 #       -DNOPROFILE do not build profiled libraries
11 #       -DNOSECURE do not go into secure subdir
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_PERL do not build perl5 and related libraries
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 # most        - build user commands, no libraries or include files
32 # installmost - install user commands, no libraries or include files
33 #
34 # Standard targets (not defined here) are documented in the makefiles in
35 # /usr/share/mk.  These include:
36 #               obj depend all install clean cleandepend cleanobj
37
38 # Put initial settings here.
39 SUBDIR=
40
41 # We must do share/info early so that installation of info `dir'
42 # entries works correctly.  Do it first since it is less likely to
43 # grow dependencies on include and lib than vice versa.
44 .if exists(${.CURDIR}/share/info)
45 SUBDIR+= share/info
46 .endif
47
48 # We must do include and lib early so that the perl *.ph generation
49 # works correctly as it uses the header files installed by this.
50 .if exists(${.CURDIR}/include)
51 SUBDIR+= include
52 .endif
53 .if exists(${.CURDIR}/lib)
54 SUBDIR+= lib
55 .endif
56
57 .if exists(${.CURDIR}/bin)
58 SUBDIR+= bin
59 .endif
60 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
61 SUBDIR+= games
62 .endif
63 .if exists(${.CURDIR}/gnu)
64 SUBDIR+= gnu
65 .endif
66 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
67     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
68 SUBDIR+= kerberosIV
69 .endif
70 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
71     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
72 SUBDIR+= kerberos5
73 .endif
74 .if exists(${.CURDIR}/libexec)
75 SUBDIR+= libexec
76 .endif
77 .if exists(${.CURDIR}/sbin)
78 SUBDIR+= sbin
79 .endif
80 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
81 SUBDIR+= secure
82 .endif
83 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
84 SUBDIR+= share
85 .endif
86 .if exists(${.CURDIR}/sys)
87 SUBDIR+= sys
88 .endif
89 .if exists(${.CURDIR}/usr.bin)
90 SUBDIR+= usr.bin
91 .endif
92 .if exists(${.CURDIR}/usr.sbin)
93 SUBDIR+= usr.sbin
94 .endif
95
96 # etc must be last for "distribute" to work
97 .if exists(${.CURDIR}/etc)
98 SUBDIR+= etc
99 .endif
100
101 # These are last, since it is nice to at least get the base system
102 # rebuilt before you do them.
103 .if defined(LOCAL_DIRS)
104 .for _DIR in ${LOCAL_DIRS}
105 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
106 SUBDIR+= ${_DIR}
107 .endif
108 .endfor
109 .endif
110
111 .if defined(SUBDIR_OVERRIDE)
112 SUBDIR=         ${SUBDIR_OVERRIDE}
113 .endif
114
115 .if defined(NOCLEANDIR)
116 CLEANDIR=       clean cleandepend
117 .else
118 CLEANDIR=       cleandir
119 .endif
120
121 CVS?=           cvs
122 SUP?=           /usr/local/bin/cvsup
123 SUPFLAGS?=      -g -L 2 -P -
124 .if defined(SUPHOST)
125 SUPFLAGS+=      -h ${SUPHOST}
126 .endif
127
128 MAKEOBJDIRPREFIX?=      /usr/obj
129 TARGET_ARCH?=   ${MACHINE_ARCH}
130 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
131 TARGET?=        ${MACHINE}
132 .else
133 TARGET?=        ${TARGET_ARCH}
134 .endif
135 .if make(buildworld)
136 BUILD_ARCH!=    sysctl -n hw.machine_arch
137 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
138 .error To cross-build, set TARGET_ARCH.
139 .endif
140 .endif
141 .if ${MACHINE} == ${TARGET}
142 OBJTREE=        ${MAKEOBJDIRPREFIX}
143 .else
144 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
145 .endif
146 WORLDTMP=       ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
147 # /usr/games added for fortune which depend on strfile
148 STRICTTMPPATH=  ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
149 TMPPATH=        ${STRICTTMPPATH}:${PATH}
150 OBJFORMAT_PATH?=        /usr/libexec
151
152 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
153
154 #
155 # Building a world goes through the following stages
156 #
157 # 1. bootstrap-tool stage [BMAKE]
158 #       This stage is responsible for creating programs that
159 #       are needed for backward compatibility reasons. They
160 #       are not built as cross-tools.
161 # 2. build-tool stage [TMAKE]
162 #       This stage is responsible for creating the object
163 #       tree and building any tools that are needed during
164 #       the build process.
165 # 3. cross-tool stage [XMAKE]
166 #       This stage is responsible for creating any tools that
167 #       are needed for cross-builds. A cross-compiler is one
168 #       of them.
169 # 4. world stage [WMAKE]
170 #       This stage actually builds the world.
171 # 5. install stage (optional) [IMAKE]
172 #       This stage installs a previously built world.
173 #
174
175 # Common environment for world related stages
176 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
177                 MACHINE_ARCH=${TARGET_ARCH} \
178                 MACHINE=${TARGET} \
179                 OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
180                 PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.1 \
181                 GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
182                 GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
183                 GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
184
185 # bootstrap-tool stage
186 BMAKEENV=       MAKEOBJDIRPREFIX=${WORLDTMP} \
187                 DESTDIR= \
188                 INSTALL="sh ${.CURDIR}/tools/install.sh"
189 BMAKE=          ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
190                 -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
191                 -DNO_WERROR
192
193 # build-tool stage
194 TMAKEENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
195                 DESTDIR= \
196                 INSTALL="sh ${.CURDIR}/tools/install.sh"
197 TMAKE=          ${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING
198
199 # cross-tool stage
200 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
201
202 # world stage
203 WMAKEENV=       ${CROSSENV} \
204                 DESTDIR=${WORLDTMP} \
205                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
206                 PATH=${TMPPATH}
207 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1
208
209 # install stage
210 IMAKEENV=       ${CROSSENV} \
211                 PATH=${STRICTTMPPATH}:${INSTALLTMP}
212 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
213
214 # kernel stage
215 KMAKEENV=       ${WMAKEENV} \
216                 OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
217
218 USRDIRS=        usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
219                 usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc \
220                 usr/share/dict \
221                 usr/share/groff_font/devX100 \
222                 usr/share/groff_font/devX100-12 \
223                 usr/share/groff_font/devX75 \
224                 usr/share/groff_font/devX75-12 \
225                 usr/share/groff_font/devascii \
226                 usr/share/groff_font/devcp1047 \
227                 usr/share/groff_font/devdvi \
228                 usr/share/groff_font/devhtml \
229                 usr/share/groff_font/devkoi8-r \
230                 usr/share/groff_font/devlatin1 \
231                 usr/share/groff_font/devlbp \
232                 usr/share/groff_font/devlj4 \
233                 usr/share/groff_font/devps \
234                 usr/share/groff_font/devutf8 \
235                 usr/share/tmac/mdoc usr/share/tmac/mm
236
237 INCDIRS=        arpa dev fs g++/std isc isofs libmilter objc openssl \
238                 protocols readline rpc rpcsvc security ufs
239
240 #
241 # buildworld
242 #
243 # Attempt to rebuild the entire system, with reasonable chance of
244 # success, regardless of how old your existing system is.
245 #
246 _worldtmp:
247         @echo
248         @echo "--------------------------------------------------------------"
249         @echo ">>> Rebuilding the temporary build tree"
250         @echo "--------------------------------------------------------------"
251 .if !defined(NOCLEAN)
252         rm -rf ${WORLDTMP}
253 .else
254         # XXX - These two can depend on any header file.
255         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
256         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
257 .endif
258 .for _dir in ${USRDIRS}
259         mkdir -p ${WORLDTMP}/${_dir}
260 .endfor
261 .for _dir in ${INCDIRS}
262         mkdir -p ${WORLDTMP}/usr/include/${_dir}
263 .endfor
264         ln -sf ${.CURDIR}/sys ${WORLDTMP}
265 _bootstrap-tools:
266         @echo
267         @echo "--------------------------------------------------------------"
268         @echo ">>> stage 1: bootstrap tools"
269         @echo "--------------------------------------------------------------"
270         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
271 _cleanobj:
272 .if !defined(NOCLEAN)
273         @echo
274         @echo "--------------------------------------------------------------"
275         @echo ">>> stage 2: cleaning up the object tree"
276         @echo "--------------------------------------------------------------"
277         cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
278 .endif
279 _obj:
280         @echo
281         @echo "--------------------------------------------------------------"
282         @echo ">>> stage 2: rebuilding the object tree"
283         @echo "--------------------------------------------------------------"
284         cd ${.CURDIR}; ${WMAKE} par-obj
285 _build-tools:
286         @echo
287         @echo "--------------------------------------------------------------"
288         @echo ">>> stage 2: build tools"
289         @echo "--------------------------------------------------------------"
290         cd ${.CURDIR}; ${TMAKE} build-tools
291 _cross-tools:
292         @echo
293         @echo "--------------------------------------------------------------"
294         @echo ">>> stage 3: cross tools"
295         @echo "--------------------------------------------------------------"
296         cd ${.CURDIR}; ${XMAKE} cross-tools
297 _includes:
298         @echo
299         @echo "--------------------------------------------------------------"
300         @echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
301         @echo "--------------------------------------------------------------"
302         cd ${.CURDIR}; ${WMAKE} includes; ${WMAKE} SHARED=symlinks incsinstall
303 _libraries:
304         @echo
305         @echo "--------------------------------------------------------------"
306         @echo ">>> stage 4: building libraries"
307         @echo "--------------------------------------------------------------"
308         cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
309 _depend:
310         @echo
311         @echo "--------------------------------------------------------------"
312         @echo ">>> stage 4: make dependencies"
313         @echo "--------------------------------------------------------------"
314         cd ${.CURDIR}; ${WMAKE} par-depend
315 everything:
316         @echo
317         @echo "--------------------------------------------------------------"
318         @echo ">>> stage 4: building everything.."
319         @echo "--------------------------------------------------------------"
320         cd ${.CURDIR}; ${WMAKE} all
321
322
323 WMAKE_TGTS=
324 .if !defined(SUBDIR_OVERRIDE)
325 WMAKE_TGTS+=    _worldtmp _bootstrap-tools
326 .endif
327 WMAKE_TGTS+=    _cleanobj _obj _build-tools
328 .if !defined(SUBDIR_OVERRIDE)
329 WMAKE_TGTS+=    _cross-tools
330 .endif
331 WMAKE_TGTS+=    _includes _libraries _depend everything
332
333 buildworld: ${WMAKE_TGTS}
334 .ORDER: ${WMAKE_TGTS}
335
336 #
337 # installcheck
338 #
339 # Checks to be sure system is ready for installworld
340 #
341 installcheck:
342 .if !defined(NO_SENDMAIL)
343         @if ! `grep -q '^smmsp:' /etc/passwd`; then \
344                 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
345                 false; \
346         fi
347         @if ! `grep -q '^smmsp:' /etc/group`; then \
348                 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
349                 false; \
350         fi
351 .endif
352
353 #
354 # distributeworld
355 #
356 # Distributes everything compiled by a `buildworld'.
357 #
358 # installworld
359 #
360 # Installs everything compiled by a 'buildworld'.
361 #
362 distributeworld installworld: installcheck
363         mkdir -p ${INSTALLTMP}
364         for prog in [ awk cat chflags chmod chown date echo egrep find grep \
365             ln make makewhatis mkdir mtree mv perl pwd_mkdb rm sed sh sysctl \
366             test true uname wc zic; do \
367                 cp `which $$prog` ${INSTALLTMP}; \
368         done
369         cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
370         rm -rf ${INSTALLTMP}
371
372 #
373 # reinstall
374 #
375 # If you have a build server, you can NFS mount the source and obj directories
376 # and do a 'make reinstall' on the *client* to install new binaries from the
377 # most recent server build.
378 #
379 reinstall:
380         @echo "--------------------------------------------------------------"
381         @echo ">>> Making hierarchy"
382         @echo "--------------------------------------------------------------"
383         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
384         @echo
385         @echo "--------------------------------------------------------------"
386         @echo ">>> Installing everything.."
387         @echo "--------------------------------------------------------------"
388         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
389 .if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
390         @echo
391         @echo "--------------------------------------------------------------"
392         @echo ">>> Rebuilding man page indices"
393         @echo "--------------------------------------------------------------"
394         cd ${.CURDIR}/share/man; ${MAKE} makedb
395 .endif
396
397 redistribute:
398         @echo "--------------------------------------------------------------"
399         @echo ">>> Distributing everything.."
400         @echo "--------------------------------------------------------------"
401         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
402
403 #
404 # buildkernel and installkernel
405 #
406 # Which kernels to build and/or install is specified by setting
407 # KERNCONF. If not defined a GENERIC kernel is built/installed.
408 # Only the existing (depending TARGET) config files are used
409 # for building kernels and only the first of these is designated
410 # as the one being installed.
411 #
412 # Note that we have to use TARGET instead of TARGET_ARCH when
413 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
414 # be set to cross-build, we have to make sure TARGET is set
415 # properly.
416
417 .if !defined(KERNCONF) && defined(KERNEL)
418 KERNCONF=       ${KERNEL}
419 KERNWARN=       yes
420 .else
421 KERNCONF?=      GENERIC
422 .endif
423 INSTKERNNAME?=  kernel
424
425 KRNLSRCDIR=     ${.CURDIR}/sys
426 KRNLCONFDIR=    ${KRNLSRCDIR}/${TARGET}/conf
427 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
428 KERNCONFDIR?=   ${KRNLCONFDIR}
429
430 BUILDKERNELS=
431 INSTALLKERNEL=
432 .for _kernel in ${KERNCONF}
433 .if exists(${KERNCONFDIR}/${_kernel})
434 BUILDKERNELS+=  ${_kernel}
435 .if empty(INSTALLKERNEL)
436 INSTALLKERNEL= ${_kernel}
437 .endif
438 .endif
439 .endfor
440
441 #
442 # buildkernel
443 #
444 # Builds all kernels defined by BUILDKERNELS.
445 #
446 buildkernel:
447 .if empty(BUILDKERNELS)
448         @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
449         @false
450 .endif
451 .if defined(KERNWARN)
452         @echo "--------------------------------------------------------------"
453         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
454         @echo "--------------------------------------------------------------"
455         @sleep 3
456 .endif
457         @echo
458 .for _kernel in ${BUILDKERNELS}
459         @echo "--------------------------------------------------------------"
460         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
461         @echo "--------------------------------------------------------------"
462         @echo "===> ${_kernel}"
463         mkdir -p ${KRNLOBJDIR}
464 .if !defined(NO_KERNELCONFIG)
465         cd ${KRNLCONFDIR}; \
466                 PATH=${TMPPATH} \
467                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
468                         ${KERNCONFDIR}/${_kernel}
469 .endif
470 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
471         cd ${KRNLOBJDIR}/${_kernel}; \
472             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
473 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
474         cd ${KRNLOBJDIR}/${_kernel}; \
475             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
476 .endif
477 .endif
478         cd ${KRNLOBJDIR}/${_kernel}; \
479                 MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
480                     ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
481 .if !defined(NO_KERNELDEPEND)
482         cd ${KRNLOBJDIR}/${_kernel}; \
483             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
484 .endif
485         cd ${KRNLOBJDIR}/${_kernel}; \
486             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
487         @echo "--------------------------------------------------------------"
488         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
489         @echo "--------------------------------------------------------------"
490 .endfor
491
492 #
493 # installkernel
494 #
495 # Install the kernel defined by INSTALLKERNEL
496 #
497 installkernel reinstallkernel:
498         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
499             ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
500
501 #
502 # update
503 #
504 # Update the source tree, by running sup and/or running cvs to update to the
505 # latest copy.
506 #
507 update:
508 .if defined(SUP_UPDATE)
509         @echo "--------------------------------------------------------------"
510         @echo ">>> Running ${SUP}"
511         @echo "--------------------------------------------------------------"
512 .if defined(SUPFILE)
513         @${SUP} ${SUPFLAGS} ${SUPFILE}
514 .endif
515 .if defined(SUPFILE1)
516         @${SUP} ${SUPFLAGS} ${SUPFILE1}
517 .endif
518 .if defined(SUPFILE2)
519         @${SUP} ${SUPFLAGS} ${SUPFILE2}
520 .endif
521 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
522         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
523 .endif
524 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
525         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
526 .endif
527 .endif
528 .if defined(CVS_UPDATE)
529         @echo "--------------------------------------------------------------"
530         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
531         @echo "--------------------------------------------------------------"
532         cd ${.CURDIR}; ${CVS} -q update -A -P -d
533 .endif
534
535 #
536 # most
537 #
538 # Build most of the user binaries on the existing system libs and includes.
539 #
540 most:
541         @echo "--------------------------------------------------------------"
542         @echo ">>> Building programs only"
543         @echo "--------------------------------------------------------------"
544 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
545         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ all
546 .endfor
547
548 #
549 # installmost
550 #
551 # Install the binaries built by the 'most' target.  This does not include
552 # libraries or include files.
553 #
554 installmost:
555         @echo "--------------------------------------------------------------"
556         @echo ">>> Installing programs only"
557         @echo "--------------------------------------------------------------"
558 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/usr.bin gnu/usr.sbin
559         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ install
560 .endfor
561
562 #
563 # ------------------------------------------------------------------------
564 #
565 # From here onwards are utility targets used by the 'make world' and
566 # related targets.  If your 'world' breaks, you may like to try to fix
567 # the problem and manually run the following targets to attempt to
568 # complete the build.  Beware, this is *not* guaranteed to work, you
569 # need to have a pretty good grip on the current state of the system
570 # to attempt to manually finish it.  If in doubt, 'make world' again.
571 #
572
573 #
574 # bootstrap-tools: Build tools needed for compatibility
575 #
576 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
577 _strfile=       games/fortune/strfile
578 .endif
579 .if ${CXX} != "c++"
580 _cxx_consumers= gnu/usr.bin/gperf gnu/usr.bin/groff
581 .endif
582
583 bootstrap-tools:
584 .for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
585     usr.bin/rpcgen usr.bin/xargs usr.bin/xinstall \
586     usr.sbin/config usr.sbin/kbdcontrol \
587     ${_cxx_consumers} gnu/usr.bin/texinfo
588         cd ${.CURDIR}/${_tool}; \
589                 ${MAKE} DIRPRFX=${_tool}/ obj; \
590                 ${MAKE} DIRPRFX=${_tool}/ depend; \
591                 ${MAKE} DIRPRFX=${_tool}/ all; \
592                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
593 .endfor
594
595 #
596 # build-tools: Build special purpose build tools
597 #
598 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
599 _games= games/adventure games/hack games/phantasia
600 .endif
601
602 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
603 _share= share/syscons/scrnmaps
604 .endif
605
606 .if !defined(NO_FORTRAN)
607 _fortran= gnu/usr.bin/cc/f771
608 .endif
609
610 .if !defined(NOPERL) && !defined(NO_PERL)
611 _perl=  gnu/usr.bin/perl/miniperl
612 .endif
613
614 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
615     !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
616 _libroken4= kerberosIV/lib/libroken
617 .endif
618
619 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
620     !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
621 _libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
622     kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
623 .endif
624
625 build-tools:
626 .for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
627     ${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
628     usr.bin/awk usr.bin/file usr.sbin/sysinstall
629         cd ${.CURDIR}/${_tool}; ${MAKE} DIRPRFX=${_tool}/ build-tools
630 .endfor
631
632 #
633 # cross-tools: Build cross-building tools
634 #
635 .if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
636 _elf2exe=       usr.sbin/elf2exe
637 .endif
638
639 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
640 _btxld= usr.sbin/btxld
641 .endif
642
643 _xlint= usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
644
645 cross-tools:
646 .for _tool in ${_btxld} ${_elf2exe} \
647     gnu/usr.bin/binutils usr.bin/objformat usr.sbin/crunch/crunchide \
648     gnu/usr.bin/cc ${_xlint}
649         cd ${.CURDIR}/${_tool}; \
650                 ${MAKE} DIRPRFX=${_tool}/ obj; \
651                 ${MAKE} DIRPRFX=${_tool}/ depend; \
652                 ${MAKE} DIRPRFX=${_tool}/ all; \
653                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
654 .endfor
655
656 #
657 # hierarchy - ensure that all the needed directories are present
658 #
659 hierarchy:
660         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
661
662 .if ${CXX} == "c++"
663 NO_CXX= yes
664 .endif
665
666 #
667 # libraries - build all libraries, and install them under ${DESTDIR}.
668 #
669 # The list of libraries with dependents (${_prebuild_libs}) and their
670 # interdependencies (__L) are built automatically by the
671 # ${.CURDIR}/tools/make_libdeps.sh script.
672 #
673 libraries:
674         cd ${.CURDIR}; \
675             ${MAKE} -f Makefile.inc1 _startup_libs; \
676             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
677             ${MAKE} -f Makefile.inc1 _generic_libs;
678
679 # These dependencies are not automatically generated:
680 #
681 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
682 # shared libraries for ELF.
683 #
684 _startup_libs=  gnu/lib/csu gnu/lib/libgcc
685 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-${OBJFORMAT})
686 _startup_libs+= lib/csu/${MACHINE_ARCH}-${OBJFORMAT}
687 .else
688 _startup_libs+= lib/csu/${MACHINE_ARCH}
689 .endif
690
691 _prebuild_libs=
692
693 _generic_libs=  gnu/lib
694
695 .if !defined(NOPERL) && !defined(NO_PERL)
696 _generic_libs+= gnu/usr.bin/perl/libperl
697 .endif
698
699 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
700 _prebuild_libs+=        kerberos5/lib/libasn1
701 _prebuild_libs+=        kerberos5/lib/libgssapi
702 _prebuild_libs+=        kerberos5/lib/libkrb5
703 _prebuild_libs+=        kerberos5/lib/libroken
704 _generic_libs+= kerberos5/lib
705 .endif
706
707 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
708 _prebuild_libs+=        kerberosIV/lib/libkrb
709 kerberosIV/lib/libkrb__L: lib/libcrypt__L
710 _generic_libs+= kerberosIV/lib
711 .endif
712
713 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libkvm lib/libmd \
714                 lib/libncurses lib/libopie lib/libradius lib/librpcsvc \
715                 lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
716                 lib/libz lib/msun
717
718 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
719 lib/libypclnt__L: lib/librpcsvc__L
720
721 _generic_libs+= lib
722
723 .if !defined(NOCRYPT) && !defined(NOSECURE)
724 _prebuild_libs+=        secure/lib/libcrypto
725 .if !defined(NO_OPENSSH)
726 _prebuild_libs+=        secure/lib/libssh
727 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
728 .endif
729 _generic_libs+= secure/lib
730 .endif
731
732 _generic_libs+= usr.bin/lex/lib
733
734 .if ${MACHINE_ARCH} == "i386"
735 _generic_libs+= usr.sbin/pcvt/keycap
736 .endif
737
738 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
739 ${_lib}__L: .PHONY
740 .if exists(${.CURDIR}/${_lib})
741         cd ${.CURDIR}/${_lib}; \
742                 ${MAKE} DIRPRFX=${_lib}/ depend; \
743                 ${MAKE} DIRPRFX=${_lib}/ all; \
744                 ${MAKE} DIRPRFX=${_lib}/ install
745 .endif
746 .endfor
747
748 _startup_libs: ${_startup_libs:S/$/__L/}
749 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
750 _generic_libs: ${_generic_libs:S/$/__L/}
751
752 .for __target in clean cleandepend cleandir depend obj
753 .for entry in ${SUBDIR}
754 ${entry}.${__target}__D: .PHONY
755         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
756                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
757                 edir=${entry}.${MACHINE_ARCH}; \
758                 cd ${.CURDIR}/$${edir}; \
759         else \
760                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
761                 edir=${entry}; \
762                 cd ${.CURDIR}/$${edir}; \
763         fi; \
764         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
765 .endfor
766 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
767 .endfor
768
769 .include <bsd.subdir.mk>