Patch this file to allow the crossbuild to work again
[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.20 2004/02/02 05:43:07 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 # 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 # /usr/bin/gccX                 version-specific gcc binaries
221 # /usr/lib/gccX                 version-specific gcc libraries
222 # /usr/libexec/gccX             version-specific gcc helper binaries
223 # /usr/libexec/binutilsXXX      version-specific binutils
224
225 USRDIRS=        usr/bin \
226                 usr/lib/gcc2 usr/lib/gcc3 \
227                 usr/libexec/gcc2 usr/libexec/gcc3 \
228                 usr/lib/compat/aout usr/games \
229                 usr/libdata \
230                 usr/libexec/binutils212 \
231                 usr/libexec/binutils212/elf \
232                 usr/libexec/binutils212/aout \
233                 usr/libexec/binutils212/ldscripts \
234                 usr/libexec/binutils214 \
235                 usr/libexec/binutils214/elf \
236                 usr/libexec/binutils214/ldscripts \
237                 usr/sbin usr/share/misc \
238                 usr/share/dict \
239                 usr/share/groff_font/devX100 \
240                 usr/share/groff_font/devX100-12 \
241                 usr/share/groff_font/devX75 \
242                 usr/share/groff_font/devX75-12 \
243                 usr/share/groff_font/devascii \
244                 usr/share/groff_font/devcp1047 \
245                 usr/share/groff_font/devdvi \
246                 usr/share/groff_font/devhtml \
247                 usr/share/groff_font/devkoi8-r \
248                 usr/share/groff_font/devlatin1 \
249                 usr/share/groff_font/devlbp \
250                 usr/share/groff_font/devlj4 \
251                 usr/share/groff_font/devps \
252                 usr/share/groff_font/devutf8 \
253                 usr/share/tmac/mdoc usr/share/tmac/mm
254
255 # XXX remove in favor of the BSD.include.dist mtree that we already have.
256 #
257 INCDIRS=        arpa dev c++/2.95 isc libmilter objc openssl \
258                 protocols readline rpc rpcsvc security
259
260 #
261 # buildworld
262 #
263 # Attempt to rebuild the entire system, with reasonable chance of
264 # success, regardless of how old your existing system is.
265 #
266 _worldtmp:
267         @echo
268         @echo "--------------------------------------------------------------"
269         @echo ">>> Rebuilding the temporary build tree"
270         @echo "--------------------------------------------------------------"
271 .if !defined(NOCLEAN)
272         rm -rf ${WORLDTMP}
273 .else
274         # XXX - These two can depend on any header file.
275         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
276         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
277 .endif
278 .for _dir in ${USRDIRS}
279         mkdir -p ${WORLDTMP}/${_dir}
280 .endfor
281 .for _dir in ${INCDIRS}
282         mkdir -p ${WORLDTMP}/usr/include/${_dir}
283 .endfor
284         ln -sf ${.CURDIR}/sys ${WORLDTMP}
285 _bootstrap-tools:
286         @echo
287         @echo "--------------------------------------------------------------"
288         @echo ">>> stage 1: bootstrap tools"
289         @echo "--------------------------------------------------------------"
290         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
291 _cleanobj:
292 .if !defined(NOCLEAN)
293         @echo
294         @echo "--------------------------------------------------------------"
295         @echo ">>> stage 2: cleaning up the object tree"
296         @echo "--------------------------------------------------------------"
297         cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
298 .endif
299 _obj:
300         @echo
301         @echo "--------------------------------------------------------------"
302         @echo ">>> stage 2: rebuilding the object tree"
303         @echo "--------------------------------------------------------------"
304         cd ${.CURDIR}; ${WMAKE} par-obj
305 _build-tools:
306         @echo
307         @echo "--------------------------------------------------------------"
308         @echo ">>> stage 2: build tools"
309         @echo "--------------------------------------------------------------"
310         cd ${.CURDIR}; ${TMAKE} build-tools
311 _cross-tools:
312         @echo
313         @echo "--------------------------------------------------------------"
314         @echo ">>> stage 3: cross tools"
315         @echo "--------------------------------------------------------------"
316         cd ${.CURDIR}; ${XMAKE} cross-tools
317 _includes:
318         @echo
319         @echo "--------------------------------------------------------------"
320         @echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
321         @echo "--------------------------------------------------------------"
322         cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
323 _libraries:
324         @echo
325         @echo "--------------------------------------------------------------"
326         @echo ">>> stage 4: building libraries"
327         @echo "--------------------------------------------------------------"
328         cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
329 _depend:
330         @echo
331         @echo "--------------------------------------------------------------"
332         @echo ">>> stage 4: make dependencies"
333         @echo "--------------------------------------------------------------"
334         cd ${.CURDIR}; ${WMAKE} par-depend
335 everything:
336         @echo
337         @echo "--------------------------------------------------------------"
338         @echo ">>> stage 4: building everything.."
339         @echo "--------------------------------------------------------------"
340         cd ${.CURDIR}; ${WMAKE} all
341
342
343 WMAKE_TGTS=
344 .if !defined(SUBDIR_OVERRIDE)
345 WMAKE_TGTS+=    _worldtmp _bootstrap-tools
346 .endif
347 WMAKE_TGTS+=    _cleanobj _obj _build-tools
348 .if !defined(SUBDIR_OVERRIDE)
349 WMAKE_TGTS+=    _cross-tools
350 .endif
351 WMAKE_TGTS+=    _includes _libraries _depend everything
352
353 buildworld: ${WMAKE_TGTS}
354 .ORDER: ${WMAKE_TGTS}
355
356 #
357 # installcheck
358 #
359 # Checks to be sure system is ready for installworld
360 #
361 installcheck:
362 .if !defined(NO_SENDMAIL)
363         @if ! `id -u smmsp > /dev/null`; then \
364                 echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
365                 false; \
366         fi
367         @if ! `id -g smmsp > /dev/null`; then \
368                 echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
369                 false; \
370         fi
371 .endif
372
373 #
374 # distributeworld
375 #
376 # Distributes everything compiled by a `buildworld'.
377 #
378 # installworld
379 #
380 # Installs everything compiled by a 'buildworld'.
381 #
382 distributeworld installworld: installcheck
383         mkdir -p ${INSTALLTMP}
384         for prog in [ awk cap_mkdb cat chflags chmod chown \
385             date echo egrep find grep \
386             ln make makewhatis mkdir mtree mv perl pwd_mkdb rm sed sh sysctl \
387             test true uname wc zic; do \
388                 cp `which $$prog` ${INSTALLTMP}; \
389         done
390         cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
391         rm -rf ${INSTALLTMP}
392
393 #
394 # reinstall
395 #
396 # If you have a build server, you can NFS mount the source and obj directories
397 # and do a 'make reinstall' on the *client* to install new binaries from the
398 # most recent server build.
399 #
400 reinstall:
401         @echo "--------------------------------------------------------------"
402         @echo ">>> Making hierarchy"
403         @echo "--------------------------------------------------------------"
404         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
405         @echo
406         @echo "--------------------------------------------------------------"
407         @echo ">>> Installing everything.."
408         @echo "--------------------------------------------------------------"
409         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
410 .if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
411         @echo
412         @echo "--------------------------------------------------------------"
413         @echo ">>> Rebuilding man page indices"
414         @echo "--------------------------------------------------------------"
415         cd ${.CURDIR}/share/man; ${MAKE} makedb
416 .endif
417
418 redistribute:
419         @echo "--------------------------------------------------------------"
420         @echo ">>> Distributing everything.."
421         @echo "--------------------------------------------------------------"
422         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
423
424 #
425 # buildkernel and installkernel
426 #
427 # Which kernels to build and/or install is specified by setting
428 # KERNCONF. If not defined a GENERIC kernel is built/installed.
429 # Only the existing (depending TARGET) config files are used
430 # for building kernels and only the first of these is designated
431 # as the one being installed.
432 #
433 # Note that we have to use TARGET instead of TARGET_ARCH when
434 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
435 # be set to cross-build, we have to make sure TARGET is set
436 # properly.
437
438 .if !defined(KERNCONF) && defined(KERNEL)
439 KERNCONF=       ${KERNEL}
440 KERNWARN=       yes
441 .else
442 KERNCONF?=      GENERIC
443 .endif
444 INSTKERNNAME?=  kernel
445
446 KRNLSRCDIR=     ${.CURDIR}/sys
447 KRNLCONFDIR=    ${KRNLSRCDIR}/${TARGET}/conf
448 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
449 KERNCONFDIR?=   ${KRNLCONFDIR}
450
451 BUILDKERNELS=
452 INSTALLKERNEL=
453 .for _kernel in ${KERNCONF}
454 .if exists(${KERNCONFDIR}/${_kernel})
455 BUILDKERNELS+=  ${_kernel}
456 .if empty(INSTALLKERNEL)
457 INSTALLKERNEL= ${_kernel}
458 .endif
459 .endif
460 .endfor
461
462 #
463 # buildkernel
464 #
465 # Builds all kernels defined by BUILDKERNELS.
466 #
467 buildkernel:
468 .if empty(BUILDKERNELS)
469         @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
470         @false
471 .endif
472 .if defined(KERNWARN)
473         @echo "--------------------------------------------------------------"
474         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
475         @echo "--------------------------------------------------------------"
476         @sleep 3
477 .endif
478         @echo
479 .for _kernel in ${BUILDKERNELS}
480         @echo "--------------------------------------------------------------"
481         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
482         @echo "--------------------------------------------------------------"
483         @echo "===> ${_kernel}"
484         mkdir -p ${KRNLOBJDIR}
485 .if !defined(NO_KERNELCONFIG)
486         cd ${KRNLCONFDIR}; \
487                 PATH=${TMPPATH} \
488                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
489                         ${KERNCONFDIR}/${_kernel}
490 .endif
491 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
492         cd ${KRNLOBJDIR}/${_kernel}; \
493             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
494 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
495         cd ${KRNLOBJDIR}/${_kernel}; \
496             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
497 .endif
498 .endif
499         cd ${KRNLOBJDIR}/${_kernel}; \
500             MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
501             ${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
502 .if !defined(NO_KERNELDEPEND)
503         cd ${KRNLOBJDIR}/${_kernel}; \
504             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
505 .endif
506         cd ${KRNLOBJDIR}/${_kernel}; \
507             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
508         @echo "--------------------------------------------------------------"
509         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
510         @echo "--------------------------------------------------------------"
511 .endfor
512
513 #
514 # installkernel
515 #
516 # Install the kernel defined by INSTALLKERNEL
517 #
518 installkernel reinstallkernel:
519         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
520             ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
521
522 #
523 # update
524 #
525 # Update the source tree, by running sup and/or running cvs to update to the
526 # latest copy.
527 #
528 update:
529 .if defined(SUP_UPDATE)
530         @echo "--------------------------------------------------------------"
531         @echo ">>> Running ${SUP}"
532         @echo "--------------------------------------------------------------"
533 .if defined(SUPFILE)
534         @${SUP} ${SUPFLAGS} ${SUPFILE}
535 .endif
536 .if defined(SUPFILE1)
537         @${SUP} ${SUPFLAGS} ${SUPFILE1}
538 .endif
539 .if defined(SUPFILE2)
540         @${SUP} ${SUPFLAGS} ${SUPFILE2}
541 .endif
542 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
543         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
544 .endif
545 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
546         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
547 .endif
548 .endif
549 .if defined(CVS_UPDATE)
550         @echo "--------------------------------------------------------------"
551         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
552         @echo "--------------------------------------------------------------"
553         cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
554 .endif
555
556 #
557 # most
558 #
559 # Build most of the user binaries on the existing system libs and includes.
560 #
561 most:
562         @echo "--------------------------------------------------------------"
563         @echo ">>> Building programs only"
564         @echo "--------------------------------------------------------------"
565 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
566         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ all
567 .endfor
568
569 #
570 # installmost
571 #
572 # Install the binaries built by the 'most' target.  This does not include
573 # libraries or include files.
574 #
575 installmost:
576         @echo "--------------------------------------------------------------"
577         @echo ">>> Installing programs only"
578         @echo "--------------------------------------------------------------"
579 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
580         cd ${.CURDIR}/${_dir};          ${MAKE} DIRPRFX=${_dir}/ install
581 .endfor
582
583 #
584 # ------------------------------------------------------------------------
585 #
586 # From here onwards are utility targets used by the 'make world' and
587 # related targets.  If your 'world' breaks, you may like to try to fix
588 # the problem and manually run the following targets to attempt to
589 # complete the build.  Beware, this is *not* guaranteed to work, you
590 # need to have a pretty good grip on the current state of the system
591 # to attempt to manually finish it.  If in doubt, 'make world' again.
592 #
593
594 # bootstrap-tools: Build tools needed for compatibility
595 #
596 # [x]install:   dependancies on various new install features
597 # rpcgen:       old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
598 #               envs are not compatible with older objformat binaries.
599 #
600 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
601 _strfile=       games/fortune/strfile
602 .endif
603
604 bootstrap-tools:
605 .for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
606     usr.bin/uudecode usr.bin/xinstall usr.bin/rpcgen \
607     usr.sbin/config \
608     gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
609         ${ECHODIR} "===> ${_tool}"; \
610                 cd ${.CURDIR}/${_tool}; \
611                 ${MAKE} DIRPRFX=${_tool}/ obj; \
612                 ${MAKE} DIRPRFX=${_tool}/ depend; \
613                 ${MAKE} DIRPRFX=${_tool}/ all; \
614                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
615 .endfor
616
617 # build-tools: Build special purpose build tools.  gcc2 related tools are
618 # only built under the i386 architecture.  Other architectures are
619 # gcc3-only.
620 #
621 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
622 _games= games/adventure games/hack games/phantasia
623 .endif
624
625 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
626 _share= share/syscons/scrnmaps
627 .endif
628
629 _gcc3_cross= gnu/usr.bin/cc3
630 _gcc3_tools= gnu/usr.bin/cc3/cc_tools
631 .if ${MACHINE_ARCH} == "i386" && ${TARGET_ARCH} == "i386"
632 _gcc2_cross= gnu/usr.bin/cc
633 _gcc2_tools= gnu/usr.bin/cc/cc_tools
634 _binutils= gnu/usr.bin/binutils gnu/usr.bin/binutils214
635 .else
636 _binutils= gnu/usr.bin/binutils214
637 .endif
638
639 .if !defined(NO_FORTRAN)
640 .if ${TARGET_ARCH} == "i386"
641 _fortran= gnu/usr.bin/cc/f771
642 .else
643 _fortran= gnu/usr.bin/cc3/f771
644 .endif
645 .endif
646
647 .if !defined(NOPERL)
648 _perl=  gnu/usr.bin/perl/miniperl
649 .endif
650
651 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
652     !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
653 _libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
654     kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
655 .endif
656
657 .if defined(RELEASEDIR)
658 _sysinstall= release/sysinstall
659 .endif
660
661 # build-tools: tools we need 
662 #
663 build-tools:
664 .for _tool in bin/csh bin/sh ${_games} ${_gcc2_tools} ${_gcc3_tools} \
665               ${_fortran} ${_perl} ${_libroken4} ${_libkrb5} \
666               lib/libncurses ${_share} usr.bin/awk usr.bin/file \
667               ${_sysinstall}
668         ${ECHODIR} "===> ${_tool}"; \
669                 cd ${.CURDIR}/${_tool}; \
670                 ${MAKE} DIRPRFX=${_tool}/ obj; \
671                 ${MAKE} DIRPRFX=${_tool}/ build-tools
672 .endfor
673
674 #
675 # cross-tools: Build cross-building tools
676 #
677 .if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
678 _elf2exe=       usr.sbin/elf2exe
679 .endif
680
681 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
682 _btxld= usr.sbin/btxld
683 .endif
684
685 cross-tools:
686 .for _tool in ${_btxld} ${_elf2exe} ${_binutils} \
687               usr.bin/objformat usr.sbin/crunch/crunchide \
688               ${_gcc2_cross} ${_gcc3_cross}
689         ${ECHODIR} "===> ${_tool}"; \
690                 cd ${.CURDIR}/${_tool}; \
691                 ${MAKE} DIRPRFX=${_tool}/ obj; \
692                 ${MAKE} DIRPRFX=${_tool}/ depend; \
693                 ${MAKE} DIRPRFX=${_tool}/ all; \
694                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
695 .endfor
696
697 #
698 # hierarchy - ensure that all the needed directories are present
699 #
700 hierarchy:
701         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
702
703 #
704 # libraries - build all libraries, and install them under ${DESTDIR}.
705 #
706 # The list of libraries with dependents (${_prebuild_libs}) and their
707 # interdependencies (__L) are built automatically by the
708 # ${.CURDIR}/tools/make_libdeps.sh script.
709 #
710 # .makeenv does not work when bootstrapping from 4.x, so we must be sure
711 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
712 #
713 libraries:
714         cd ${.CURDIR}; \
715             CCVER=gcc2 ${MAKE} -f Makefile.inc1 _startup_libs2; \
716             CCVER=gcc3 ${MAKE} -f Makefile.inc1 _startup_libs3; \
717             ${MAKE} -f Makefile.inc1 _startup_libs; \
718             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
719             ${MAKE} -f Makefile.inc1 _generic_libs;
720
721 # These dependencies are not automatically generated:
722 #
723 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
724 # shared libraries for ELF.  The targets for _startup_libs{2,3} are
725 # specifically built using gcc{2,3}.
726 #
727 _startup_libs2= gnu/lib/gcc2/csu gnu/lib/gcc2/libgcc
728 _startup_libs3= gnu/lib/gcc3/csu gnu/lib/gcc3/libgcc
729 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-${OBJFORMAT})
730 _startup_libs=  lib/csu/${MACHINE_ARCH}-${OBJFORMAT}
731 .else
732 _startup_libs=  lib/csu/${MACHINE_ARCH}
733 .endif
734
735 _prebuild_libs=
736
737 _generic_libs=  gnu/lib
738
739 .if !defined(NOPERL)
740 _generic_libs+= gnu/usr.bin/perl/libperl
741 .endif
742
743 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
744 _prebuild_libs+=        kerberos5/lib/libasn1
745 _prebuild_libs+=        kerberos5/lib/libgssapi
746 _prebuild_libs+=        kerberos5/lib/libkrb5
747 _prebuild_libs+=        kerberos5/lib/libroken
748 _generic_libs+= kerberos5/lib
749 .endif
750
751 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
752                 lib/libncurses lib/libopie lib/libradius lib/libskey \
753                 lib/libtacplus lib/libutil \
754                 lib/libz lib/msun
755
756 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
757 lib/libskey__L: lib/libcrypt__L lib/libmd__L
758
759 _generic_libs+= lib
760
761 .if !defined(NOCRYPT)
762 .if !defined(NO_OPENSSL)
763 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
764 .if !defined(NO_OPENSSH)
765 _prebuild_libs+=        secure/lib/libssh
766 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
767 .endif
768 .endif
769 _generic_libs+= secure/lib
770 .endif
771
772 _generic_libs+= usr.bin/lex/lib
773
774 .if ${MACHINE_ARCH} == "i386"
775 _generic_libs+= usr.sbin/pcvt/keycap
776 .endif
777
778 .for _lib in ${_startup_libs2} ${_startup_libs3} ${_startup_libs} \
779                 ${_prebuild_libs} ${_generic_libs}
780 ${_lib}__L: .PHONY
781 .if exists(${.CURDIR}/${_lib})
782         ${ECHODIR} "===> ${_lib}"; \
783                 cd ${.CURDIR}/${_lib}; \
784                 ${MAKE} DIRPRFX=${_lib}/ depend; \
785                 ${MAKE} DIRPRFX=${_lib}/ all; \
786                 ${MAKE} DIRPRFX=${_lib}/ install
787 .endif
788 .endfor
789
790 # only mess with gcc2 for i386 architectures.
791 #
792 _startup_libs: ${_startup_libs:S/$/__L/}
793 .if ${TARGET_ARCH} == "i386"
794 _startup_libs2: ${_startup_libs2:S/$/__L/}
795 .else
796 _startup_libs2:
797 .endif
798 _startup_libs3: ${_startup_libs3:S/$/__L/}
799 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
800 _generic_libs: ${_generic_libs:S/$/__L/}
801
802 .for __target in clean cleandepend cleandir depend includes obj
803 .for entry in ${SUBDIR}
804 ${entry}.${__target}__D: .PHONY
805         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
806                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
807                 edir=${entry}.${MACHINE_ARCH}; \
808                 cd ${.CURDIR}/$${edir}; \
809         else \
810                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
811                 edir=${entry}; \
812                 cd ${.CURDIR}/$${edir}; \
813         fi; \
814         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
815 .endfor
816 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
817 .endfor
818
819 # The wmake target is used by /usr/bin/wmake to run make in a
820 # world build environment.
821 #
822 wmake:
823         @echo '${WMAKEENV} ${MAKE} ${WMAKE_ARGS}'
824
825 wmakeenv:
826         @echo '${WMAKEENV} /bin/sh'
827
828 bmakeenv:
829         @echo '${BMAKEENV} /bin/sh'
830
831 tmakeenv:
832         @echo '${TMAKEENV} /bin/sh'
833
834 .include <bsd.subdir.mk>
835