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