]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
This commit was generated by cvs2svn to compensate for changes in r47139,
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 #       $Id: Makefile.inc1,v 1.75 1999/05/02 15:23:55 markm Exp $
3 #
4 # Make command line options:
5 #       -DCLOBBER will remove /usr/include
6 #       -DMAKE_KERBEROS4 to build KerberosIV
7 #       -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8 #       -DNOCLEAN do not clean at all
9 #       -DNOTOOLS do not rebuild any tools first
10 #       -DNOCRYPT will prevent building of crypt versions
11 #       -DNOPROFILE do not build profiled libraries
12 #       -DNOSECURE do not go into secure subdir
13 #       -DNOGAMES do not go into games subdir
14 #       -DNOSHARE do not go into share subdir
15 #       -DNOINFO do not make or install info files
16 #       -DNOLIBC_R do not build libc_r.
17 #       -DNO_FORTRAN do not build g77 and related libraries.
18 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19
20 #
21 # The intended user-driven targets are:
22 # buildworld  - rebuild *everything*, including glue to help do upgrades
23 # installworld- install everything built by "buildworld"
24 # update      - convenient way to update your source tree (eg: sup/cvs)
25 # most        - build user commands, no libraries or include files
26 # installmost - install user commands, no libraries or include files
27 #
28 # Standard targets (not defined here) are documented in the makefiles in
29 # /usr/share/mk.  These include:
30 #               obj depend all install clean cleandepend cleanobj
31
32 # Put initial settings here.
33 SUBDIR=
34
35 # We must do share/info early so that installation of info `dir'
36 # entries works correctly.  Do it first since it is less likely to
37 # grow dependencies on include and lib than vice versa.
38 .if exists(${.CURDIR}/share/info)
39 SUBDIR+= share/info
40 .endif
41
42 # We must do include and lib early so that the perl *.ph generation
43 # works correctly as it uses the header files installed by this.
44 .if exists(${.CURDIR}/include)
45 SUBDIR+= include
46 .endif
47 .if exists(${.CURDIR}/lib)
48 SUBDIR+= lib
49 .endif
50
51 .if exists(${.CURDIR}/bin)
52 SUBDIR+= bin
53 .endif
54 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
55 SUBDIR+= games
56 .endif
57 .if exists(${.CURDIR}/gnu)
58 SUBDIR+= gnu
59 .endif
60 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
61     !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
62 SUBDIR+= kerberosIV
63 .endif
64 .if exists(${.CURDIR}/libexec)
65 SUBDIR+= libexec
66 .endif
67 .if exists(${.CURDIR}/sbin)
68 SUBDIR+= sbin
69 .endif
70 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
71 SUBDIR+= share
72 .endif
73 .if exists(${.CURDIR}/sys)
74 SUBDIR+= sys
75 .endif
76 .if exists(${.CURDIR}/usr.bin)
77 SUBDIR+= usr.bin
78 .endif
79 .if exists(${.CURDIR}/usr.sbin)
80 SUBDIR+= usr.sbin
81 .endif
82 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
83 SUBDIR+= secure
84 .endif
85
86 # etc must be last for "distribute" to work
87 .if exists(${.CURDIR}/etc)
88 SUBDIR+= etc
89 .endif
90
91 # These are last, since it is nice to at least get the base system
92 # rebuilt before you do them.
93 .if defined(LOCAL_DIRS)
94 .for _DIR in ${LOCAL_DIRS}
95 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
96 SUBDIR+= ${_DIR}
97 .endif
98 .endfor
99 .endif
100
101 OBJDIR=         obj
102
103 .if defined(NOCLEAN)
104 CLEANDIR=
105 .else
106 .if defined(NOCLEANDIR)
107 CLEANDIR=       clean cleandepend
108 .else
109 CLEANDIR=       cleandir
110 .endif
111 .endif
112
113 .if !defined(NOCLEAN)
114 _NODEPEND=      true
115 .endif
116 .if defined(_NODEPEND)
117 _DEPEND=        cleandepend
118 .else
119 _DEPEND=        depend
120 .endif
121
122 SUP?=           cvsup
123 SUPFLAGS?=      -g -L 2 -P -
124
125 #
126 # While building tools for bootstrapping, we don't need to waste time on
127 # shared or profiled libraries, shared linkage, or documentation, except
128 # when the tools won't get cleaned we must use the defaults for shared
129 # libraries and shared linkage (and this doesn't waste time).
130 # XXX actually, we do need to waste time building shared libraries.
131 #
132 .if defined(NOCLEAN)
133 MK_FLAGS=       -DWORLD -DNOINFO -DNOMAN         -DNOPROFILE
134 .else
135 MK_FLAGS=       -DWORLD -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
136 .endif
137
138 #
139 # Define the location of the temporary installation directory. Note that
140 # MAKEOBJDIRPREFIX normally isn't defined so if the current directory is
141 # /usr/src, then the world temporary directory is /usr/obj/usr/src/tmp.
142 #
143 # During the transition from aout to elf format on i386, MAKEOBJDIRPREFIX
144 # is set by the parent makefile (Makefile.inc0) to be /usr/obj/${OBJFORMAT}
145 # in order to keep aout and elf format files apart.
146 #
147 .if defined(MAKEOBJDIRPREFIX)
148 WORLDTMP=       ${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
149 .else
150 WORLDTMP=       /usr/obj${.CURDIR}/tmp
151 .endif
152
153 #
154 # Define the PATH to the build tools.
155 #
156 # If not building tools, the PATH always points to the installed binaries.
157 # The NOTOOLS option assumes that in installed tools are good enough and that
158 # the user's PATH will locate to appropriate tools. This option is required
159 # for a cross-compiled build environment.
160 #
161 # If building tools, then the PATH includes the world temporary directories
162 # so that the bootstrapped tools are used as soon as they are built. The
163 # strict path is for use after all tools are supposed to have been
164 # bootstrapped. It doesn't allow any of the installed tools to be used.
165 #
166 .if     defined(NOTOOLS)
167 # Default root of the tool tree
168 TOOLROOT?=      
169 # Choose the PATH relative to the root of the tool tree
170 PATH=           ${TOOLROOT}/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/sbin:${TOOLROOT}/usr/bin
171 .else
172 TOOLROOT=       ${WORLDTMP}
173 .endif
174 STRICTTMPPATH=  ${TOOLROOT}/sbin:${TOOLROOT}/usr/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/bin
175 TMPPATH=        ${STRICTTMPPATH}:${PATH}
176
177 # XXX COMPILER_PATH is needed for finding cc1, ld and as
178 # XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecessary now
179 #       that LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
180 #       wouldn't link *crt.o or libgcc if it were used.
181 # XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
182 #       want that - all compile-time library paths should be resolved by gcc.
183 #       It fails for set[ug]id executables (are any used?).
184 COMPILER_ENV=   BISON_SIMPLE=${TOOLROOT}/usr/share/misc/bison.simple \
185                 COMPILER_PATH=${TOOLROOT}/usr/libexec:${TOOLROOT}/usr/bin \
186                 GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
187                 LD_LIBRARY_PATH=${TOOLROOT}${SHLIBDIR} \
188                 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
189
190 BMAKEENV=       PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t \
191                 OBJFORMAT_PATH=${TOOLROOT}/usr/libexec:/usr/libexec
192 XMAKEENV=       PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
193                 PERL5LIB=${DESTDIR}/usr/libdata/perl/5.00503 \
194                 OBJFORMAT_PATH=${TOOLROOT}/usr/libexec \
195                 CFLAGS="-nostdinc ${CFLAGS}"    # XXX -nostdlib
196
197 # used to compile and install 'make' in temporary build tree
198 MAKETMP=        ${WORLDTMP}/make
199 IBMAKE= ${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
200
201 .if     defined(NOTOOLS)
202 # bootstrap make
203 BMAKE=  ${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
204 # cross make used for compilation
205 XMAKE=  ${XMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
206 # cross make used for final installation
207 IXMAKE= ${XMAKEENV} ${MAKE}
208 .else
209 # bootstrap make
210 BMAKE=  ${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
211 # cross make used for compilation
212 XMAKE=  ${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
213 # cross make used for final installation
214 IXMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/make
215 .endif
216
217 #
218 # buildworld
219 #
220 # Attempt to rebuild the entire system, with reasonable chance of
221 # success, regardless of how old your existing system is.
222 #
223 buildworld: check-objformat
224 .if !defined(NOCLEAN)
225         @echo
226         @echo "--------------------------------------------------------------"
227         @echo ">>> Cleaning up the temporary ${OBJFORMAT} build tree"
228         @echo "--------------------------------------------------------------"
229         mkdir -p ${WORLDTMP}
230         -chflags -R noschg ${WORLDTMP}/
231         rm -rf ${WORLDTMP}
232 .endif
233 .if !defined(NOTOOLS)
234         @echo
235         @echo "--------------------------------------------------------------"
236         @echo ">>> Making make"
237         @echo "--------------------------------------------------------------"
238         mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
239         ( \
240         cd ${.CURDIR}/usr.bin/make; \
241                 MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
242                 ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
243                 ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
244                 ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
245         )
246         @echo
247         @echo "--------------------------------------------------------------"
248         @echo ">>> Making mtree"
249         @echo "--------------------------------------------------------------"
250         mkdir -p ${WORLDTMP}/usr/sbin ${WORLDTMP}/mtree
251         ( \
252         cd ${.CURDIR}/usr.sbin/mtree; \
253                 MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
254                 export MAKEOBJDIR=${WORLDTMP}/mtree; \
255                 ${BMAKE} ${MK_FLAGS} all; \
256                 ${BMAKE} ${MK_FLAGS} -B install clean \
257         )
258 .endif
259         @echo
260         @echo "--------------------------------------------------------------"
261         @echo ">>> Making hierarchy"
262         @echo "--------------------------------------------------------------"
263         mkdir -p ${WORLDTMP}
264         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 hierarchy
265 .if !defined(NOCLEAN)
266         @echo
267         @echo "--------------------------------------------------------------"
268         @echo ">>> Cleaning up the ${OBJFORMAT} obj tree"
269         @echo "--------------------------------------------------------------"
270         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
271 .endif
272         @echo
273         @echo "--------------------------------------------------------------"
274         @echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
275         @echo "--------------------------------------------------------------"
276         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 par-${OBJDIR}
277 .if !defined(NOTOOLS)
278         @echo
279         @echo "--------------------------------------------------------------"
280         @echo ">>> Rebuilding ${OBJFORMAT} bootstrap tools"
281         @echo "--------------------------------------------------------------"
282         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap
283         @echo
284         @echo "--------------------------------------------------------------"
285         @echo ">>> Rebuilding tools necessary to build the include files"
286         @echo "--------------------------------------------------------------"
287         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 include-tools
288 .endif
289         @echo
290         @echo "--------------------------------------------------------------"
291         @echo ">>> Rebuilding ${DESTDIR}/usr/include"
292         @echo "--------------------------------------------------------------"
293         cd ${.CURDIR}; SHARED=copies ${BMAKE} -f Makefile.inc1 includes
294         @echo
295         @echo "--------------------------------------------------------------"
296         @echo ">>> Rebuilding bootstrap libraries"
297         @echo "--------------------------------------------------------------"
298         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap-libraries
299 .if !defined(NOTOOLS)
300         @echo
301         @echo "--------------------------------------------------------------"
302         @echo ">>> Rebuilding tools needed to build libraries"
303         @echo "--------------------------------------------------------------"
304         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 lib-tools
305 .endif
306 .if !defined(NOTOOLS)
307         @echo
308         @echo "--------------------------------------------------------------"
309         @echo ">>> Rebuilding all other tools needed to build the ${OBJFORMAT} world"
310         @echo "--------------------------------------------------------------"
311         cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 build-tools
312 .endif
313 .if !defined(_NODEPEND)
314         @echo
315         @echo "--------------------------------------------------------------"
316         @echo ">>> Rebuilding dependencies"
317         @echo "--------------------------------------------------------------"
318         cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-depend
319 .endif
320         @echo
321         @echo "--------------------------------------------------------------"
322         @echo ">>> Building ${OBJFORMAT} libraries"
323         @echo "--------------------------------------------------------------"
324         cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
325         @echo
326         @echo "--------------------------------------------------------------"
327         @echo ">>> Building everything.."
328         @echo "--------------------------------------------------------------"
329         cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
330
331 everything:
332         @echo "--------------------------------------------------------------"
333         @echo ">>> Building everything.."
334         @echo "--------------------------------------------------------------"
335         cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
336
337 #
338 # installworld
339 #
340 # Installs everything compiled by a 'buildworld'.
341 #
342 installworld:
343         cd ${.CURDIR}; ${IXMAKE} -f Makefile.inc1 reinstall
344
345 #
346 # reinstall
347 #
348 # If you have a build server, you can NFS mount the source and obj directories
349 # and do a 'make reinstall' on the *client* to install new binaries from the
350 # most recent server build.
351 #
352 reinstall:
353         @echo "--------------------------------------------------------------"
354         @echo ">>> Making hierarchy"
355         @echo "--------------------------------------------------------------"
356         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
357         @echo
358         @echo "--------------------------------------------------------------"
359         @echo ">>> Installing everything.."
360         @echo "--------------------------------------------------------------"
361         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
362 .if ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout" && !defined(DESTDIR)
363         @echo
364         @echo "--------------------------------------------------------------"
365         @echo ">>> Re-scanning the shared libraries.."
366         @echo "--------------------------------------------------------------"
367         -cd ${.CURDIR}; /sbin/ldconfig -R
368 .endif
369 .if !defined(NOMAN)
370         @echo
371         @echo "--------------------------------------------------------------"
372         @echo ">>> Rebuilding man page indices"
373         @echo "--------------------------------------------------------------"
374         cd ${.CURDIR}/share/man; ${MAKE} makedb
375 .endif
376
377 #
378 # update
379 #
380 # Update the source tree, by running sup and/or running cvs to update to the
381 # latest copy.
382 #
383 update:
384 .if defined(SUP_UPDATE)
385         @echo "--------------------------------------------------------------"
386         @echo ">>> Running ${SUP}"
387         @echo "--------------------------------------------------------------"
388         @${SUP} ${SUPFLAGS} ${SUPFILE}
389 .if defined(SUPFILE1)
390         @${SUP} ${SUPFLAGS} ${SUPFILE1}
391 .endif
392 .if defined(SUPFILE2)
393         @${SUP} ${SUPFLAGS} ${SUPFILE2}
394 .endif
395 .endif
396 .if defined(CVS_UPDATE)
397         @echo "--------------------------------------------------------------"
398         @echo ">>> Updating /usr/src from cvs repository" ${CVSROOT}
399         @echo "--------------------------------------------------------------"
400         cd ${.CURDIR}; cvs -q update -P -d
401 .endif
402
403 #
404 # most
405 #
406 # Build most of the user binaries on the existing system libs and includes.
407 #
408 most:
409         @echo "--------------------------------------------------------------"
410         @echo ">>> Building programs only"
411         @echo "--------------------------------------------------------------"
412         cd ${.CURDIR}/bin;              ${MAKE} all
413         cd ${.CURDIR}/sbin;             ${MAKE} all
414         cd ${.CURDIR}/libexec;          ${MAKE} all
415         cd ${.CURDIR}/usr.bin;          ${MAKE} all
416         cd ${.CURDIR}/usr.sbin;         ${MAKE} all
417         cd ${.CURDIR}/gnu/libexec;      ${MAKE} all
418         cd ${.CURDIR}/gnu/usr.bin;      ${MAKE} all
419         cd ${.CURDIR}/gnu/usr.sbin;     ${MAKE} all
420 #.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
421 #       cd ${.CURDIR}/kerberosIV;       ${MAKE} most
422 #.endif
423 #.if !defined(NOSECURE) && !defined(NOCRYPT)
424 #       cd ${.CURDIR}/secure;           ${MAKE} most
425 #.endif
426
427 #
428 # installmost
429 #
430 # Install the binaries built by the 'most' target.  This does not include
431 # libraries or include files.
432 #
433 installmost:
434         @echo "--------------------------------------------------------------"
435         @echo ">>> Installing programs only"
436         @echo "--------------------------------------------------------------"
437         cd ${.CURDIR}/bin;              ${MAKE} install
438         cd ${.CURDIR}/sbin;             ${MAKE} install
439         cd ${.CURDIR}/libexec;          ${MAKE} install
440         cd ${.CURDIR}/usr.bin;          ${MAKE} install
441         cd ${.CURDIR}/usr.sbin;         ${MAKE} install
442         cd ${.CURDIR}/gnu/libexec;      ${MAKE} install
443         cd ${.CURDIR}/gnu/usr.bin;      ${MAKE} install
444         cd ${.CURDIR}/gnu/usr.sbin;     ${MAKE} install
445 #.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
446 #       cd ${.CURDIR}/kerberosIV;       ${MAKE} installmost
447 #.endif
448 #.if !defined(NOSECURE) && !defined(NOCRYPT)
449 #       cd ${.CURDIR}/secure;           ${MAKE} installmost
450 #.endif
451
452 #
453 # ------------------------------------------------------------------------
454 #
455 # From here onwards are utility targets used by the 'make world' and
456 # related targets.  If your 'world' breaks, you may like to try to fix
457 # the problem and manually run the following targets to attempt to
458 # complete the build.  Beware, this is *not* guaranteed to work, you
459 # need to have a pretty good grip on the current state of the system
460 # to attempt to manually finish it.  If in doubt, 'make world' again.
461 #
462
463 #
464 # hierarchy - ensure that all the needed directories are present
465 #
466 hierarchy:
467         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
468
469 #
470 # bootstrap - [re]build tools needed to run the actual build, this includes
471 # tools needed by 'make depend', as some tools are needed to generate source
472 # for the dependency information to be gathered from.
473 #
474 bootstrap:
475         cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
476                 ${MAKE} ${MK_FLAGS} all; \
477                 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
478         cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
479                 ${MAKE} ${MK_FLAGS} all; \
480                 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
481         cd ${.CURDIR}/usr.bin/yacc; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
482                 ${MAKE} ${MK_FLAGS} all; \
483                 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
484         cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
485                 ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
486                 ${MAKE} ${MK_FLAGS} -DNOLIB all; \
487                 ${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
488         cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
489         cd ${.CURDIR}/usr.sbin/mtree; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
490                 ${MAKE} ${MK_FLAGS} all; \
491                 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
492
493 #
494 # include-tools - generally the same as 'bootstrap', except that it's for
495 # things that are specifically needed to generate include files.
496 #
497 # XXX should be merged with bootstrap, it's not worth keeeping them separate.
498 # Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
499 # on cleaned away headers in ${WORLDTMP}.
500 #
501 include-tools:
502 .for d in usr.bin/compile_et usr.bin/rpcgen
503         cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
504                 ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
505                 ${MAKE} ${MK_FLAGS} all; \
506                 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
507 .endfor
508
509 #
510 # includes - possibly generate and install the include files.
511 #
512 includes:
513 .if defined(CLOBBER)
514         rm -rf ${DESTDIR}/usr/include/*
515         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
516                 -p ${DESTDIR}/usr/include
517 .endif
518         cd ${.CURDIR}/include;                  ${MAKE} -B all install
519         cd ${.CURDIR}/gnu/include;              ${MAKE} install
520         cd ${.CURDIR}/gnu/lib/libmp;            ${MAKE} beforeinstall
521         cd ${.CURDIR}/gnu/lib/libobjc;          ${MAKE} beforeinstall
522         cd ${.CURDIR}/gnu/lib/libreadline;      ${MAKE} beforeinstall
523         cd ${.CURDIR}/gnu/lib/libregex;         ${MAKE} beforeinstall
524         cd ${.CURDIR}/gnu/lib/libstdc++;        ${MAKE} beforeinstall
525         cd ${.CURDIR}/gnu/lib/libdialog;        ${MAKE} beforeinstall
526         cd ${.CURDIR}/gnu/lib/libgmp;           ${MAKE} beforeinstall
527         cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;   ${MAKE} beforeinstall
528 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
529         cd ${.CURDIR}/secure/lib/libdes;        ${MAKE} beforeinstall
530 .endif
531 .if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
532     defined(MAKE_KERBEROS4)
533         cd ${.CURDIR}/kerberosIV/lib/libacl;    ${MAKE} beforeinstall
534         cd ${.CURDIR}/kerberosIV/lib/libkadm;   ${MAKE} beforeinstall
535         cd ${.CURDIR}/kerberosIV/lib/libkafs;   ${MAKE} beforeinstall
536         cd ${.CURDIR}/kerberosIV/lib/libkdb;    ${MAKE} beforeinstall
537         cd ${.CURDIR}/kerberosIV/lib/libkrb;    ${MAKE} beforeinstall
538         cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
539 .else
540         cd ${.CURDIR}/lib/libtelnet;            ${MAKE} beforeinstall
541 .endif
542 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
543         cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};  ${MAKE} beforeinstall
544 .endif
545         cd ${.CURDIR}/lib/libalias;             ${MAKE} beforeinstall
546         cd ${.CURDIR}/lib/libatm;               ${MAKE} beforeinstall
547         cd ${.CURDIR}/lib/libdevstat;           ${MAKE} beforeinstall
548         cd ${.CURDIR}/lib/libc;                 ${MAKE} beforeinstall
549         cd ${.CURDIR}/lib/libcalendar;          ${MAKE} beforeinstall
550         cd ${.CURDIR}/lib/libcam;               ${MAKE} beforeinstall
551         cd ${.CURDIR}/lib/libcurses;            ${MAKE} beforeinstall
552         cd ${.CURDIR}/lib/libdisk;              ${MAKE} beforeinstall
553         cd ${.CURDIR}/lib/libedit;              ${MAKE} beforeinstall
554         cd ${.CURDIR}/lib/libftpio;             ${MAKE} beforeinstall
555         cd ${.CURDIR}/lib/libmd;                ${MAKE} beforeinstall
556         cd ${.CURDIR}/lib/libmytinfo;           ${MAKE} beforeinstall
557         cd ${.CURDIR}/lib/libncurses;           ${MAKE} beforeinstall
558 .if !defined(WANT_CSRG_LIBM)
559         cd ${.CURDIR}/lib/msun;                 ${MAKE} beforeinstall
560 .endif
561         cd ${.CURDIR}/lib/libopie;              ${MAKE} beforeinstall
562         cd ${.CURDIR}/lib/libpam/libpam;        ${MAKE} beforeinstall
563         cd ${.CURDIR}/lib/libpcap;              ${MAKE} beforeinstall
564         cd ${.CURDIR}/lib/libradius;            ${MAKE} beforeinstall
565         cd ${.CURDIR}/lib/librpcsvc;            ${MAKE} beforeinstall
566         cd ${.CURDIR}/lib/libskey;              ${MAKE} beforeinstall
567         cd ${.CURDIR}/lib/libstand;             ${MAKE} beforeinstall
568         cd ${.CURDIR}/lib/libtacplus;           ${MAKE} beforeinstall
569         cd ${.CURDIR}/lib/libtermcap;           ${MAKE} beforeinstall
570         cd ${.CURDIR}/lib/libcom_err;           ${MAKE} beforeinstall
571         cd ${.CURDIR}/lib/libss;                ${MAKE} -B hdrs beforeinstall
572         cd ${.CURDIR}/lib/libutil;              ${MAKE} beforeinstall
573         cd ${.CURDIR}/lib/libvgl;               ${MAKE} beforeinstall
574         cd ${.CURDIR}/lib/libwrap;              ${MAKE} beforeinstall
575         cd ${.CURDIR}/lib/libz;                 ${MAKE} beforeinstall
576         cd ${.CURDIR}/usr.bin/f2c;              ${MAKE} beforeinstall
577         cd ${.CURDIR}/usr.bin/lex;              ${MAKE} beforeinstall
578
579 #
580 # Declare tools if they are not required on all architectures.
581 #
582 .if ${MACHINE_ARCH} == "i386"
583 # aout tools:
584 _aout_ar        = usr.bin/ar
585 _aout_as        = gnu/usr.bin/as
586 _aout_ld        = gnu/usr.bin/ld
587 _aout_nm        = usr.bin/nm
588 _aout_ranlib    = usr.bin/ranlib
589 _aout_size      = usr.bin/size
590 _aout_strip     = usr.bin/strip
591 # boot block/loader tools:
592 _btxld          = usr.sbin/btxld
593 .endif
594
595 #
596 # lib-tools - build tools to compile and install the libraries.
597 #
598 # XXX gperf is required for cc
599 # XXX a new ld and tsort is required for cc
600 lib-tools:
601 .for d in                               \
602                 gnu/usr.bin/gperf       \
603                 ${_aout_ld}             \
604                 usr.bin/tsort           \
605                 ${_aout_as}             \
606                 gnu/usr.bin/bison       \
607                 gnu/usr.bin/cc          \
608                 gnu/lib/libgcc          \
609                 ${_aout_ar}             \
610                 usr.bin/env             \
611                 usr.bin/lex/lib         \
612                 usr.bin/mk_cmds         \
613                 ${_aout_nm}             \
614                 ${_aout_ranlib}         \
615                 ${_aout_strip}          \
616                 gnu/usr.bin/binutils    \
617                 usr.bin/uudecode        \
618                 usr.bin/objformat
619         cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
620                 ${MAKE} ${MK_FLAGS} all; \
621                 ${MAKE} ${MK_FLAGS} -B install; \
622                 ${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
623 .endfor
624
625 #
626 # We have to know too much about ordering and subdirs in the lib trees:
627 #
628 # To satisfy shared library linkage when only the libraries being built
629 # are visible:
630 #
631 # csu must be built before all shared libaries for ELF.
632 # libcom_err must be built before libss.
633 # libcrypt must be built before libskey and libkrb.
634 # libdes must be built before libpam.
635 # libkrb must be built before libpam.
636 # libm must be built before libf2c and libstdc++.
637 # libmd must be built before libatm, libopie, libradius, libskey,
638 # libtacplus and libcrypt.
639 # libmytinfo must be built before libdialog and libncurses.
640 # libncurses must be built before libdialog.
641 # libradius must be built before libpam.
642 # libskey must be built before libpam.
643 # libtacplus must be built before libpam.
644 # libtermcap must be built before libcurses, libedit and libreadline.
645 #
646 # Some libraries are built conditionally and/or are in inconsistently
647 # named directories:
648 #
649 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
650 _csu=lib/csu/${MACHINE_ARCH}.pcc
651 .elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
652 _csu=lib/csu/i386-elf
653 .else
654 _csu=lib/csu/${MACHINE_ARCH}
655 .endif
656
657 .if !defined(NOSECURE) && !defined(NOCRYPT)
658 _libcrypt=      lib/libcrypt secure/lib/libcrypt
659 _secure_lib=    secure/lib
660 .else
661 _libcrypt=      lib/libcrypt
662 .endif
663
664 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
665 _kerberosIV_lib=kerberosIV/lib
666 .endif
667
668 .if defined(WANT_CSRG_LIBM)
669 _libm=  lib/libm
670 .else
671 _libm=  lib/msun
672 .endif
673
674 .if !defined(NOPERL)
675 _libperl=               gnu/usr.bin/perl/libperl
676 .endif
677
678 #
679 # bootstrap-libraries - build just enough libraries for the bootstrap
680 # tools, and install them under ${WORLDTMP}.
681 #
682 # Build csu early so that some tools get linked to the new
683 # version (too late for the main tools, however).  Then build the
684 # necessary prerequisite libraries (libtermcap just needs to be before
685 # libcurses, and this only matters for the NOCLEAN case when NOPIC is
686 # not set).
687 #
688 # This is mostly wrong.  The build tools must run on the host system,
689 # so they should use host libraries.  We depend on the target being
690 # similar enough to the host for new target libraries to work on the
691 # host.
692 #
693 bootstrap-libraries:
694 .for _lib in ${_csu} lib/libtermcap \
695     gnu/lib/libregex gnu/lib/libreadline lib/libc \
696     lib/libcurses lib/libedit ${_libm} \
697     lib/libmd lib/libcrypt lib/libutil lib/libz usr.bin/lex/lib \
698     ${_libperl}
699 .if exists(${.CURDIR}/${_lib})
700         cd ${.CURDIR}/${_lib}; \
701                 ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
702                 ${MAKE} ${MK_FLAGS} all; \
703                 ${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
704 .endif
705 .endfor
706
707 #
708 # libraries - build all libraries, and install them under ${DESTDIR}.
709 #
710 # The ordering is not as special as for bootstrap-libraries.  Build
711 # the prerequisites first, then build almost everything else in
712 # alphabetical order.
713 #
714 libraries:
715 .for _lib in ${_csu} lib/libcom_err ${_libm} lib/libmd ${_libcrypt} \
716     lib/libmytinfo lib/libncurses lib/libtermcap \
717     lib/libradius lib/libskey lib/libtacplus \
718     ${_secure_lib} ${_kerberosIV_lib} \
719     gnu/lib ${_libperl} lib usr.bin/lex/lib \
720     usr.sbin/pcvt/keycap
721 .if exists(${.CURDIR}/${_lib})
722         cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
723 .endif
724 .endfor
725
726 #
727 # Exclude unused tools from build-tools.
728 #
729 .if !defined(NOGAMES) && exists(${.CURDIR}/games)
730 _adventure=     games/adventure
731 _caesar=        games/caesar
732 _hack=          games/hack
733 _phantasia=     games/phantasia
734 _strfile=       games/fortune/strfile
735 .endif
736 .if !defined(NOPERL)
737 _perl=          gnu/usr.bin/perl/miniperl
738 .endif
739 .if !defined(NOSHARE) && exists(${.CURDIR}/share)
740 _scrnmaps=      share/syscons/scrnmaps
741 .endif
742 .if ${MACHINE_ARCH} == i386
743 _kldlinux=      sys/modules/linux
744 .endif
745 .if ${OBJFORMAT} == "aout"
746 _netboot=       sys/${MACHINE}/boot/netboot
747 .endif
748
749 BTMAKEFLAGS=    ${MK_FLAGS} -D_BUILD_TOOLS
750
751 #
752 # build-tools - build and install any other tools needed to complete the
753 # compile and install.
754 # ifdef stale
755 # bc and cpp are required to build groff.  Otherwise, the order here is
756 # mostly historical, i.e., bogus.
757 # chmod is used to build gcc's tmpmultilib[2] at obscure times.
758 # endif stale
759 # XXX uname is a bug - the target should not depend on the host.
760 #
761 build-tools:
762 .for d in                               \
763                 bin/cat                 \
764                 bin/chmod               \
765                 bin/cp                  \
766                 bin/date                \
767                 bin/dd                  \
768                 bin/echo                \
769                 bin/expr                \
770                 bin/hostname            \
771                 bin/ln                  \
772                 bin/ls                  \
773                 bin/mkdir               \
774                 bin/mv                  \
775                 bin/rm                  \
776                 bin/test                \
777                 ${_caesar}              \
778                 ${_strfile}             \
779                 gnu/usr.bin/awk         \
780                 gnu/usr.bin/bc          \
781                 gnu/usr.bin/grep        \
782                 gnu/usr.bin/groff       \
783                 gnu/usr.bin/gzip        \
784                 gnu/usr.bin/man/makewhatis      \
785                 gnu/usr.bin/patch       \
786                 ${_perl}                \
787                 gnu/usr.bin/sort        \
788                 gnu/usr.bin/texinfo     \
789                 usr.bin/basename        \
790                 usr.bin/cap_mkdb        \
791                 usr.bin/chflags         \
792                 usr.bin/cmp             \
793                 usr.bin/col             \
794                 usr.bin/colldef         \
795                 usr.bin/cpp             \
796                 usr.bin/expand          \
797                 usr.bin/file2c          \
798                 usr.bin/find            \
799                 usr.bin/gencat          \
800                 usr.bin/gensetdefs      \
801                 usr.bin/id              \
802                 usr.bin/join            \
803                 usr.bin/lorder          \
804                 usr.bin/m4              \
805                 usr.bin/mkdep           \
806                 usr.bin/mklocale        \
807                 usr.bin/paste           \
808                 usr.bin/printf          \
809                 usr.bin/sed             \
810                 ${_aout_size}           \
811                 usr.bin/soelim          \
812                 usr.bin/symorder        \
813                 usr.bin/touch           \
814                 usr.bin/tr              \
815                 usr.bin/true            \
816                 usr.bin/uname           \
817                 usr.bin/uuencode        \
818                 usr.bin/vgrind          \
819                 usr.bin/vi              \
820                 usr.bin/wc              \
821                 usr.bin/xargs           \
822                 usr.bin/yacc            \
823                 ${_btxld}               \
824                 usr.sbin/chown          \
825                 usr.sbin/mtree          \
826                 usr.sbin/zic            \
827                 bin/sh
828         cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} ${_DEPEND}; \
829                 ${MAKE} ${BTMAKEFLAGS} all; \
830                 ${MAKE} ${BTMAKEFLAGS} -B install ${CLEANDIR} ${OBJDIR}
831 .endfor
832 .if !defined(NOGAMES) && exists(${.CURDIR}/games)
833         cd ${DESTDIR}/usr/games; cp -p caesar strfile ${DESTDIR}/usr/bin
834 .endif
835 .for d in                               \
836                 bin/sh                  \
837                 ${_adventure}           \
838                 ${_hack}                \
839                 ${_phantasia}           \
840                 gnu/usr.bin/cc/cc_tools \
841                 lib/libmytinfo          \
842                 ${_linux}               \
843                 ${_kldlinux}            \
844                 ${_scrnmaps}            \
845                 ${_netboot}
846         cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} build-tools
847 .endfor
848         cd ${.CURDIR}/usr.bin/tn3270/tools; ${MAKE} ${BTMAKEFLAGS} all
849
850 #
851 # Build aout versions of things that provide legacy support when all the
852 # rest of the world is elf.
853 #
854 legacy-build:
855 .if     ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
856         @echo
857         @echo "--------------------------------------------------------------"
858         @echo ">>> Making hierarchy"
859         @echo "--------------------------------------------------------------"
860         mkdir -p ${WORLDTMP}
861         cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 hierarchy
862         @echo
863         @echo "--------------------------------------------------------------"
864         @echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
865         @echo "--------------------------------------------------------------"
866         cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-${OBJDIR}
867         @echo
868         @echo "--------------------------------------------------------------"
869         @echo ">>> Rebuilding ${DESTDIR}/usr/include"
870         @echo "--------------------------------------------------------------"
871         cd ${.CURDIR}; SHARED=copies ${XMAKE} -f Makefile.inc1 includes
872         @echo
873         @echo "--------------------------------------------------------------"
874         @echo ">>> Building legacy libraries"
875         @echo "--------------------------------------------------------------"
876         cd ${.CURDIR}; \
877                 ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 bootstrap-libraries
878         cd ${.CURDIR}; \
879                 ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
880         @echo
881         @echo "--------------------------------------------------------------"
882         @echo ">>> Building legacy rtld"
883         @echo "--------------------------------------------------------------"
884         cd ${.CURDIR}/libexec/rtld-aout; \
885                 ${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
886         @echo
887         @echo "--------------------------------------------------------------"
888         @echo ">>> Building legacy boot"
889         @echo "--------------------------------------------------------------"
890         cd ${.CURDIR}/sys/${MACHINE}/boot && \
891                 ${XMAKE} -DNOMAN -B obj depend; ${XMAKE} -DNOMAN all;
892 .endif
893
894 #
895 # Install aout versions of things that provide legacy support when all the
896 # rest of the world is elf.
897 #
898 legacy-install:
899 .if     ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
900         @echo
901         @echo "--------------------------------------------------------------"
902         @echo ">>> Installing legacy libraries"
903         @echo "--------------------------------------------------------------"
904         cd ${.CURDIR}/lib; ${MAKE} -B -DNOMAN -DNOINFO install
905         cd ${.CURDIR}/gnu/lib; ${MAKE} -B -DNOMAN -DNOINFO install
906         cd ${.CURDIR}/gnu/lib/libgcc; \
907                 ${MAKE} -B -DNOMAN -DNOINFO install
908         cd ${.CURDIR}/usr.bin/lex/lib; \
909                 ${MAKE} -B -DNOMAN -DNOINFO install
910         cd ${.CURDIR}/usr.sbin/pcvt/keycap; \
911                 ${MAKE} -B -DNOMAN -DNOINFO install
912 .if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
913         cd ${.CURDIR}/secure/lib; ${MAKE} -B -DNOMAN -DNOINFO install
914 .endif
915 .if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
916     defined(MAKE_KERBEROS4)
917         cd ${.CURDIR}/kerberosIV/lib; ${MAKE} -B -DNOMAN -DNOINFO install
918 .endif
919         @echo
920         @echo "--------------------------------------------------------------"
921         @echo ">>> Installing legacy rtld"
922         @echo "--------------------------------------------------------------"
923         cd ${.CURDIR}/libexec/rtld-aout; ${MAKE} -DNOMAN install
924         @echo
925 .if ${MACHINE_ARCH} == "i386"
926         @echo "--------------------------------------------------------------"
927         @echo ">>> Installing legacy boot"
928         @echo "--------------------------------------------------------------"
929         cd ${.CURDIR}/sys/${MACHINE}/boot && ${MAKE} -DNOMAN install
930 .endif
931 .endif
932
933
934 # Get the object format that the tools see.
935 #
936 #
937 .if exists(/usr/bin/objformat)
938 __OBJFORMAT!=   objformat
939 .else
940 __OBJFORMAT=    ${OBJFORMAT}
941 .endif
942
943 #
944 # Check if the local /etc/make.conf or /etc/make.conf.local have attempted
945 # to override the OBJFORMAT without updating the environment for the tools
946 # to see.
947 #
948 check-objformat :
949 .if     ${__OBJFORMAT} != ${OBJFORMAT}
950         @/bin/sh -c "echo \"It looks like you set OBJFORMAT=${OBJFORMAT} in /etc/make.conf. Don't do that!\" "
951         @/bin/sh -c "echo \"If you want to override the installed object format, you must set OBJFORMAT\" "
952         @/bin/sh -c "echo \"in your environment.\" "
953         @exit 1
954 .endif
955 .if     !defined(REALLY_WANT_DEPRECIATED_AOUT) && ${OBJFORMAT} == "aout"
956         @echo "==== NOTICE: a.out buildworld is depreciated and disabled! ====="
957         @echo "Read: http://www.freebsd.org/~peter/elfday.html for information."
958         @echo "You need to complete a 'make aout-to-elf' to bring your system"
959         @echo "up to date with ELF tools.  This requires a fair amount of disk"
960         @echo "space to complete.  Alternatively, you can do a binary upgrade"
961         @echo "using the 3.0-RELEASE binaries from CD or ftp.freebsd.org in"
962         @echo "/pub/FreeBSD/3.0-RELEASE/bin/ to convert your userland to ELF."
963         @exit 1
964 .endif
965
966
967 .for __target in clean cleandepend cleandir depend obj
968 .for entry in ${SUBDIR}
969 ${entry}.${__target}__D: .PHONY
970         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
971                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
972                 edir=${entry}.${MACHINE_ARCH}; \
973                 cd ${.CURDIR}/$${edir}; \
974         else \
975                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
976                 edir=${entry}; \
977                 cd ${.CURDIR}/$${edir}; \
978         fi; \
979         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
980 .endfor
981 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
982 .endfor
983
984 .include <bsd.subdir.mk>