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