MFP4: 221483, 221567, 221568, 221670, 221677, 221678, 221800, 221801,
[freebsd-src.git] / Makefile.inc1
blob712622ebc2b17bf74ff5afd940c2962f7aedee06
2 # $FreeBSD$
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
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)
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
44 .if !defined(TARGET) || !defined(TARGET_ARCH)
45 .error "Both TARGET and TARGET_ARCH must be defined."
46 .endif
48 .include <bsd.own.mk>
49 .include <bsd.arch.inc.mk>
50 .include <bsd.compiler.mk>
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.
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.
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
91 # We must do etc/ last for install/distribute to work.
93 SUBDIR+=etc
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
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
113 LOCAL_TOOL_DIRS?=
115 BUILDENV_SHELL?=/bin/sh
117 SVN?=           /usr/local/bin/svn
118 SVNFLAGS?=      -r HEAD
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
130 .if !defined(VERSION)
131 VERSION!=       uname -srp
132 VERSION+=       ${OSRELDATE}
133 .endif
135 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
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
147 .if ${TARGET} == ${MACHINE}
148 TARGET_CPUTYPE?=${CPUTYPE}
149 .else
150 TARGET_CPUTYPE?=
151 .endif
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}
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.
186 .if make(distributeworld) || make(installworld)
187 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
188 .endif
191 # Building a world goes through the following stages
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.
215 BOOTSTRAPPING?= 0
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
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
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
254 # cross-tools stage
255 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
256                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
257                 -DWITHOUT_GDB
259 # world stage
260 WMAKEENV=       ${CROSSENV} \
261                 _SHLIBDIRPREFIX=${WORLDTMP} \
262                 _LDSCRIPTROOT= \
263                 VERSION="${VERSION}" \
264                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
265                 PATH=${TMPPATH}
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
273 .if ${MK_CDDL} == "no"
274 WMAKEENV+=      NO_CTF=1
275 .endif
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}
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}
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}-freebsd11.0
333 XFLAGS+=        -target ${TARGET_TRIPLE}
334 .endif
335 .endif
337 WMAKEENV+=      COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
338 WMAKE=          ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
340 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
341 # 32 bit world
342 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
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"
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
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
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                 LIBPRIVATEDIR=/usr/lib32/private \
386                 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
387 LIB32WMAKEFLAGS+=       \
388                 CC="${XCC} ${LIB32FLAGS}" \
389                 CXX="${XCXX} ${LIB32FLAGS}" \
390                 DESTDIR=${LIB32TMP} \
391                 -DCOMPAT_32BIT \
392                 -DLIBRARIES_ONLY \
393                 -DNO_CPU_CFLAGS \
394                 -DNO_CTF \
395                 -DNO_LINT
397 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
398                 -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
399 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
400                 ${IMAKE_INSTALL}
401 .endif
403 IMAKEENV=       ${CROSSENV:N_LDSCRIPTROOT=*}
404 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
405                 ${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_COMPILER_TYPE}
406 .if empty(.MAKEFLAGS:M-n)
407 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
408                 LD_LIBRARY_PATH=${INSTALLTMP} \
409                 PATH_LOCALE=${INSTALLTMP}/locale
410 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
411 .else
412 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
413 .endif
414 .if defined(DB_FROM_SRC)
415 INSTALLFLAGS+=  -N ${.CURDIR}/etc
416 MTREEFLAGS+=    -N ${.CURDIR}/etc
417 .endif
418 _INSTALL_DDIR=  ${DESTDIR}/${DISTDIR}
419 INSTALL_DDIR=   ${_INSTALL_DDIR:S://:/:g:C:/$::}
420 .if defined(NO_ROOT)
421 METALOG?=       ${DESTDIR}/${DISTDIR}/METALOG
422 IMAKE+=         -DNO_ROOT METALOG=${METALOG}
423 INSTALLFLAGS+=  -U -M ${METALOG} -D ${INSTALL_DDIR}
424 MTREEFLAGS+=    -W
425 .endif
426 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
427 IMAKE_INSTALL=  INSTALL="install ${INSTALLFLAGS}"
428 IMAKE_MTREE=    MTREE_CMD="nmtree ${MTREEFLAGS}"
429 .endif
431 # kernel stage
432 KMAKEENV=       ${WMAKEENV}
433 KMAKE=          ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
436 # buildworld
438 # Attempt to rebuild the entire system, with reasonable chance of
439 # success, regardless of how old your existing system is.
441 _worldtmp:
442 .if ${.CURDIR:C/[^,]//g} != ""
443 #       The m4 build of sendmail files doesn't like it if ',' is used
444 #       anywhere in the path of it's files.
445         @echo
446         @echo "*** Error: path to source tree contains a comma ','"
447         @echo
448         false
449 .endif
450         @echo
451         @echo "--------------------------------------------------------------"
452         @echo ">>> Rebuilding the temporary build tree"
453         @echo "--------------------------------------------------------------"
454 .if !defined(NO_CLEAN)
455         rm -rf ${WORLDTMP}
456 .if defined(LIB32TMP)
457         rm -rf ${LIB32TMP}
458 .endif
459 .else
460         rm -rf ${WORLDTMP}/legacy/usr/include
461 #       XXX - These three can depend on any header file.
462         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
463         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
464         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
465 .endif
466 .for _dir in \
467     lib usr legacy/bin legacy/usr
468         mkdir -p ${WORLDTMP}/${_dir}
469 .endfor
470         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
471             -p ${WORLDTMP}/legacy/usr >/dev/null
472 .if ${MK_GROFF} != "no"
473         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
474             -p ${WORLDTMP}/legacy/usr >/dev/null
475 .endif
476         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
477             -p ${WORLDTMP}/usr >/dev/null
478         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
479             -p ${WORLDTMP}/usr/include >/dev/null
480         ln -sf ${.CURDIR}/sys ${WORLDTMP}
481 .if ${MK_DEBUG_FILES} != "no"
482         # We could instead disable debug files for these build stages
483         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
484             -p ${WORLDTMP}/legacy/usr/lib >/dev/null
485         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
486             -p ${WORLDTMP}/usr/lib >/dev/null
487 .endif
488 .for _mtree in ${LOCAL_MTREE}
489         mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
490 .endfor
491 _legacy:
492         @echo
493         @echo "--------------------------------------------------------------"
494         @echo ">>> stage 1.1: legacy release compatibility shims"
495         @echo "--------------------------------------------------------------"
496         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
497 _bootstrap-tools:
498         @echo
499         @echo "--------------------------------------------------------------"
500         @echo ">>> stage 1.2: bootstrap tools"
501         @echo "--------------------------------------------------------------"
502         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
503 _cleanobj:
504 .if !defined(NO_CLEAN)
505         @echo
506         @echo "--------------------------------------------------------------"
507         @echo ">>> stage 2.1: cleaning up the object tree"
508         @echo "--------------------------------------------------------------"
509         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
510 .if defined(LIB32TMP)
511         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
512 .endif
513 .endif
514 _obj:
515         @echo
516         @echo "--------------------------------------------------------------"
517         @echo ">>> stage 2.2: rebuilding the object tree"
518         @echo "--------------------------------------------------------------"
519         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
520 _build-tools:
521         @echo
522         @echo "--------------------------------------------------------------"
523         @echo ">>> stage 2.3: build tools"
524         @echo "--------------------------------------------------------------"
525         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
526 _cross-tools:
527         @echo
528         @echo "--------------------------------------------------------------"
529         @echo ">>> stage 3: cross tools"
530         @echo "--------------------------------------------------------------"
531         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
532 _includes:
533         @echo
534         @echo "--------------------------------------------------------------"
535         @echo ">>> stage 4.1: building includes"
536         @echo "--------------------------------------------------------------"
537         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
538 _libraries:
539         @echo
540         @echo "--------------------------------------------------------------"
541         @echo ">>> stage 4.2: building libraries"
542         @echo "--------------------------------------------------------------"
543         ${_+_}cd ${.CURDIR}; \
544             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
545             -DWITHOUT_MAN -DNO_PROFILE libraries
546 _depend:
547         @echo
548         @echo "--------------------------------------------------------------"
549         @echo ">>> stage 4.3: make dependencies"
550         @echo "--------------------------------------------------------------"
551         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
552 everything:
553         @echo
554         @echo "--------------------------------------------------------------"
555         @echo ">>> stage 4.4: building everything"
556         @echo "--------------------------------------------------------------"
557         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
558 .if defined(LIB32TMP)
559 build32:
560         @echo
561         @echo "--------------------------------------------------------------"
562         @echo ">>> stage 5.1: building 32 bit shim libraries"
563         @echo "--------------------------------------------------------------"
564         mkdir -p ${LIB32TMP}/usr/include
565         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
566             -p ${LIB32TMP}/usr >/dev/null
567         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
568             -p ${LIB32TMP}/usr/include >/dev/null
569 .if ${MK_DEBUG_FILES} != "no"
570         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
571             -p ${LIB32TMP}/usr/lib >/dev/null
572 .endif
573         mkdir -p ${WORLDTMP}
574         ln -sf ${.CURDIR}/sys ${WORLDTMP}
575 .for _t in obj includes
576         cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
577         cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
578 .if ${MK_CDDL} != "no"
579         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
580 .endif
581         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
582 .if ${MK_CRYPT} != "no"
583         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
584 .endif
585 .if ${MK_KERBEROS} != "no"
586         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
587 .endif
588 .endfor
589 .for _dir in usr.bin/lex/lib
590         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
591 .endfor
592 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
593         cd ${.CURDIR}/${_dir}; \
594             WORLDTMP=${WORLDTMP} \
595             MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
596             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
597             DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
598             -DEARLY_BUILD build-tools
599 .endfor
600         cd ${.CURDIR}; \
601             ${LIB32WMAKE} -f Makefile.inc1 libraries
602 .for _t in obj depend all
603         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
604             DIRPRFX=libexec/rtld-elf/ ${_t}
605         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
606             DIRPRFX=usr.bin/ldd ${_t}
607 .endfor
609 distribute32 install32:
610         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
611 .if ${MK_CDDL} != "no"
612         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
613 .endif
614         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
615 .if ${MK_CRYPT} != "no"
616         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
617 .endif
618 .if ${MK_KERBEROS} != "no"
619         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
620 .endif
621         cd ${.CURDIR}/libexec/rtld-elf; \
622             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
623         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
624 .endif
626 WMAKE_TGTS=
627 .if !defined(SUBDIR_OVERRIDE)
628 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
629 .endif
630 WMAKE_TGTS+=    _cleanobj _obj _build-tools
631 .if !defined(SUBDIR_OVERRIDE)
632 WMAKE_TGTS+=    _cross-tools
633 .endif
634 WMAKE_TGTS+=    _includes _libraries _depend everything
635 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
636 WMAKE_TGTS+=    build32
637 .endif
639 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
640 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
642 buildworld_prologue:
643         @echo "--------------------------------------------------------------"
644         @echo ">>> World build started on `LC_ALL=C date`"
645         @echo "--------------------------------------------------------------"
647 buildworld_epilogue:
648         @echo
649         @echo "--------------------------------------------------------------"
650         @echo ">>> World build completed on `LC_ALL=C date`"
651         @echo "--------------------------------------------------------------"
654 # We need to have this as a target because the indirection between Makefile
655 # and Makefile.inc1 causes the correct PATH to be used, rather than a
656 # modification of the current environment's PATH.  In addition, we need
657 # to quote multiword values.
659 buildenvvars:
660         @echo ${WMAKEENV:Q}
662 buildenv:
663         @echo Entering world for ${TARGET_ARCH}:${TARGET}
664         @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
666 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
667 toolchain: ${TOOLCHAIN_TGTS}
668 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
671 # installcheck
673 # Checks to be sure system is ready for installworld/installkernel.
675 installcheck: _installcheck_world _installcheck_kernel
676 _installcheck_world:
677 _installcheck_kernel:
680 # Require DESTDIR to be set if installing for a different architecture or
681 # using the user/group database in the source tree.
683 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
684     defined(DB_FROM_SRC)
685 .if !make(distributeworld)
686 _installcheck_world: __installcheck_DESTDIR
687 _installcheck_kernel: __installcheck_DESTDIR
688 __installcheck_DESTDIR:
689 .if !defined(DESTDIR) || empty(DESTDIR)
690         @echo "ERROR: Please set DESTDIR!"; \
691         false
692 .endif
693 .endif
694 .endif
696 .if !defined(DB_FROM_SRC)
698 # Check for missing UIDs/GIDs.
700 CHECK_UIDS=     auditdistd
701 CHECK_GIDS=     audit
702 .if ${MK_SENDMAIL} != "no"
703 CHECK_UIDS+=    smmsp
704 CHECK_GIDS+=    smmsp
705 .endif
706 .if ${MK_PF} != "no"
707 CHECK_UIDS+=    proxy
708 CHECK_GIDS+=    proxy authpf
709 .endif
710 .if ${MK_UNBOUND} != "no"
711 CHECK_UIDS+=    unbound
712 CHECK_GIDS+=    unbound
713 .endif
714 _installcheck_world: __installcheck_UGID
715 __installcheck_UGID:
716 .for uid in ${CHECK_UIDS}
717         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
718                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
719                 false; \
720         fi
721 .endfor
722 .for gid in ${CHECK_GIDS}
723         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
724                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
725                 false; \
726         fi
727 .endfor
728 .endif
731 # Required install tools to be saved in a scratch dir for safety.
733 .if ${MK_INFO} != "no"
734 _install-info=  install-info
735 .endif
736 .if ${MK_ZONEINFO} != "no"
737 _zoneinfo=      zic tzsetup
738 .endif
740 .if exists(/usr/sbin/nmtree)
741 _nmtree_itools= nmtree
742 .endif
744 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
745         date echo egrep find grep id install ${_install-info} \
746         ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
747         rm sed sh sysctl test true uname wc ${_zoneinfo}
750 # distributeworld
752 # Distributes everything compiled by a `buildworld'.
754 # installworld
756 # Installs everything compiled by a 'buildworld'.
759 # Non-base distributions produced by the base system
760 EXTRA_DISTRIBUTIONS=    doc
761 .if ${MK_GAMES} != "no"
762 EXTRA_DISTRIBUTIONS+=   games
763 .endif
764 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
765 EXTRA_DISTRIBUTIONS+=   lib32
766 .endif
768 MTREE_MAGIC?=   mtree 2.0
770 distributeworld installworld: _installcheck_world
771         mkdir -p ${INSTALLTMP}
772         progs=$$(for prog in ${ITOOLS}; do \
773                 if progpath=`which $$prog`; then \
774                         echo $$progpath; \
775                 else \
776                         echo "Required tool $$prog not found in PATH." >&2; \
777                         exit 1; \
778                 fi; \
779             done); \
780         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
781             while read line; do \
782                 set -- $$line; \
783                 if [ "$$2 $$3" != "not found" ]; then \
784                         echo $$2; \
785                 else \
786                         echo "Required library $$1 not found." >&2; \
787                         exit 1; \
788                 fi; \
789             done); \
790         cp $$libs $$progs ${INSTALLTMP}
791         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
792 .if defined(NO_ROOT)
793         echo "#${MTREE_MAGIC}" > ${METALOG}
794 .endif
795 .if make(distributeworld)
796 .for dist in ${EXTRA_DISTRIBUTIONS}
797         -mkdir ${DESTDIR}/${DISTDIR}/${dist}
798         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
799             -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
800         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
801             -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
802         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
803             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
804 .if ${MK_DEBUG_FILES} != "no"
805         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
806             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
807 .endif
808 .if defined(NO_ROOT)
809         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
810             sed -e 's#^\./#./${dist}/#' >> ${METALOG}
811         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
812             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
813         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
814             sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
815 .endif
816 .endfor
817         -mkdir ${DESTDIR}/${DISTDIR}/base
818         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
819             METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
820             DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
821             LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
822 .endif
823         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
824             ${IMAKEENV} rm -rf ${INSTALLTMP}
825 .if make(distributeworld)
826 .for dist in ${EXTRA_DISTRIBUTIONS}
827         find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
828 .endfor
829 .if defined(NO_ROOT)
830 .for dist in base ${EXTRA_DISTRIBUTIONS}
831         @# For each file that exists in this dist, print the corresponding
832         @# line from the METALOG.  This relies on the fact that
833         @# a line containing only the filename will sort immediatly before
834         @# the relevant mtree line.
835         cd ${DESTDIR}/${DISTDIR}; \
836         find ./${dist} | sort -u ${METALOG} - | \
837         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
838         ${DESTDIR}/${DISTDIR}/${dist}.meta
839 .endfor
840 .if ${MK_DEBUG_FILES} != "no"
841 . for dist in base ${EXTRA_DISTRIBUTIONS}
842         @# For each file that exists in this dist, print the corresponding
843         @# line from the METALOG.  This relies on the fact that
844         @# a line containing only the filename will sort immediatly before
845         @# the relevant mtree line.
846         cd ${DESTDIR}/${DISTDIR}; \
847         find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
848         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
849         ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
850 . endfor
851 .endif
852 .endif
853 .endif
855 packageworld:
856 .for dist in base ${EXTRA_DISTRIBUTIONS}
857 .if defined(NO_ROOT)
858         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
859             tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
860             --exclude usr/lib/debug \
861             @${DESTDIR}/${DISTDIR}/${dist}.meta
862 .else
863         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
864             tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
865             --exclude usr/lib/debug .
866 .endif
867 .endfor
869 .if ${MK_DEBUG_FILES} != "no"
870 . for dist in base ${EXTRA_DISTRIBUTIONS}
871 .  if defined(NO_ROOT)
872         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
873             tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
874             @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
875 .  else
876         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
877             tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
878             usr/lib/debug
879 .  endif
880 . endfor
881 .endif
884 # reinstall
886 # If you have a build server, you can NFS mount the source and obj directories
887 # and do a 'make reinstall' on the *client* to install new binaries from the
888 # most recent server build.
890 reinstall:
891         @echo "--------------------------------------------------------------"
892         @echo ">>> Making hierarchy"
893         @echo "--------------------------------------------------------------"
894         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
895             LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
896         @echo
897         @echo "--------------------------------------------------------------"
898         @echo ">>> Installing everything"
899         @echo "--------------------------------------------------------------"
900         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
901 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
902         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
903 .endif
905 redistribute:
906         @echo "--------------------------------------------------------------"
907         @echo ">>> Distributing everything"
908         @echo "--------------------------------------------------------------"
909         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
910 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
911         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
912             DISTRIBUTION=lib32
913 .endif
915 distrib-dirs distribution:
916         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
917             ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
920 # buildkernel and installkernel
922 # Which kernels to build and/or install is specified by setting
923 # KERNCONF. If not defined a GENERIC kernel is built/installed.
924 # Only the existing (depending TARGET) config files are used
925 # for building kernels and only the first of these is designated
926 # as the one being installed.
928 # Note that we have to use TARGET instead of TARGET_ARCH when
929 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
930 # be set to cross-build, we have to make sure TARGET is set
931 # properly.
933 .if defined(KERNFAST)
934 NO_KERNELCLEAN= t
935 NO_KERNELCONFIG=        t
936 NO_KERNELDEPEND=        t
937 NO_KERNELOBJ=           t
938 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
939 .if !defined(KERNCONF) && ${KERNFAST} != "1"
940 KERNCONF=${KERNFAST}
941 .endif
942 .endif
943 .if ${TARGET_ARCH} == "powerpc64"
944 KERNCONF?=      GENERIC64
945 .else
946 KERNCONF?=      GENERIC
947 .endif
948 INSTKERNNAME?=  kernel
950 KERNSRCDIR?=    ${.CURDIR}/sys
951 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
952 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
953 KERNCONFDIR?=   ${KRNLCONFDIR}
955 BUILDKERNELS=
956 INSTALLKERNEL=
957 .for _kernel in ${KERNCONF}
958 .if exists(${KERNCONFDIR}/${_kernel})
959 BUILDKERNELS+=  ${_kernel}
960 .if empty(INSTALLKERNEL)
961 INSTALLKERNEL= ${_kernel}
962 .endif
963 .endif
964 .endfor
967 # buildkernel
969 # Builds all kernels defined by BUILDKERNELS.
971 buildkernel:
972 .if empty(BUILDKERNELS)
973         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
974         false
975 .endif
976         @echo
977 .for _kernel in ${BUILDKERNELS}
978         @echo "--------------------------------------------------------------"
979         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
980         @echo "--------------------------------------------------------------"
981         @echo "===> ${_kernel}"
982         mkdir -p ${KRNLOBJDIR}
983 .if !defined(NO_KERNELCONFIG)
984         @echo
985         @echo "--------------------------------------------------------------"
986         @echo ">>> stage 1: configuring the kernel"
987         @echo "--------------------------------------------------------------"
988         cd ${KRNLCONFDIR}; \
989                 PATH=${TMPPATH} \
990                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
991                         ${KERNCONFDIR}/${_kernel}
992 .endif
993 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
994         @echo
995         @echo "--------------------------------------------------------------"
996         @echo ">>> stage 2.1: cleaning up the object tree"
997         @echo "--------------------------------------------------------------"
998         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
999 .endif
1000 .if !defined(NO_KERNELOBJ)
1001         @echo
1002         @echo "--------------------------------------------------------------"
1003         @echo ">>> stage 2.2: rebuilding the object tree"
1004         @echo "--------------------------------------------------------------"
1005         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1006 .endif
1007         @echo
1008         @echo "--------------------------------------------------------------"
1009         @echo ">>> stage 2.3: build tools"
1010         @echo "--------------------------------------------------------------"
1011         cd ${KRNLOBJDIR}/${_kernel}; \
1012             PATH=${BPATH}:${PATH} \
1013             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
1014             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
1015             -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
1016 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
1017 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
1018 .for target in obj depend all
1019         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
1020             PATH=${BPATH}:${PATH} \
1021             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
1022             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
1023 .endfor
1024 .endif
1025 .if !defined(NO_KERNELDEPEND)
1026         @echo
1027         @echo "--------------------------------------------------------------"
1028         @echo ">>> stage 3.1: making dependencies"
1029         @echo "--------------------------------------------------------------"
1030         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1031 .endif
1032         @echo
1033         @echo "--------------------------------------------------------------"
1034         @echo ">>> stage 3.2: building everything"
1035         @echo "--------------------------------------------------------------"
1036         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1037         @echo "--------------------------------------------------------------"
1038         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1039         @echo "--------------------------------------------------------------"
1040 .endfor
1043 # installkernel, etc.
1045 # Install the kernel defined by INSTALLKERNEL
1047 installkernel installkernel.debug \
1048 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1049 .if empty(INSTALLKERNEL)
1050         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1051         false
1052 .endif
1053         @echo "--------------------------------------------------------------"
1054         @echo ">>> Installing kernel ${INSTALLKERNEL}"
1055         @echo "--------------------------------------------------------------"
1056         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1057             ${CROSSENV} PATH=${TMPPATH} \
1058             ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1060 distributekernel distributekernel.debug:
1061 .if empty(INSTALLKERNEL)
1062         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1063         false
1064 .endif
1065         mkdir -p ${DESTDIR}/${DISTDIR}
1066 .if defined(NO_ROOT)
1067         echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1068 .endif
1069         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1070             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1071             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1072             DESTDIR=${INSTALL_DDIR}/kernel \
1073             ${.TARGET:S/distributekernel/install/}
1074 .if defined(NO_ROOT)
1075         sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1076             ${DESTDIR}/${DISTDIR}/kernel.meta
1077 .endif
1078 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1079 .if defined(NO_ROOT)
1080         echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1081 .endif
1082         cd ${KRNLOBJDIR}/${_kernel}; \
1083             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1084             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1085             KERNEL=${INSTKERNNAME}.${_kernel} \
1086             DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1087             ${.TARGET:S/distributekernel/install/}
1088 .if defined(NO_ROOT)
1089         sed -e 's|^./kernel|.|' \
1090             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1091             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1092 .endif
1093 .endfor
1095 packagekernel:
1096 .if defined(NO_ROOT)
1097         cd ${DESTDIR}/${DISTDIR}/kernel; \
1098             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
1099             @${DESTDIR}/${DISTDIR}/kernel.meta
1100 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1101         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1102             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
1103             @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1104 .endfor
1105 .else
1106         cd ${DESTDIR}/${DISTDIR}/kernel; \
1107             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1108 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1109         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1110             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1111 .endfor
1112 .endif
1115 # doxygen
1117 # Build the API documentation with doxygen
1119 doxygen:
1120         @if [ ! -x `/usr/bin/which doxygen` ]; then \
1121                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1122                 exit 1; \
1123         fi
1124         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1127 # update
1129 # Update the source tree(s), by running svn/svnup to update to the
1130 # latest copy.
1132 update:
1133 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1134         @echo "--------------------------------------------------------------"
1135         @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1136         @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1137         @echo "--------------------------------------------------------------"
1138         @exit 1
1139 .endif
1140 .if defined(SVN_UPDATE)
1141         @echo "--------------------------------------------------------------"
1142         @echo ">>> Updating ${.CURDIR} using Subversion"
1143         @echo "--------------------------------------------------------------"
1144         @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1145 .endif
1148 # ------------------------------------------------------------------------
1150 # From here onwards are utility targets used by the 'make world' and
1151 # related targets.  If your 'world' breaks, you may like to try to fix
1152 # the problem and manually run the following targets to attempt to
1153 # complete the build.  Beware, this is *not* guaranteed to work, you
1154 # need to have a pretty good grip on the current state of the system
1155 # to attempt to manually finish it.  If in doubt, 'make world' again.
1159 # legacy: Build compatibility shims for the next three targets
1161 legacy:
1162 .if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0
1163         @echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \
1164         false
1165 .endif
1166 .for _tool in tools/build
1167         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1168             cd ${.CURDIR}/${_tool} && \
1169             ${MAKE} DIRPRFX=${_tool}/ obj && \
1170             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1171             ${MAKE} DIRPRFX=${_tool}/ depend && \
1172             ${MAKE} DIRPRFX=${_tool}/ all && \
1173             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1174 .endfor
1177 # bootstrap-tools: Build tools needed for compatibility
1179 .if ${MK_GAMES} != "no"
1180 _strfile=       games/fortune/strfile
1181 .endif
1183 .if ${MK_CXX} != "no"
1184 _gperf=         gnu/usr.bin/gperf
1185 .endif
1187 .if ${MK_GROFF} != "no"
1188 _groff=         gnu/usr.bin/groff
1189 .endif
1191 .if ${BOOTSTRAPPING} < 800022
1192 _ar=            usr.bin/ar
1193 .endif
1195 .if ${BOOTSTRAPPING} < 800013
1196 _mklocale=      usr.bin/mklocale
1197 .endif
1199 .if ${BOOTSTRAPPING} < 900002
1200 _sed=           usr.bin/sed
1201 .endif
1203 .if ${BOOTSTRAPPING} < 900006
1204 _lex=           usr.bin/lex
1205 .endif
1207 .if ${BOOTSTRAPPING} < 1000002
1208 _m4=            usr.bin/m4
1209 .endif
1211 .if ${BOOTSTRAPPING} < 1000013
1212 _yacc=          lib/liby \
1213                 usr.bin/yacc
1214 .endif
1216 .if ${BOOTSTRAPPING} < 1000014
1217 _crunch=        usr.sbin/crunch
1218 .endif
1220 .if ${BOOTSTRAPPING} < 1000026
1221 _nmtree=        lib/libnetbsd \
1222                 usr.sbin/nmtree
1223 .endif
1225 .if ${BOOTSTRAPPING} < 1000027
1226 _cat=           bin/cat
1227 .endif
1229 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1230 _awk=           usr.bin/awk
1231 .endif
1233 .if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree)
1234 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
1235 .endif
1237 .if ${MK_CLANG} != "no"
1238 _clang_tblgen= \
1239         lib/clang/libllvmsupport \
1240         lib/clang/libllvmtablegen \
1241         usr.bin/clang/tblgen \
1242         usr.bin/clang/clang-tblgen
1243 .endif
1245 # dtrace tools are required for older bootstrap env and cross-build
1246 .if ${MK_CDDL} != "no" && \
1247     ((${BOOTSTRAPPING} < 1000034 && \
1248           !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
1249       || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1250 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1251     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1252 .endif
1254 # Default to building the BSDL DTC, but build the GPL one if users explicitly
1255 # request it.
1256 _dtc= usr.bin/dtc
1257 .if ${MK_GPL_DTC} != "no"
1258 _dtc= gnu/usr.bin/dtc
1259 .endif
1261 .if ${MK_KERBEROS} != "no"
1262 _kerberos5_bootstrap_tools= \
1263         kerberos5/tools/make-roken \
1264         kerberos5/lib/libroken \
1265         kerberos5/lib/libvers \
1266         kerberos5/tools/asn1_compile \
1267         kerberos5/tools/slc \
1268         usr.bin/compile_et
1269 .endif
1271 #       Please document (add comment) why something is in 'bootstrap-tools'.
1272 #       Try to bound the building of the bootstrap-tool to just the
1273 #       FreeBSD versions that need the tool built at this stage of the build.
1274 bootstrap-tools: .MAKE
1275 .for _tool in \
1276     ${_clang_tblgen} \
1277     ${_kerberos5_bootstrap_tools} \
1278     ${_dtrace_tools} \
1279     ${_strfile} \
1280     ${_gperf} \
1281     ${_groff} \
1282     ${_ar} \
1283     ${_dtc} \
1284     ${_awk} \
1285     ${_cat} \
1286     usr.bin/lorder \
1287     usr.bin/makewhatis \
1288     ${_mklocale} \
1289     usr.bin/rpcgen \
1290     ${_sed} \
1291     ${_yacc} \
1292     ${_m4} \
1293     ${_lex} \
1294     lib/libmd \
1295     usr.bin/xinstall \
1296     ${_gensnmptree} \
1297     usr.sbin/config \
1298     ${_crunch} \
1299     ${_nmtree}
1300         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1301                 cd ${.CURDIR}/${_tool} && \
1302                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1303                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1304                 ${MAKE} DIRPRFX=${_tool}/ all && \
1305                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1306 .endfor
1309 # build-tools: Build special purpose build tools
1311 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1312 _aicasm= sys/modules/aic7xxx/aicasm
1313 .endif
1315 .if !defined(NO_SHARE)
1316 _share= share/syscons/scrnmaps
1317 .endif
1319 .if ${MK_GCC} != "no"
1320 _gcc_tools= gnu/usr.bin/cc/cc_tools
1321 .endif
1323 .if ${MK_RESCUE} != "no"
1324 _rescue= rescue/rescue
1325 .endif
1327 build-tools: .MAKE
1328 .for _tool in \
1329     bin/csh \
1330     bin/sh \
1331     ${_rescue} \
1332     ${LOCAL_TOOL_DIRS} \
1333     lib/ncurses/ncurses \
1334     lib/ncurses/ncursesw \
1335     ${_share} \
1336     ${_aicasm} \
1337     usr.bin/awk \
1338     lib/libmagic \
1339     usr.bin/mkesdb_static \
1340     usr.bin/mkcsmapper_static \
1341     usr.bin/vi/catalog
1342         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1343                 cd ${.CURDIR}/${_tool} && \
1344                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1345                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1346 .endfor
1347 .for _tool in \
1348     ${_gcc_tools}
1349         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1350                 cd ${.CURDIR}/${_tool} && \
1351                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1352                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1353                 ${MAKE} DIRPRFX=${_tool}/ all
1354 .endfor
1357 # cross-tools: Build cross-building tools
1359 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1360 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1361 _btxld=         usr.sbin/btxld
1362 .endif
1363 .endif
1364 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1365 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1366 _crunchide=     usr.sbin/crunch/crunchide
1367 .endif
1368 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1369 _kgzip=         usr.sbin/kgzip
1370 .endif
1371 .endif
1373 .if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
1374 _binutils=      gnu/usr.bin/binutils
1375 .endif
1377 # If an full path to an external cross compiler is given, don't build
1378 # a cross compiler.
1379 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1380 .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1381 _clang=         usr.bin/clang
1382 _clang_libs=    lib/clang
1383 .endif
1385 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1386 _cc=            gnu/usr.bin/cc
1387 .endif
1388 .endif
1390 cross-tools: .MAKE
1391 .for _tool in \
1392     ${_clang_libs} \
1393     ${_clang} \
1394     ${_binutils} \
1395     ${_cc} \
1396     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1397     ${_btxld} \
1398     ${_crunchide} \
1399     ${_kgzip}
1400         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1401                 cd ${.CURDIR}/${_tool} && \
1402                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1403                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1404                 ${MAKE} DIRPRFX=${_tool}/ all && \
1405                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1406 .endfor
1409 # hierarchy - ensure that all the needed directories are present
1411 hierarchy hier:
1412         cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1415 # libraries - build all libraries, and install them under ${DESTDIR}.
1417 # The list of libraries with dependents (${_prebuild_libs}) and their
1418 # interdependencies (__L) are built automatically by the
1419 # ${.CURDIR}/tools/make_libdeps.sh script.
1421 libraries: .MAKE
1422         cd ${.CURDIR} && \
1423             ${MAKE} -f Makefile.inc1 _prereq_libs && \
1424             ${MAKE} -f Makefile.inc1 _startup_libs && \
1425             ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1426             ${MAKE} -f Makefile.inc1 _generic_libs
1429 # static libgcc.a prerequisite for shared libc
1431 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1433 # These dependencies are not automatically generated:
1435 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1436 # all shared libraries for ELF.
1438 _startup_libs=  gnu/lib/csu
1439 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1440 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1441 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1442 _startup_libs+= lib/csu/${MACHINE_ARCH}
1443 .else
1444 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1445 .endif
1446 _startup_libs+= gnu/lib/libgcc
1447 _startup_libs+= lib/libcompiler_rt
1448 _startup_libs+= lib/libc
1449 .if ${MK_LIBCPLUSPLUS} != "no"
1450 _startup_libs+= lib/libcxxrt
1451 .endif
1453 gnu/lib/libgcc__L: lib/libc__L
1454 .if ${MK_LIBCPLUSPLUS} != "no"
1455 lib/libcxxrt__L: gnu/lib/libgcc__L
1456 .endif
1458 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1459                 ${_kerberos5_lib_libhdb} \
1460                 ${_kerberos5_lib_libheimbase} \
1461                 ${_kerberos5_lib_libheimntlm} \
1462                 ${_kerberos5_lib_libheimsqlite} \
1463                 ${_kerberos5_lib_libheimipcc} \
1464                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1465                 ${_kerberos5_lib_libroken} \
1466                 ${_kerberos5_lib_libwind} \
1467                 ${_lib_atf_libatf_c} \
1468                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1469                 lib/libelf lib/libexpat \
1470                 ${_lib_libgssapi} ${_lib_libipx} \
1471                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1472                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1473                 lib/libopie lib/libpam ${_lib_libthr} \
1474                 lib/libradius lib/libsbuf lib/libtacplus \
1475                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1476                 ${_cddl_lib_libzfs_core} \
1477                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1478                 ${_secure_lib_libcrypto} ${_lib_libldns} \
1479                 ${_secure_lib_libssh} ${_secure_lib_libssl}
1481 .if ${MK_ATF} != "no"
1482 _lib_atf_libatf_c=      lib/atf/libatf-c
1483 .endif
1485 .if ${MK_LIBTHR} != "no"
1486 _lib_libthr=    lib/libthr
1487 .endif
1489 .if ${MK_OFED} != "no"
1490 _ofed_lib=      contrib/ofed/usr.lib/
1491 .endif
1493 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1494 .for _DIR in ${LOCAL_LIB_DIRS}
1495 .if exists(${.CURDIR}/${_DIR}/Makefile)
1496 _generic_libs+= ${_DIR}
1497 .endif
1498 .endfor
1500 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1502 .if ${MK_CDDL} != "no"
1503 _cddl_lib_libumem= cddl/lib/libumem
1504 _cddl_lib_libnvpair= cddl/lib/libnvpair
1505 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1506 _cddl_lib= cddl/lib
1507 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1508 .endif
1510 .if ${MK_CRYPT} != "no"
1511 .if ${MK_OPENSSL} != "no"
1512 _secure_lib_libcrypto= secure/lib/libcrypto
1513 _secure_lib_libssl= secure/lib/libssl
1514 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1515 .if ${MK_LDNS} != "no"
1516 _lib_libldns= lib/libldns
1517 lib/libldns__L: secure/lib/libcrypto__L
1518 .endif
1519 .if ${MK_OPENSSH} != "no"
1520 _secure_lib_libssh= secure/lib/libssh
1521 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1522 .if ${MK_LDNS} != "no"
1523 secure/lib/libssh__L: lib/libldns__L
1524 .endif
1525 .if ${MK_KERBEROS_SUPPORT} != "no"
1526 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1527     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1528     lib/libmd__L kerberos5/lib/libroken__L
1529 .endif
1530 .endif
1531 .endif
1532 _secure_lib=    secure/lib
1533 .endif
1535 .if ${MK_KERBEROS} != "no"
1536 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1537 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1538     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1539     kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1540 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1541     kerberos5/lib/libroken__L lib/libcom_err__L
1542 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1543     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1544 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1545     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1546     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1547     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1548 kerberos5/lib/libroken__L: lib/libcrypt__L
1549 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1550 kerberos5/lib/libheimbase__L: lib/libthr__L
1551 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1552 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1553 .endif
1555 .if ${MK_GSSAPI} != "no"
1556 _lib_libgssapi= lib/libgssapi
1557 .endif
1559 .if ${MK_IPX} != "no"
1560 _lib_libipx=    lib/libipx
1561 .endif
1563 .if ${MK_KERBEROS} != "no"
1564 _kerberos5_lib= kerberos5/lib
1565 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1566 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1567 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1568 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1569 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1570 _kerberos5_lib_libroken= kerberos5/lib/libroken
1571 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1572 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1573 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1574 _kerberos5_lib_libwind= kerberos5/lib/libwind
1575 _libcom_err= lib/libcom_err
1576 .endif
1578 .if ${MK_NIS} != "no"
1579 _lib_libypclnt= lib/libypclnt
1580 .endif
1582 .if ${MK_OPENSSL} == "no"
1583 lib/libradius__L: lib/libmd__L
1584 .endif
1586 .for _lib in ${_prereq_libs}
1587 ${_lib}__PL: .PHONY .MAKE
1588 .if exists(${.CURDIR}/${_lib})
1589         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1590                 cd ${.CURDIR}/${_lib} && \
1591                 ${MAKE} DIRPRFX=${_lib}/ obj && \
1592                 ${MAKE} DIRPRFX=${_lib}/ depend && \
1593                 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all && \
1594                 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1595 .endif
1596 .endfor
1598 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1599 ${_lib}__L: .PHONY .MAKE
1600 .if exists(${.CURDIR}/${_lib})
1601         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1602                 cd ${.CURDIR}/${_lib} && \
1603                 ${MAKE} DIRPRFX=${_lib}/ obj && \
1604                 ${MAKE} DIRPRFX=${_lib}/ depend && \
1605                 ${MAKE} DIRPRFX=${_lib}/ all && \
1606                 ${MAKE} DIRPRFX=${_lib}/ install
1607 .endif
1608 .endfor
1610 # libpam is special: we need to build static PAM modules before
1611 # static PAM library, and dynamic PAM library before dynamic PAM
1612 # modules.
1613 lib/libpam__L: .PHONY .MAKE
1614         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1615                 cd ${.CURDIR}/lib/libpam && \
1616                 ${MAKE} DIRPRFX=lib/libpam/ obj && \
1617                 ${MAKE} DIRPRFX=lib/libpam/ depend && \
1618                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all && \
1619                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1621 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1622 _startup_libs: ${_startup_libs:S/$/__L/}
1623 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1624 _generic_libs: ${_generic_libs:S/$/__L/}
1626 .for __target in all clean cleandepend cleandir depend includes obj
1627 .for entry in ${SUBDIR}
1628 ${entry}.${__target}__D: .PHONY .MAKE
1629         ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1630                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1631                 edir=${entry}.${MACHINE_ARCH}; \
1632                 cd ${.CURDIR}/$${edir}; \
1633         else \
1634                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1635                 edir=${entry}; \
1636                 cd ${.CURDIR}/$${edir}; \
1637         fi; \
1638         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1639 .endfor
1640 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1641 .endfor
1643 .include <bsd.subdir.mk>
1645 .if make(check-old) || make(check-old-dirs) || \
1646     make(check-old-files) || make(check-old-libs) || \
1647     make(delete-old) || make(delete-old-dirs) || \
1648     make(delete-old-files) || make(delete-old-libs)
1651 # check for / delete old files section
1654 .include "ObsoleteFiles.inc"
1656 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1657 else you can not start such an application. Consult UPDATING for more \
1658 information regarding how to cope with the removal/revision bump of a \
1659 specific library."
1661 .if !defined(BATCH_DELETE_OLD_FILES)
1662 RM_I=-i
1663 .else
1664 RM_I=-v
1665 .endif
1667 delete-old-files:
1668         @echo ">>> Removing old files (only deletes safe to delete libs)"
1669 # Ask for every old file if the user really wants to remove it.
1670 # It's annoying, but better safe than sorry.
1671 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1672 # argument list will get too long. Using .for/.endfor make "loops" will make
1673 # the Makefile parser segfault.
1674         @exec 3<&0; \
1675         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1676             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1677         while read file; do \
1678                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1679                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1680                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1681                 fi; \
1682         done
1683 # Remove catpages without corresponding manpages.
1684         @exec 3<&0; \
1685         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1686         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1687         while read catpage; do \
1688                 read manpage; \
1689                 if [ ! -e "$${manpage}" ]; then \
1690                         rm ${RM_I} $${catpage} <&3; \
1691                 fi; \
1692         done
1693         @echo ">>> Old files removed"
1695 check-old-files:
1696         @echo ">>> Checking for old files"
1697         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1698             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1699         while read file; do \
1700                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1701                         echo "${DESTDIR}/$${file}"; \
1702                 fi; \
1703         done
1704 # Check for catpages without corresponding manpages.
1705         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1706         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1707         while read catpage; do \
1708                 read manpage; \
1709                 if [ ! -e "$${manpage}" ]; then \
1710                         echo $${catpage}; \
1711                 fi; \
1712         done
1714 delete-old-libs:
1715         @echo ">>> Removing old libraries"
1716         @echo "${OLD_LIBS_MESSAGE}" | fmt
1717         @exec 3<&0; \
1718         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1719             -V OLD_LIBS | xargs -n1 | \
1720         while read file; do \
1721                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1722                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1723                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1724                 fi; \
1725         done
1726         @echo ">>> Old libraries removed"
1728 check-old-libs:
1729         @echo ">>> Checking for old libraries"
1730         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1731             -V OLD_LIBS | xargs -n1 | \
1732         while read file; do \
1733                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1734                         echo "${DESTDIR}/$${file}"; \
1735                 fi; \
1736         done
1738 delete-old-dirs:
1739         @echo ">>> Removing old directories"
1740         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1741             -V OLD_DIRS | xargs -n1 | sort -r | \
1742         while read dir; do \
1743                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1744                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1745                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1746                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1747                 fi; \
1748         done
1749         @echo ">>> Old directories removed"
1751 check-old-dirs:
1752         @echo ">>> Checking for old directories"
1753         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1754             -V OLD_DIRS | xargs -n1 | \
1755         while read dir; do \
1756                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1757                         echo "${DESTDIR}/$${dir}"; \
1758                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1759                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1760                 fi; \
1761         done
1763 delete-old: delete-old-files delete-old-dirs
1764         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1766 check-old: check-old-files check-old-libs check-old-dirs
1767         @echo "To remove old files and directories run '${MAKE} delete-old'."
1768         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1770 .endif
1773 # showconfig - show build configuration.
1775 showconfig:
1776         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1778 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1779 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1781 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1782 .if exists(${KERNCONFDIR}/${KERNCONF})
1783 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1784         ${KERNCONFDIR}/${KERNCONF} ; echo
1785 .endif
1786 .endif
1788 .endif
1790 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1791 DTBOUTPUTPATH= ${.CURDIR}
1792 .endif
1795 # Build 'standalone' Device Tree Blob
1797 builddtb:
1798         @if [ "${FDT_DTS_FILE}" = "" ]; then \
1799                 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1800                 exit 1; \
1801         fi;     \
1802         if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1803                 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1804                         exist!"; \
1805                 exit 1; \
1806         fi;     \
1807         if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then  \
1808                 echo "WARNING: DTB will be placed in the current working \
1809                         directory"; \
1810         fi
1811         @PATH=${TMPPATH} \
1812         dtc -O dtb -o \
1813             ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1814             -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1816 ###############
1818 .if defined(XDEV) && defined(XDEV_ARCH)
1820 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1821 XDEV_CPUTYPE?=${CPUTYPE}
1822 .else
1823 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1824 .endif
1826 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1827         -DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1828         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1829         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1830         CPUTYPE=${XDEV_CPUTYPE}
1832 XDDIR=${XDEV_ARCH}-freebsd
1833 XDTP=usr/${XDDIR}
1834 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1835         INSTALL="sh ${.CURDIR}/tools/install.sh"
1836 CDENV= ${CDBENV} \
1837         _SHLIBDIRPREFIX=${XDDESTDIR} \
1838         TOOLS_PREFIX=${XDDESTDIR}
1839 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1840         -B${XDDESTDIR}/usr/lib
1841 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" \
1842         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1844 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1845 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1846 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1847 XDDESTDIR=${DESTDIR}/${XDTP}
1848 .if !defined(OSREL)
1849 OSREL!= uname -r | sed -e 's/[-(].*//'
1850 .endif
1852 .ORDER: xdev-build xdev-install
1853 xdev: xdev-build xdev-install
1855 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1856 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1858 _xb-worldtmp:
1859         mkdir -p ${CDTMP}/usr
1860         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1861             -p ${CDTMP}/usr >/dev/null
1863 _xb-bootstrap-tools:
1864 .for _tool in \
1865     ${_clang_tblgen}
1866         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1867         cd ${.CURDIR}/${_tool} && \
1868         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1869         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1870         ${CDMAKE} DIRPRFX=${_tool}/ all && \
1871         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1872 .endfor
1874 _xb-build-tools:
1875         ${_+_}@cd ${.CURDIR}; \
1876         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1878 _xb-cross-tools:
1879 .for _tool in \
1880     gnu/usr.bin/binutils \
1881     gnu/usr.bin/cc \
1882     usr.bin/ar \
1883     ${_clang_libs} \
1884     ${_clang}
1885         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1886         cd ${.CURDIR}/${_tool} && \
1887         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1888         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1889         ${CDMAKE} DIRPRFX=${_tool}/ all
1890 .endfor
1892 _xi-mtree:
1893         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1894         mkdir -p ${XDDESTDIR}
1895         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1896             -p ${XDDESTDIR} >/dev/null
1897         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1898             -p ${XDDESTDIR}/usr >/dev/null
1899         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1900             -p ${XDDESTDIR}/usr/include >/dev/null
1902 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1903 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1905 _xi-cross-tools:
1906         @echo "_xi-cross-tools"
1907 .for _tool in \
1908     gnu/usr.bin/binutils \
1909     gnu/usr.bin/cc \
1910     usr.bin/ar \
1911     ${_clang}
1912         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1913         cd ${.CURDIR}/${_tool}; \
1914         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1915 .endfor
1917 _xi-includes:
1918         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1919                 DESTDIR=${XDDESTDIR}
1921 _xi-libraries:
1922         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1923                 DESTDIR=${XDDESTDIR}
1925 _xi-links:
1926         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1927        mkdir -p ../../../../usr/bin; \
1928                 for i in *; do \
1929                         ln -sf ../../${XDTP}/usr/bin/$$i \
1930                             ../../../../usr/bin/${XDDIR}-$$i; \
1931                         ln -sf ../../${XDTP}/usr/bin/$$i \
1932                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1933                 done
1934 .else
1935 xdev xdev-build xdev-install:
1936         @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
1937 .endif
1939 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE