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