]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - Makefile.inc1
MFC r256915
[FreeBSD/stable/10.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 #       -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 #           the system database when installing.
9 #       -DNO_SHARE do not go into share subdir
10 #       -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 #       -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 #       -DNO_ROOT install without using root privilege
17 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 #       -DNO_CTF do not run the DTrace CTF conversion tools on built objects
19 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 #       LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 #       LOCAL_MTREE="list of mtree files" to process to allow local directories
22 #           to be created before files are installed
23 #       LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
24 #           list
25 #       METALOG="path to metadata log" to write permission and ownership
26 #           when NO_ROOT is set.  (default: ${DESTDIR}/METALOG)
27 #       TARGET="machine" to crossbuild world for a different machine type
28 #       TARGET_ARCH= may be required when a TARGET supports multiple endians
29 #       BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
30 #       WORLD_FLAGS= additional flags to pass to make(1) during buildworld
31 #       KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
32
33 #
34 # The intended user-driven targets are:
35 # buildworld  - rebuild *everything*, including glue to help do upgrades
36 # installworld- install everything built by "buildworld"
37 # doxygen     - build API documentation of the kernel
38 # update      - convenient way to update your source tree (eg: svn/svnup)
39 #
40 # Standard targets (not defined here) are documented in the makefiles in
41 # /usr/share/mk.  These include:
42 #               obj depend all install clean cleandepend cleanobj
43
44 .if !defined(TARGET) || !defined(TARGET_ARCH)
45 .error "Both TARGET and TARGET_ARCH must be defined."
46 .endif
47
48 .include <bsd.own.mk>
49 .include <bsd.arch.inc.mk>
50 .include <bsd.compiler.mk>
51
52 # We must do share/info early so that installation of info `dir'
53 # entries works correctly.  Do it first since it is less likely to
54 # grow dependencies on include and lib than vice versa.
55 #
56 # We must do lib/ and libexec/ before bin/, because if installworld
57 # installs a new /bin/sh, the 'make' command will *immediately*
58 # use that new version.  And the new (dynamically-linked) /bin/sh
59 # will expect to find appropriate libraries in /lib and /libexec.
60 #
61 SRCDIR?=        ${.CURDIR}
62 .if defined(SUBDIR_OVERRIDE)
63 SUBDIR= ${SUBDIR_OVERRIDE}
64 .else
65 SUBDIR= share/info lib libexec
66 SUBDIR+=bin
67 .if ${MK_GAMES} != "no"
68 SUBDIR+=games
69 .endif
70 .if ${MK_CDDL} != "no"
71 SUBDIR+=cddl
72 .endif
73 SUBDIR+=gnu include
74 .if ${MK_KERBEROS} != "no"
75 SUBDIR+=kerberos5
76 .endif
77 .if ${MK_RESCUE} != "no"
78 SUBDIR+=rescue
79 .endif
80 SUBDIR+=sbin
81 .if ${MK_CRYPT} != "no"
82 SUBDIR+=secure
83 .endif
84 .if !defined(NO_SHARE)
85 SUBDIR+=share
86 .endif
87 SUBDIR+=sys usr.bin usr.sbin
88 .if ${MK_OFED} != "no"
89 SUBDIR+=contrib/ofed
90 .endif
91 #
92 # We must do etc/ last for install/distribute to work.
93 #
94 SUBDIR+=etc
95
96 # These are last, since it is nice to at least get the base system
97 # rebuilt before you do them.
98 .for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS}
99 .if exists(${.CURDIR}/${_DIR}/Makefile)
100 SUBDIR+= ${_DIR}
101 .endif
102 .endfor
103 .endif
104
105 .if defined(NOCLEAN)
106 NO_CLEAN=       ${NOCLEAN}
107 .endif
108 .if defined(NO_CLEANDIR)
109 CLEANDIR=       clean cleandepend
110 .else
111 CLEANDIR=       cleandir
112 .endif
113
114 LOCAL_TOOL_DIRS?=
115
116 BUILDENV_SHELL?=/bin/sh
117
118 SVN?=           /usr/local/bin/svn
119 SVNFLAGS?=      -r HEAD
120
121 MAKEOBJDIRPREFIX?=      /usr/obj
122 .if !defined(OSRELDATE)
123 .if exists(/usr/include/osreldate.h)
124 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
125                 /usr/include/osreldate.h
126 .else
127 OSRELDATE=      0
128 .endif
129 .endif
130
131 .if !defined(VERSION)
132 REVISION!=      make -C ${SRCDIR}/release -V REVISION
133 BRANCH!=        make -C ${SRCDIR}/release -V BRANCH
134 SRCRELDATE!=    awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
135                 ${SRCDIR}/sys/sys/param.h
136 VERSION=        FreeBSD ${REVISION}-${BRANCH} ${TARGET_ARCH} ${SRCRELDATE}
137 .endif
138
139 KNOWN_ARCHES?=  amd64 arm armeb/arm armv6/arm i386 i386/pc98 ia64 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
140 .if ${TARGET} == ${TARGET_ARCH}
141 _t=             ${TARGET}
142 .else
143 _t=             ${TARGET_ARCH}/${TARGET}
144 .endif
145 .for _t in ${_t}
146 .if empty(KNOWN_ARCHES:M${_t})
147 .error Unknown target ${TARGET_ARCH}:${TARGET}.
148 .endif
149 .endfor
150
151 .if ${TARGET} == ${MACHINE}
152 TARGET_CPUTYPE?=${CPUTYPE}
153 .else
154 TARGET_CPUTYPE?=
155 .endif
156
157 .if !empty(TARGET_CPUTYPE)
158 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
159 .else
160 _TARGET_CPUTYPE=dummy
161 .endif
162 _CPUTYPE!=      MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
163                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
164 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
165 .error CPUTYPE global should be set with ?=.
166 .endif
167 .if make(buildworld)
168 BUILD_ARCH!=    uname -p
169 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
170 .error To cross-build, set TARGET_ARCH.
171 .endif
172 .endif
173 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
174 OBJTREE=        ${MAKEOBJDIRPREFIX}
175 .else
176 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
177 .endif
178 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
179 # /usr/games added for fortune which depend on strfile
180 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
181 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
182 STRICTTMPPATH=  ${BPATH}:${XPATH}
183 TMPPATH=        ${STRICTTMPPATH}:${PATH}
184
185 #
186 # Avoid running mktemp(1) unless actually needed.
187 # It may not be functional, e.g., due to new ABI
188 # when in the middle of installing over this system.
189 #
190 .if make(distributeworld) || make(installworld)
191 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
192 .endif
193
194 #
195 # Building a world goes through the following stages
196 #
197 # 1. legacy stage [BMAKE]
198 #       This stage is responsible for creating compatibility
199 #       shims that are needed by the bootstrap-tools,
200 #       build-tools and cross-tools stages.
201 # 1. bootstrap-tools stage [BMAKE]
202 #       This stage is responsible for creating programs that
203 #       are needed for backward compatibility reasons. They
204 #       are not built as cross-tools.
205 # 2. build-tools stage [TMAKE]
206 #       This stage is responsible for creating the object
207 #       tree and building any tools that are needed during
208 #       the build process.
209 # 3. cross-tools stage [XMAKE]
210 #       This stage is responsible for creating any tools that
211 #       are needed for cross-builds. A cross-compiler is one
212 #       of them.
213 # 4. world stage [WMAKE]
214 #       This stage actually builds the world.
215 # 5. install stage (optional) [IMAKE]
216 #       This stage installs a previously built world.
217 #
218
219 BOOTSTRAPPING?= 0
220
221 # Common environment for world related stages
222 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
223                 MACHINE_ARCH=${TARGET_ARCH} \
224                 MACHINE=${TARGET} \
225                 CPUTYPE=${TARGET_CPUTYPE}
226 .if ${MK_GROFF} != "no"
227 CROSSENV+=      GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
228                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
229                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
230 .endif
231
232 # bootstrap-tools stage
233 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
234                 PATH=${BPATH}:${PATH} \
235                 WORLDTMP=${WORLDTMP} \
236                 VERSION="${VERSION}" \
237                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
238                 COMPILER_TYPE=${COMPILER_TYPE}
239 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
240                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
241                 DESTDIR= \
242                 BOOTSTRAPPING=${OSRELDATE} \
243                 SSP_CFLAGS= \
244                 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
245                 -DNO_PIC -DNO_PROFILE -DNO_SHARED \
246                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
247
248 # build-tools stage
249 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
250                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
251                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
252                 DESTDIR= \
253                 BOOTSTRAPPING=${OSRELDATE} \
254                 SSP_CFLAGS= \
255                 -DNO_LINT \
256                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
257
258 # cross-tools stage
259 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
260                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
261                 -DWITHOUT_GDB
262
263 # world stage
264 WMAKEENV=       ${CROSSENV} \
265                 _SHLIBDIRPREFIX=${WORLDTMP} \
266                 _LDSCRIPTROOT= \
267                 VERSION="${VERSION}" \
268                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
269                 PATH=${TMPPATH}
270
271 # make hierarchy
272 HMAKE=          PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
273 .if defined(NO_ROOT)
274 HMAKE+=         PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
275 .endif
276
277 .if ${MK_CDDL} == "no"
278 WMAKEENV+=      NO_CTF=1
279 .endif
280
281 .if defined(CROSS_TOOLCHAIN_PREFIX)
282 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
283 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
284 .endif
285 XCOMPILERS=     CC CXX CPP
286 .for COMPILER in ${XCOMPILERS}
287 .if defined(CROSS_COMPILER_PREFIX)
288 X${COMPILER}?=  ${CROSS_COMPILER_PREFIX}${${COMPILER}}
289 .else
290 X${COMPILER}?=  ${${COMPILER}}
291 .endif
292 .endfor
293 XBINUTILS=      AS AR LD NM OBJDUMP RANLIB STRINGS
294 .for BINUTIL in ${XBINUTILS}
295 .if defined(CROSS_BINUTILS_PREFIX)
296 X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
297 .else
298 X${BINUTIL}?=   ${${BINUTIL}}
299 .endif
300 .endfor
301 WMAKEENV+=      CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS}" \
302                 CPP="${XCPP} ${XFLAGS}" \
303                 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
304                 OBJDUMP=${XOBJDUMP} RANLIB=${XRANLIB} STRINGS=${XSTRINGS}
305
306 .if ${XCC:T:Mgcc} == "gcc"
307 WMAKE_COMPILER_TYPE=    gcc
308 .elif ${XCC:T:Mclang} == "clang"
309 WMAKE_COMPILER_TYPE=    clang
310 .elif ${MK_CLANG_IS_CC} == "no"
311 WMAKE_COMPILER_TYPE=    gcc
312 .else
313 WMAKE_COMPILER_TYPE=    clang
314 .endif
315 IMAKE_COMPILER_TYPE=    COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
316
317 .if ${XCC:M/*}
318 XFLAGS=         --sysroot=${WORLDTMP}
319 .if defined(CROSS_BINUTILS_PREFIX)
320 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
321 # directory, but the compiler will look in the right place for it's
322 # tools so we don't need to tell it where to look.
323 .if exists(${CROSS_BINUTILS_PREFIX})
324 XFLAGS+=        -B${CROSS_BINUTILS_PREFIX}
325 .endif
326 .else
327 XFLAGS+=        -B${WORLDTMP}/usr/bin
328 .endif
329 .if ${TARGET_ARCH} != ${MACHINE_ARCH} && ${WMAKE_COMPILER_TYPE} == "clang"
330 .if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \
331 ${MK_ARM_EABI} != "no"
332 TARGET_ABI=     gnueabi
333 .else
334 TARGET_ABI=     unknown
335 .endif
336 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd10.0
337 XFLAGS+=        -target ${TARGET_TRIPLE}
338 .endif
339 .endif
340
341 WMAKEENV+=      COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
342 WMAKE=          ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
343
344 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
345 # 32 bit world
346 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
347
348 .if ${TARGET_ARCH} == "amd64"
349 .if empty(TARGET_CPUTYPE)
350 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
351 .else
352 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
353 .endif
354 LIB32WMAKEENV=  MACHINE=i386 MACHINE_ARCH=i386 \
355                 MACHINE_CPU="i686 mmx sse sse2"
356 LIB32WMAKEFLAGS=        \
357                 AS="${AS} --32" \
358                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
359
360 .elif ${TARGET_ARCH} == "powerpc64"
361 .if empty(TARGET_CPUTYPE)
362 LIB32CPUFLAGS=  -mcpu=powerpc
363 .else
364 LIB32CPUFLAGS=  -mcpu=${TARGET_CPUTYPE}
365 .endif
366 LIB32WMAKEENV=  MACHINE=powerpc MACHINE_ARCH=powerpc
367 LIB32WMAKEFLAGS=        \
368                 LD="${LD} -m elf32ppc_fbsd"
369 .endif
370
371
372 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
373                 -isystem ${LIB32TMP}/usr/include/ \
374                 -L${LIB32TMP}/usr/lib32 \
375                 -B${LIB32TMP}/usr/lib32
376 .if ${XCC:M/*}
377 LIB32FLAGS+=            --sysroot=${WORLDTMP}
378 .endif
379
380 # Yes, the flags are redundant.
381 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
382                 _SHLIBDIRPREFIX=${LIB32TMP} \
383                 _LDSCRIPTROOT=${LIB32TMP} \
384                 VERSION="${VERSION}" \
385                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
386                 PATH=${TMPPATH} \
387                 LIBDIR=/usr/lib32 \
388                 SHLIBDIR=/usr/lib32 \
389                 LIBPRIVATEDIR=/usr/lib32/private \
390                 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
391 LIB32WMAKEFLAGS+=       \
392                 CC="${XCC} ${LIB32FLAGS}" \
393                 CXX="${XCXX} ${LIB32FLAGS}" \
394                 DESTDIR=${LIB32TMP} \
395                 -DCOMPAT_32BIT \
396                 -DLIBRARIES_ONLY \
397                 -DNO_CPU_CFLAGS \
398                 -DNO_CTF \
399                 -DNO_LINT
400
401 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
402                 -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
403 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
404                 ${IMAKE_INSTALL}
405 .endif
406
407 IMAKEENV=       ${CROSSENV:N_LDSCRIPTROOT=*}
408 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
409                 ${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_COMPILER_TYPE}
410 .if empty(.MAKEFLAGS:M-n)
411 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
412                 LD_LIBRARY_PATH=${INSTALLTMP} \
413                 PATH_LOCALE=${INSTALLTMP}/locale
414 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
415 .else
416 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
417 .endif
418 .if defined(DB_FROM_SRC)
419 INSTALLFLAGS+=  -N ${.CURDIR}/etc
420 MTREEFLAGS+=    -N ${.CURDIR}/etc
421 .endif
422 _INSTALL_DDIR=  ${DESTDIR}/${DISTDIR}
423 INSTALL_DDIR=   ${_INSTALL_DDIR:S://:/:g:C:/$::}
424 .if defined(NO_ROOT)
425 METALOG?=       ${DESTDIR}/${DISTDIR}/METALOG
426 IMAKE+=         -DNO_ROOT METALOG=${METALOG}
427 INSTALLFLAGS+=  -U -M ${METALOG} -D ${INSTALL_DDIR}
428 MTREEFLAGS+=    -W
429 .endif
430 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
431 IMAKE_INSTALL=  INSTALL="install ${INSTALLFLAGS}"
432 IMAKE_MTREE=    MTREE_CMD="nmtree ${MTREEFLAGS}"
433 .endif
434
435 # kernel stage
436 KMAKEENV=       ${WMAKEENV}
437 KMAKE=          ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
438
439 #
440 # buildworld
441 #
442 # Attempt to rebuild the entire system, with reasonable chance of
443 # success, regardless of how old your existing system is.
444 #
445 _worldtmp:
446 .if ${.CURDIR:C/[^,]//g} != ""
447 #       The m4 build of sendmail files doesn't like it if ',' is used
448 #       anywhere in the path of it's files.
449         @echo
450         @echo "*** Error: path to source tree contains a comma ','"
451         @echo
452         false
453 .endif
454         @echo
455         @echo "--------------------------------------------------------------"
456         @echo ">>> Rebuilding the temporary build tree"
457         @echo "--------------------------------------------------------------"
458 .if !defined(NO_CLEAN)
459         rm -rf ${WORLDTMP}
460 .if defined(LIB32TMP)
461         rm -rf ${LIB32TMP}
462 .endif
463 .else
464         rm -rf ${WORLDTMP}/legacy/usr/include
465 #       XXX - These three can depend on any header file.
466         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
467         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
468         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
469 .endif
470 .for _dir in \
471     lib usr legacy/bin legacy/usr
472         mkdir -p ${WORLDTMP}/${_dir}
473 .endfor
474         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
475             -p ${WORLDTMP}/legacy/usr >/dev/null
476 .if ${MK_GROFF} != "no"
477         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
478             -p ${WORLDTMP}/legacy/usr >/dev/null
479 .endif
480         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
481             -p ${WORLDTMP}/usr >/dev/null
482         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
483             -p ${WORLDTMP}/usr/include >/dev/null
484         ln -sf ${.CURDIR}/sys ${WORLDTMP}
485 .if ${MK_DEBUG_FILES} != "no"
486         # We could instead disable debug files for these build stages
487         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
488             -p ${WORLDTMP}/legacy/usr/lib >/dev/null
489         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
490             -p ${WORLDTMP}/usr/lib >/dev/null
491 .endif
492 .for _mtree in ${LOCAL_MTREE}
493         mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
494 .endfor
495 _legacy:
496         @echo
497         @echo "--------------------------------------------------------------"
498         @echo ">>> stage 1.1: legacy release compatibility shims"
499         @echo "--------------------------------------------------------------"
500         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
501 _bootstrap-tools:
502         @echo
503         @echo "--------------------------------------------------------------"
504         @echo ">>> stage 1.2: bootstrap tools"
505         @echo "--------------------------------------------------------------"
506         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
507 _cleanobj:
508 .if !defined(NO_CLEAN)
509         @echo
510         @echo "--------------------------------------------------------------"
511         @echo ">>> stage 2.1: cleaning up the object tree"
512         @echo "--------------------------------------------------------------"
513         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
514 .if defined(LIB32TMP)
515         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
516 .endif
517 .endif
518 _obj:
519         @echo
520         @echo "--------------------------------------------------------------"
521         @echo ">>> stage 2.2: rebuilding the object tree"
522         @echo "--------------------------------------------------------------"
523         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
524 _build-tools:
525         @echo
526         @echo "--------------------------------------------------------------"
527         @echo ">>> stage 2.3: build tools"
528         @echo "--------------------------------------------------------------"
529         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
530 _cross-tools:
531         @echo
532         @echo "--------------------------------------------------------------"
533         @echo ">>> stage 3: cross tools"
534         @echo "--------------------------------------------------------------"
535         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
536 _includes:
537         @echo
538         @echo "--------------------------------------------------------------"
539         @echo ">>> stage 4.1: building includes"
540         @echo "--------------------------------------------------------------"
541         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
542 _libraries:
543         @echo
544         @echo "--------------------------------------------------------------"
545         @echo ">>> stage 4.2: building libraries"
546         @echo "--------------------------------------------------------------"
547         ${_+_}cd ${.CURDIR}; \
548             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
549             -DWITHOUT_MAN -DNO_PROFILE libraries
550 _depend:
551         @echo
552         @echo "--------------------------------------------------------------"
553         @echo ">>> stage 4.3: make dependencies"
554         @echo "--------------------------------------------------------------"
555         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
556 everything:
557         @echo
558         @echo "--------------------------------------------------------------"
559         @echo ">>> stage 4.4: building everything"
560         @echo "--------------------------------------------------------------"
561         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
562 .if defined(LIB32TMP)
563 build32:
564         @echo
565         @echo "--------------------------------------------------------------"
566         @echo ">>> stage 5.1: building 32 bit shim libraries"
567         @echo "--------------------------------------------------------------"
568         mkdir -p ${LIB32TMP}/usr/include
569         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
570             -p ${LIB32TMP}/usr >/dev/null
571         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
572             -p ${LIB32TMP}/usr/include >/dev/null
573 .if ${MK_DEBUG_FILES} != "no"
574         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
575             -p ${LIB32TMP}/usr/lib >/dev/null
576 .endif
577         mkdir -p ${WORLDTMP}
578         ln -sf ${.CURDIR}/sys ${WORLDTMP}
579 .for _t in obj includes
580         cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
581         cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
582 .if ${MK_CDDL} != "no"
583         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
584 .endif
585         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
586 .if ${MK_CRYPT} != "no"
587         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
588 .endif
589 .if ${MK_KERBEROS} != "no"
590         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
591 .endif
592 .endfor
593 .for _dir in usr.bin/lex/lib
594         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
595 .endfor
596 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
597         cd ${.CURDIR}/${_dir}; \
598             WORLDTMP=${WORLDTMP} \
599             MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
600             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
601             DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
602             -DEARLY_BUILD build-tools
603 .endfor
604         cd ${.CURDIR}; \
605             ${LIB32WMAKE} -f Makefile.inc1 libraries
606 .for _t in obj depend all
607         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
608             DIRPRFX=libexec/rtld-elf/ ${_t}
609         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
610             DIRPRFX=usr.bin/ldd ${_t}
611 .endfor
612
613 distribute32 install32:
614         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
615 .if ${MK_CDDL} != "no"
616         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
617 .endif
618         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
619 .if ${MK_CRYPT} != "no"
620         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
621 .endif
622 .if ${MK_KERBEROS} != "no"
623         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
624 .endif
625         cd ${.CURDIR}/libexec/rtld-elf; \
626             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
627         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
628 .endif
629
630 WMAKE_TGTS=
631 .if !defined(SUBDIR_OVERRIDE)
632 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
633 .endif
634 WMAKE_TGTS+=    _cleanobj _obj _build-tools
635 .if !defined(SUBDIR_OVERRIDE)
636 WMAKE_TGTS+=    _cross-tools
637 .endif
638 WMAKE_TGTS+=    _includes _libraries _depend everything
639 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
640 WMAKE_TGTS+=    build32
641 .endif
642
643 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
644 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
645
646 buildworld_prologue:
647         @echo "--------------------------------------------------------------"
648         @echo ">>> World build started on `LC_ALL=C date`"
649         @echo "--------------------------------------------------------------"
650
651 buildworld_epilogue:
652         @echo
653         @echo "--------------------------------------------------------------"
654         @echo ">>> World build completed on `LC_ALL=C date`"
655         @echo "--------------------------------------------------------------"
656
657 #
658 # We need to have this as a target because the indirection between Makefile
659 # and Makefile.inc1 causes the correct PATH to be used, rather than a
660 # modification of the current environment's PATH.  In addition, we need
661 # to quote multiword values.
662 #
663 buildenvvars:
664         @echo ${WMAKEENV:Q}
665
666 buildenv:
667         @echo Entering world for ${TARGET_ARCH}:${TARGET}
668         @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
669
670 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
671 toolchain: ${TOOLCHAIN_TGTS}
672 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
673
674 #
675 # installcheck
676 #
677 # Checks to be sure system is ready for installworld/installkernel.
678 #
679 installcheck: _installcheck_world _installcheck_kernel
680 _installcheck_world:
681 _installcheck_kernel:
682
683 #
684 # Require DESTDIR to be set if installing for a different architecture or
685 # using the user/group database in the source tree.
686 #
687 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
688     defined(DB_FROM_SRC)
689 .if !make(distributeworld)
690 _installcheck_world: __installcheck_DESTDIR
691 _installcheck_kernel: __installcheck_DESTDIR
692 __installcheck_DESTDIR:
693 .if !defined(DESTDIR) || empty(DESTDIR)
694         @echo "ERROR: Please set DESTDIR!"; \
695         false
696 .endif
697 .endif
698 .endif
699
700 .if !defined(DB_FROM_SRC)
701 #
702 # Check for missing UIDs/GIDs.
703 #
704 CHECK_UIDS=     auditdistd
705 CHECK_GIDS=     audit
706 .if ${MK_SENDMAIL} != "no"
707 CHECK_UIDS+=    smmsp
708 CHECK_GIDS+=    smmsp
709 .endif
710 .if ${MK_PF} != "no"
711 CHECK_UIDS+=    proxy
712 CHECK_GIDS+=    proxy authpf
713 .endif
714 .if ${MK_UNBOUND} != "no"
715 CHECK_UIDS+=    unbound
716 CHECK_GIDS+=    unbound
717 .endif
718 _installcheck_world: __installcheck_UGID
719 __installcheck_UGID:
720 .for uid in ${CHECK_UIDS}
721         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
722                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
723                 false; \
724         fi
725 .endfor
726 .for gid in ${CHECK_GIDS}
727         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
728                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
729                 false; \
730         fi
731 .endfor
732 .endif
733
734 #
735 # Required install tools to be saved in a scratch dir for safety.
736 #
737 .if ${MK_INFO} != "no"
738 _install-info=  install-info
739 .endif
740 .if ${MK_ZONEINFO} != "no"
741 _zoneinfo=      zic tzsetup
742 .endif
743
744 .if exists(/usr/sbin/nmtree)
745 _nmtree_itools= nmtree
746 .endif
747
748 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
749         date echo egrep find grep id install ${_install-info} \
750         ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
751         rm sed sh sysctl test true uname wc ${_zoneinfo}
752
753 #
754 # distributeworld
755 #
756 # Distributes everything compiled by a `buildworld'.
757 #
758 # installworld
759 #
760 # Installs everything compiled by a 'buildworld'.
761 #
762
763 # Non-base distributions produced by the base system
764 EXTRA_DISTRIBUTIONS=    doc
765 .if ${MK_GAMES} != "no"
766 EXTRA_DISTRIBUTIONS+=   games
767 .endif
768 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
769 EXTRA_DISTRIBUTIONS+=   lib32
770 .endif
771
772 MTREE_MAGIC?=   mtree 2.0
773
774 distributeworld installworld: _installcheck_world
775         mkdir -p ${INSTALLTMP}
776         progs=$$(for prog in ${ITOOLS}; do \
777                 if progpath=`which $$prog`; then \
778                         echo $$progpath; \
779                 else \
780                         echo "Required tool $$prog not found in PATH." >&2; \
781                         exit 1; \
782                 fi; \
783             done); \
784         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
785             while read line; do \
786                 set -- $$line; \
787                 if [ "$$2 $$3" != "not found" ]; then \
788                         echo $$2; \
789                 else \
790                         echo "Required library $$1 not found." >&2; \
791                         exit 1; \
792                 fi; \
793             done); \
794         cp $$libs $$progs ${INSTALLTMP}
795         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
796 .if defined(NO_ROOT)
797         echo "#${MTREE_MAGIC}" > ${METALOG}
798 .endif
799 .if make(distributeworld)
800 .for dist in ${EXTRA_DISTRIBUTIONS}
801         -mkdir ${DESTDIR}/${DISTDIR}/${dist}
802         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
803             -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
804         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
805             -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
806         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
807             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
808 .if ${MK_DEBUG_FILES} != "no"
809         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
810             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
811 .endif
812 .if defined(NO_ROOT)
813         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
814             sed -e 's#^\./#./${dist}/#' >> ${METALOG}
815         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
816             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
817         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
818             sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
819 .endif
820 .endfor
821         -mkdir ${DESTDIR}/${DISTDIR}/base
822         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
823             METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
824             DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
825             LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
826 .endif
827         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
828             ${IMAKEENV} rm -rf ${INSTALLTMP}
829 .if make(distributeworld)
830 .for dist in ${EXTRA_DISTRIBUTIONS}
831         find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
832 .endfor
833 .if defined(NO_ROOT)
834 .for dist in base ${EXTRA_DISTRIBUTIONS}
835         @# For each file that exists in this dist, print the corresponding
836         @# line from the METALOG.  This relies on the fact that
837         @# a line containing only the filename will sort immediatly before
838         @# the relevant mtree line.
839         cd ${DESTDIR}/${DISTDIR}; \
840         find ./${dist} | sort -u ${METALOG} - | \
841         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
842         ${DESTDIR}/${DISTDIR}/${dist}.meta
843 .endfor
844 .if ${MK_DEBUG_FILES} != "no"
845 . for dist in base ${EXTRA_DISTRIBUTIONS}
846         @# For each file that exists in this dist, print the corresponding
847         @# line from the METALOG.  This relies on the fact that
848         @# a line containing only the filename will sort immediatly before
849         @# the relevant mtree line.
850         cd ${DESTDIR}/${DISTDIR}; \
851         find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
852         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
853         ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
854 . endfor
855 .endif
856 .endif
857 .endif
858
859 packageworld:
860 .for dist in base ${EXTRA_DISTRIBUTIONS}
861 .if defined(NO_ROOT)
862         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
863             tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
864             --exclude usr/lib/debug \
865             @${DESTDIR}/${DISTDIR}/${dist}.meta
866 .else
867         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
868             tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
869             --exclude usr/lib/debug .
870 .endif
871 .endfor
872
873 .if ${MK_DEBUG_FILES} != "no"
874 . for dist in base ${EXTRA_DISTRIBUTIONS}
875 .  if defined(NO_ROOT)
876         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
877             tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
878             @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
879 .  else
880         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
881             tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
882             usr/lib/debug
883 .  endif
884 . endfor
885 .endif
886
887 #
888 # reinstall
889 #
890 # If you have a build server, you can NFS mount the source and obj directories
891 # and do a 'make reinstall' on the *client* to install new binaries from the
892 # most recent server build.
893 #
894 reinstall:
895         @echo "--------------------------------------------------------------"
896         @echo ">>> Making hierarchy"
897         @echo "--------------------------------------------------------------"
898         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
899             LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
900         @echo
901         @echo "--------------------------------------------------------------"
902         @echo ">>> Installing everything"
903         @echo "--------------------------------------------------------------"
904         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
905 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
906         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
907 .endif
908
909 redistribute:
910         @echo "--------------------------------------------------------------"
911         @echo ">>> Distributing everything"
912         @echo "--------------------------------------------------------------"
913         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
914 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
915         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
916             DISTRIBUTION=lib32
917 .endif
918
919 distrib-dirs distribution:
920         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
921             ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
922
923 #
924 # buildkernel and installkernel
925 #
926 # Which kernels to build and/or install is specified by setting
927 # KERNCONF. If not defined a GENERIC kernel is built/installed.
928 # Only the existing (depending TARGET) config files are used
929 # for building kernels and only the first of these is designated
930 # as the one being installed.
931 #
932 # Note that we have to use TARGET instead of TARGET_ARCH when
933 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
934 # be set to cross-build, we have to make sure TARGET is set
935 # properly.
936
937 .if defined(KERNFAST)
938 NO_KERNELCLEAN= t
939 NO_KERNELCONFIG=        t
940 NO_KERNELDEPEND=        t
941 NO_KERNELOBJ=           t
942 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
943 .if !defined(KERNCONF) && ${KERNFAST} != "1"
944 KERNCONF=${KERNFAST}
945 .endif
946 .endif
947 .if ${TARGET_ARCH} == "powerpc64"
948 KERNCONF?=      GENERIC64
949 .else
950 KERNCONF?=      GENERIC
951 .endif
952 INSTKERNNAME?=  kernel
953
954 KERNSRCDIR?=    ${.CURDIR}/sys
955 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
956 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
957 KERNCONFDIR?=   ${KRNLCONFDIR}
958
959 BUILDKERNELS=
960 INSTALLKERNEL=
961 .for _kernel in ${KERNCONF}
962 .if exists(${KERNCONFDIR}/${_kernel})
963 BUILDKERNELS+=  ${_kernel}
964 .if empty(INSTALLKERNEL)
965 INSTALLKERNEL= ${_kernel}
966 .endif
967 .endif
968 .endfor
969
970 #
971 # buildkernel
972 #
973 # Builds all kernels defined by BUILDKERNELS.
974 #
975 buildkernel:
976 .if empty(BUILDKERNELS)
977         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
978         false
979 .endif
980         @echo
981 .for _kernel in ${BUILDKERNELS}
982         @echo "--------------------------------------------------------------"
983         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
984         @echo "--------------------------------------------------------------"
985         @echo "===> ${_kernel}"
986         mkdir -p ${KRNLOBJDIR}
987 .if !defined(NO_KERNELCONFIG)
988         @echo
989         @echo "--------------------------------------------------------------"
990         @echo ">>> stage 1: configuring the kernel"
991         @echo "--------------------------------------------------------------"
992         cd ${KRNLCONFDIR}; \
993                 PATH=${TMPPATH} \
994                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
995                         ${KERNCONFDIR}/${_kernel}
996 .endif
997 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
998         @echo
999         @echo "--------------------------------------------------------------"
1000         @echo ">>> stage 2.1: cleaning up the object tree"
1001         @echo "--------------------------------------------------------------"
1002         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1003 .endif
1004 .if !defined(NO_KERNELOBJ)
1005         @echo
1006         @echo "--------------------------------------------------------------"
1007         @echo ">>> stage 2.2: rebuilding the object tree"
1008         @echo "--------------------------------------------------------------"
1009         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1010 .endif
1011         @echo
1012         @echo "--------------------------------------------------------------"
1013         @echo ">>> stage 2.3: build tools"
1014         @echo "--------------------------------------------------------------"
1015         cd ${KRNLOBJDIR}/${_kernel}; \
1016             PATH=${BPATH}:${PATH} \
1017             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
1018             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
1019             -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
1020 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
1021 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
1022 .for target in obj depend all
1023         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
1024             PATH=${BPATH}:${PATH} \
1025             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
1026             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
1027 .endfor
1028 .endif
1029 .if !defined(NO_KERNELDEPEND)
1030         @echo
1031         @echo "--------------------------------------------------------------"
1032         @echo ">>> stage 3.1: making dependencies"
1033         @echo "--------------------------------------------------------------"
1034         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1035 .endif
1036         @echo
1037         @echo "--------------------------------------------------------------"
1038         @echo ">>> stage 3.2: building everything"
1039         @echo "--------------------------------------------------------------"
1040         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1041         @echo "--------------------------------------------------------------"
1042         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1043         @echo "--------------------------------------------------------------"
1044 .endfor
1045
1046 #
1047 # installkernel, etc.
1048 #
1049 # Install the kernel defined by INSTALLKERNEL
1050 #
1051 installkernel installkernel.debug \
1052 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1053 .if empty(INSTALLKERNEL)
1054         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1055         false
1056 .endif
1057         @echo "--------------------------------------------------------------"
1058         @echo ">>> Installing kernel ${INSTALLKERNEL}"
1059         @echo "--------------------------------------------------------------"
1060         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1061             ${CROSSENV} PATH=${TMPPATH} \
1062             ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1063
1064 distributekernel distributekernel.debug:
1065 .if empty(INSTALLKERNEL)
1066         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1067         false
1068 .endif
1069         mkdir -p ${DESTDIR}/${DISTDIR}
1070 .if defined(NO_ROOT)
1071         echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1072 .endif
1073         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1074             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1075             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1076             DESTDIR=${INSTALL_DDIR}/kernel \
1077             ${.TARGET:S/distributekernel/install/}
1078 .if defined(NO_ROOT)
1079         sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1080             ${DESTDIR}/${DISTDIR}/kernel.meta
1081 .endif
1082 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1083 .if defined(NO_ROOT)
1084         echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1085 .endif
1086         cd ${KRNLOBJDIR}/${_kernel}; \
1087             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1088             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1089             KERNEL=${INSTKERNNAME}.${_kernel} \
1090             DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1091             ${.TARGET:S/distributekernel/install/}
1092 .if defined(NO_ROOT)
1093         sed -e 's|^./kernel|.|' \
1094             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1095             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1096 .endif
1097 .endfor
1098
1099 packagekernel:
1100 .if defined(NO_ROOT)
1101         cd ${DESTDIR}/${DISTDIR}/kernel; \
1102             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
1103             @${DESTDIR}/${DISTDIR}/kernel.meta
1104 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1105         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1106             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
1107             @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1108 .endfor
1109 .else
1110         cd ${DESTDIR}/${DISTDIR}/kernel; \
1111             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1112 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1113         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1114             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1115 .endfor
1116 .endif
1117
1118 #
1119 # doxygen
1120 #
1121 # Build the API documentation with doxygen
1122 #
1123 doxygen:
1124         @if [ ! -x `/usr/bin/which doxygen` ]; then \
1125                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1126                 exit 1; \
1127         fi
1128         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1129
1130 #
1131 # update
1132 #
1133 # Update the source tree(s), by running svn/svnup to update to the
1134 # latest copy.
1135 #
1136 update:
1137 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1138         @echo "--------------------------------------------------------------"
1139         @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1140         @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1141         @echo "--------------------------------------------------------------"
1142         @exit 1
1143 .endif
1144 .if defined(SVN_UPDATE)
1145         @echo "--------------------------------------------------------------"
1146         @echo ">>> Updating ${.CURDIR} using Subversion"
1147         @echo "--------------------------------------------------------------"
1148         @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1149 .endif
1150
1151 #
1152 # ------------------------------------------------------------------------
1153 #
1154 # From here onwards are utility targets used by the 'make world' and
1155 # related targets.  If your 'world' breaks, you may like to try to fix
1156 # the problem and manually run the following targets to attempt to
1157 # complete the build.  Beware, this is *not* guaranteed to work, you
1158 # need to have a pretty good grip on the current state of the system
1159 # to attempt to manually finish it.  If in doubt, 'make world' again.
1160 #
1161
1162 #
1163 # legacy: Build compatibility shims for the next three targets
1164 #
1165 legacy:
1166 .if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0
1167         @echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \
1168         false
1169 .endif
1170 .for _tool in tools/build
1171         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1172             cd ${.CURDIR}/${_tool} && \
1173             ${MAKE} DIRPRFX=${_tool}/ obj && \
1174             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1175             ${MAKE} DIRPRFX=${_tool}/ depend && \
1176             ${MAKE} DIRPRFX=${_tool}/ all && \
1177             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1178 .endfor
1179
1180 #
1181 # bootstrap-tools: Build tools needed for compatibility
1182 #
1183 .if ${MK_GAMES} != "no"
1184 _strfile=       games/fortune/strfile
1185 .endif
1186
1187 .if ${MK_CXX} != "no"
1188 _gperf=         gnu/usr.bin/gperf
1189 .endif
1190
1191 .if ${MK_GROFF} != "no"
1192 _groff=         gnu/usr.bin/groff
1193 .endif
1194
1195 .if ${BOOTSTRAPPING} < 800022
1196 _ar=            usr.bin/ar
1197 .endif
1198
1199 .if ${BOOTSTRAPPING} < 800013
1200 _mklocale=      usr.bin/mklocale
1201 .endif
1202
1203 .if ${BOOTSTRAPPING} < 900002
1204 _sed=           usr.bin/sed
1205 .endif
1206
1207 .if ${BOOTSTRAPPING} < 900006
1208 _lex=           usr.bin/lex
1209 .endif
1210
1211 .if ${BOOTSTRAPPING} < 1000002
1212 _m4=            usr.bin/m4
1213 .endif
1214
1215 .if ${BOOTSTRAPPING} < 1000013
1216 _yacc=          lib/liby \
1217                 usr.bin/yacc
1218 .endif
1219
1220 .if ${BOOTSTRAPPING} < 1000014
1221 _crunch=        usr.sbin/crunch
1222 .endif
1223
1224 .if ${BOOTSTRAPPING} < 1000026
1225 _nmtree=        lib/libnetbsd \
1226                 usr.sbin/nmtree
1227 .endif
1228
1229 .if ${BOOTSTRAPPING} < 1000027
1230 _cat=           bin/cat
1231 .endif
1232
1233 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1234 _awk=           usr.bin/awk
1235 .endif
1236
1237 .if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree)
1238 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
1239 .endif
1240
1241 .if ${MK_CLANG} != "no"
1242 _clang_tblgen= \
1243         lib/clang/libllvmsupport \
1244         lib/clang/libllvmtablegen \
1245         usr.bin/clang/tblgen \
1246         usr.bin/clang/clang-tblgen
1247 .endif
1248
1249 # dtrace tools are required for older bootstrap env and cross-build
1250 .if ${MK_CDDL} != "no" && \
1251     ((${BOOTSTRAPPING} < 1000034 && \
1252           !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
1253       || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1254 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1255     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1256 .endif
1257
1258 # Default to building the BSDL DTC, but build the GPL one if users explicitly
1259 # request it.
1260 _dtc= usr.bin/dtc
1261 .if ${MK_GPL_DTC} != "no"
1262 _dtc= gnu/usr.bin/dtc
1263 .endif
1264
1265 .if ${MK_KERBEROS} != "no"
1266 _kerberos5_bootstrap_tools= \
1267         kerberos5/tools/make-roken \
1268         kerberos5/lib/libroken \
1269         kerberos5/lib/libvers \
1270         kerberos5/tools/asn1_compile \
1271         kerberos5/tools/slc \
1272         usr.bin/compile_et
1273 .endif
1274
1275 #       Please document (add comment) why something is in 'bootstrap-tools'.
1276 #       Try to bound the building of the bootstrap-tool to just the
1277 #       FreeBSD versions that need the tool built at this stage of the build.
1278 bootstrap-tools: .MAKE
1279 .for _tool in \
1280     ${_clang_tblgen} \
1281     ${_kerberos5_bootstrap_tools} \
1282     ${_dtrace_tools} \
1283     ${_strfile} \
1284     ${_gperf} \
1285     ${_groff} \
1286     ${_ar} \
1287     ${_dtc} \
1288     ${_awk} \
1289     ${_cat} \
1290     usr.bin/lorder \
1291     usr.bin/makewhatis \
1292     ${_mklocale} \
1293     usr.bin/rpcgen \
1294     ${_sed} \
1295     ${_yacc} \
1296     ${_m4} \
1297     ${_lex} \
1298     lib/libmd \
1299     usr.bin/xinstall \
1300     ${_gensnmptree} \
1301     usr.sbin/config \
1302     ${_crunch} \
1303     ${_nmtree}
1304         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1305                 cd ${.CURDIR}/${_tool} && \
1306                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1307                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1308                 ${MAKE} DIRPRFX=${_tool}/ all && \
1309                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1310 .endfor
1311
1312 #
1313 # build-tools: Build special purpose build tools
1314 #
1315 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1316 _aicasm= sys/modules/aic7xxx/aicasm
1317 .endif
1318
1319 .if !defined(NO_SHARE)
1320 _share= share/syscons/scrnmaps
1321 .endif
1322
1323 .if ${MK_GCC} != "no"
1324 _gcc_tools= gnu/usr.bin/cc/cc_tools
1325 .endif
1326
1327 .if ${MK_RESCUE} != "no"
1328 _rescue= rescue/rescue
1329 .endif
1330
1331 build-tools: .MAKE
1332 .for _tool in \
1333     bin/csh \
1334     bin/sh \
1335     ${_rescue} \
1336     ${LOCAL_TOOL_DIRS} \
1337     lib/ncurses/ncurses \
1338     lib/ncurses/ncursesw \
1339     ${_share} \
1340     ${_aicasm} \
1341     usr.bin/awk \
1342     lib/libmagic \
1343     usr.bin/mkesdb_static \
1344     usr.bin/mkcsmapper_static \
1345     usr.bin/vi/catalog
1346         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1347                 cd ${.CURDIR}/${_tool} && \
1348                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1349                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1350 .endfor
1351 .for _tool in \
1352     ${_gcc_tools}
1353         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1354                 cd ${.CURDIR}/${_tool} && \
1355                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1356                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1357                 ${MAKE} DIRPRFX=${_tool}/ all
1358 .endfor
1359
1360 #
1361 # cross-tools: Build cross-building tools
1362 #
1363 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1364 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1365 _btxld=         usr.sbin/btxld
1366 .endif
1367 .endif
1368 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1369 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1370 _crunchide=     usr.sbin/crunch/crunchide
1371 .endif
1372 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1373 _kgzip=         usr.sbin/kgzip
1374 .endif
1375 .endif
1376
1377 .if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
1378 _binutils=      gnu/usr.bin/binutils
1379 .endif
1380
1381 # If an full path to an external cross compiler is given, don't build
1382 # a cross compiler.
1383 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1384 .if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && ${TARGET} != "pc98"
1385 _clang=         usr.bin/clang
1386 _clang_libs=    lib/clang
1387 .else
1388 _cc=            gnu/usr.bin/cc
1389 .endif
1390 .endif
1391
1392 cross-tools: .MAKE
1393 .for _tool in \
1394     ${_clang_libs} \
1395     ${_clang} \
1396     ${_binutils} \
1397     ${_cc} \
1398     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1399     ${_btxld} \
1400     ${_crunchide} \
1401     ${_kgzip}
1402         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1403                 cd ${.CURDIR}/${_tool} && \
1404                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1405                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1406                 ${MAKE} DIRPRFX=${_tool}/ all && \
1407                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1408 .endfor
1409
1410 #
1411 # hierarchy - ensure that all the needed directories are present
1412 #
1413 hierarchy hier:
1414         cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1415
1416 #
1417 # libraries - build all libraries, and install them under ${DESTDIR}.
1418 #
1419 # The list of libraries with dependents (${_prebuild_libs}) and their
1420 # interdependencies (__L) are built automatically by the
1421 # ${.CURDIR}/tools/make_libdeps.sh script.
1422 #
1423 libraries: .MAKE
1424         cd ${.CURDIR} && \
1425             ${MAKE} -f Makefile.inc1 _prereq_libs && \
1426             ${MAKE} -f Makefile.inc1 _startup_libs && \
1427             ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1428             ${MAKE} -f Makefile.inc1 _generic_libs
1429
1430 #
1431 # static libgcc.a prerequisite for shared libc
1432 #
1433 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1434
1435 # These dependencies are not automatically generated:
1436 #
1437 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1438 # all shared libraries for ELF.
1439 #
1440 _startup_libs=  gnu/lib/csu
1441 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1442 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1443 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1444 _startup_libs+= lib/csu/${MACHINE_ARCH}
1445 .else
1446 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1447 .endif
1448 _startup_libs+= gnu/lib/libgcc
1449 _startup_libs+= lib/libcompiler_rt
1450 _startup_libs+= lib/libc
1451 .if ${MK_LIBCPLUSPLUS} != "no"
1452 _startup_libs+= lib/libcxxrt
1453 .endif
1454
1455 gnu/lib/libgcc__L: lib/libc__L
1456 .if ${MK_LIBCPLUSPLUS} != "no"
1457 lib/libcxxrt__L: gnu/lib/libgcc__L
1458 .endif
1459
1460 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1461                 ${_kerberos5_lib_libhdb} \
1462                 ${_kerberos5_lib_libheimbase} \
1463                 ${_kerberos5_lib_libheimntlm} \
1464                 ${_kerberos5_lib_libheimsqlite} \
1465                 ${_kerberos5_lib_libheimipcc} \
1466                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1467                 ${_kerberos5_lib_libroken} \
1468                 ${_kerberos5_lib_libwind} \
1469                 ${_lib_atf_libatf_c} \
1470                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1471                 lib/libelf lib/libexpat \
1472                 ${_lib_libgssapi} ${_lib_libipx} \
1473                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1474                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1475                 lib/libopie lib/libpam ${_lib_libthr} \
1476                 lib/libradius lib/libsbuf lib/libtacplus \
1477                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1478                 ${_cddl_lib_libzfs_core} \
1479                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1480                 ${_secure_lib_libcrypto} ${_lib_libldns} \
1481                 ${_secure_lib_libssh} ${_secure_lib_libssl}
1482
1483 .if ${MK_ATF} != "no"
1484 _lib_atf_libatf_c=      lib/atf/libatf-c
1485 .endif
1486
1487 .if ${MK_LIBTHR} != "no"
1488 _lib_libthr=    lib/libthr
1489 .endif
1490
1491 .if ${MK_OFED} != "no"
1492 _ofed_lib=      contrib/ofed/usr.lib/
1493 .endif
1494
1495 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1496 .for _DIR in ${LOCAL_LIB_DIRS}
1497 .if exists(${.CURDIR}/${_DIR}/Makefile)
1498 _generic_libs+= ${_DIR}
1499 .endif
1500 .endfor
1501
1502 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1503
1504 .if ${MK_CDDL} != "no"
1505 _cddl_lib_libumem= cddl/lib/libumem
1506 _cddl_lib_libnvpair= cddl/lib/libnvpair
1507 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1508 _cddl_lib= cddl/lib
1509 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1510 .endif
1511
1512 .if ${MK_CRYPT} != "no"
1513 .if ${MK_OPENSSL} != "no"
1514 _secure_lib_libcrypto= secure/lib/libcrypto
1515 _secure_lib_libssl= secure/lib/libssl
1516 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1517 .if ${MK_LDNS} != "no"
1518 _lib_libldns= lib/libldns
1519 lib/libldns__L: secure/lib/libcrypto__L
1520 .endif
1521 .if ${MK_OPENSSH} != "no"
1522 _secure_lib_libssh= secure/lib/libssh
1523 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1524 .if ${MK_LDNS} != "no"
1525 secure/lib/libssh__L: lib/libldns__L
1526 .endif
1527 .if ${MK_KERBEROS_SUPPORT} != "no"
1528 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1529     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1530     lib/libmd__L kerberos5/lib/libroken__L
1531 .endif
1532 .endif
1533 .endif
1534 _secure_lib=    secure/lib
1535 .endif
1536
1537 .if ${MK_KERBEROS} != "no"
1538 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1539 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1540     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1541     kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1542 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1543     kerberos5/lib/libroken__L lib/libcom_err__L
1544 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1545     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1546 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1547     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1548     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1549     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1550 kerberos5/lib/libroken__L: lib/libcrypt__L
1551 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1552 kerberos5/lib/libheimbase__L: lib/libthr__L
1553 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1554 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1555 .endif
1556
1557 .if ${MK_GSSAPI} != "no"
1558 _lib_libgssapi= lib/libgssapi
1559 .endif
1560
1561 .if ${MK_IPX} != "no"
1562 _lib_libipx=    lib/libipx
1563 .endif
1564
1565 .if ${MK_KERBEROS} != "no"
1566 _kerberos5_lib= kerberos5/lib
1567 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1568 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1569 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1570 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1571 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1572 _kerberos5_lib_libroken= kerberos5/lib/libroken
1573 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1574 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1575 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1576 _kerberos5_lib_libwind= kerberos5/lib/libwind
1577 _libcom_err= lib/libcom_err
1578 .endif
1579
1580 .if ${MK_NIS} != "no"
1581 _lib_libypclnt= lib/libypclnt
1582 .endif
1583
1584 .if ${MK_OPENSSL} == "no"
1585 lib/libradius__L: lib/libmd__L
1586 .endif
1587
1588 .for _lib in ${_prereq_libs}
1589 ${_lib}__PL: .PHONY .MAKE
1590 .if exists(${.CURDIR}/${_lib})
1591         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1592                 cd ${.CURDIR}/${_lib} && \
1593                 ${MAKE} DIRPRFX=${_lib}/ obj && \
1594                 ${MAKE} DIRPRFX=${_lib}/ depend && \
1595                 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all && \
1596                 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1597 .endif
1598 .endfor
1599
1600 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1601 ${_lib}__L: .PHONY .MAKE
1602 .if exists(${.CURDIR}/${_lib})
1603         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1604                 cd ${.CURDIR}/${_lib} && \
1605                 ${MAKE} DIRPRFX=${_lib}/ obj && \
1606                 ${MAKE} DIRPRFX=${_lib}/ depend && \
1607                 ${MAKE} DIRPRFX=${_lib}/ all && \
1608                 ${MAKE} DIRPRFX=${_lib}/ install
1609 .endif
1610 .endfor
1611
1612 # libpam is special: we need to build static PAM modules before
1613 # static PAM library, and dynamic PAM library before dynamic PAM
1614 # modules.
1615 lib/libpam__L: .PHONY .MAKE
1616         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1617                 cd ${.CURDIR}/lib/libpam && \
1618                 ${MAKE} DIRPRFX=lib/libpam/ obj && \
1619                 ${MAKE} DIRPRFX=lib/libpam/ depend && \
1620                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all && \
1621                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1622
1623 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1624 _startup_libs: ${_startup_libs:S/$/__L/}
1625 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1626 _generic_libs: ${_generic_libs:S/$/__L/}
1627
1628 .for __target in all clean cleandepend cleandir depend includes obj
1629 .for entry in ${SUBDIR}
1630 ${entry}.${__target}__D: .PHONY .MAKE
1631         ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1632                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1633                 edir=${entry}.${MACHINE_ARCH}; \
1634                 cd ${.CURDIR}/$${edir}; \
1635         else \
1636                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1637                 edir=${entry}; \
1638                 cd ${.CURDIR}/$${edir}; \
1639         fi; \
1640         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1641 .endfor
1642 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1643 .endfor
1644
1645 .include <bsd.subdir.mk>
1646
1647 .if make(check-old) || make(check-old-dirs) || \
1648     make(check-old-files) || make(check-old-libs) || \
1649     make(delete-old) || make(delete-old-dirs) || \
1650     make(delete-old-files) || make(delete-old-libs)
1651
1652 #
1653 # check for / delete old files section
1654 #
1655
1656 .include "ObsoleteFiles.inc"
1657
1658 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1659 else you can not start such an application. Consult UPDATING for more \
1660 information regarding how to cope with the removal/revision bump of a \
1661 specific library."
1662
1663 .if !defined(BATCH_DELETE_OLD_FILES)
1664 RM_I=-i
1665 .else
1666 RM_I=-v
1667 .endif
1668
1669 delete-old-files:
1670         @echo ">>> Removing old files (only deletes safe to delete libs)"
1671 # Ask for every old file if the user really wants to remove it.
1672 # It's annoying, but better safe than sorry.
1673 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1674 # argument list will get too long. Using .for/.endfor make "loops" will make
1675 # the Makefile parser segfault.
1676         @exec 3<&0; \
1677         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1678             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1679         while read file; do \
1680                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1681                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1682                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1683                 fi; \
1684         done
1685 # Remove catpages without corresponding manpages.
1686         @exec 3<&0; \
1687         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1688         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1689         while read catpage; do \
1690                 read manpage; \
1691                 if [ ! -e "$${manpage}" ]; then \
1692                         rm ${RM_I} $${catpage} <&3; \
1693                 fi; \
1694         done
1695         @echo ">>> Old files removed"
1696
1697 check-old-files:
1698         @echo ">>> Checking for old files"
1699         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1700             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1701         while read file; do \
1702                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1703                         echo "${DESTDIR}/$${file}"; \
1704                 fi; \
1705         done
1706 # Check for catpages without corresponding manpages.
1707         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1708         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1709         while read catpage; do \
1710                 read manpage; \
1711                 if [ ! -e "$${manpage}" ]; then \
1712                         echo $${catpage}; \
1713                 fi; \
1714         done
1715
1716 delete-old-libs:
1717         @echo ">>> Removing old libraries"
1718         @echo "${OLD_LIBS_MESSAGE}" | fmt
1719         @exec 3<&0; \
1720         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1721             -V OLD_LIBS | xargs -n1 | \
1722         while read file; do \
1723                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1724                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1725                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1726                 fi; \
1727                 for ext in debug symbols; do \
1728                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1729                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1730                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1731                               <&3; \
1732                   fi; \
1733                 done; \
1734         done
1735         @echo ">>> Old libraries removed"
1736
1737 check-old-libs:
1738         @echo ">>> Checking for old libraries"
1739         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1740             -V OLD_LIBS | xargs -n1 | \
1741         while read file; do \
1742                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1743                         echo "${DESTDIR}/$${file}"; \
1744                 fi; \
1745                 for ext in debug symbols; do \
1746                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1747                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1748                   fi; \
1749                 done; \
1750         done
1751
1752 delete-old-dirs:
1753         @echo ">>> Removing old directories"
1754         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1755             -V OLD_DIRS | xargs -n1 | sort -r | \
1756         while read dir; do \
1757                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1758                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1759                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1760                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1761                 fi; \
1762         done
1763         @echo ">>> Old directories removed"
1764
1765 check-old-dirs:
1766         @echo ">>> Checking for old directories"
1767         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1768             -V OLD_DIRS | xargs -n1 | \
1769         while read dir; do \
1770                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1771                         echo "${DESTDIR}/$${dir}"; \
1772                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1773                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1774                 fi; \
1775         done
1776
1777 delete-old: delete-old-files delete-old-dirs
1778         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1779
1780 check-old: check-old-files check-old-libs check-old-dirs
1781         @echo "To remove old files and directories run '${MAKE} delete-old'."
1782         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1783
1784 .endif
1785
1786 #
1787 # showconfig - show build configuration.
1788 #
1789 showconfig:
1790         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1791
1792 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1793 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1794
1795 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1796 .if exists(${KERNCONFDIR}/${KERNCONF})
1797 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1798         ${KERNCONFDIR}/${KERNCONF} ; echo
1799 .endif
1800 .endif
1801
1802 .endif
1803
1804 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1805 DTBOUTPUTPATH= ${.CURDIR}
1806 .endif
1807
1808 #
1809 # Build 'standalone' Device Tree Blob
1810 #
1811 builddtb:
1812         @if [ "${FDT_DTS_FILE}" = "" ]; then \
1813                 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1814                 exit 1; \
1815         fi;     \
1816         if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1817                 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1818                         exist!"; \
1819                 exit 1; \
1820         fi;     \
1821         if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then  \
1822                 echo "WARNING: DTB will be placed in the current working \
1823                         directory"; \
1824         fi
1825         @PATH=${TMPPATH} \
1826         dtc -O dtb -o \
1827             ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1828             -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1829
1830 ###############
1831
1832 .if defined(XDEV) && defined(XDEV_ARCH)
1833
1834 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1835 XDEV_CPUTYPE?=${CPUTYPE}
1836 .else
1837 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1838 .endif
1839
1840 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1841         -DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1842         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1843         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1844         CPUTYPE=${XDEV_CPUTYPE}
1845
1846 XDDIR=${XDEV_ARCH}-freebsd
1847 XDTP=/usr/${XDDIR}
1848 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1849         INSTALL="sh ${.CURDIR}/tools/install.sh"
1850 CDENV= ${CDBENV} \
1851         _SHLIBDIRPREFIX=${XDDESTDIR} \
1852         TOOLS_PREFIX=${XDDESTDIR}
1853 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1854         -B${XDDESTDIR}/usr/lib
1855 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" \
1856         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1857
1858 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1859 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1860 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1861 XDDESTDIR=${DESTDIR}${XDTP}
1862 .if !defined(OSREL)
1863 OSREL!= uname -r | sed -e 's/[-(].*//'
1864 .endif
1865
1866 .ORDER: xdev-build xdev-install
1867 xdev: xdev-build xdev-install
1868
1869 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1870 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1871
1872 _xb-worldtmp:
1873         mkdir -p ${CDTMP}/usr
1874         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1875             -p ${CDTMP}/usr >/dev/null
1876
1877 _xb-bootstrap-tools:
1878 .for _tool in \
1879     ${_clang_tblgen}
1880         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1881         cd ${.CURDIR}/${_tool} && \
1882         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1883         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1884         ${CDMAKE} DIRPRFX=${_tool}/ all && \
1885         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1886 .endfor
1887
1888 _xb-build-tools:
1889         ${_+_}@cd ${.CURDIR}; \
1890         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1891
1892 _xb-cross-tools:
1893 .for _tool in \
1894     gnu/usr.bin/binutils \
1895     gnu/usr.bin/cc \
1896     usr.bin/ar \
1897     ${_clang_libs} \
1898     ${_clang}
1899         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1900         cd ${.CURDIR}/${_tool} && \
1901         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1902         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1903         ${CDMAKE} DIRPRFX=${_tool}/ all
1904 .endfor
1905
1906 _xi-mtree:
1907         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1908         mkdir -p ${XDDESTDIR}
1909         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1910             -p ${XDDESTDIR} >/dev/null
1911         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1912             -p ${XDDESTDIR}/usr >/dev/null
1913         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1914             -p ${XDDESTDIR}/usr/include >/dev/null
1915
1916 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1917 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1918
1919 _xi-cross-tools:
1920         @echo "_xi-cross-tools"
1921 .for _tool in \
1922     gnu/usr.bin/binutils \
1923     gnu/usr.bin/cc \
1924     usr.bin/ar \
1925     ${_clang}
1926         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1927         cd ${.CURDIR}/${_tool}; \
1928         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1929 .endfor
1930
1931 _xi-includes:
1932         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1933                 DESTDIR=${XDDESTDIR}
1934
1935 _xi-libraries:
1936         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1937                 DESTDIR=${XDDESTDIR}
1938
1939 _xi-links:
1940         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1941                 for i in *; do \
1942                         ln -sf ../../${XDTP}/usr/bin/$$i \
1943                             ../../../../usr/bin/${XDDIR}-$$i; \
1944                         ln -sf ../../${XDTP}/usr/bin/$$i \
1945                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1946                 done
1947 .else
1948 xdev xdev-build xdev-install:
1949         @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
1950 .endif
1951
1952 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE