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