]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Move all atf directories to the tests mtree.
[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
235 # bootstrap-tools stage
236 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
237                 PATH=${BPATH}:${PATH} \
238                 WORLDTMP=${WORLDTMP} \
239                 VERSION="${VERSION}" \
240                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
241                 COMPILER_TYPE=${COMPILER_TYPE}
242 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
243                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
244                 DESTDIR= \
245                 BOOTSTRAPPING=${OSRELDATE} \
246                 SSP_CFLAGS= \
247                 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
248                 -DNO_PIC -DNO_PROFILE -DNO_SHARED \
249                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
250
251 # build-tools stage
252 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
253                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
254                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
255                 DESTDIR= \
256                 BOOTSTRAPPING=${OSRELDATE} \
257                 SSP_CFLAGS= \
258                 -DNO_LINT \
259                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
260
261 # cross-tools stage
262 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
263                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
264                 -DWITHOUT_GDB
265
266 # kernel-tools stage
267 KTMAKEENV=      INSTALL="sh ${.CURDIR}/tools/install.sh" \
268                 PATH=${BPATH}:${PATH} \
269                 WORLDTMP=${WORLDTMP} \
270                 VERSION="${VERSION}" \
271                 COMPILER_TYPE=${COMPILER_TYPE}
272 KTMAKE=         TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
273                 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
274                 DESTDIR= \
275                 BOOTSTRAPPING=${OSRELDATE} \
276                 SSP_CFLAGS= \
277                 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
278                 -DNO_PIC -DNO_PROFILE -DNO_SHARED \
279                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
280
281 # world stage
282 WMAKEENV=       ${CROSSENV} \
283                 _SHLIBDIRPREFIX=${WORLDTMP} \
284                 _LDSCRIPTROOT= \
285                 VERSION="${VERSION}" \
286                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
287                 PATH=${TMPPATH}
288
289 # make hierarchy
290 HMAKE=          PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
291 .if defined(NO_ROOT)
292 HMAKE+=         PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
293 .endif
294
295 .if ${MK_CDDL} == "no"
296 WMAKEENV+=      NO_CTF=1
297 .endif
298
299 .if defined(CROSS_TOOLCHAIN_PREFIX)
300 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
301 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
302 .endif
303 XCOMPILERS=     CC CXX CPP
304 .for COMPILER in ${XCOMPILERS}
305 .if defined(CROSS_COMPILER_PREFIX)
306 X${COMPILER}?=  ${CROSS_COMPILER_PREFIX}${${COMPILER}}
307 .else
308 X${COMPILER}?=  ${${COMPILER}}
309 .endif
310 .endfor
311 XBINUTILS=      AS AR LD NM OBJDUMP RANLIB STRINGS
312 .for BINUTIL in ${XBINUTILS}
313 .if defined(CROSS_BINUTILS_PREFIX)
314 X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
315 .else
316 X${BINUTIL}?=   ${${BINUTIL}}
317 .endif
318 .endfor
319 WMAKEENV+=      CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS}" \
320                 CPP="${XCPP} ${XFLAGS}" \
321                 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
322                 OBJDUMP=${XOBJDUMP} RANLIB=${XRANLIB} STRINGS=${XSTRINGS}
323
324 .if ${XCC:T:Mgcc} == "gcc"
325 WMAKE_COMPILER_TYPE=    gcc
326 .elif ${XCC:T:Mclang} == "clang"
327 WMAKE_COMPILER_TYPE=    clang
328 .elif ${MK_CLANG_IS_CC} == "no"
329 WMAKE_COMPILER_TYPE=    gcc
330 .else
331 WMAKE_COMPILER_TYPE=    clang
332 .endif
333 IMAKE_COMPILER_TYPE=    COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
334
335 .if ${XCC:M/*}
336 XFLAGS=         --sysroot=${WORLDTMP}
337 .if defined(CROSS_BINUTILS_PREFIX)
338 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
339 # directory, but the compiler will look in the right place for it's
340 # tools so we don't need to tell it where to look.
341 .if exists(${CROSS_BINUTILS_PREFIX})
342 XFLAGS+=        -B${CROSS_BINUTILS_PREFIX}
343 .endif
344 .else
345 XFLAGS+=        -B${WORLDTMP}/usr/bin
346 .endif
347 .if ${TARGET_ARCH} != ${MACHINE_ARCH} && ${WMAKE_COMPILER_TYPE} == "clang"
348 .if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \
349 ${MK_ARM_EABI} != "no"
350 TARGET_ABI=     gnueabi
351 .else
352 TARGET_ABI=     unknown
353 .endif
354 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
355 XFLAGS+=        -target ${TARGET_TRIPLE}
356 .endif
357 .endif
358
359 WMAKEENV+=      COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
360 WMAKE=          ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
361
362 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
363 # 32 bit world
364 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
365
366 .if ${TARGET_ARCH} == "amd64"
367 .if empty(TARGET_CPUTYPE)
368 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
369 .else
370 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
371 .endif
372 LIB32WMAKEENV=  MACHINE=i386 MACHINE_ARCH=i386 \
373                 MACHINE_CPU="i686 mmx sse sse2"
374 LIB32WMAKEFLAGS=        \
375                 AS="${AS} --32" \
376                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
377
378 .elif ${TARGET_ARCH} == "powerpc64"
379 .if empty(TARGET_CPUTYPE)
380 LIB32CPUFLAGS=  -mcpu=powerpc
381 .else
382 LIB32CPUFLAGS=  -mcpu=${TARGET_CPUTYPE}
383 .endif
384 LIB32WMAKEENV=  MACHINE=powerpc MACHINE_ARCH=powerpc
385 LIB32WMAKEFLAGS=        \
386                 LD="${LD} -m elf32ppc_fbsd"
387 .endif
388
389
390 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
391                 -isystem ${LIB32TMP}/usr/include/ \
392                 -L${LIB32TMP}/usr/lib32 \
393                 -B${LIB32TMP}/usr/lib32
394 .if ${XCC:M/*}
395 LIB32FLAGS+=            --sysroot=${WORLDTMP}
396 .endif
397
398 # Yes, the flags are redundant.
399 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
400                 _SHLIBDIRPREFIX=${LIB32TMP} \
401                 _LDSCRIPTROOT=${LIB32TMP} \
402                 VERSION="${VERSION}" \
403                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
404                 PATH=${TMPPATH} \
405                 LIBDIR=/usr/lib32 \
406                 SHLIBDIR=/usr/lib32 \
407                 LIBPRIVATEDIR=/usr/lib32/private \
408                 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
409 LIB32WMAKEFLAGS+=       \
410                 CC="${XCC} ${LIB32FLAGS}" \
411                 CXX="${XCXX} ${LIB32FLAGS}" \
412                 DESTDIR=${LIB32TMP} \
413                 -DCOMPAT_32BIT \
414                 -DLIBRARIES_ONLY \
415                 -DNO_CPU_CFLAGS \
416                 -DNO_CTF \
417                 -DNO_LINT
418
419 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
420                 -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
421 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
422                 ${IMAKE_INSTALL}
423 .endif
424
425 IMAKEENV=       ${CROSSENV:N_LDSCRIPTROOT=*}
426 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
427                 ${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_COMPILER_TYPE}
428 .if empty(.MAKEFLAGS:M-n)
429 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
430                 LD_LIBRARY_PATH=${INSTALLTMP} \
431                 PATH_LOCALE=${INSTALLTMP}/locale
432 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
433 .else
434 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
435 .endif
436 .if defined(DB_FROM_SRC)
437 INSTALLFLAGS+=  -N ${.CURDIR}/etc
438 MTREEFLAGS+=    -N ${.CURDIR}/etc
439 .endif
440 _INSTALL_DDIR=  ${DESTDIR}/${DISTDIR}
441 INSTALL_DDIR=   ${_INSTALL_DDIR:S://:/:g:C:/$::}
442 .if defined(NO_ROOT)
443 METALOG?=       ${DESTDIR}/${DISTDIR}/METALOG
444 IMAKE+=         -DNO_ROOT METALOG=${METALOG}
445 INSTALLFLAGS+=  -U -M ${METALOG} -D ${INSTALL_DDIR}
446 MTREEFLAGS+=    -W
447 .endif
448 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
449 IMAKE_INSTALL=  INSTALL="install ${INSTALLFLAGS}"
450 IMAKE_MTREE=    MTREE_CMD="nmtree ${MTREEFLAGS}"
451 .endif
452
453 # kernel stage
454 KMAKEENV=       ${WMAKEENV}
455 KMAKE=          ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
456
457 #
458 # buildworld
459 #
460 # Attempt to rebuild the entire system, with reasonable chance of
461 # success, regardless of how old your existing system is.
462 #
463 _worldtmp:
464 .if ${.CURDIR:C/[^,]//g} != ""
465 #       The m4 build of sendmail files doesn't like it if ',' is used
466 #       anywhere in the path of it's files.
467         @echo
468         @echo "*** Error: path to source tree contains a comma ','"
469         @echo
470         false
471 .endif
472         @echo
473         @echo "--------------------------------------------------------------"
474         @echo ">>> Rebuilding the temporary build tree"
475         @echo "--------------------------------------------------------------"
476 .if !defined(NO_CLEAN)
477         rm -rf ${WORLDTMP}
478 .if defined(LIB32TMP)
479         rm -rf ${LIB32TMP}
480 .endif
481 .else
482         rm -rf ${WORLDTMP}/legacy/usr/include
483 #       XXX - These three can depend on any header file.
484         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
485         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
486         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
487 .endif
488 .for _dir in \
489     lib usr legacy/bin legacy/usr
490         mkdir -p ${WORLDTMP}/${_dir}
491 .endfor
492         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
493             -p ${WORLDTMP}/legacy/usr >/dev/null
494 .if ${MK_GROFF} != "no"
495         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
496             -p ${WORLDTMP}/legacy/usr >/dev/null
497 .endif
498         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
499             -p ${WORLDTMP}/usr >/dev/null
500         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
501             -p ${WORLDTMP}/usr/include >/dev/null
502         ln -sf ${.CURDIR}/sys ${WORLDTMP}
503 .if ${MK_DEBUG_FILES} != "no"
504         # We could instead disable debug files for these build stages
505         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
506             -p ${WORLDTMP}/legacy/usr/lib >/dev/null
507         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
508             -p ${WORLDTMP}/usr/lib >/dev/null
509 .endif
510 .if ${MK_TESTS} != "no"
511         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
512             -p ${WORLDTMP}/usr >/dev/null
513 .endif
514 .for _mtree in ${LOCAL_MTREE}
515         mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
516 .endfor
517 _legacy:
518         @echo
519         @echo "--------------------------------------------------------------"
520         @echo ">>> stage 1.1: legacy release compatibility shims"
521         @echo "--------------------------------------------------------------"
522         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
523 _bootstrap-tools:
524         @echo
525         @echo "--------------------------------------------------------------"
526         @echo ">>> stage 1.2: bootstrap tools"
527         @echo "--------------------------------------------------------------"
528         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
529 _cleanobj:
530 .if !defined(NO_CLEAN)
531         @echo
532         @echo "--------------------------------------------------------------"
533         @echo ">>> stage 2.1: cleaning up the object tree"
534         @echo "--------------------------------------------------------------"
535         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
536 .if defined(LIB32TMP)
537         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
538 .endif
539 .endif
540 _obj:
541         @echo
542         @echo "--------------------------------------------------------------"
543         @echo ">>> stage 2.2: rebuilding the object tree"
544         @echo "--------------------------------------------------------------"
545         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
546 _build-tools:
547         @echo
548         @echo "--------------------------------------------------------------"
549         @echo ">>> stage 2.3: build tools"
550         @echo "--------------------------------------------------------------"
551         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
552 _cross-tools:
553         @echo
554         @echo "--------------------------------------------------------------"
555         @echo ">>> stage 3: cross tools"
556         @echo "--------------------------------------------------------------"
557         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
558         ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
559 _includes:
560         @echo
561         @echo "--------------------------------------------------------------"
562         @echo ">>> stage 4.1: building includes"
563         @echo "--------------------------------------------------------------"
564         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
565 _libraries:
566         @echo
567         @echo "--------------------------------------------------------------"
568         @echo ">>> stage 4.2: building libraries"
569         @echo "--------------------------------------------------------------"
570         ${_+_}cd ${.CURDIR}; \
571             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
572             -DWITHOUT_MAN -DNO_PROFILE libraries
573 _depend:
574         @echo
575         @echo "--------------------------------------------------------------"
576         @echo ">>> stage 4.3: make dependencies"
577         @echo "--------------------------------------------------------------"
578         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
579 everything:
580         @echo
581         @echo "--------------------------------------------------------------"
582         @echo ">>> stage 4.4: building everything"
583         @echo "--------------------------------------------------------------"
584         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
585 .if defined(LIB32TMP)
586 build32:
587         @echo
588         @echo "--------------------------------------------------------------"
589         @echo ">>> stage 5.1: building 32 bit shim libraries"
590         @echo "--------------------------------------------------------------"
591         mkdir -p ${LIB32TMP}/usr/include
592         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
593             -p ${LIB32TMP}/usr >/dev/null
594         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
595             -p ${LIB32TMP}/usr/include >/dev/null
596 .if ${MK_DEBUG_FILES} != "no"
597         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
598             -p ${LIB32TMP}/usr/lib >/dev/null
599 .endif
600         mkdir -p ${WORLDTMP}
601         ln -sf ${.CURDIR}/sys ${WORLDTMP}
602 .for _t in obj includes
603         cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
604         cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
605 .if ${MK_CDDL} != "no"
606         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
607 .endif
608         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
609 .if ${MK_CRYPT} != "no"
610         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
611 .endif
612 .if ${MK_KERBEROS} != "no"
613         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
614 .endif
615 .endfor
616 .for _dir in usr.bin/lex/lib
617         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
618 .endfor
619 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
620         cd ${.CURDIR}/${_dir}; \
621             WORLDTMP=${WORLDTMP} \
622             MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
623             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
624             DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
625             -DEARLY_BUILD build-tools
626 .endfor
627         cd ${.CURDIR}; \
628             ${LIB32WMAKE} -f Makefile.inc1 libraries
629 .for _t in obj depend all
630         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
631             DIRPRFX=libexec/rtld-elf/ ${_t}
632         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
633             DIRPRFX=usr.bin/ldd ${_t}
634 .endfor
635
636 distribute32 install32:
637         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
638 .if ${MK_CDDL} != "no"
639         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
640 .endif
641         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
642 .if ${MK_CRYPT} != "no"
643         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
644 .endif
645 .if ${MK_KERBEROS} != "no"
646         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
647 .endif
648         cd ${.CURDIR}/libexec/rtld-elf; \
649             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
650         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
651 .endif
652
653 WMAKE_TGTS=
654 .if !defined(SUBDIR_OVERRIDE)
655 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
656 .endif
657 WMAKE_TGTS+=    _cleanobj _obj _build-tools
658 .if !defined(SUBDIR_OVERRIDE)
659 WMAKE_TGTS+=    _cross-tools
660 .endif
661 WMAKE_TGTS+=    _includes _libraries _depend everything
662 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
663 WMAKE_TGTS+=    build32
664 .endif
665
666 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
667 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
668
669 buildworld_prologue:
670         @echo "--------------------------------------------------------------"
671         @echo ">>> World build started on `LC_ALL=C date`"
672         @echo "--------------------------------------------------------------"
673
674 buildworld_epilogue:
675         @echo
676         @echo "--------------------------------------------------------------"
677         @echo ">>> World build completed on `LC_ALL=C date`"
678         @echo "--------------------------------------------------------------"
679
680 #
681 # We need to have this as a target because the indirection between Makefile
682 # and Makefile.inc1 causes the correct PATH to be used, rather than a
683 # modification of the current environment's PATH.  In addition, we need
684 # to quote multiword values.
685 #
686 buildenvvars:
687         @echo ${WMAKEENV:Q}
688
689 buildenv:
690         @echo Entering world for ${TARGET_ARCH}:${TARGET}
691         @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
692
693 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
694 toolchain: ${TOOLCHAIN_TGTS}
695 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
696
697 #
698 # installcheck
699 #
700 # Checks to be sure system is ready for installworld/installkernel.
701 #
702 installcheck: _installcheck_world _installcheck_kernel
703 _installcheck_world:
704 _installcheck_kernel:
705
706 #
707 # Require DESTDIR to be set if installing for a different architecture or
708 # using the user/group database in the source tree.
709 #
710 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
711     defined(DB_FROM_SRC)
712 .if !make(distributeworld)
713 _installcheck_world: __installcheck_DESTDIR
714 _installcheck_kernel: __installcheck_DESTDIR
715 __installcheck_DESTDIR:
716 .if !defined(DESTDIR) || empty(DESTDIR)
717         @echo "ERROR: Please set DESTDIR!"; \
718         false
719 .endif
720 .endif
721 .endif
722
723 .if !defined(DB_FROM_SRC)
724 #
725 # Check for missing UIDs/GIDs.
726 #
727 CHECK_UIDS=     auditdistd
728 CHECK_GIDS=     audit
729 .if ${MK_SENDMAIL} != "no"
730 CHECK_UIDS+=    smmsp
731 CHECK_GIDS+=    smmsp
732 .endif
733 .if ${MK_PF} != "no"
734 CHECK_UIDS+=    proxy
735 CHECK_GIDS+=    proxy authpf
736 .endif
737 .if ${MK_UNBOUND} != "no"
738 CHECK_UIDS+=    unbound
739 CHECK_GIDS+=    unbound
740 .endif
741 _installcheck_world: __installcheck_UGID
742 __installcheck_UGID:
743 .for uid in ${CHECK_UIDS}
744         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
745                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
746                 false; \
747         fi
748 .endfor
749 .for gid in ${CHECK_GIDS}
750         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
751                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
752                 false; \
753         fi
754 .endfor
755 .endif
756
757 #
758 # Required install tools to be saved in a scratch dir for safety.
759 #
760 .if ${MK_INFO} != "no"
761 _install-info=  install-info
762 .endif
763 .if ${MK_ZONEINFO} != "no"
764 _zoneinfo=      zic tzsetup
765 .endif
766
767 .if exists(/usr/sbin/nmtree)
768 _nmtree_itools= nmtree
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 ${_nmtree_itools} mv pwd_mkdb \
774         rm sed 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} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
837             sed -e 's#^\./#./${dist}/#' >> ${METALOG}
838         ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
839             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
840         ${IMAKEENV} nmtree -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 BSDL DTC, but build the GPL 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 .for _tool in \
1373     sys/dev/aic7xxx/aicasm
1374         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1375                 cd ${.CURDIR}/${_tool} && \
1376                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1377                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1378                 ${MAKE} DIRPRFX=${_tool}/ all && \
1379                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1380 .endfor
1381
1382 #
1383 # cross-tools: Build cross-building tools
1384 #
1385 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1386 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1387 _btxld=         usr.sbin/btxld
1388 .endif
1389 .endif
1390 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1391 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1392 _crunchide=     usr.sbin/crunch/crunchide
1393 .endif
1394 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1395 _kgzip=         usr.sbin/kgzip
1396 .endif
1397 .endif
1398
1399 .if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
1400 _binutils=      gnu/usr.bin/binutils
1401 .endif
1402
1403 # If an full path to an external cross compiler is given, don't build
1404 # a cross compiler.
1405 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1406 .if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
1407 _clang=         usr.bin/clang
1408 _clang_libs=    lib/clang
1409 .else
1410 _cc=            gnu/usr.bin/cc
1411 .endif
1412
1413 # The boot2 for pc98 requires gcc.
1414 .if ${TARGET} == "pc98"
1415 _cc=            gnu/usr.bin/cc
1416 .endif
1417 .endif
1418
1419 cross-tools: .MAKE
1420 .for _tool in \
1421     ${_clang_libs} \
1422     ${_clang} \
1423     ${_binutils} \
1424     ${_cc} \
1425     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1426     ${_btxld} \
1427     ${_crunchide} \
1428     ${_kgzip}
1429         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1430                 cd ${.CURDIR}/${_tool} && \
1431                 ${MAKE} DIRPRFX=${_tool}/ obj && \
1432                 ${MAKE} DIRPRFX=${_tool}/ depend && \
1433                 ${MAKE} DIRPRFX=${_tool}/ all && \
1434                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1435 .endfor
1436
1437 #
1438 # hierarchy - ensure that all the needed directories are present
1439 #
1440 hierarchy hier:
1441         cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1442
1443 #
1444 # libraries - build all libraries, and install them under ${DESTDIR}.
1445 #
1446 # The list of libraries with dependents (${_prebuild_libs}) and their
1447 # interdependencies (__L) are built automatically by the
1448 # ${.CURDIR}/tools/make_libdeps.sh script.
1449 #
1450 libraries: .MAKE
1451         cd ${.CURDIR} && \
1452             ${MAKE} -f Makefile.inc1 _prereq_libs && \
1453             ${MAKE} -f Makefile.inc1 _startup_libs && \
1454             ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1455             ${MAKE} -f Makefile.inc1 _generic_libs
1456
1457 #
1458 # static libgcc.a prerequisite for shared libc
1459 #
1460 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1461
1462 # These dependencies are not automatically generated:
1463 #
1464 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1465 # all shared libraries for ELF.
1466 #
1467 _startup_libs=  gnu/lib/csu
1468 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1469 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1470 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1471 _startup_libs+= lib/csu/${MACHINE_ARCH}
1472 .else
1473 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1474 .endif
1475 _startup_libs+= gnu/lib/libgcc
1476 _startup_libs+= lib/libcompiler_rt
1477 _startup_libs+= lib/libc
1478 .if ${MK_LIBCPLUSPLUS} != "no"
1479 _startup_libs+= lib/libcxxrt
1480 .endif
1481
1482 gnu/lib/libgcc__L: lib/libc__L
1483 .if ${MK_LIBCPLUSPLUS} != "no"
1484 lib/libcxxrt__L: gnu/lib/libgcc__L
1485 .endif
1486
1487 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1488                 ${_kerberos5_lib_libhdb} \
1489                 ${_kerberos5_lib_libheimbase} \
1490                 ${_kerberos5_lib_libheimntlm} \
1491                 ${_kerberos5_lib_libheimsqlite} \
1492                 ${_kerberos5_lib_libheimipcc} \
1493                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1494                 ${_kerberos5_lib_libroken} \
1495                 ${_kerberos5_lib_libwind} \
1496                 ${_lib_atf} \
1497                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1498                 lib/libelf lib/libexpat \
1499                 ${_lib_libgssapi} ${_lib_libipx} \
1500                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1501                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1502                 lib/libopie lib/libpam ${_lib_libthr} \
1503                 lib/libradius lib/libsbuf lib/libtacplus \
1504                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1505                 ${_cddl_lib_libzfs_core} \
1506                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1507                 ${_secure_lib_libcrypto} ${_lib_libldns} \
1508                 ${_secure_lib_libssh} ${_secure_lib_libssl}
1509
1510 .if ${MK_TESTS} != "no"
1511 _lib_atf=       lib/atf
1512 .endif
1513
1514 .if ${MK_LIBTHR} != "no"
1515 _lib_libthr=    lib/libthr
1516 .endif
1517
1518 .if ${MK_OFED} != "no"
1519 _ofed_lib=      contrib/ofed/usr.lib/
1520 .endif
1521
1522 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1523 .for _DIR in ${LOCAL_LIB_DIRS}
1524 .if exists(${.CURDIR}/${_DIR}/Makefile)
1525 _generic_libs+= ${_DIR}
1526 .endif
1527 .endfor
1528
1529 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1530
1531 .if ${MK_CDDL} != "no"
1532 _cddl_lib_libumem= cddl/lib/libumem
1533 _cddl_lib_libnvpair= cddl/lib/libnvpair
1534 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1535 _cddl_lib= cddl/lib
1536 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1537 .endif
1538
1539 .if ${MK_CRYPT} != "no"
1540 .if ${MK_OPENSSL} != "no"
1541 _secure_lib_libcrypto= secure/lib/libcrypto
1542 _secure_lib_libssl= secure/lib/libssl
1543 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1544 .if ${MK_LDNS} != "no"
1545 _lib_libldns= lib/libldns
1546 lib/libldns__L: secure/lib/libcrypto__L
1547 .endif
1548 .if ${MK_OPENSSH} != "no"
1549 _secure_lib_libssh= secure/lib/libssh
1550 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1551 .if ${MK_LDNS} != "no"
1552 secure/lib/libssh__L: lib/libldns__L
1553 .endif
1554 .if ${MK_KERBEROS_SUPPORT} != "no"
1555 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1556     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1557     lib/libmd__L kerberos5/lib/libroken__L
1558 .endif
1559 .endif
1560 .endif
1561 _secure_lib=    secure/lib
1562 .endif
1563
1564 .if ${MK_KERBEROS} != "no"
1565 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1566 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1567     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1568     kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1569 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1570     kerberos5/lib/libroken__L lib/libcom_err__L
1571 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1572     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1573 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1574     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1575     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1576     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1577 kerberos5/lib/libroken__L: lib/libcrypt__L
1578 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1579 kerberos5/lib/libheimbase__L: lib/libthr__L
1580 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1581 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1582 .endif
1583
1584 .if ${MK_GSSAPI} != "no"
1585 _lib_libgssapi= lib/libgssapi
1586 .endif
1587
1588 .if ${MK_IPX} != "no"
1589 _lib_libipx=    lib/libipx
1590 .endif
1591
1592 .if ${MK_KERBEROS} != "no"
1593 _kerberos5_lib= kerberos5/lib
1594 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1595 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1596 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1597 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1598 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1599 _kerberos5_lib_libroken= kerberos5/lib/libroken
1600 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1601 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1602 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1603 _kerberos5_lib_libwind= kerberos5/lib/libwind
1604 _libcom_err= lib/libcom_err
1605 .endif
1606
1607 .if ${MK_NIS} != "no"
1608 _lib_libypclnt= lib/libypclnt
1609 .endif
1610
1611 .if ${MK_OPENSSL} == "no"
1612 lib/libradius__L: lib/libmd__L
1613 .endif
1614
1615 .for _lib in ${_prereq_libs}
1616 ${_lib}__PL: .PHONY .MAKE
1617 .if exists(${.CURDIR}/${_lib})
1618         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1619                 cd ${.CURDIR}/${_lib} && \
1620                 ${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ obj && \
1621                 ${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ depend && \
1622                 ${MAKE} -DNO_TESTS -DNO_PROFILE -DNO_PIC \
1623                     DIRPRFX=${_lib}/ all && \
1624                 ${MAKE} -DNO_TESTS -DNO_PROFILE -DNO_PIC \
1625                     DIRPRFX=${_lib}/ install
1626 .endif
1627 .endfor
1628
1629 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1630 ${_lib}__L: .PHONY .MAKE
1631 .if exists(${.CURDIR}/${_lib})
1632         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1633                 cd ${.CURDIR}/${_lib} && \
1634                 ${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ obj && \
1635                 ${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ depend && \
1636                 ${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ all && \
1637                 ${MAKE} -DNO_TESTS DIRPRFX=${_lib}/ install
1638 .endif
1639 .endfor
1640
1641 # libpam is special: we need to build static PAM modules before
1642 # static PAM library, and dynamic PAM library before dynamic PAM
1643 # modules.
1644 lib/libpam__L: .PHONY .MAKE
1645         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1646                 cd ${.CURDIR}/lib/libpam && \
1647                 ${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ obj && \
1648                 ${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ depend && \
1649                 ${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ \
1650                     -D_NO_LIBPAM_SO_YET all && \
1651                 ${MAKE} -DNO_TESTS DIRPRFX=lib/libpam/ \
1652                     -D_NO_LIBPAM_SO_YET install
1653
1654 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1655 _startup_libs: ${_startup_libs:S/$/__L/}
1656 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1657 _generic_libs: ${_generic_libs:S/$/__L/}
1658
1659 .for __target in all clean cleandepend cleandir depend includes obj
1660 .for entry in ${SUBDIR}
1661 ${entry}.${__target}__D: .PHONY .MAKE
1662         ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1663                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1664                 edir=${entry}.${MACHINE_ARCH}; \
1665                 cd ${.CURDIR}/$${edir}; \
1666         else \
1667                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1668                 edir=${entry}; \
1669                 cd ${.CURDIR}/$${edir}; \
1670         fi; \
1671         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1672 .endfor
1673 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1674 .endfor
1675
1676 .include <bsd.subdir.mk>
1677
1678 .if make(check-old) || make(check-old-dirs) || \
1679     make(check-old-files) || make(check-old-libs) || \
1680     make(delete-old) || make(delete-old-dirs) || \
1681     make(delete-old-files) || make(delete-old-libs)
1682
1683 #
1684 # check for / delete old files section
1685 #
1686
1687 .include "ObsoleteFiles.inc"
1688
1689 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1690 else you can not start such an application. Consult UPDATING for more \
1691 information regarding how to cope with the removal/revision bump of a \
1692 specific library."
1693
1694 .if !defined(BATCH_DELETE_OLD_FILES)
1695 RM_I=-i
1696 .else
1697 RM_I=-v
1698 .endif
1699
1700 delete-old-files:
1701         @echo ">>> Removing old files (only deletes safe to delete libs)"
1702 # Ask for every old file if the user really wants to remove it.
1703 # It's annoying, but better safe than sorry.
1704 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1705 # argument list will get too long. Using .for/.endfor make "loops" will make
1706 # the Makefile parser segfault.
1707         @exec 3<&0; \
1708         cd ${.CURDIR}; \
1709         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1710             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1711         while read file; do \
1712                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1713                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1714                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1715                 fi; \
1716         done
1717 # Remove catpages without corresponding manpages.
1718         @exec 3<&0; \
1719         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1720         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1721         while read catpage; do \
1722                 read manpage; \
1723                 if [ ! -e "$${manpage}" ]; then \
1724                         rm ${RM_I} $${catpage} <&3; \
1725                 fi; \
1726         done
1727         @echo ">>> Old files removed"
1728
1729 check-old-files:
1730         @echo ">>> Checking for old files"
1731         @cd ${.CURDIR}; \
1732         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1733             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1734         while read file; do \
1735                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1736                         echo "${DESTDIR}/$${file}"; \
1737                 fi; \
1738         done
1739 # Check for catpages without corresponding manpages.
1740         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1741         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1742         while read catpage; do \
1743                 read manpage; \
1744                 if [ ! -e "$${manpage}" ]; then \
1745                         echo $${catpage}; \
1746                 fi; \
1747         done
1748
1749 delete-old-libs:
1750         @echo ">>> Removing old libraries"
1751         @echo "${OLD_LIBS_MESSAGE}" | fmt
1752         @exec 3<&0; \
1753         cd ${.CURDIR}; \
1754         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1755             -V OLD_LIBS | xargs -n1 | \
1756         while read file; do \
1757                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1758                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1759                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1760                 fi; \
1761                 for ext in debug symbols; do \
1762                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1763                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1764                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1765                               <&3; \
1766                   fi; \
1767                 done; \
1768         done
1769         @echo ">>> Old libraries removed"
1770
1771 check-old-libs:
1772         @echo ">>> Checking for old libraries"
1773         @cd ${.CURDIR}; \
1774         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1775             -V OLD_LIBS | xargs -n1 | \
1776         while read file; do \
1777                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1778                         echo "${DESTDIR}/$${file}"; \
1779                 fi; \
1780                 for ext in debug symbols; do \
1781                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1782                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1783                   fi; \
1784                 done; \
1785         done
1786
1787 delete-old-dirs:
1788         @echo ">>> Removing old directories"
1789         @cd ${.CURDIR}; \
1790         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1791             -V OLD_DIRS | xargs -n1 | sort -r | \
1792         while read dir; do \
1793                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1794                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1795                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1796                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1797                 fi; \
1798         done
1799         @echo ">>> Old directories removed"
1800
1801 check-old-dirs:
1802         @echo ">>> Checking for old directories"
1803         @cd ${.CURDIR}; \
1804         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1805             -V OLD_DIRS | xargs -n1 | \
1806         while read dir; do \
1807                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1808                         echo "${DESTDIR}/$${dir}"; \
1809                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1810                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1811                 fi; \
1812         done
1813
1814 delete-old: delete-old-files delete-old-dirs
1815         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1816
1817 check-old: check-old-files check-old-libs check-old-dirs
1818         @echo "To remove old files and directories run '${MAKE} delete-old'."
1819         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1820
1821 .endif
1822
1823 #
1824 # showconfig - show build configuration.
1825 #
1826 showconfig:
1827         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1828
1829 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1830 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1831
1832 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1833 .if exists(${KERNCONFDIR}/${KERNCONF})
1834 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1835         ${KERNCONFDIR}/${KERNCONF} ; echo
1836 .endif
1837 .endif
1838
1839 .endif
1840
1841 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1842 DTBOUTPUTPATH= ${.CURDIR}
1843 .endif
1844
1845 #
1846 # Build 'standalone' Device Tree Blob
1847 #
1848 builddtb:
1849         @if [ "${FDT_DTS_FILE}" = "" ]; then \
1850                 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1851                 exit 1; \
1852         fi;     \
1853         if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1854                 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1855                         exist!"; \
1856                 exit 1; \
1857         fi;     \
1858         if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then  \
1859                 echo "WARNING: DTB will be placed in the current working \
1860                         directory"; \
1861         fi
1862         @PATH=${TMPPATH} \
1863         dtc -O dtb -o \
1864             ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1865             -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1866
1867 ###############
1868
1869 .if defined(XDEV) && defined(XDEV_ARCH)
1870
1871 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1872 XDEV_CPUTYPE?=${CPUTYPE}
1873 .else
1874 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1875 .endif
1876
1877 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1878         -DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1879         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1880         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1881         CPUTYPE=${XDEV_CPUTYPE}
1882
1883 XDDIR=${XDEV_ARCH}-freebsd
1884 XDTP=usr/${XDDIR}
1885 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1886         INSTALL="sh ${.CURDIR}/tools/install.sh"
1887 CDENV= ${CDBENV} \
1888         _SHLIBDIRPREFIX=${XDDESTDIR} \
1889         TOOLS_PREFIX=${XDDESTDIR}
1890 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1891         -B${XDDESTDIR}/usr/lib
1892 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" \
1893         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1894
1895 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1896 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1897 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1898 XDDESTDIR=${DESTDIR}/${XDTP}
1899 .if !defined(OSREL)
1900 OSREL!= uname -r | sed -e 's/[-(].*//'
1901 .endif
1902
1903 .ORDER: xdev-build xdev-install
1904 xdev: xdev-build xdev-install
1905
1906 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1907 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1908
1909 _xb-worldtmp:
1910         mkdir -p ${CDTMP}/usr
1911         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1912             -p ${CDTMP}/usr >/dev/null
1913
1914 _xb-bootstrap-tools:
1915 .for _tool in \
1916     ${_clang_tblgen}
1917         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1918         cd ${.CURDIR}/${_tool} && \
1919         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1920         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1921         ${CDMAKE} DIRPRFX=${_tool}/ all && \
1922         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1923 .endfor
1924
1925 _xb-build-tools:
1926         ${_+_}@cd ${.CURDIR}; \
1927         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1928
1929 _xb-cross-tools:
1930 .for _tool in \
1931     gnu/usr.bin/binutils \
1932     gnu/usr.bin/cc \
1933     usr.bin/ar \
1934     ${_clang_libs} \
1935     ${_clang}
1936         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1937         cd ${.CURDIR}/${_tool} && \
1938         ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1939         ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1940         ${CDMAKE} DIRPRFX=${_tool}/ all
1941 .endfor
1942
1943 _xi-mtree:
1944         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1945         mkdir -p ${XDDESTDIR}
1946         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1947             -p ${XDDESTDIR} >/dev/null
1948         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1949             -p ${XDDESTDIR}/usr >/dev/null
1950         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1951             -p ${XDDESTDIR}/usr/include >/dev/null
1952
1953 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1954 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1955
1956 _xi-cross-tools:
1957         @echo "_xi-cross-tools"
1958 .for _tool in \
1959     gnu/usr.bin/binutils \
1960     gnu/usr.bin/cc \
1961     usr.bin/ar \
1962     ${_clang}
1963         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1964         cd ${.CURDIR}/${_tool}; \
1965         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1966 .endfor
1967
1968 _xi-includes:
1969         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1970                 DESTDIR=${XDDESTDIR}
1971
1972 _xi-libraries:
1973         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1974                 DESTDIR=${XDDESTDIR}
1975
1976 _xi-links:
1977         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1978        mkdir -p ../../../../usr/bin; \
1979                 for i in *; do \
1980                         ln -sf ../../${XDTP}/usr/bin/$$i \
1981                             ../../../../usr/bin/${XDDIR}-$$i; \
1982                         ln -sf ../../${XDTP}/usr/bin/$$i \
1983                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1984                 done
1985 .else
1986 xdev xdev-build xdev-install:
1987         @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
1988 .endif
1989
1990 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE