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