]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Fixed world breakage. mkdir was not copied to ${INSTALLTMP}, but it is
[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_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 #       MACHINE_ARCH="machine 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}/kerberosIV) && exists(${.CURDIR}/crypto) && \
66     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
67 SUBDIR+= kerberosIV
68 .endif
69 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
70     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
71 SUBDIR+= kerberos5
72 .endif
73 .if exists(${.CURDIR}/libexec)
74 SUBDIR+= libexec
75 .endif
76 .if exists(${.CURDIR}/sbin)
77 SUBDIR+= sbin
78 .endif
79 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
80 SUBDIR+= share
81 .endif
82 .if exists(${.CURDIR}/sys)
83 SUBDIR+= sys
84 .endif
85 .if exists(${.CURDIR}/usr.bin)
86 SUBDIR+= usr.bin
87 .endif
88 .if exists(${.CURDIR}/usr.sbin)
89 SUBDIR+= usr.sbin
90 .endif
91 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
92 SUBDIR+= secure
93 .endif
94
95 # etc must be last for "distribute" to work
96 .if exists(${.CURDIR}/etc)
97 SUBDIR+= etc
98 .endif
99
100 # These are last, since it is nice to at least get the base system
101 # rebuilt before you do them.
102 .if defined(LOCAL_DIRS)
103 .for _DIR in ${LOCAL_DIRS}
104 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
105 SUBDIR+= ${_DIR}
106 .endif
107 .endfor
108 .endif
109
110 .if defined(NOCLEANDIR)
111 CLEANDIR=       clean cleandepend
112 .else
113 CLEANDIR=       cleandir
114 .endif
115
116 SUP?=           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 BUILD_ARCH!=    sysctl -n hw.machine_arch
125 .if ${BUILD_ARCH} == ${MACHINE_ARCH}
126 OBJTREE=        ${MAKEOBJDIRPREFIX}
127 .else
128 OBJTREE=        ${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
129 .endif
130 WORLDTMP=       ${OBJTREE}${.CURDIR}/${BUILD_ARCH}
131 # /usr/games added for fortune which depend on strfile
132 STRICTTMPPATH=  ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
133 TMPPATH=        ${STRICTTMPPATH}:${PATH}
134 OBJFORMAT_PATH?=        /usr/libexec
135
136 TMPDIR?=        /tmp
137 TMPPID!=        echo $$$$
138 INSTALLTMP=     ${TMPDIR}/install.${TMPPID}
139
140 #
141 # Building a world goes through the following stages
142 #
143 # 1. bootstrap-tool stage [BMAKE]
144 #       This stage is responsible for creating programs that
145 #       are needed for backward compatibility reasons. They
146 #       are not built as cross-tools.
147 # 2. build-tool stage [TMAKE]
148 #       This stage is responsible for creating the object
149 #       tree and building any tools that are needed during
150 #       the build process.
151 # 3. cross-tool stage [XMAKE]
152 #       This stage is responsible for creating any tools that
153 #       are needed for cross-builds. A cross-compiler is one
154 #       of them.
155 # 4. world stage [WMAKE]
156 #       This stage actually builds the world.
157 # 5. install stage (optional) [IMAKE]
158 #       This stage installs a previously built world.
159 #
160
161 # Common environment for bootstrap related stages
162 BOOTSTRAPENV=   MAKEOBJDIRPREFIX=${WORLDTMP} \
163                 DESTDIR=${WORLDTMP} \
164                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
165                 MACHINE_ARCH=${BUILD_ARCH} \
166                 TOOLS_PREFIX=${WORLDTMP} \
167                 PATH=${TMPPATH}
168
169 # Common environment for world related stages
170 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
171                 COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
172                 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
173                 OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
174                 CFLAGS="-nostdinc ${CFLAGS}" \
175                 PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.0 \
176                 GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
177                 GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
178                 GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
179
180 # bootstrap-tool stage
181 BMAKEENV=       ${BOOTSTRAPENV}
182 BMAKE=          ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOHTML -DNOINFO \
183                         -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
184
185 # build-tool stage
186 TMAKEENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
187                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
188                 PATH=${TMPPATH}
189 TMAKE=          ${TMAKEENV} ${MAKE} -f Makefile.inc1
190
191 # cross-tool stage
192 XMAKEENV=       ${BOOTSTRAPENV} \
193                 TARGET_ARCH=${MACHINE_ARCH}
194 XMAKE=          ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
195                         -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE \
196                         -DNOSHARED
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 INCDIRS=        arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
234                 security
235
236 #
237 # buildworld
238 #
239 # Attempt to rebuild the entire system, with reasonable chance of
240 # success, regardless of how old your existing system is.
241 #
242 buildworld:
243         @echo
244         @echo "--------------------------------------------------------------"
245         @echo ">>> Rebuilding the temporary build tree"
246         @echo "--------------------------------------------------------------"
247 .if !defined(NOCLEAN)
248         rm -rf ${WORLDTMP}
249 .else
250         for dir in bin games include lib sbin share; do \
251                 rm -rf ${WORLDTMP}/usr/$$dir; \
252         done
253         # XXX - Work-around for broken cc/cc_tools/Makefile.
254         # This is beyond dirty...
255         rm -f ${OBJTREE}${.CURDIR}/gnu/usr.bin/cc/cc_tools/.depend
256 .endif
257 .for _dir in ${USRDIRS}
258         mkdir -p ${WORLDTMP}/${_dir}
259 .endfor
260 .for _dir in ${INCDIRS}
261         mkdir -p ${WORLDTMP}/usr/include/${_dir}
262 .endfor
263         ln -sf ${.CURDIR}/sys ${WORLDTMP}
264         @echo
265         @echo "--------------------------------------------------------------"
266         @echo ">>> stage 1: bootstrap tools"
267         @echo "--------------------------------------------------------------"
268         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
269 .if !defined(NOCLEAN)
270         @echo
271         @echo "--------------------------------------------------------------"
272         @echo ">>> stage 2: cleaning up the object tree"
273         @echo "--------------------------------------------------------------"
274         cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
275 .endif
276         @echo
277         @echo "--------------------------------------------------------------"
278         @echo ">>> stage 2: rebuilding the object tree"
279         @echo "--------------------------------------------------------------"
280         cd ${.CURDIR}; ${TMAKE} par-obj
281         @echo
282         @echo "--------------------------------------------------------------"
283         @echo ">>> stage 2: build tools"
284         @echo "--------------------------------------------------------------"
285         cd ${.CURDIR}; ${TMAKE} build-tools
286         @echo
287         @echo "--------------------------------------------------------------"
288         @echo ">>> stage 3: cross tools"
289         @echo "--------------------------------------------------------------"
290         cd ${.CURDIR}; ${XMAKE} cross-tools
291         @echo
292         @echo "--------------------------------------------------------------"
293         @echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
294         @echo "--------------------------------------------------------------"
295         cd ${.CURDIR}; ${WMAKE} SHARED=copies includes
296         @echo
297         @echo "--------------------------------------------------------------"
298         @echo ">>> stage 4: building libraries"
299         @echo "--------------------------------------------------------------"
300         cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
301         @echo
302         @echo "--------------------------------------------------------------"
303         @echo ">>> stage 4: make dependencies"
304         @echo "--------------------------------------------------------------"
305         cd ${.CURDIR}; ${WMAKE} par-depend
306         @echo
307         @echo "--------------------------------------------------------------"
308         @echo ">>> stage 4: building everything.."
309         @echo "--------------------------------------------------------------"
310         cd ${.CURDIR}; ${WMAKE} all
311
312 everything:
313         @echo "--------------------------------------------------------------"
314         @echo ">>> Building everything.."
315         @echo "--------------------------------------------------------------"
316         cd ${.CURDIR}; ${WMAKE} all
317
318 #
319 # installworld
320 #
321 # Installs everything compiled by a 'buildworld'.
322 #
323 installworld:
324         mkdir -p ${INSTALLTMP}
325         for prog in [ awk cat chflags chmod chown date echo egrep find grep \
326             ln make makewhatis mkdir mtree mv perl rm sed sh sysctl \
327             test true uname wc zic; do \
328                 cp `which $$prog` ${INSTALLTMP}; \
329         done
330         cd ${.CURDIR}; ${IMAKE} reinstall
331         rm -rf ${INSTALLTMP}
332
333 #
334 # reinstall
335 #
336 # If you have a build server, you can NFS mount the source and obj directories
337 # and do a 'make reinstall' on the *client* to install new binaries from the
338 # most recent server build.
339 #
340 reinstall:
341         @echo "--------------------------------------------------------------"
342         @echo ">>> Making hierarchy"
343         @echo "--------------------------------------------------------------"
344         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
345         @echo
346         @echo "--------------------------------------------------------------"
347         @echo ">>> Installing everything.."
348         @echo "--------------------------------------------------------------"
349         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
350 .if !defined(NOMAN)
351         @echo
352         @echo "--------------------------------------------------------------"
353         @echo ">>> Rebuilding man page indices"
354         @echo "--------------------------------------------------------------"
355         cd ${.CURDIR}/share/man; ${MAKE} makedb
356 .endif
357
358 #
359 # distribworld
360 #
361 # Front-end to distribute to make sure the search path contains
362 # the object directory. Needed for miniperl.
363 #
364 distribworld:
365         cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
366
367 #
368 # buildkernel and installkernel
369 #
370 # Which kernels to build and/or install is specified by setting
371 # KERNCONF. If not defined a GENERIC kernel is built/installed.
372 # Only the existing (depending MACHINE) config files are used
373 # for building kernels and only the first of these is designated
374 # as the one being installed.
375 #
376 # Note that we have to use MACHINE instead of MACHINE_ARCH when
377 # we're in kernel-land. Since only MACHINE_ARCH is (expected) to
378 # be set to cross-build, we have to make sure MACHINE is set
379 # properly.
380
381 .if !defined(KERNCONF) && defined(KERNEL)
382 KERNCONF=       ${KERNEL}
383 KERNWARN=       yes
384 .else
385 KERNCONF?=      GENERIC
386 .endif
387 INSTKERNNAME?=  kernel
388
389 # The only exotic MACHINE_ARCH/MACHINE combination valid at this
390 # time is i386/pc98. In all other cases set MACHINE equal to
391 # MACHINE_ARCH.
392 .if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
393 MACHINE=        ${MACHINE_ARCH}
394 .endif
395
396 KRNLSRCDIR=     ${.CURDIR}/sys
397 KRNLCONFDIR=    ${KRNLSRCDIR}/${MACHINE}/conf
398 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
399 KERNCONFDIR?=   ${KRNLCONFDIR}
400
401 BUILDKERNELS=
402 INSTALLKERNEL=
403 .for _kernel in ${KERNCONF}
404 .if exists(${KERNCONFDIR}/${_kernel})
405 BUILDKERNELS+=  ${_kernel}
406 .if empty(INSTALLKERNEL)
407 INSTALLKERNEL= ${_kernel}
408 .endif
409 .endif
410 .endfor
411
412 #
413 # buildkernel
414 #
415 # Builds all kernels defined by BUILDKERNELS.
416 #
417 buildkernel:
418 .if empty(BUILDKERNELS)
419         @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
420         @false
421 .endif
422 .if defined(KERNWARN)
423         @echo "--------------------------------------------------------------"
424         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
425         @echo "--------------------------------------------------------------"
426         @sleep 3
427 .endif
428         @echo
429 .for _kernel in ${BUILDKERNELS}
430         @echo "--------------------------------------------------------------"
431         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
432         @echo "--------------------------------------------------------------"
433         @echo "===> ${_kernel}"
434         mkdir -p ${KRNLOBJDIR}
435 .if !defined(NO_KERNELCONFIG)
436         cd ${KRNLCONFDIR}; \
437                 PATH=${TMPPATH} \
438                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
439                         ${KERNCONFDIR}/${_kernel}
440 .endif
441 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
442         cd ${KRNLOBJDIR}/${_kernel}; \
443             ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} clean
444 .endif
445         cd ${KRNLOBJDIR}/${_kernel}; \
446                 MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
447                     ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
448 .if !defined(NO_KERNELDEPEND)
449         cd ${KRNLOBJDIR}/${_kernel}; \
450             ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} depend
451 .endif
452         cd ${KRNLOBJDIR}/${_kernel}; \
453             ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} all
454         @echo "--------------------------------------------------------------"
455         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
456         @echo "--------------------------------------------------------------"
457 .endfor
458
459 #
460 # installkernel
461 #
462 # Install the kernel defined by INSTALLKERNEL
463 #
464 installkernel:
465         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
466             ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} install
467 reinstallkernel:
468         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
469             ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
470
471 #
472 # kernel
473 #
474 # Short hand for `make buildkernel installkernel'
475 #
476 kernel: buildkernel installkernel
477
478 #
479 # update
480 #
481 # Update the source tree, by running sup and/or running cvs to update to the
482 # latest copy.
483 #
484 update:
485 .if defined(SUP_UPDATE)
486         @echo "--------------------------------------------------------------"
487         @echo ">>> Running ${SUP}"
488         @echo "--------------------------------------------------------------"
489 .if defined(SUPFILE)
490         @${SUP} ${SUPFLAGS} ${SUPFILE}
491 .endif
492 .if defined(SUPFILE1)
493         @${SUP} ${SUPFLAGS} ${SUPFILE1}
494 .endif
495 .if defined(SUPFILE2)
496         @${SUP} ${SUPFLAGS} ${SUPFILE2}
497 .endif
498 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
499         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
500 .endif
501 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
502         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
503 .endif
504 .endif
505 .if defined(CVS_UPDATE)
506         @echo "--------------------------------------------------------------"
507         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
508         @echo "--------------------------------------------------------------"
509         cd ${.CURDIR}; cvs -q update -A -P -d
510 .endif
511
512 #
513 # most
514 #
515 # Build most of the user binaries on the existing system libs and includes.
516 #
517 most:
518         @echo "--------------------------------------------------------------"
519         @echo ">>> Building programs only"
520         @echo "--------------------------------------------------------------"
521         cd ${.CURDIR}/bin;              ${MAKE} all
522         cd ${.CURDIR}/sbin;             ${MAKE} all
523         cd ${.CURDIR}/libexec;          ${MAKE} all
524         cd ${.CURDIR}/usr.bin;          ${MAKE} all
525         cd ${.CURDIR}/usr.sbin;         ${MAKE} all
526         cd ${.CURDIR}/gnu/libexec;      ${MAKE} all
527         cd ${.CURDIR}/gnu/usr.bin;      ${MAKE} all
528         cd ${.CURDIR}/gnu/usr.sbin;     ${MAKE} all
529
530 #
531 # installmost
532 #
533 # Install the binaries built by the 'most' target.  This does not include
534 # libraries or include files.
535 #
536 installmost:
537         @echo "--------------------------------------------------------------"
538         @echo ">>> Installing programs only"
539         @echo "--------------------------------------------------------------"
540         cd ${.CURDIR}/bin;              ${MAKE} install
541         cd ${.CURDIR}/sbin;             ${MAKE} install
542         cd ${.CURDIR}/libexec;          ${MAKE} install
543         cd ${.CURDIR}/usr.bin;          ${MAKE} install
544         cd ${.CURDIR}/usr.sbin;         ${MAKE} install
545         cd ${.CURDIR}/gnu/libexec;      ${MAKE} install
546         cd ${.CURDIR}/gnu/usr.bin;      ${MAKE} install
547         cd ${.CURDIR}/gnu/usr.sbin;     ${MAKE} install
548
549 #
550 # ------------------------------------------------------------------------
551 #
552 # From here onwards are utility targets used by the 'make world' and
553 # related targets.  If your 'world' breaks, you may like to try to fix
554 # the problem and manually run the following targets to attempt to
555 # complete the build.  Beware, this is *not* guaranteed to work, you
556 # need to have a pretty good grip on the current state of the system
557 # to attempt to manually finish it.  If in doubt, 'make world' again.
558 #
559
560 #
561 # bootstrap-tools: Build tools needed for compatibility
562 #
563 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
564 _strfile=       games/fortune/strfile
565 .endif
566
567 bootstrap-tools:
568 .for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.bin/xinstall \
569     usr.sbin/config usr.sbin/kbdcontrol \
570     gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
571         cd ${.CURDIR}/${_tool}; \
572                 ${MAKE} obj; \
573                 ${MAKE} depend; \
574                 ${MAKE} all; \
575                 ${MAKE} install
576 .endfor
577
578 #
579 # build-tools: Build special purpose build tools
580 #
581 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
582 _games= games/adventure games/hack games/phantasia
583 .endif
584
585 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
586 _share= share/syscons/scrnmaps
587 .endif
588
589 .if !defined(NO_FORTRAN)
590 _fortran= gnu/usr.bin/cc/f771
591 .endif
592
593 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
594     !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
595 _libroken4= kerberosIV/lib/libroken
596 .endif
597
598 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
599     !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
600 _libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
601 .endif
602
603 build-tools:
604 .for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
605     ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.bin/file \
606     usr.sbin/sysinstall
607         cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
608 .endfor
609
610 #
611 # cross-tools: Build cross-building tools
612 #
613 # WARNING: Because the bootstrap tools are expected to run on the
614 # build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
615 # target is being made. TARGET_ARCH is *always* set to reflect the
616 # target-machine (which you can set by specifying MACHINE_ARCH on
617 # make's command-line, get it?).
618 # The reason is simple: we build these tools not to be run on the
619 # architecture we're cross-building, but on the architecture we're
620 # currently building on (ie the host-machine) and we expect these
621 # tools to produce output for the architecture we're trying to
622 # cross-build.
623 #
624 .if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
625 _elf2exe=       usr.sbin/elf2exe
626 .endif
627
628 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
629 _btxld= usr.sbin/btxld
630 .endif
631
632 .if !defined(NOPERL)
633 _perl=  gnu/usr.bin/perl/libperl gnu/usr.bin/perl/miniperl
634 .endif
635
636 cross-tools:
637 .for _tool in ${_btxld} ${_elf2exe} ${_perl} \
638     gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
639         cd ${.CURDIR}/${_tool}; \
640                 ${MAKE} obj; \
641                 ${MAKE} depend; \
642                 ${MAKE} all; \
643                 ${MAKE} install
644 .endfor
645
646 #
647 # hierarchy - ensure that all the needed directories are present
648 #
649 hierarchy:
650         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
651
652 #
653 # includes - possibly generate and install the include files.
654 #
655 includes:
656         cd ${.CURDIR}/include;                  ${MAKE} -B all install
657         cd ${.CURDIR}/gnu/include;              ${MAKE} install
658         cd ${.CURDIR}/gnu/lib/libobjc;          ${MAKE} beforeinstall
659         cd ${.CURDIR}/gnu/lib/libreadline/readline;     ${MAKE} beforeinstall
660         cd ${.CURDIR}/gnu/lib/libregex;         ${MAKE} beforeinstall
661         cd ${.CURDIR}/gnu/lib/libstdc++;        ${MAKE} beforeinstall
662         cd ${.CURDIR}/gnu/lib/libdialog;        ${MAKE} beforeinstall
663         cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;   ${MAKE} beforeinstall
664 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
665 .if exists(${.CURDIR}/secure/lib/libcrypto)
666         cd ${.CURDIR}/secure/lib/libcrypto;     ${MAKE} beforeinstall
667 .endif
668 .if exists(${.CURDIR}/secure/lib/libssl)
669         cd ${.CURDIR}/secure/lib/libssl;        ${MAKE} beforeinstall
670 .endif
671 .endif
672 .if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
673     defined(MAKE_KERBEROS4)
674         cd ${.CURDIR}/kerberosIV/lib/libacl;    ${MAKE} beforeinstall
675         cd ${.CURDIR}/kerberosIV/lib/libkadm;   ${MAKE} beforeinstall
676         cd ${.CURDIR}/kerberosIV/lib/libkafs;   ${MAKE} beforeinstall
677         cd ${.CURDIR}/kerberosIV/lib/libkdb;    ${MAKE} beforeinstall
678         cd ${.CURDIR}/kerberosIV/lib/libkrb;    ${MAKE} beforeinstall
679         cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
680 .else
681         cd ${.CURDIR}/lib/libtelnet;            ${MAKE} beforeinstall
682 .endif
683 .if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
684     defined(MAKE_KERBEROS5)
685         cd ${.CURDIR}/kerberos5/lib/libasn1;            ${MAKE} beforeinstall
686         cd ${.CURDIR}/kerberos5/lib/libhdb;             ${MAKE} beforeinstall
687         cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;       ${MAKE} beforeinstall
688         cd ${.CURDIR}/kerberos5/lib/libkadm5srv;        ${MAKE} beforeinstall
689         cd ${.CURDIR}/kerberos5/lib/libkafs5;           ${MAKE} beforeinstall
690         cd ${.CURDIR}/kerberos5/lib/libkrb5;            ${MAKE} beforeinstall
691         cd ${.CURDIR}/kerberos5/lib/libsl;              ${MAKE} beforeinstall
692 .endif
693 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
694         cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};  ${MAKE} beforeinstall
695 .endif
696         cd ${.CURDIR}/gnu/lib/csu;              ${MAKE} beforeinstall
697         cd ${.CURDIR}/lib/libalias;             ${MAKE} beforeinstall
698         cd ${.CURDIR}/lib/libatm;               ${MAKE} beforeinstall
699         cd ${.CURDIR}/lib/libdevstat;           ${MAKE} beforeinstall
700         cd ${.CURDIR}/lib/libc;                 ${MAKE} beforeinstall
701         cd ${.CURDIR}/lib/libcalendar;          ${MAKE} beforeinstall
702         cd ${.CURDIR}/lib/libcam;               ${MAKE} beforeinstall
703         cd ${.CURDIR}/lib/libdisk;              ${MAKE} beforeinstall
704         cd ${.CURDIR}/lib/libedit;              ${MAKE} beforeinstall
705         cd ${.CURDIR}/lib/libfetch;             ${MAKE} beforeinstall
706         cd ${.CURDIR}/lib/libftpio;             ${MAKE} beforeinstall
707         cd ${.CURDIR}/lib/libkvm;               ${MAKE} beforeinstall
708         cd ${.CURDIR}/lib/libmd;                ${MAKE} beforeinstall
709         cd ${.CURDIR}/lib/libmp;                ${MAKE} beforeinstall
710 .if !defined(WANT_CSRG_LIBM)
711         cd ${.CURDIR}/lib/msun;                 ${MAKE} beforeinstall
712 .endif
713         cd ${.CURDIR}/lib/libncp;               ${MAKE} beforeinstall
714         cd ${.CURDIR}/lib/libncurses;           ${MAKE} beforeinstall
715         cd ${.CURDIR}/lib/libnetgraph;          ${MAKE} beforeinstall
716         cd ${.CURDIR}/lib/libopie;              ${MAKE} beforeinstall
717         cd ${.CURDIR}/lib/libpcap;              ${MAKE} beforeinstall
718         cd ${.CURDIR}/lib/libradius;            ${MAKE} beforeinstall
719         cd ${.CURDIR}/lib/librpcsvc;            ${MAKE} beforeinstall
720         cd ${.CURDIR}/lib/libpam/libpam;        ${MAKE} beforeinstall
721         cd ${.CURDIR}/lib/libsbuf;              ${MAKE} beforeinstall
722         cd ${.CURDIR}/lib/libstand;             ${MAKE} beforeinstall
723         cd ${.CURDIR}/lib/libtacplus;           ${MAKE} beforeinstall
724         cd ${.CURDIR}/lib/libcom_err;           ${MAKE} beforeinstall
725         cd ${.CURDIR}/lib/libutil;              ${MAKE} beforeinstall
726         cd ${.CURDIR}/lib/libvgl;               ${MAKE} beforeinstall
727         cd ${.CURDIR}/lib/libwrap;              ${MAKE} beforeinstall
728         cd ${.CURDIR}/lib/libz;                 ${MAKE} beforeinstall
729         cd ${.CURDIR}/usr.bin/lex;              ${MAKE} beforeinstall
730
731 #
732 # libraries - build all libraries, and install them under ${DESTDIR}.
733 #
734 # The following dependencies exist between the libraries:
735 #
736 # lib*: csu libgcc_pic
737 # libatm: libmd
738 # libcam: libsbuf
739 # libcrypt: libmd
740 # libdevstat: libkvm
741 # libdialog: libncurses
742 # libedit: libncurses
743 # libg++: libm
744 # libkrb: libcrypt
745 # libopie: libmd
746 # libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
747 #         librpcsvc libtacplus libutil libz libssh
748 # libradius: libmd
749 # libreadline: libncurses
750 # libstc++: libm
751 # libtacplus: libmd
752 #
753 # Across directories this comes down to (rougly):
754 #
755 # gnu/lib: lib/libm lib/libncurses
756 # kerberosIV/lib kerberos5/lib: lib/libcrypt
757 # lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
758 #             secure/lib/libssh lib/libz
759 # secure/lib: lib/libmd
760 #
761 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
762 _csu=   lib/csu/${MACHINE_ARCH}.pcc
763 .elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
764 _csu=   lib/csu/i386-elf
765 .else
766 _csu=   lib/csu/${MACHINE_ARCH}
767 .endif
768
769 .if !defined(NOSECURE) && !defined(NOCRYPT)
770 _secure_lib=    secure/lib
771 .endif
772
773 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
774 _kerberosIV_lib=        kerberosIV/lib
775 .endif
776
777 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
778 _kerberos5_lib= kerberos5/lib
779 .endif
780
781 .if defined(WANT_CSRG_LIBM)
782 _libm=  lib/libm
783 .else
784 _libm=  lib/msun
785 .endif
786
787 .if ${MACHINE_ARCH} == "i386"
788 _libkeycap=     usr.sbin/pcvt/keycap
789 .endif
790
791 .if !defined(NOPERL)
792 _libperl=       gnu/usr.bin/perl/libperl
793 .endif
794
795 libraries:
796 .for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
797     ${_secure_lib} ${_kerberosIV_lib} \
798     ${_kerberos5_lib} lib/libcom_err lib/libkvm ${_libm} lib/libncurses \
799     lib/libopie lib/libradius lib/librpcsvc lib/libsbuf lib/libtacplus \
800     lib/libutil lib/libz lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
801 .if exists(${.CURDIR}/${_lib})
802         cd ${.CURDIR}/${_lib}; \
803                 ${MAKE} depend; \
804                 ${MAKE} all; \
805                 ${MAKE} install
806 .endif
807 .endfor
808
809 .for __target in clean cleandepend cleandir depend obj
810 .for entry in ${SUBDIR}
811 ${entry}.${__target}__D: .PHONY
812         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
813                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
814                 edir=${entry}.${MACHINE_ARCH}; \
815                 cd ${.CURDIR}/$${edir}; \
816         else \
817                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
818                 edir=${entry}; \
819                 cd ${.CURDIR}/$${edir}; \
820         fi; \
821         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
822 .endfor
823 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
824 .endfor
825
826 .include <bsd.subdir.mk>