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