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