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