]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - Makefile.inc1
Fix named(8) DNSSEC validation Denial of Service.
[FreeBSD/releng/8.2.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 #       -DNO_CLEAN do not clean at all
7 #       -DNO_SHARE do not go into share subdir
8 #       -DKERNFAST define NO_KERNELCONFIG, NO_KERNELCLEAN and NO_KERNELDEPEND
9 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
13 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
14 #       -DNO_CTF do not run the DTrace CTF conversion tools on built objects
15 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
16 #       TARGET="machine" to crossbuild world for a different machine type
17
18 #
19 # The intended user-driven targets are:
20 # buildworld  - rebuild *everything*, including glue to help do upgrades
21 # installworld- install everything built by "buildworld"
22 # doxygen     - build API documentation of the kernel
23 # update      - convenient way to update your source tree (eg: cvsup/cvs)
24 #
25 # Standard targets (not defined here) are documented in the makefiles in
26 # /usr/share/mk.  These include:
27 #               obj depend all install clean cleandepend cleanobj
28
29 .include <bsd.own.mk>
30
31 .if ${MACHINE_ARCH} == "mips"
32 MK_RESCUE=no    # not yet
33 .endif
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 #
39 # We must do lib/ and libexec/ before bin/, because if installworld
40 # installs a new /bin/sh, the 'make' command will *immediately*
41 # use that new version.  And the new (dynamically-linked) /bin/sh
42 # will expect to find appropriate libraries in /lib and /libexec.
43 #
44 SUBDIR= share/info lib libexec
45 SUBDIR+=bin
46 .if ${MK_GAMES} != "no"
47 SUBDIR+=games
48 .endif
49 .if ${MK_CDDL} != "no"
50 SUBDIR+=cddl
51 .else
52 NO_CTF=1
53 .endif
54 SUBDIR+=gnu include
55 .if ${MK_KERBEROS} != "no"
56 SUBDIR+=kerberos5
57 .endif
58 .if ${MK_RESCUE} != "no"
59 SUBDIR+=rescue
60 .endif
61 SUBDIR+=sbin
62 .if ${MK_CRYPT} != "no"
63 SUBDIR+=secure
64 .endif
65 .if !defined(NO_SHARE)
66 SUBDIR+=share
67 .endif
68 SUBDIR+=sys usr.bin usr.sbin
69 #
70 # We must do etc/ last for install/distribute to work.
71 #
72 SUBDIR+=etc
73
74 # These are last, since it is nice to at least get the base system
75 # rebuilt before you do them.
76 .for _DIR in ${LOCAL_DIRS}
77 .if exists(${.CURDIR}/${_DIR}/Makefile)
78 SUBDIR+= ${_DIR}
79 .endif
80 .endfor
81
82 .if defined(SUBDIR_OVERRIDE)
83 SUBDIR=         ${SUBDIR_OVERRIDE}
84 .endif
85
86 .if defined(NOCLEAN)
87 NO_CLEAN=       ${NOCLEAN}
88 .endif
89 .if defined(NO_CLEANDIR)
90 CLEANDIR=       clean cleandepend
91 .else
92 CLEANDIR=       cleandir
93 .endif
94
95 CVS?=           cvs
96 CVSFLAGS?=      -r RELENG_8_2 -P -d -I!
97 SVN?=           svn
98 SVNFLAGS?=      -r HEAD
99 SUP?=           /usr/bin/csup
100 SUPFLAGS?=      -g -L 2
101 .if defined(SUPHOST)
102 SUPFLAGS+=      -h ${SUPHOST}
103 .endif
104
105 MAKEOBJDIRPREFIX?=      /usr/obj
106 .if !defined(OSRELDATE)
107 .if exists(/usr/include/osreldate.h)
108 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
109                 /usr/include/osreldate.h
110 .else
111 OSRELDATE=      0
112 .endif
113 .endif
114
115 .if !defined(VERSION)
116 VERSION!=       uname -srp
117 VERSION+=       ${OSRELDATE}
118 .endif
119
120 # Guess machine architecture from machine type, and vice versa.
121 .if !defined(TARGET_ARCH) && defined(TARGET)
122 TARGET_ARCH=    ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
123 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
124     ${TARGET_ARCH} != ${MACHINE_ARCH}
125 TARGET=         ${TARGET_ARCH}
126 .endif
127 # Otherwise, default to current machine type and architecture.
128 TARGET?=        ${MACHINE}
129 TARGET_ARCH?=   ${MACHINE_ARCH}
130
131 KNOWN_ARCHES?=  amd64 arm i386 i386/pc98 ia64 mips powerpc sparc64 sparc64/sun4v
132 .if ${TARGET} == ${TARGET_ARCH}
133 _t=             ${TARGET}
134 .else
135 _t=             ${TARGET_ARCH}/${TARGET}
136 .endif
137 .for _t in ${_t}
138 .if empty(KNOWN_ARCHES:M${_t})
139 .error Unknown target ${TARGET_ARCH}:${TARGET}.
140 .endif
141 .endfor
142
143 .if ${TARGET} == ${MACHINE}
144 TARGET_CPUTYPE?=${CPUTYPE}
145 .else
146 TARGET_CPUTYPE?=
147 .endif
148
149 .if !empty(TARGET_CPUTYPE)
150 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
151 .else
152 _TARGET_CPUTYPE=dummy
153 .endif
154 _CPUTYPE!=      MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
155                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
156 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
157 .error CPUTYPE global should be set with ?=.
158 .endif
159 .if make(buildworld)
160 BUILD_ARCH!=    uname -p
161 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
162 .error To cross-build, set TARGET_ARCH.
163 .endif
164 .endif
165 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
166 OBJTREE=        ${MAKEOBJDIRPREFIX}
167 .else
168 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
169 .endif
170 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
171 # /usr/games added for fortune which depend on strfile
172 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
173 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
174 STRICTTMPPATH=  ${BPATH}:${XPATH}
175 TMPPATH=        ${STRICTTMPPATH}:${PATH}
176
177 #
178 # Avoid running mktemp(1) unless actually needed.
179 # It may not be functional, e.g., due to new ABI
180 # when in the middle of installing over this system.
181 #
182 .if make(distributeworld) || make(installworld)
183 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
184 .endif
185
186 #
187 # Building a world goes through the following stages
188 #
189 # 1. legacy stage [BMAKE]
190 #       This stage is responsible for creating compatibility
191 #       shims that are needed by the bootstrap-tools,
192 #       build-tools and cross-tools stages.
193 # 1. bootstrap-tools stage [BMAKE]
194 #       This stage is responsible for creating programs that
195 #       are needed for backward compatibility reasons. They
196 #       are not built as cross-tools.
197 # 2. build-tools stage [TMAKE]
198 #       This stage is responsible for creating the object
199 #       tree and building any tools that are needed during
200 #       the build process.
201 # 3. cross-tools stage [XMAKE]
202 #       This stage is responsible for creating any tools that
203 #       are needed for cross-builds. A cross-compiler is one
204 #       of them.
205 # 4. world stage [WMAKE]
206 #       This stage actually builds the world.
207 # 5. install stage (optional) [IMAKE]
208 #       This stage installs a previously built world.
209 #
210
211 BOOTSTRAPPING?= 0
212
213 # Common environment for world related stages
214 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
215                 MACHINE_ARCH=${TARGET_ARCH} \
216                 MACHINE=${TARGET} \
217                 CPUTYPE=${TARGET_CPUTYPE} \
218                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
219                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
220                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
221 .if ${OSRELDATE} < 700044
222 CROSSENV+=      AR=gnu-ar RANLIB=gnu-ranlib
223 .endif
224
225 # bootstrap-tools stage
226 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
227                 PATH=${BPATH}:${PATH} \
228                 WORLDTMP=${WORLDTMP} \
229                 VERSION="${VERSION}" \
230                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
231 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
232                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
233                 DESTDIR= \
234                 BOOTSTRAPPING=${OSRELDATE} \
235                 SSP_CFLAGS= \
236                 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
237                 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
238                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
239
240 # build-tools stage
241 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
242                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
243                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
244                 DESTDIR= \
245                 SSP_CFLAGS= \
246                 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
247                 -DNO_WARNS -DNO_CTF
248
249 # cross-tools stage
250 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
251                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
252                 -DWITHOUT_GDB
253
254 # world stage
255 WMAKEENV=       ${CROSSENV} \
256                 _SHLIBDIRPREFIX=${WORLDTMP} \
257                 VERSION="${VERSION}" \
258                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
259                 PATH=${TMPPATH}
260 .if ${MK_CDDL} == "no" || defined(NO_CTF)
261 WMAKEENV+=      NO_CTF=1
262 .endif
263 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
264
265 .if ${TARGET_ARCH} == "amd64"
266 # 32 bit world
267 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
268
269 .if empty(TARGET_CPUTYPE)
270 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
271 .else
272 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
273 .endif
274 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -mfancy-math-387 -DCOMPAT_32BIT \
275                 -iprefix ${LIB32TMP}/usr/ \
276                 -L${LIB32TMP}/usr/lib32 \
277                 -B${LIB32TMP}/usr/lib32
278
279 # Yes, the flags are redundant.
280 LIB32WMAKEENV=  MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
281                 _SHLIBDIRPREFIX=${LIB32TMP} \
282                 VERSION="${VERSION}" \
283                 MACHINE=i386 \
284                 MACHINE_ARCH=i386 \
285                 MACHINE_CPU="i686 mmx sse sse2" \
286                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
287                 PATH=${TMPPATH} \
288                 CC="${CC} ${LIB32FLAGS}" \
289                 CXX="${CXX} ${LIB32FLAGS}" \
290                 OBJC="${OBJC} ${LIB32FLAGS}" \
291                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
292                 AS="${AS} --32" \
293                 LIBDIR=/usr/lib32 \
294                 SHLIBDIR=/usr/lib32
295
296 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
297                 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
298                 -DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
299 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
300 .endif
301
302 # install stage
303 IMAKEENV=       ${CROSSENV}
304 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
305 .if empty(.MAKEFLAGS:M-n)
306 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
307                 LD_LIBRARY_PATH=${INSTALLTMP} \
308                 PATH_LOCALE=${INSTALLTMP}/locale
309 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
310 .else
311 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
312 .endif
313
314 # kernel stage
315 KMAKEENV=       ${WMAKEENV}
316 KMAKE=          ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
317
318 #
319 # buildworld
320 #
321 # Attempt to rebuild the entire system, with reasonable chance of
322 # success, regardless of how old your existing system is.
323 #
324 _worldtmp:
325 .if ${.CURDIR:C/[^,]//g} != ""
326 #       The m4 build of sendmail files doesn't like it if ',' is used
327 #       anywhere in the path of it's files.
328         @echo
329         @echo "*** Error: path to source tree contains a comma ','"
330         @echo
331         false
332 .endif
333         @echo
334         @echo "--------------------------------------------------------------"
335         @echo ">>> Rebuilding the temporary build tree"
336         @echo "--------------------------------------------------------------"
337 .if !defined(NO_CLEAN)
338         rm -rf ${WORLDTMP}
339 .if ${TARGET_ARCH} == "amd64"
340         rm -rf ${LIB32TMP}
341 .endif
342 .else
343         rm -rf ${WORLDTMP}/legacy/usr/include
344 #       XXX - These three can depend on any header file.
345         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
346         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
347         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
348 .endif
349 .for _dir in \
350     lib usr legacy/usr
351         mkdir -p ${WORLDTMP}/${_dir}
352 .endfor
353         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
354             -p ${WORLDTMP}/legacy/usr >/dev/null
355         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
356             -p ${WORLDTMP}/usr >/dev/null
357         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
358             -p ${WORLDTMP}/usr/include >/dev/null
359         ln -sf ${.CURDIR}/sys ${WORLDTMP}
360 .if ${MK_BIND_LIBS} != "no"
361         mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
362             -p ${WORLDTMP}/usr/include >/dev/null
363 .endif
364 _legacy:
365         @echo
366         @echo "--------------------------------------------------------------"
367         @echo ">>> stage 1.1: legacy release compatibility shims"
368         @echo "--------------------------------------------------------------"
369         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
370 _bootstrap-tools:
371         @echo
372         @echo "--------------------------------------------------------------"
373         @echo ">>> stage 1.2: bootstrap tools"
374         @echo "--------------------------------------------------------------"
375         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
376 _cleanobj:
377 .if !defined(NO_CLEAN)
378         @echo
379         @echo "--------------------------------------------------------------"
380         @echo ">>> stage 2.1: cleaning up the object tree"
381         @echo "--------------------------------------------------------------"
382         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
383 .if ${TARGET_ARCH} == "amd64"
384         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
385 .endif
386 .endif
387 _obj:
388         @echo
389         @echo "--------------------------------------------------------------"
390         @echo ">>> stage 2.2: rebuilding the object tree"
391         @echo "--------------------------------------------------------------"
392         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
393 _build-tools:
394         @echo
395         @echo "--------------------------------------------------------------"
396         @echo ">>> stage 2.3: build tools"
397         @echo "--------------------------------------------------------------"
398         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
399 _cross-tools:
400         @echo
401         @echo "--------------------------------------------------------------"
402         @echo ">>> stage 3: cross tools"
403         @echo "--------------------------------------------------------------"
404         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
405 _includes:
406         @echo
407         @echo "--------------------------------------------------------------"
408         @echo ">>> stage 4.1: building includes"
409         @echo "--------------------------------------------------------------"
410         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
411 _libraries:
412         @echo
413         @echo "--------------------------------------------------------------"
414         @echo ">>> stage 4.2: building libraries"
415         @echo "--------------------------------------------------------------"
416         ${_+_}cd ${.CURDIR}; \
417             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
418             -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
419 _depend:
420         @echo
421         @echo "--------------------------------------------------------------"
422         @echo ">>> stage 4.3: make dependencies"
423         @echo "--------------------------------------------------------------"
424         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
425 everything:
426         @echo
427         @echo "--------------------------------------------------------------"
428         @echo ">>> stage 4.4: building everything"
429         @echo "--------------------------------------------------------------"
430         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
431 .if ${TARGET_ARCH} == "amd64"
432 build32:
433         @echo
434         @echo "--------------------------------------------------------------"
435         @echo ">>> stage 5.1: building 32 bit shim libraries"
436         @echo "--------------------------------------------------------------"
437         mkdir -p ${LIB32TMP}/usr/lib32
438         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
439             -p ${LIB32TMP}/usr >/dev/null
440         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
441             -p ${LIB32TMP}/usr/include >/dev/null
442         mkdir -p ${WORLDTMP}
443         ln -sf ${.CURDIR}/sys ${WORLDTMP}
444 .if ${MK_KERBEROS} != "no"
445 .for _t in obj depend all
446         cd ${.CURDIR}/kerberos5/tools; \
447             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
448             ${_t}
449 .endfor
450 .endif
451 .for _t in obj includes
452         cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
453         cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
454 .if ${MK_CDDL} != "no"
455         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
456 .endif
457         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
458 .if ${MK_CRYPT} != "no"
459         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
460 .endif
461 .if ${MK_KERBEROS} != "no"
462         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
463 .endif
464 .endfor
465 .for _dir in usr.bin/lex/lib
466         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
467 .endfor
468 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
469         cd ${.CURDIR}/${_dir}; \
470             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
471             build-tools
472 .endfor
473         cd ${.CURDIR}; \
474             ${LIB32WMAKE} -f Makefile.inc1 libraries
475 .for _t in obj depend all
476         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
477         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
478 .endfor
479
480 distribute32 install32:
481 .if make(distribute32)
482         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
483         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace    # XXX add to mtree
484 .else
485         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
486         mkdir -p ${DESTDIR}/usr/lib32/dtrace            # XXX add to mtree
487 .endif
488         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
489 .if ${MK_CDDL} != "no"
490         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
491 .endif
492         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
493 .if ${MK_CRYPT} != "no"
494         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
495 .endif
496 .if ${MK_KERBEROS} != "no"
497         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
498 .endif
499         cd ${.CURDIR}/libexec/rtld-elf; \
500             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
501         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
502 .endif
503
504 WMAKE_TGTS=
505 .if !defined(SUBDIR_OVERRIDE)
506 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
507 .endif
508 WMAKE_TGTS+=    _cleanobj _obj _build-tools
509 .if !defined(SUBDIR_OVERRIDE)
510 WMAKE_TGTS+=    _cross-tools
511 .endif
512 WMAKE_TGTS+=    _includes _libraries _depend everything
513 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
514 WMAKE_TGTS+=    build32
515 .endif
516
517 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
518 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
519
520 buildworld_prologue:
521         @echo "--------------------------------------------------------------"
522         @echo ">>> World build started on `LC_ALL=C date`"
523         @echo "--------------------------------------------------------------"
524
525 buildworld_epilogue:
526         @echo
527         @echo "--------------------------------------------------------------"
528         @echo ">>> World build completed on `LC_ALL=C date`"
529         @echo "--------------------------------------------------------------"
530
531 #
532 # We need to have this as a target because the indirection between Makefile
533 # and Makefile.inc1 causes the correct PATH to be used, rather than a
534 # modification of the current environment's PATH.  In addition, we need
535 # to quote multiword values.
536 #
537 buildenvvars:
538         @echo ${WMAKEENV:Q}
539
540 buildenv:
541         @echo Entering world for ${TARGET_ARCH}:${TARGET}
542         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
543
544 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
545 toolchain: ${TOOLCHAIN_TGTS}
546 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
547
548 #
549 # installcheck
550 #
551 # Checks to be sure system is ready for installworld/installkernel.
552 #
553 installcheck:
554
555 #
556 # Require DESTDIR to be set if installing for a different architecture.
557 #
558 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
559 .if !make(distributeworld)
560 installcheck: installcheck_DESTDIR
561 installcheck_DESTDIR:
562 .if !defined(DESTDIR) || empty(DESTDIR)
563         @echo "ERROR: Please set DESTDIR!"; \
564         false
565 .endif
566 .endif
567 .endif
568
569 #
570 # Check for missing UIDs/GIDs.
571 #
572 CHECK_UIDS=
573 CHECK_GIDS=     audit
574 .if ${MK_SENDMAIL} != "no"
575 CHECK_UIDS+=    smmsp
576 CHECK_GIDS+=    smmsp
577 .endif
578 .if ${MK_PF} != "no"
579 CHECK_UIDS+=    proxy
580 CHECK_GIDS+=    proxy authpf
581 .endif
582 installcheck: installcheck_UGID
583 installcheck_UGID:
584 .for uid in ${CHECK_UIDS}
585         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
586                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
587                 false; \
588         fi
589 .endfor
590 .for gid in ${CHECK_GIDS}
591         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
592                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
593                 false; \
594         fi
595 .endfor
596
597 #
598 # Required install tools to be saved in a scratch dir for safety.
599 #
600 .if ${MK_INFO} != "no"
601 _install-info=  install-info
602 .endif
603
604 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
605         date echo egrep find grep ${_install-info} \
606         ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
607         test true uname wc zic
608
609 #
610 # distributeworld
611 #
612 # Distributes everything compiled by a `buildworld'.
613 #
614 # installworld
615 #
616 # Installs everything compiled by a 'buildworld'.
617 #
618 distributeworld installworld: installcheck
619         mkdir -p ${INSTALLTMP}
620         progs=$$(for prog in ${ITOOLS}; do \
621                 if progpath=`which $$prog`; then \
622                         echo $$progpath; \
623                 else \
624                         echo "Required tool $$prog not found in PATH." >&2; \
625                         exit 1; \
626                 fi; \
627             done); \
628         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
629             while read line; do \
630                 set -- $$line; \
631                 if [ "$$2 $$3" != "not found" ]; then \
632                         echo $$2; \
633                 else \
634                         echo "Required library $$1 not found." >&2; \
635                         exit 1; \
636                 fi; \
637             done); \
638         cp $$libs $$progs ${INSTALLTMP}
639         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
640         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
641             ${IMAKEENV} rm -rf ${INSTALLTMP}
642
643 #
644 # reinstall
645 #
646 # If you have a build server, you can NFS mount the source and obj directories
647 # and do a 'make reinstall' on the *client* to install new binaries from the
648 # most recent server build.
649 #
650 reinstall:
651         @echo "--------------------------------------------------------------"
652         @echo ">>> Making hierarchy"
653         @echo "--------------------------------------------------------------"
654         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
655         @echo
656         @echo "--------------------------------------------------------------"
657         @echo ">>> Installing everything"
658         @echo "--------------------------------------------------------------"
659         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
660 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
661         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
662 .endif
663
664 redistribute:
665         @echo "--------------------------------------------------------------"
666         @echo ">>> Distributing everything"
667         @echo "--------------------------------------------------------------"
668         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
669 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
670         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
671             DISTRIBUTION=lib32
672 .endif
673
674 distrib-dirs distribution:
675         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
676
677 #
678 # buildkernel and installkernel
679 #
680 # Which kernels to build and/or install is specified by setting
681 # KERNCONF. If not defined a GENERIC kernel is built/installed.
682 # Only the existing (depending TARGET) config files are used
683 # for building kernels and only the first of these is designated
684 # as the one being installed.
685 #
686 # Note that we have to use TARGET instead of TARGET_ARCH when
687 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
688 # be set to cross-build, we have to make sure TARGET is set
689 # properly.
690
691 .if defined(KERNFAST)
692 NO_KERNELCLEAN= t
693 NO_KERNELCONFIG=        t
694 NO_KERNELDEPEND=        t
695 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
696 .if !defined(KERNCONF) && ${KERNFAST} != "1"
697 KERNCONF=${KERNFAST}
698 .endif
699 .endif
700 .if !defined(KERNCONF) && defined(KERNEL)
701 KERNCONF=       ${KERNEL}
702 KERNWARN=
703 .else
704 KERNCONF?=      GENERIC
705 .endif
706 INSTKERNNAME?=  kernel
707
708 KERNSRCDIR?=    ${.CURDIR}/sys
709 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
710 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
711 KERNCONFDIR?=   ${KRNLCONFDIR}
712
713 BUILDKERNELS=
714 INSTALLKERNEL=
715 .for _kernel in ${KERNCONF}
716 .if exists(${KERNCONFDIR}/${_kernel})
717 BUILDKERNELS+=  ${_kernel}
718 .if empty(INSTALLKERNEL)
719 INSTALLKERNEL= ${_kernel}
720 .endif
721 .endif
722 .endfor
723
724 #
725 # buildkernel
726 #
727 # Builds all kernels defined by BUILDKERNELS.
728 #
729 buildkernel:
730 .if empty(BUILDKERNELS)
731         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
732         false
733 .endif
734 .if defined(KERNWARN)
735         @echo "--------------------------------------------------------------"
736         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
737         @echo "--------------------------------------------------------------"
738         @sleep 3
739 .endif
740         @echo
741 .for _kernel in ${BUILDKERNELS}
742         @echo "--------------------------------------------------------------"
743         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
744         @echo "--------------------------------------------------------------"
745         @echo "===> ${_kernel}"
746         mkdir -p ${KRNLOBJDIR}
747 .if !defined(NO_KERNELCONFIG)
748         @echo
749         @echo "--------------------------------------------------------------"
750         @echo ">>> stage 1: configuring the kernel"
751         @echo "--------------------------------------------------------------"
752         cd ${KRNLCONFDIR}; \
753                 PATH=${TMPPATH} \
754                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
755                         ${KERNCONFDIR}/${_kernel}
756 .endif
757 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
758         @echo
759         @echo "--------------------------------------------------------------"
760         @echo ">>> stage 2.1: cleaning up the object tree"
761         @echo "--------------------------------------------------------------"
762         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
763 .endif
764         @echo
765         @echo "--------------------------------------------------------------"
766         @echo ">>> stage 2.2: rebuilding the object tree"
767         @echo "--------------------------------------------------------------"
768         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
769         @echo
770         @echo "--------------------------------------------------------------"
771         @echo ">>> stage 2.3: build tools"
772         @echo "--------------------------------------------------------------"
773         cd ${KRNLOBJDIR}/${_kernel}; \
774             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
775             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \
776             -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
777 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
778 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
779 .for target in obj depend all
780         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
781             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
782             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
783 .endfor
784 .endif
785 .if !defined(NO_KERNELDEPEND)
786         @echo
787         @echo "--------------------------------------------------------------"
788         @echo ">>> stage 3.1: making dependencies"
789         @echo "--------------------------------------------------------------"
790         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
791 .endif
792         @echo
793         @echo "--------------------------------------------------------------"
794         @echo ">>> stage 3.2: building everything"
795         @echo "--------------------------------------------------------------"
796         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
797         @echo "--------------------------------------------------------------"
798         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
799         @echo "--------------------------------------------------------------"
800 .endfor
801
802 #
803 # installkernel, etc.
804 #
805 # Install the kernel defined by INSTALLKERNEL
806 #
807 installkernel installkernel.debug \
808 reinstallkernel reinstallkernel.debug: installcheck
809 .if empty(INSTALLKERNEL)
810         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
811         false
812 .endif
813         @echo "--------------------------------------------------------------"
814         @echo ">>> Installing kernel"
815         @echo "--------------------------------------------------------------"
816         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
817             ${CROSSENV} PATH=${TMPPATH} \
818             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
819
820 #
821 # doxygen
822 #
823 # Build the API documentation with doxygen
824 #
825 doxygen:
826         @if [ ! -x `/usr/bin/which doxygen` ]; then \
827                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
828                 exit 1; \
829         fi
830         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
831
832 #
833 # update
834 #
835 # Update the source tree, by running cvsup and/or running cvs to update to the
836 # latest copy.
837 #
838 update:
839 .if defined(SUP_UPDATE)
840         @echo "--------------------------------------------------------------"
841         @echo ">>> Running ${SUP}"
842         @echo "--------------------------------------------------------------"
843 .if defined(SUPFILE)
844         @${SUP} ${SUPFLAGS} ${SUPFILE}
845 .endif
846 .if defined(SUPFILE1)
847         @${SUP} ${SUPFLAGS} ${SUPFILE1}
848 .endif
849 .if defined(SUPFILE2)
850         @${SUP} ${SUPFLAGS} ${SUPFILE2}
851 .endif
852 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
853         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
854 .endif
855 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
856         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
857 .endif
858 .endif
859 .if defined(CVS_UPDATE)
860         @cd ${.CURDIR} ; \
861         if [ -d CVS ] ; then \
862                 echo "--------------------------------------------------------------" ; \
863                 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
864                 echo "--------------------------------------------------------------" ; \
865                 echo ${CVS} -R -q update ${CVSFLAGS} ; \
866                 ${CVS} -R -q update ${CVSFLAGS} ; \
867         fi
868 .endif
869 .if defined(SVN_UPDATE)
870         @cd ${.CURDIR} ; \
871         if [ -d .svn ] ; then \
872                 echo "--------------------------------------------------------------" ; \
873                 echo ">>> Updating ${.CURDIR} using Subversion" ; \
874                 echo "--------------------------------------------------------------" ; \
875                 echo ${SVN} update ${SVNFLAGS} ; \
876                 ${SVN} update ${SVNFLAGS} ; \
877         fi
878 .endif
879
880 #
881 # ------------------------------------------------------------------------
882 #
883 # From here onwards are utility targets used by the 'make world' and
884 # related targets.  If your 'world' breaks, you may like to try to fix
885 # the problem and manually run the following targets to attempt to
886 # complete the build.  Beware, this is *not* guaranteed to work, you
887 # need to have a pretty good grip on the current state of the system
888 # to attempt to manually finish it.  If in doubt, 'make world' again.
889 #
890
891 #
892 # legacy: Build compatibility shims for the next three targets
893 #
894 legacy:
895 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
896         @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
897         false
898 .endif
899 .for _tool in tools/build
900         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
901             cd ${.CURDIR}/${_tool}; \
902             ${MAKE} DIRPRFX=${_tool}/ obj; \
903             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
904             ${MAKE} DIRPRFX=${_tool}/ depend; \
905             ${MAKE} DIRPRFX=${_tool}/ all; \
906             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
907 .endfor
908
909 #
910 # bootstrap-tools: Build tools needed for compatibility
911 #
912 .if ${MK_GAMES} != "no"
913 _strfile=       games/fortune/strfile
914 .endif
915
916 .if ${MK_CXX} != "no"
917 _gperf=         gnu/usr.bin/gperf
918 .if ${BOOTSTRAPPING} < 700004
919 _groff=         gnu/usr.bin/groff
920 .else
921 _groff=         gnu/usr.bin/groff/tmac
922 .endif
923 .endif
924
925 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
926 _ar=            usr.bin/ar
927 .endif
928
929 .if ${BOOTSTRAPPING} < 800013
930 _mklocale=      usr.bin/mklocale
931 .endif
932
933 .if ${BOOTSTRAPPING} < 700018
934 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
935 .endif
936
937 .if ${MK_RESCUE} != "no" && \
938     ${BOOTSTRAPPING} < 700026
939 _crunchgen=     usr.sbin/crunch/crunchgen
940 .endif
941
942 .if ${MK_CDDL} != "no"
943 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
944     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
945 .endif
946
947 bootstrap-tools:
948 .for _tool in \
949     ${_dtrace_tools} \
950     ${_strfile} \
951     ${_gperf} \
952     ${_groff} \
953     ${_ar} \
954     usr.bin/lorder \
955     usr.bin/makewhatis \
956     ${_mklocale} \
957     usr.bin/rpcgen \
958     usr.bin/xinstall \
959     ${_gensnmptree} \
960     usr.sbin/config \
961     ${_crunchgen}
962         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
963                 cd ${.CURDIR}/${_tool}; \
964                 ${MAKE} DIRPRFX=${_tool}/ obj; \
965                 ${MAKE} DIRPRFX=${_tool}/ depend; \
966                 ${MAKE} DIRPRFX=${_tool}/ all; \
967                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
968 .endfor
969
970 #
971 # build-tools: Build special purpose build tools
972 #
973 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
974 _aicasm= sys/modules/aic7xxx/aicasm
975 .endif
976
977 .if !defined(NO_SHARE)
978 _share= share/syscons/scrnmaps
979 .endif
980
981 .if ${MK_KERBEROS} != "no"
982 _kerberos5_tools= kerberos5/tools
983 .endif
984
985 .if ${MK_RESCUE} != "no"
986 _rescue= rescue/rescue
987 .endif
988
989 build-tools:
990 .for _tool in \
991     bin/csh \
992     bin/sh \
993     ${_rescue} \
994     lib/ncurses/ncurses \
995     lib/ncurses/ncursesw \
996     ${_share} \
997     ${_aicasm} \
998     usr.bin/awk \
999     lib/libmagic \
1000     usr.sbin/sysinstall
1001         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1002                 cd ${.CURDIR}/${_tool}; \
1003                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1004                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1005 .endfor
1006 .for _tool in \
1007     gnu/usr.bin/cc/cc_tools \
1008     ${_kerberos5_tools}
1009         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1010                 cd ${.CURDIR}/${_tool}; \
1011                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1012                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1013                 ${MAKE} DIRPRFX=${_tool}/ all
1014 .endfor
1015
1016 #
1017 # cross-tools: Build cross-building tools
1018 #
1019 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1020 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1021 _btxld=         usr.sbin/btxld
1022 .endif
1023 .endif
1024 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1025 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1026 _crunchide=     usr.sbin/crunch/crunchide
1027 .endif
1028 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1029 _kgzip=         usr.sbin/kgzip
1030 .endif
1031 .endif
1032
1033 cross-tools:
1034 .for _tool in \
1035     gnu/usr.bin/binutils \
1036     gnu/usr.bin/cc \
1037     usr.bin/sed \
1038     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1039     ${_btxld} \
1040     ${_crunchide} \
1041     ${_kgzip}
1042         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1043                 cd ${.CURDIR}/${_tool}; \
1044                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1045                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1046                 ${MAKE} DIRPRFX=${_tool}/ all; \
1047                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1048 .endfor
1049
1050 #
1051 # hierarchy - ensure that all the needed directories are present
1052 #
1053 hierarchy:
1054         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
1055
1056 #
1057 # libraries - build all libraries, and install them under ${DESTDIR}.
1058 #
1059 # The list of libraries with dependents (${_prebuild_libs}) and their
1060 # interdependencies (__L) are built automatically by the
1061 # ${.CURDIR}/tools/make_libdeps.sh script.
1062 #
1063 libraries:
1064         cd ${.CURDIR}; \
1065             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1066             ${MAKE} -f Makefile.inc1 _startup_libs; \
1067             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1068             ${MAKE} -f Makefile.inc1 _generic_libs;
1069
1070 #
1071 # static libgcc.a prerequisite for shared libc
1072 #
1073 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc
1074
1075 # These dependencies are not automatically generated:
1076 #
1077 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1078 # all shared libraries for ELF.
1079 #
1080 _startup_libs=  gnu/lib/csu
1081 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1082 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1083 .else
1084 _startup_libs+= lib/csu/${MACHINE_ARCH}
1085 .endif
1086 _startup_libs+= gnu/lib/libgcc
1087 _startup_libs+= lib/libc
1088
1089 gnu/lib/libgcc__L: lib/libc__L
1090
1091 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1092                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1093                 ${_kerberos5_lib_libroken} \
1094                 lib/libbz2 lib/libcom_err lib/libcrypt \
1095                 lib/libexpat \
1096                 ${_lib_libgssapi} ${_lib_libipx} \
1097                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1098                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1099                 lib/libopie lib/libpam ${_lib_libthr} \
1100                 lib/libradius lib/libsbuf lib/libtacplus \
1101                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1102                 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1103                 ${_secure_lib_libssl}
1104
1105 .if ${MK_LIBTHR} != "no"
1106 _lib_libthr=    lib/libthr
1107 .endif
1108
1109 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1110
1111 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1112
1113 .if ${MK_CDDL} != "no"
1114 _cddl_lib= cddl/lib
1115 .endif
1116
1117 .if ${MK_CRYPT} != "no"
1118 .if ${MK_OPENSSL} != "no"
1119 _secure_lib_libcrypto= secure/lib/libcrypto
1120 _secure_lib_libssl= secure/lib/libssl
1121 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1122 .if ${MK_OPENSSH} != "no"
1123 _secure_lib_libssh= secure/lib/libssh
1124 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1125 .if ${MK_KERBEROS_SUPPORT} != "no"
1126 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1127     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1128     lib/libmd__L kerberos5/lib/libroken__L
1129 .endif
1130 .endif
1131 .endif
1132 _secure_lib=    secure/lib
1133 .endif
1134
1135 .if ${MK_GSSAPI} != "no"
1136 _lib_libgssapi= lib/libgssapi
1137 .endif
1138
1139 .if ${MK_IPX} != "no"
1140 _lib_libipx=    lib/libipx
1141 .endif
1142
1143 .if ${MK_KERBEROS} != "no"
1144 _kerberos5_lib= kerberos5/lib
1145 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1146 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1147 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1148 _kerberos5_lib_libroken= kerberos5/lib/libroken
1149 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1150 .endif
1151
1152 .if ${MK_NIS} != "no"
1153 _lib_libypclnt= lib/libypclnt
1154 .endif
1155
1156 .if ${MK_OPENSSL} == "no"
1157 lib/libradius__L: lib/libmd__L
1158 .endif
1159
1160 .for _lib in ${_prereq_libs}
1161 ${_lib}__PL: .PHONY
1162 .if exists(${.CURDIR}/${_lib})
1163         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1164                 cd ${.CURDIR}/${_lib}; \
1165                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1166                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1167                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1168                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1169 .endif
1170 .endfor
1171
1172 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1173 ${_lib}__L: .PHONY
1174 .if exists(${.CURDIR}/${_lib})
1175         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1176                 cd ${.CURDIR}/${_lib}; \
1177                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1178                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1179                 ${MAKE} DIRPRFX=${_lib}/ all; \
1180                 ${MAKE} DIRPRFX=${_lib}/ install
1181 .endif
1182 .endfor
1183
1184 # libpam is special: we need to build static PAM modules before
1185 # static PAM library, and dynamic PAM library before dynamic PAM
1186 # modules.
1187 lib/libpam__L: .PHONY
1188         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1189                 cd ${.CURDIR}/lib/libpam; \
1190                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1191                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1192                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1193                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1194
1195 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1196 _startup_libs: ${_startup_libs:S/$/__L/}
1197 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1198 _generic_libs: ${_generic_libs:S/$/__L/}
1199
1200 .for __target in all clean cleandepend cleandir depend includes obj
1201 .for entry in ${SUBDIR}
1202 ${entry}.${__target}__D: .PHONY
1203         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1204                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1205                 edir=${entry}.${MACHINE_ARCH}; \
1206                 cd ${.CURDIR}/$${edir}; \
1207         else \
1208                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1209                 edir=${entry}; \
1210                 cd ${.CURDIR}/$${edir}; \
1211         fi; \
1212         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1213 .endfor
1214 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1215 .endfor
1216
1217 .include <bsd.subdir.mk>
1218
1219 .if make(check-old) || make(check-old-dirs) || \
1220     make(check-old-files) || make(check-old-libs) || \
1221     make(delete-old) || make(delete-old-dirs) || \
1222     make(delete-old-files) || make(delete-old-libs)
1223
1224 #
1225 # check for / delete old files section
1226 #
1227
1228 .include "ObsoleteFiles.inc"
1229
1230 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1231 else you can not start such an application. Consult UPDATING for more \
1232 information regarding how to cope with the removal/revision bump of a \
1233 specific library."
1234
1235 .if !defined(BATCH_DELETE_OLD_FILES)
1236 RM_I=-i
1237 .else
1238 RM_I=-v
1239 .endif
1240
1241 delete-old-files:
1242         @echo ">>> Removing old files (only deletes safe to delete libs)"
1243 # Ask for every old file if the user really wants to remove it.
1244 # It's annoying, but better safe than sorry.
1245         @for file in ${OLD_FILES}; do \
1246                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1247                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1248                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1249                 fi; \
1250         done
1251 # Remove catpages without corresponding manpages.
1252         @exec 3<&0; \
1253         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1254         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1255         while read catpage; do \
1256                 read manpage; \
1257                 if [ ! -e "$${manpage}" ]; then \
1258                         rm ${RM_I} $${catpage} <&3 ; \
1259                 fi; \
1260         done
1261         @echo ">>> Old files removed"
1262
1263 check-old-files:
1264         @echo ">>> Checking for old files"
1265         @for file in ${OLD_FILES}; do \
1266                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1267                         echo "${DESTDIR}/$${file}"; \
1268                 fi; \
1269         done
1270 # Check for catpages without corresponding manpages.
1271         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1272         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1273         while read catpage; do \
1274                 read manpage; \
1275                 if [ ! -e "$${manpage}" ]; then \
1276                         echo $${catpage} ; \
1277                 fi; \
1278         done
1279
1280 delete-old-libs:
1281         @echo ">>> Removing old libraries"
1282         @echo "${OLD_LIBS_MESSAGE}" | fmt
1283         @for file in ${OLD_LIBS}; do \
1284                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1285                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1286                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1287                 fi; \
1288         done
1289         @echo ">>> Old libraries removed"
1290
1291 check-old-libs:
1292         @echo ">>> Checking for old libraries"
1293         @for file in ${OLD_LIBS}; do \
1294                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1295                         echo "${DESTDIR}/$${file}"; \
1296                 fi; \
1297         done
1298
1299 delete-old-dirs:
1300         @echo ">>> Removing old directories"
1301         @for dir in ${OLD_DIRS}; do \
1302                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1303                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1304                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1305                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1306                 fi; \
1307         done
1308         @echo ">>> Old directories removed"
1309
1310 check-old-dirs:
1311         @echo ">>> Checking for old directories"
1312         @for dir in ${OLD_DIRS}; do \
1313                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1314                         echo "${DESTDIR}/$${dir}"; \
1315                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1316                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1317                 fi; \
1318         done
1319
1320 delete-old: delete-old-files delete-old-dirs
1321         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1322
1323 check-old: check-old-files check-old-libs check-old-dirs
1324         @echo "To remove old files and directories run '${MAKE} delete-old'."
1325         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1326
1327 .endif
1328
1329 #
1330 # showconfig - show build configuration.
1331 #
1332 showconfig:
1333         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1334
1335
1336 ###############
1337
1338 .if defined(XDEV) && defined(XDEV_ARCH)
1339
1340 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1341         -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1342         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS
1343
1344 XDDIR=${XDEV}-freebsd
1345 XDTP=/usr/${XDDIR}
1346 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1347         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH}
1348 CDENV= ${CDBENV} \
1349         _SHLIBDIRPREFIX=${XDTP} \
1350         TOOLS_PREFIX=${XDTP}
1351 CD2ENV=${CDENV} \
1352         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1353
1354 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1355 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1356 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1357 XDDESTDIR=${DESTDIR}${XDTP}
1358 .if !defined(OSREL)
1359 OSREL!= uname -r | sed -e 's/[-(].*//'
1360 .endif
1361
1362 .ORDER: xdev-build xdev-install
1363 xdev: xdev-build xdev-install
1364
1365 .ORDER: _xb-build-tools _xb-cross-tools
1366 xdev-build: _xb-build-tools _xb-cross-tools
1367
1368 _xb-build-tools:
1369         ${_+_}cd ${.CURDIR}; \
1370         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1371
1372 _xb-cross-tools:
1373 .for _tool in \
1374     gnu/usr.bin/binutils \
1375     gnu/usr.bin/cc
1376         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1377         cd ${.CURDIR}/${_tool}; \
1378         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1379         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1380         ${CDMAKE} DIRPRFX=${_tool}/ all
1381 .endfor
1382
1383 _xi-mtree:
1384         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1385         mkdir -p ${XDDESTDIR}
1386         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1387             -p ${XDDESTDIR} >/dev/null
1388         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1389             -p ${XDDESTDIR}/usr >/dev/null
1390         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1391             -p ${XDDESTDIR}/usr/include >/dev/null
1392
1393 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1394 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1395
1396 _xi-cross-tools:
1397         @echo "_xi-cross-tools"
1398 .for _tool in \
1399     gnu/usr.bin/binutils \
1400     gnu/usr.bin/cc
1401         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1402         cd ${.CURDIR}/${_tool}; \
1403         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1404 .endfor
1405
1406 _xi-includes:
1407         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1408                 DESTDIR=${XDDESTDIR}
1409
1410 _xi-libraries:
1411         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1412                 DESTDIR=${XDDESTDIR}
1413
1414 _xi-links:
1415         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1416                 for i in *; do \
1417                         ln -sf ../../${XDTP}/usr/bin/$$i \
1418                             ../../../../usr/bin/${XDDIR}-$$i; \
1419                         ln -sf ../../${XDTP}/usr/bin/$$i \
1420                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1421                 done
1422 .endif