]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - Makefile.inc1
MFC: r220954 & r221469: Note which of the built kernels is being installed.
[FreeBSD/stable/8.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 -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             DIRPRFX=kerberos5/tools/ ${_t}
449 .endfor
450 .endif
451 .for _t in obj includes
452         cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
453         cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
454 .if ${MK_CDDL} != "no"
455         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
456 .endif
457         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
458 .if ${MK_CRYPT} != "no"
459         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
460 .endif
461 .if ${MK_KERBEROS} != "no"
462         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
463 .endif
464 .endfor
465 .for _dir in usr.bin/lex/lib
466         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ 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             DIRPRFX=${_dir}/ 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} \
477             DIRPRFX=libexec/rtld-elf/ ${_t}
478         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
479             DIRPRFX=usr.bin/ldd ${_t}
480 .endfor
481
482 distribute32 install32:
483 .if make(distribute32)
484         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
485         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace    # XXX add to mtree
486 .else
487         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
488         mkdir -p ${DESTDIR}/usr/lib32/dtrace            # XXX add to mtree
489 .endif
490         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
491 .if ${MK_CDDL} != "no"
492         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
493 .endif
494         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
495 .if ${MK_CRYPT} != "no"
496         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
497 .endif
498 .if ${MK_KERBEROS} != "no"
499         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
500 .endif
501         cd ${.CURDIR}/libexec/rtld-elf; \
502             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
503         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
504 .endif
505
506 WMAKE_TGTS=
507 .if !defined(SUBDIR_OVERRIDE)
508 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
509 .endif
510 WMAKE_TGTS+=    _cleanobj _obj _build-tools
511 .if !defined(SUBDIR_OVERRIDE)
512 WMAKE_TGTS+=    _cross-tools
513 .endif
514 WMAKE_TGTS+=    _includes _libraries _depend everything
515 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
516 WMAKE_TGTS+=    build32
517 .endif
518
519 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
520 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
521
522 buildworld_prologue:
523         @echo "--------------------------------------------------------------"
524         @echo ">>> World build started on `LC_ALL=C date`"
525         @echo "--------------------------------------------------------------"
526
527 buildworld_epilogue:
528         @echo
529         @echo "--------------------------------------------------------------"
530         @echo ">>> World build completed on `LC_ALL=C date`"
531         @echo "--------------------------------------------------------------"
532
533 #
534 # We need to have this as a target because the indirection between Makefile
535 # and Makefile.inc1 causes the correct PATH to be used, rather than a
536 # modification of the current environment's PATH.  In addition, we need
537 # to quote multiword values.
538 #
539 buildenvvars:
540         @echo ${WMAKEENV:Q}
541
542 buildenv:
543         @echo Entering world for ${TARGET_ARCH}:${TARGET}
544         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
545
546 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
547 toolchain: ${TOOLCHAIN_TGTS}
548 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
549
550 #
551 # installcheck
552 #
553 # Checks to be sure system is ready for installworld/installkernel.
554 #
555 installcheck:
556
557 #
558 # Require DESTDIR to be set if installing for a different architecture.
559 #
560 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
561 .if !make(distributeworld)
562 installcheck: installcheck_DESTDIR
563 installcheck_DESTDIR:
564 .if !defined(DESTDIR) || empty(DESTDIR)
565         @echo "ERROR: Please set DESTDIR!"; \
566         false
567 .endif
568 .endif
569 .endif
570
571 #
572 # Check for missing UIDs/GIDs.
573 #
574 CHECK_UIDS=
575 CHECK_GIDS=     audit
576 .if ${MK_SENDMAIL} != "no"
577 CHECK_UIDS+=    smmsp
578 CHECK_GIDS+=    smmsp
579 .endif
580 .if ${MK_PF} != "no"
581 CHECK_UIDS+=    proxy
582 CHECK_GIDS+=    proxy authpf
583 .endif
584 installcheck: installcheck_UGID
585 installcheck_UGID:
586 .for uid in ${CHECK_UIDS}
587         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
588                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
589                 false; \
590         fi
591 .endfor
592 .for gid in ${CHECK_GIDS}
593         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
594                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
595                 false; \
596         fi
597 .endfor
598
599 #
600 # Required install tools to be saved in a scratch dir for safety.
601 #
602 .if ${MK_INFO} != "no"
603 _install-info=  install-info
604 .endif
605
606 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
607         date echo egrep find grep ${_install-info} \
608         ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
609         test true uname wc zic
610
611 #
612 # distributeworld
613 #
614 # Distributes everything compiled by a `buildworld'.
615 #
616 # installworld
617 #
618 # Installs everything compiled by a 'buildworld'.
619 #
620 distributeworld installworld: installcheck
621         mkdir -p ${INSTALLTMP}
622         progs=$$(for prog in ${ITOOLS}; do \
623                 if progpath=`which $$prog`; then \
624                         echo $$progpath; \
625                 else \
626                         echo "Required tool $$prog not found in PATH." >&2; \
627                         exit 1; \
628                 fi; \
629             done); \
630         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
631             while read line; do \
632                 set -- $$line; \
633                 if [ "$$2 $$3" != "not found" ]; then \
634                         echo $$2; \
635                 else \
636                         echo "Required library $$1 not found." >&2; \
637                         exit 1; \
638                 fi; \
639             done); \
640         cp $$libs $$progs ${INSTALLTMP}
641         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
642         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
643             ${IMAKEENV} rm -rf ${INSTALLTMP}
644
645 #
646 # reinstall
647 #
648 # If you have a build server, you can NFS mount the source and obj directories
649 # and do a 'make reinstall' on the *client* to install new binaries from the
650 # most recent server build.
651 #
652 reinstall:
653         @echo "--------------------------------------------------------------"
654         @echo ">>> Making hierarchy"
655         @echo "--------------------------------------------------------------"
656         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
657         @echo
658         @echo "--------------------------------------------------------------"
659         @echo ">>> Installing everything"
660         @echo "--------------------------------------------------------------"
661         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
662 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
663         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
664 .endif
665
666 redistribute:
667         @echo "--------------------------------------------------------------"
668         @echo ">>> Distributing everything"
669         @echo "--------------------------------------------------------------"
670         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
671 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
672         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
673             DISTRIBUTION=lib32
674 .endif
675
676 distrib-dirs distribution:
677         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
678
679 #
680 # buildkernel and installkernel
681 #
682 # Which kernels to build and/or install is specified by setting
683 # KERNCONF. If not defined a GENERIC kernel is built/installed.
684 # Only the existing (depending TARGET) config files are used
685 # for building kernels and only the first of these is designated
686 # as the one being installed.
687 #
688 # Note that we have to use TARGET instead of TARGET_ARCH when
689 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
690 # be set to cross-build, we have to make sure TARGET is set
691 # properly.
692
693 .if defined(KERNFAST)
694 NO_KERNELCLEAN= t
695 NO_KERNELCONFIG=        t
696 NO_KERNELDEPEND=        t
697 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
698 .if !defined(KERNCONF) && ${KERNFAST} != "1"
699 KERNCONF=${KERNFAST}
700 .endif
701 .endif
702 .if !defined(KERNCONF) && defined(KERNEL)
703 KERNCONF=       ${KERNEL}
704 KERNWARN=
705 .else
706 KERNCONF?=      GENERIC
707 .endif
708 INSTKERNNAME?=  kernel
709
710 KERNSRCDIR?=    ${.CURDIR}/sys
711 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
712 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
713 KERNCONFDIR?=   ${KRNLCONFDIR}
714
715 BUILDKERNELS=
716 INSTALLKERNEL=
717 .for _kernel in ${KERNCONF}
718 .if exists(${KERNCONFDIR}/${_kernel})
719 BUILDKERNELS+=  ${_kernel}
720 .if empty(INSTALLKERNEL)
721 INSTALLKERNEL= ${_kernel}
722 .endif
723 .endif
724 .endfor
725
726 #
727 # buildkernel
728 #
729 # Builds all kernels defined by BUILDKERNELS.
730 #
731 buildkernel:
732 .if empty(BUILDKERNELS)
733         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
734         false
735 .endif
736 .if defined(KERNWARN)
737         @echo "--------------------------------------------------------------"
738         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
739         @echo "--------------------------------------------------------------"
740         @sleep 3
741 .endif
742         @echo
743 .for _kernel in ${BUILDKERNELS}
744         @echo "--------------------------------------------------------------"
745         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
746         @echo "--------------------------------------------------------------"
747         @echo "===> ${_kernel}"
748         mkdir -p ${KRNLOBJDIR}
749 .if !defined(NO_KERNELCONFIG)
750         @echo
751         @echo "--------------------------------------------------------------"
752         @echo ">>> stage 1: configuring the kernel"
753         @echo "--------------------------------------------------------------"
754         cd ${KRNLCONFDIR}; \
755                 PATH=${TMPPATH} \
756                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
757                         ${KERNCONFDIR}/${_kernel}
758 .endif
759 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
760         @echo
761         @echo "--------------------------------------------------------------"
762         @echo ">>> stage 2.1: cleaning up the object tree"
763         @echo "--------------------------------------------------------------"
764         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
765 .endif
766         @echo
767         @echo "--------------------------------------------------------------"
768         @echo ">>> stage 2.2: rebuilding the object tree"
769         @echo "--------------------------------------------------------------"
770         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
771         @echo
772         @echo "--------------------------------------------------------------"
773         @echo ">>> stage 2.3: build tools"
774         @echo "--------------------------------------------------------------"
775         cd ${KRNLOBJDIR}/${_kernel}; \
776             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
777             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \
778             -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
779 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
780 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
781 .for target in obj depend all
782         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
783             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
784             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
785 .endfor
786 .endif
787 .if !defined(NO_KERNELDEPEND)
788         @echo
789         @echo "--------------------------------------------------------------"
790         @echo ">>> stage 3.1: making dependencies"
791         @echo "--------------------------------------------------------------"
792         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
793 .endif
794         @echo
795         @echo "--------------------------------------------------------------"
796         @echo ">>> stage 3.2: building everything"
797         @echo "--------------------------------------------------------------"
798         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
799         @echo "--------------------------------------------------------------"
800         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
801         @echo "--------------------------------------------------------------"
802 .endfor
803
804 #
805 # installkernel, etc.
806 #
807 # Install the kernel defined by INSTALLKERNEL
808 #
809 installkernel installkernel.debug \
810 reinstallkernel reinstallkernel.debug: installcheck
811 .if empty(INSTALLKERNEL)
812         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
813         false
814 .endif
815         @echo "--------------------------------------------------------------"
816         @echo ">>> Installing kernel ${INSTALLKERNEL}"
817         @echo "--------------------------------------------------------------"
818         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
819             ${CROSSENV} PATH=${TMPPATH} \
820             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
821
822 #
823 # doxygen
824 #
825 # Build the API documentation with doxygen
826 #
827 doxygen:
828         @if [ ! -x `/usr/bin/which doxygen` ]; then \
829                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
830                 exit 1; \
831         fi
832         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
833
834 #
835 # update
836 #
837 # Update the source tree, by running cvsup and/or running cvs to update to the
838 # latest copy.
839 #
840 update:
841 .if defined(SUP_UPDATE)
842         @echo "--------------------------------------------------------------"
843         @echo ">>> Running ${SUP}"
844         @echo "--------------------------------------------------------------"
845 .if defined(SUPFILE)
846         @${SUP} ${SUPFLAGS} ${SUPFILE}
847 .endif
848 .if defined(SUPFILE1)
849         @${SUP} ${SUPFLAGS} ${SUPFILE1}
850 .endif
851 .if defined(SUPFILE2)
852         @${SUP} ${SUPFLAGS} ${SUPFILE2}
853 .endif
854 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
855         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
856 .endif
857 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
858         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
859 .endif
860 .endif
861 .if defined(CVS_UPDATE)
862         @cd ${.CURDIR} ; \
863         if [ -d CVS ] ; then \
864                 echo "--------------------------------------------------------------" ; \
865                 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
866                 echo "--------------------------------------------------------------" ; \
867                 echo ${CVS} -R -q update ${CVSFLAGS} ; \
868                 ${CVS} -R -q update ${CVSFLAGS} ; \
869         fi
870 .endif
871 .if defined(SVN_UPDATE)
872         @cd ${.CURDIR} ; \
873         if [ -d .svn ] ; then \
874                 echo "--------------------------------------------------------------" ; \
875                 echo ">>> Updating ${.CURDIR} using Subversion" ; \
876                 echo "--------------------------------------------------------------" ; \
877                 echo ${SVN} update ${SVNFLAGS} ; \
878                 ${SVN} update ${SVNFLAGS} ; \
879         fi
880 .endif
881
882 #
883 # ------------------------------------------------------------------------
884 #
885 # From here onwards are utility targets used by the 'make world' and
886 # related targets.  If your 'world' breaks, you may like to try to fix
887 # the problem and manually run the following targets to attempt to
888 # complete the build.  Beware, this is *not* guaranteed to work, you
889 # need to have a pretty good grip on the current state of the system
890 # to attempt to manually finish it.  If in doubt, 'make world' again.
891 #
892
893 #
894 # legacy: Build compatibility shims for the next three targets
895 #
896 legacy:
897 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
898         @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
899         false
900 .endif
901 .for _tool in tools/build
902         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
903             cd ${.CURDIR}/${_tool}; \
904             ${MAKE} DIRPRFX=${_tool}/ obj; \
905             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
906             ${MAKE} DIRPRFX=${_tool}/ depend; \
907             ${MAKE} DIRPRFX=${_tool}/ all; \
908             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
909 .endfor
910
911 #
912 # bootstrap-tools: Build tools needed for compatibility
913 #
914 .if ${MK_GAMES} != "no"
915 _strfile=       games/fortune/strfile
916 .endif
917
918 .if ${MK_CXX} != "no"
919 _gperf=         gnu/usr.bin/gperf
920 .if ${BOOTSTRAPPING} < 700004
921 _groff=         gnu/usr.bin/groff
922 .else
923 _groff=         gnu/usr.bin/groff/tmac
924 .endif
925 .endif
926
927 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
928 _ar=            usr.bin/ar
929 .endif
930
931 .if ${BOOTSTRAPPING} < 802000
932 _lex=           usr.bin/lex
933 .endif
934
935 .if ${BOOTSTRAPPING} < 800013
936 _mklocale=      usr.bin/mklocale
937 .endif
938
939 .if ${BOOTSTRAPPING} < 700018
940 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
941 .endif
942
943 .if ${MK_RESCUE} != "no" && \
944     ${BOOTSTRAPPING} < 700026
945 _crunchgen=     usr.sbin/crunch/crunchgen
946 .endif
947
948 .if ${MK_CDDL} != "no"
949 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
950     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
951 .endif
952
953 bootstrap-tools:
954 .for _tool in \
955     ${_dtrace_tools} \
956     ${_strfile} \
957     ${_gperf} \
958     ${_groff} \
959     ${_ar} \
960     ${_lex} \
961     usr.bin/lorder \
962     usr.bin/makewhatis \
963     ${_mklocale} \
964     usr.bin/rpcgen \
965     usr.bin/xinstall \
966     ${_gensnmptree} \
967     usr.sbin/config \
968     ${_crunchgen}
969         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
970                 cd ${.CURDIR}/${_tool}; \
971                 ${MAKE} DIRPRFX=${_tool}/ obj; \
972                 ${MAKE} DIRPRFX=${_tool}/ depend; \
973                 ${MAKE} DIRPRFX=${_tool}/ all; \
974                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
975 .endfor
976
977 #
978 # build-tools: Build special purpose build tools
979 #
980 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
981 _aicasm= sys/modules/aic7xxx/aicasm
982 .endif
983
984 .if !defined(NO_SHARE)
985 _share= share/syscons/scrnmaps
986 .endif
987
988 .if ${MK_KERBEROS} != "no"
989 _kerberos5_tools= kerberos5/tools
990 .endif
991
992 .if ${MK_RESCUE} != "no"
993 _rescue= rescue/rescue
994 .endif
995
996 build-tools:
997 .for _tool in \
998     bin/csh \
999     bin/sh \
1000     ${_rescue} \
1001     lib/ncurses/ncurses \
1002     lib/ncurses/ncursesw \
1003     ${_share} \
1004     ${_aicasm} \
1005     usr.bin/awk \
1006     lib/libmagic \
1007     usr.sbin/sysinstall
1008         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1009                 cd ${.CURDIR}/${_tool}; \
1010                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1011                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1012 .endfor
1013 .for _tool in \
1014     gnu/usr.bin/cc/cc_tools \
1015     ${_kerberos5_tools}
1016         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1017                 cd ${.CURDIR}/${_tool}; \
1018                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1019                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1020                 ${MAKE} DIRPRFX=${_tool}/ all
1021 .endfor
1022
1023 #
1024 # cross-tools: Build cross-building tools
1025 #
1026 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1027 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1028 _btxld=         usr.sbin/btxld
1029 .endif
1030 .endif
1031 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1032 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1033 _crunchide=     usr.sbin/crunch/crunchide
1034 .endif
1035 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1036 _kgzip=         usr.sbin/kgzip
1037 .endif
1038 .endif
1039
1040 cross-tools:
1041 .for _tool in \
1042     gnu/usr.bin/binutils \
1043     gnu/usr.bin/cc \
1044     usr.bin/sed \
1045     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1046     ${_btxld} \
1047     ${_crunchide} \
1048     ${_kgzip}
1049         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1050                 cd ${.CURDIR}/${_tool}; \
1051                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1052                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1053                 ${MAKE} DIRPRFX=${_tool}/ all; \
1054                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1055 .endfor
1056
1057 #
1058 # hierarchy - ensure that all the needed directories are present
1059 #
1060 hierarchy:
1061         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
1062
1063 #
1064 # libraries - build all libraries, and install them under ${DESTDIR}.
1065 #
1066 # The list of libraries with dependents (${_prebuild_libs}) and their
1067 # interdependencies (__L) are built automatically by the
1068 # ${.CURDIR}/tools/make_libdeps.sh script.
1069 #
1070 libraries:
1071         cd ${.CURDIR}; \
1072             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1073             ${MAKE} -f Makefile.inc1 _startup_libs; \
1074             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1075             ${MAKE} -f Makefile.inc1 _generic_libs;
1076
1077 #
1078 # static libgcc.a prerequisite for shared libc
1079 #
1080 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc
1081
1082 # These dependencies are not automatically generated:
1083 #
1084 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1085 # all shared libraries for ELF.
1086 #
1087 _startup_libs=  gnu/lib/csu
1088 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1089 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1090 .else
1091 _startup_libs+= lib/csu/${MACHINE_ARCH}
1092 .endif
1093 _startup_libs+= gnu/lib/libgcc
1094 _startup_libs+= lib/libc
1095
1096 gnu/lib/libgcc__L: lib/libc__L
1097
1098 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1099                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1100                 ${_kerberos5_lib_libroken} \
1101                 lib/libbz2 lib/libcom_err lib/libcrypt \
1102                 lib/libexpat \
1103                 ${_lib_libgssapi} ${_lib_libipx} \
1104                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1105                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1106                 lib/libopie lib/libpam ${_lib_libthr} \
1107                 lib/libradius lib/libsbuf lib/libtacplus \
1108                 ${_cddl_lib_libumem} \
1109                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1110                 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1111                 ${_secure_lib_libssl}
1112
1113 .if ${MK_LIBTHR} != "no"
1114 _lib_libthr=    lib/libthr
1115 .endif
1116
1117 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1118
1119 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1120
1121 .if ${MK_CDDL} != "no"
1122 _cddl_lib_libumem= cddl/lib/libumem
1123 _cddl_lib= cddl/lib
1124 .endif
1125
1126 .if ${MK_CRYPT} != "no"
1127 .if ${MK_OPENSSL} != "no"
1128 _secure_lib_libcrypto= secure/lib/libcrypto
1129 _secure_lib_libssl= secure/lib/libssl
1130 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1131 .if ${MK_OPENSSH} != "no"
1132 _secure_lib_libssh= secure/lib/libssh
1133 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1134 .if ${MK_KERBEROS_SUPPORT} != "no"
1135 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1136     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1137     lib/libmd__L kerberos5/lib/libroken__L
1138 .endif
1139 .endif
1140 .endif
1141 _secure_lib=    secure/lib
1142 .endif
1143
1144 .if ${MK_GSSAPI} != "no"
1145 _lib_libgssapi= lib/libgssapi
1146 .endif
1147
1148 .if ${MK_IPX} != "no"
1149 _lib_libipx=    lib/libipx
1150 .endif
1151
1152 .if ${MK_KERBEROS} != "no"
1153 _kerberos5_lib= kerberos5/lib
1154 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1155 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1156 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1157 _kerberos5_lib_libroken= kerberos5/lib/libroken
1158 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1159 .endif
1160
1161 .if ${MK_NIS} != "no"
1162 _lib_libypclnt= lib/libypclnt
1163 .endif
1164
1165 .if ${MK_OPENSSL} == "no"
1166 lib/libradius__L: lib/libmd__L
1167 .endif
1168
1169 .for _lib in ${_prereq_libs}
1170 ${_lib}__PL: .PHONY
1171 .if exists(${.CURDIR}/${_lib})
1172         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1173                 cd ${.CURDIR}/${_lib}; \
1174                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1175                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1176                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1177                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1178 .endif
1179 .endfor
1180
1181 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1182 ${_lib}__L: .PHONY
1183 .if exists(${.CURDIR}/${_lib})
1184         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1185                 cd ${.CURDIR}/${_lib}; \
1186                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1187                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1188                 ${MAKE} DIRPRFX=${_lib}/ all; \
1189                 ${MAKE} DIRPRFX=${_lib}/ install
1190 .endif
1191 .endfor
1192
1193 # libpam is special: we need to build static PAM modules before
1194 # static PAM library, and dynamic PAM library before dynamic PAM
1195 # modules.
1196 lib/libpam__L: .PHONY
1197         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1198                 cd ${.CURDIR}/lib/libpam; \
1199                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1200                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1201                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1202                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1203
1204 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1205 _startup_libs: ${_startup_libs:S/$/__L/}
1206 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1207 _generic_libs: ${_generic_libs:S/$/__L/}
1208
1209 .for __target in all clean cleandepend cleandir depend includes obj
1210 .for entry in ${SUBDIR}
1211 ${entry}.${__target}__D: .PHONY
1212         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1213                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1214                 edir=${entry}.${MACHINE_ARCH}; \
1215                 cd ${.CURDIR}/$${edir}; \
1216         else \
1217                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1218                 edir=${entry}; \
1219                 cd ${.CURDIR}/$${edir}; \
1220         fi; \
1221         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1222 .endfor
1223 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1224 .endfor
1225
1226 .include <bsd.subdir.mk>
1227
1228 .if make(check-old) || make(check-old-dirs) || \
1229     make(check-old-files) || make(check-old-libs) || \
1230     make(delete-old) || make(delete-old-dirs) || \
1231     make(delete-old-files) || make(delete-old-libs)
1232
1233 #
1234 # check for / delete old files section
1235 #
1236
1237 .include "ObsoleteFiles.inc"
1238
1239 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1240 else you can not start such an application. Consult UPDATING for more \
1241 information regarding how to cope with the removal/revision bump of a \
1242 specific library."
1243
1244 .if !defined(BATCH_DELETE_OLD_FILES)
1245 RM_I=-i
1246 .else
1247 RM_I=-v
1248 .endif
1249
1250 delete-old-files:
1251         @echo ">>> Removing old files (only deletes safe to delete libs)"
1252 # Ask for every old file if the user really wants to remove it.
1253 # It's annoying, but better safe than sorry.
1254         @for file in ${OLD_FILES}; do \
1255                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1256                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1257                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1258                 fi; \
1259         done
1260 # Remove catpages without corresponding manpages.
1261         @exec 3<&0; \
1262         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1263         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1264         while read catpage; do \
1265                 read manpage; \
1266                 if [ ! -e "$${manpage}" ]; then \
1267                         rm ${RM_I} $${catpage} <&3 ; \
1268                 fi; \
1269         done
1270         @echo ">>> Old files removed"
1271
1272 check-old-files:
1273         @echo ">>> Checking for old files"
1274         @for file in ${OLD_FILES}; do \
1275                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1276                         echo "${DESTDIR}/$${file}"; \
1277                 fi; \
1278         done
1279 # Check for catpages without corresponding manpages.
1280         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1281         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1282         while read catpage; do \
1283                 read manpage; \
1284                 if [ ! -e "$${manpage}" ]; then \
1285                         echo $${catpage} ; \
1286                 fi; \
1287         done
1288
1289 delete-old-libs:
1290         @echo ">>> Removing old libraries"
1291         @echo "${OLD_LIBS_MESSAGE}" | fmt
1292         @for file in ${OLD_LIBS}; do \
1293                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1294                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1295                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1296                 fi; \
1297         done
1298         @echo ">>> Old libraries removed"
1299
1300 check-old-libs:
1301         @echo ">>> Checking for old libraries"
1302         @for file in ${OLD_LIBS}; do \
1303                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1304                         echo "${DESTDIR}/$${file}"; \
1305                 fi; \
1306         done
1307
1308 delete-old-dirs:
1309         @echo ">>> Removing old directories"
1310         @for dir in ${OLD_DIRS}; do \
1311                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1312                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1313                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1314                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1315                 fi; \
1316         done
1317         @echo ">>> Old directories removed"
1318
1319 check-old-dirs:
1320         @echo ">>> Checking for old directories"
1321         @for dir in ${OLD_DIRS}; do \
1322                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1323                         echo "${DESTDIR}/$${dir}"; \
1324                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1325                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1326                 fi; \
1327         done
1328
1329 delete-old: delete-old-files delete-old-dirs
1330         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1331
1332 check-old: check-old-files check-old-libs check-old-dirs
1333         @echo "To remove old files and directories run '${MAKE} delete-old'."
1334         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1335
1336 .endif
1337
1338 #
1339 # showconfig - show build configuration.
1340 #
1341 showconfig:
1342         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1343
1344
1345 ###############
1346
1347 .if defined(XDEV) && defined(XDEV_ARCH)
1348
1349 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1350         -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1351         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS
1352
1353 XDDIR=${XDEV}-freebsd
1354 XDTP=/usr/${XDDIR}
1355 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1356         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH}
1357 CDENV= ${CDBENV} \
1358         _SHLIBDIRPREFIX=${XDTP} \
1359         TOOLS_PREFIX=${XDTP}
1360 CD2ENV=${CDENV} \
1361         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1362
1363 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1364 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1365 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1366 XDDESTDIR=${DESTDIR}${XDTP}
1367 .if !defined(OSREL)
1368 OSREL!= uname -r | sed -e 's/[-(].*//'
1369 .endif
1370
1371 .ORDER: xdev-build xdev-install
1372 xdev: xdev-build xdev-install
1373
1374 .ORDER: _xb-build-tools _xb-cross-tools
1375 xdev-build: _xb-build-tools _xb-cross-tools
1376
1377 _xb-build-tools:
1378         ${_+_}cd ${.CURDIR}; \
1379         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1380
1381 _xb-cross-tools:
1382 .for _tool in \
1383     gnu/usr.bin/binutils \
1384     gnu/usr.bin/cc
1385         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1386         cd ${.CURDIR}/${_tool}; \
1387         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1388         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1389         ${CDMAKE} DIRPRFX=${_tool}/ all
1390 .endfor
1391
1392 _xi-mtree:
1393         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1394         mkdir -p ${XDDESTDIR}
1395         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1396             -p ${XDDESTDIR} >/dev/null
1397         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1398             -p ${XDDESTDIR}/usr >/dev/null
1399         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1400             -p ${XDDESTDIR}/usr/include >/dev/null
1401
1402 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1403 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1404
1405 _xi-cross-tools:
1406         @echo "_xi-cross-tools"
1407 .for _tool in \
1408     gnu/usr.bin/binutils \
1409     gnu/usr.bin/cc
1410         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1411         cd ${.CURDIR}/${_tool}; \
1412         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1413 .endfor
1414
1415 _xi-includes:
1416         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1417                 DESTDIR=${XDDESTDIR}
1418
1419 _xi-libraries:
1420         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1421                 DESTDIR=${XDDESTDIR}
1422
1423 _xi-links:
1424         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1425                 for i in *; do \
1426                         ln -sf ../../${XDTP}/usr/bin/$$i \
1427                             ../../../../usr/bin/${XDDIR}-$$i; \
1428                         ln -sf ../../${XDTP}/usr/bin/$$i \
1429                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1430                 done
1431 .endif