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