]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
MFH
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 #       -DNO_CLEAN do not clean at all
7 #       -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 #           the system database when installing.
9 #       -DNO_SHARE do not go into share subdir
10 #       -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 #       -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 #       -DNO_ROOT install without using root privilege
16 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 #       -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 #       LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS 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:${SHELL})
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 #       SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
33 #           All libraries and includes, and some build tools will still build.
34
35 #
36 # The intended user-driven targets are:
37 # buildworld  - rebuild *everything*, including glue to help do upgrades
38 # installworld- install everything built by "buildworld"
39 # checkworld  - run test suite on installed world
40 # doxygen     - build API documentation of the kernel
41 # update      - convenient way to update your source tree (eg: svn/svnup)
42 #
43 # Standard targets (not defined here) are documented in the makefiles in
44 # /usr/share/mk.  These include:
45 #               obj depend all install clean cleandepend cleanobj
46
47 .if !defined(TARGET) || !defined(TARGET_ARCH)
48 .error "Both TARGET and TARGET_ARCH must be defined."
49 .endif
50
51 LOCALBASE?=     /usr/local
52
53 # Cross toolchain changes must be in effect before bsd.compiler.mk
54 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
55 .if defined(CROSS_TOOLCHAIN)
56 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
57 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
58 .endif
59 .include <bsd.compiler.mk>              # don't depend on src.opts.mk doing it
60 .include "share/mk/src.opts.mk" 
61
62 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
63 # keep the users system reasonably usable.  For static->dynamic root upgrades,
64 # we don't want to install a dynamic binary without rtld and the needed
65 # libraries.  More commonly, for dynamic root, we don't want to install a
66 # binary that requires a newer library version that hasn't been installed yet.
67 # This ordering is not a guarantee though.  The only guarantee of a working
68 # system here would require fine-grained ordering of all components based
69 # on their dependencies.
70 SRCDIR?=        ${.CURDIR}
71 .if !empty(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
73 .else
74 SUBDIR= lib libexec
75 .if !defined(NO_ROOT) && (make(installworld) || make(install))
76 # Ensure libraries are installed before progressing.
77 SUBDIR+=.WAIT
78 .endif
79 SUBDIR+=bin
80 .if ${MK_CDDL} != "no"
81 SUBDIR+=cddl
82 .endif
83 SUBDIR+=gnu include
84 .if ${MK_KERBEROS} != "no"
85 SUBDIR+=kerberos5
86 .endif
87 .if ${MK_RESCUE} != "no"
88 SUBDIR+=rescue
89 .endif
90 SUBDIR+=sbin
91 .if ${MK_CRYPT} != "no"
92 SUBDIR+=secure
93 .endif
94 .if !defined(NO_SHARE)
95 SUBDIR+=share
96 .endif
97 SUBDIR+=sys usr.bin usr.sbin
98 .if ${MK_TESTS} != "no"
99 SUBDIR+=        tests
100 .endif
101 .if ${MK_OFED} != "no"
102 SUBDIR+=contrib/ofed
103 .endif
104
105 # Local directories are last, since it is nice to at least get the base
106 # system rebuilt before you do them.
107 .for _DIR in ${LOCAL_DIRS}
108 .if exists(${.CURDIR}/${_DIR}/Makefile)
109 SUBDIR+=        ${_DIR}
110 .endif
111 .endfor
112 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
113 # of a LOCAL_DIRS directory.  This allows LOCAL_DIRS=foo and
114 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
115 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
116 _REDUNDENT_LIB_DIRS+=    ${LOCAL_LIB_DIRS:M${_DIR}*}
117 .endfor
118 .for _DIR in ${LOCAL_LIB_DIRS}
119 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
120 SUBDIR+=        ${_DIR}
121 .else
122 .warning ${_DIR} not added to SUBDIR list.  See UPDATING 20141121.
123 .endif
124 .endfor
125
126 # We must do etc/ last as it hooks into building the man whatis file
127 # by calling 'makedb' in share/man.  This is only relevant for
128 # install/distribute so they build the whatis file after every manpage is
129 # installed.
130 .if make(installworld) || make(install)
131 SUBDIR+=.WAIT
132 .endif
133 SUBDIR+=etc
134
135 .endif  # !empty(SUBDIR_OVERRIDE)
136
137 .if defined(NOCLEAN)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
139 NO_CLEAN=       ${NOCLEAN}
140 .endif
141 .if defined(NO_CLEANDIR)
142 CLEANDIR=       clean cleandepend
143 .else
144 CLEANDIR=       cleandir
145 .endif
146
147 LOCAL_TOOL_DIRS?=
148 PACKAGEDIR?=    ${DESTDIR}/${DISTDIR}
149
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
152 .else
153 BUILDENV_SHELL?=/bin/sh
154 .endif
155
156 .if !defined(SVN) || empty(SVN)
157 . for _P in /usr/bin /usr/local/bin
158 .  for _S in svn svnlite
159 .   if exists(${_P}/${_S})
160 SVN=   ${_P}/${_S}
161 .   endif
162 .  endfor
163 . endfor
164 .endif
165 SVNFLAGS?=      -r HEAD
166
167 MAKEOBJDIRPREFIX?=      /usr/obj
168 .if !defined(OSRELDATE)
169 .if exists(/usr/include/osreldate.h)
170 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
171                 /usr/include/osreldate.h
172 .else
173 OSRELDATE=      0
174 .endif
175 .export OSRELDATE
176 .endif
177
178 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
179 .if !defined(VERSION)
180 REVISION!=      MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
181 BRANCH!=        MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
182 SRCRELDATE!=    awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
183                 ${SRCDIR}/sys/sys/param.h
184 VERSION=        FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
185 .export VERSION
186 .endif
187
188 .if !defined(PKG_VERSION)
189 REVISION!=      ${MAKE} -C ${SRCDIR}/release -V REVISION
190 BRANCH!=        ${MAKE} -C ${SRCDIR}/release -V BRANCH
191 SRCRELDATE!=    awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
192                 ${SRCDIR}/sys/sys/param.h
193 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
194 TIMENOW=        %Y%m%d%H%M%S
195 EXTRA_REVISION= .s${TIMENOW:gmtime}
196 .endif
197 .if ${BRANCH:M*-p*}
198 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
199 .endif
200 PKG_VERSION=    ${REVISION}${EXTRA_REVISION}
201 .endif
202
203 KNOWN_ARCHES?=  aarch64/arm64 \
204                 amd64 \
205                 arm \
206                 armeb/arm \
207                 armv6/arm \
208                 armv6hf/arm \
209                 i386 \
210                 i386/pc98 \
211                 mips \
212                 mipsel/mips \
213                 mips64el/mips \
214                 mips64/mips \
215                 mipsn32el/mips \
216                 mipsn32/mips \
217                 powerpc \
218                 powerpc64/powerpc \
219                 riscv64/riscv \
220                 sparc64
221
222 .if ${TARGET} == ${TARGET_ARCH}
223 _t=             ${TARGET}
224 .else
225 _t=             ${TARGET_ARCH}/${TARGET}
226 .endif
227 .for _t in ${_t}
228 .if empty(KNOWN_ARCHES:M${_t})
229 .error Unknown target ${TARGET_ARCH}:${TARGET}.
230 .endif
231 .endfor
232
233 .if ${TARGET} == ${MACHINE}
234 TARGET_CPUTYPE?=${CPUTYPE}
235 .else
236 TARGET_CPUTYPE?=
237 .endif
238
239 .if !empty(TARGET_CPUTYPE)
240 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
241 .else
242 _TARGET_CPUTYPE=dummy
243 .endif
244 _CPUTYPE!=      MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
245                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
246 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
247 .error CPUTYPE global should be set with ?=.
248 .endif
249 .if make(buildworld)
250 BUILD_ARCH!=    uname -p
251 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
252 .error To cross-build, set TARGET_ARCH.
253 .endif
254 .endif
255 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
256 OBJTREE=        ${MAKEOBJDIRPREFIX}
257 .else
258 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
259 .endif
260 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
261 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
262 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
263 STRICTTMPPATH=  ${BPATH}:${XPATH}
264 TMPPATH=        ${STRICTTMPPATH}:${PATH}
265
266 #
267 # Avoid running mktemp(1) unless actually needed.
268 # It may not be functional, e.g., due to new ABI
269 # when in the middle of installing over this system.
270 #
271 .if make(distributeworld) || make(installworld) || make(stageworld)
272 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
273 .endif
274
275 .if make(stagekernel) || make(distributekernel)
276 TAGS+=          kernel
277 PACKAGE=        kernel
278 .endif
279
280 #
281 # Building a world goes through the following stages
282 #
283 # 1. legacy stage [BMAKE]
284 #       This stage is responsible for creating compatibility
285 #       shims that are needed by the bootstrap-tools,
286 #       build-tools and cross-tools stages. These are generally
287 #       APIs that tools from one of those three stages need to
288 #       build that aren't present on the host.
289 # 1. bootstrap-tools stage [BMAKE]
290 #       This stage is responsible for creating programs that
291 #       are needed for backward compatibility reasons. They
292 #       are not built as cross-tools.
293 # 2. build-tools stage [TMAKE]
294 #       This stage is responsible for creating the object
295 #       tree and building any tools that are needed during
296 #       the build process. Some programs are listed during
297 #       this phase because they build binaries to generate
298 #       files needed to build these programs. This stage also
299 #       builds the 'build-tools' target rather than 'all'.
300 # 3. cross-tools stage [XMAKE]
301 #       This stage is responsible for creating any tools that
302 #       are needed for building the system. A cross-compiler is one
303 #       of them. This differs from build tools in two ways:
304 #       1. the 'all' target is built rather than 'build-tools'
305 #       2. these tools are installed into TMPPATH for stage 4.
306 # 4. world stage [WMAKE]
307 #       This stage actually builds the world.
308 # 5. install stage (optional) [IMAKE]
309 #       This stage installs a previously built world.
310 #
311
312 BOOTSTRAPPING?= 0
313
314 # Common environment for world related stages
315 CROSSENV+=      MAKEOBJDIRPREFIX=${OBJTREE} \
316                 MACHINE_ARCH=${TARGET_ARCH} \
317                 MACHINE=${TARGET} \
318                 CPUTYPE=${TARGET_CPUTYPE}
319 .if ${MK_GROFF} != "no"
320 CROSSENV+=      GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
321                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
322                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
323 .endif
324 .if defined(TARGET_CFLAGS)
325 CROSSENV+=      ${TARGET_CFLAGS}
326 .endif
327
328 # bootstrap-tools stage
329 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
330                 PATH=${BPATH}:${PATH} \
331                 WORLDTMP=${WORLDTMP} \
332                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
333 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
334 BSARGS=         DESTDIR= \
335                 BOOTSTRAPPING=${OSRELDATE} \
336                 SSP_CFLAGS= \
337                 MK_HTML=no NO_LINT=yes MK_MAN=no \
338                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
339                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
340                 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
341                 MK_LLDB=no MK_TESTS=no \
342                 MK_INCLUDES=yes
343
344 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
345                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
346                 ${BSARGS}
347
348 # build-tools stage
349 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
350                 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
351                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
352                 DESTDIR= \
353                 BOOTSTRAPPING=${OSRELDATE} \
354                 SSP_CFLAGS= \
355                 -DNO_LINT \
356                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
357                 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
358                 MK_LLDB=no MK_TESTS=no
359
360 # cross-tools stage
361 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
362                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
363                 MK_GDB=no MK_TESTS=no
364
365 # kernel-tools stage
366 KTMAKEENV=      INSTALL="sh ${.CURDIR}/tools/install.sh" \
367                 PATH=${BPATH}:${PATH} \
368                 WORLDTMP=${WORLDTMP}
369 KTMAKE=         TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
370                 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
371                 DESTDIR= \
372                 BOOTSTRAPPING=${OSRELDATE} \
373                 SSP_CFLAGS= \
374                 MK_HTML=no -DNO_LINT MK_MAN=no \
375                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
376                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
377
378 # world stage
379 WMAKEENV=       ${CROSSENV} \
380                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
381                 PATH=${TMPPATH}
382
383 # make hierarchy
384 HMAKE=          PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
385 .if defined(NO_ROOT)
386 HMAKE+=         PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
387 .endif
388
389 .if defined(CROSS_TOOLCHAIN_PREFIX)
390 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
391 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
392 .endif
393
394 # If we do not have a bootstrap binutils (because the in-tree one does not
395 # support the target architecture), provide a default cross-binutils prefix.
396 # This allows aarch64 builds, for example, to automatically use the
397 # aarch64-binutils port or package.
398 .if !make(showconfig)
399 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
400     !defined(CROSS_BINUTILS_PREFIX)
401 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
402 .if !exists(${CROSS_BINUTILS_PREFIX})
403 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
404 .endif
405 .endif
406 .endif
407
408 XCOMPILERS=     CC CXX CPP
409 .for COMPILER in ${XCOMPILERS}
410 .if defined(CROSS_COMPILER_PREFIX)
411 X${COMPILER}?=  ${CROSS_COMPILER_PREFIX}${${COMPILER}}
412 .else
413 X${COMPILER}?=  ${${COMPILER}}
414 .endif
415 .endfor
416 XBINUTILS=      AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
417 .for BINUTIL in ${XBINUTILS}
418 .if defined(CROSS_BINUTILS_PREFIX) && \
419     exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
420 X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
421 .else
422 X${BINUTIL}?=   ${${BINUTIL}}
423 .endif
424 .endfor
425 CROSSENV+=      CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
426                 CPP="${XCPP} ${XCFLAGS}" \
427                 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
428                 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
429                 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
430                 SIZE="${XSIZE}"
431
432 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
433 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
434 # directory, but the compiler will look in the right place for its
435 # tools so we don't need to tell it where to look.
436 BFLAGS+=        -B${CROSS_BINUTILS_PREFIX}
437 .endif
438
439 # External compiler needs sysroot and target flags.
440 .if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
441 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
442 BFLAGS+=        -B${WORLDTMP}/usr/bin
443 .endif
444 .if ${TARGET} == "arm"
445 .if ${TARGET_ARCH:M*hf*} != ""
446 TARGET_ABI=     gnueabihf
447 .else
448 TARGET_ABI=     gnueabi
449 .endif
450 .endif
451 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
452 # GCC requires -isystem and -L when using a cross-compiler.
453 XCFLAGS+=       -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
454 # Force using libc++ for external GCC.
455 XCXXFLAGS+=     -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
456                 -nostdinc++ -L${WORLDTMP}/../lib/libc++
457 .else
458 TARGET_ABI?=    unknown
459 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
460 XCFLAGS+=       -target ${TARGET_TRIPLE}
461 .endif
462 XCFLAGS+=       --sysroot=${WORLDTMP}
463 .else
464 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
465
466 .if !empty(BFLAGS)
467 XCFLAGS+=       ${BFLAGS}
468 .endif
469
470 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
471     ${TARGET_ARCH} == "powerpc64")
472 LIBCOMPAT= 32
473 .include "Makefile.libcompat"
474 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
475 LIBCOMPAT= SOFT
476 .include "Makefile.libcompat"
477 .endif
478
479 WMAKE=          ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
480
481 IMAKEENV=       ${CROSSENV}
482 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
483                 ${IMAKE_INSTALL} ${IMAKE_MTREE}
484 .if empty(.MAKEFLAGS:M-n)
485 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
486                 LD_LIBRARY_PATH=${INSTALLTMP} \
487                 PATH_LOCALE=${INSTALLTMP}/locale
488 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
489 .else
490 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
491 .endif
492 .if defined(DB_FROM_SRC)
493 INSTALLFLAGS+=  -N ${.CURDIR}/etc
494 MTREEFLAGS+=    -N ${.CURDIR}/etc
495 .endif
496 _INSTALL_DDIR=  ${DESTDIR}/${DISTDIR}
497 INSTALL_DDIR=   ${_INSTALL_DDIR:S://:/:g:C:/$::}
498 .if defined(NO_ROOT)
499 METALOG?=       ${DESTDIR}/${DISTDIR}/METALOG
500 IMAKE+=         -DNO_ROOT METALOG=${METALOG}
501 INSTALLFLAGS+=  -U -M ${METALOG} -D ${INSTALL_DDIR}
502 MTREEFLAGS+=    -W
503 .endif
504 .if defined(BUILD_PKGS)
505 INSTALLFLAGS+=  -h sha256
506 .endif
507 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
508 IMAKE_INSTALL=  INSTALL="install ${INSTALLFLAGS}"
509 IMAKE_MTREE=    MTREE_CMD="mtree ${MTREEFLAGS}"
510 .endif
511
512 # kernel stage
513 KMAKEENV=       ${WMAKEENV}
514 KMAKE=          ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
515
516 #
517 # buildworld
518 #
519 # Attempt to rebuild the entire system, with reasonable chance of
520 # success, regardless of how old your existing system is.
521 #
522 _worldtmp: .PHONY
523 .if ${.CURDIR:C/[^,]//g} != ""
524 #       The m4 build of sendmail files doesn't like it if ',' is used
525 #       anywhere in the path of it's files.
526         @echo
527         @echo "*** Error: path to source tree contains a comma ','"
528         @echo
529         false
530 .endif
531         @echo
532         @echo "--------------------------------------------------------------"
533         @echo ">>> Rebuilding the temporary build tree"
534         @echo "--------------------------------------------------------------"
535 .if !defined(NO_CLEAN)
536         rm -rf ${WORLDTMP}
537 .if defined(LIBCOMPAT)
538         rm -rf ${LIBCOMPATTMP}
539 .endif
540 .else
541         rm -rf ${WORLDTMP}/legacy/usr/include
542 #       XXX - These can depend on any header file.
543         rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
544         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
545 .endif
546 .for _dir in \
547     lib lib/casper usr legacy/bin legacy/usr
548         mkdir -p ${WORLDTMP}/${_dir}
549 .endfor
550         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
551             -p ${WORLDTMP}/legacy/usr >/dev/null
552 .if ${MK_GROFF} != "no"
553         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
554             -p ${WORLDTMP}/legacy/usr >/dev/null
555 .endif
556         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
557             -p ${WORLDTMP}/usr >/dev/null
558         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
559             -p ${WORLDTMP}/usr/include >/dev/null
560         ln -sf ${.CURDIR}/sys ${WORLDTMP}
561 .if ${MK_DEBUG_FILES} != "no"
562         # We could instead disable debug files for these build stages
563         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
564             -p ${WORLDTMP}/legacy/usr/lib >/dev/null
565         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
566             -p ${WORLDTMP}/usr/lib >/dev/null
567 .endif
568 .if defined(LIBCOMPAT)
569         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
570             -p ${WORLDTMP}/usr >/dev/null
571 .if ${MK_DEBUG_FILES} != "no"
572         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
573             -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
574         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
575             -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
576 .endif
577 .endif
578 .if ${MK_TESTS} != "no"
579         mkdir -p ${WORLDTMP}${TESTSBASE}
580         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
581             -p ${WORLDTMP}${TESTSBASE} >/dev/null
582 .if ${MK_DEBUG_FILES} != "no"
583         mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
584         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
585             -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
586 .endif
587 .endif
588 .for _mtree in ${LOCAL_MTREE}
589         mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
590 .endfor
591 _legacy:
592         @echo
593         @echo "--------------------------------------------------------------"
594         @echo ">>> stage 1.1: legacy release compatibility shims"
595         @echo "--------------------------------------------------------------"
596         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
597 _bootstrap-tools:
598         @echo
599         @echo "--------------------------------------------------------------"
600         @echo ">>> stage 1.2: bootstrap tools"
601         @echo "--------------------------------------------------------------"
602         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
603 _cleanobj:
604 .if !defined(NO_CLEAN)
605         @echo
606         @echo "--------------------------------------------------------------"
607         @echo ">>> stage 2.1: cleaning up the object tree"
608         @echo "--------------------------------------------------------------"
609         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
610 .if defined(LIBCOMPAT)
611         ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
612 .endif
613 .endif
614 _obj:
615         @echo
616         @echo "--------------------------------------------------------------"
617         @echo ">>> stage 2.2: rebuilding the object tree"
618         @echo "--------------------------------------------------------------"
619         ${_+_}cd ${.CURDIR}; ${WMAKE} obj
620 _build-tools:
621         @echo
622         @echo "--------------------------------------------------------------"
623         @echo ">>> stage 2.3: build tools"
624         @echo "--------------------------------------------------------------"
625         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
626 _cross-tools:
627         @echo
628         @echo "--------------------------------------------------------------"
629         @echo ">>> stage 3: cross tools"
630         @echo "--------------------------------------------------------------"
631         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
632         ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
633 _includes:
634         @echo
635         @echo "--------------------------------------------------------------"
636         @echo ">>> stage 4.1: building includes"
637         @echo "--------------------------------------------------------------"
638 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
639 # headers from default SUBDIR.  Do SUBDIR_OVERRIDE includes last.
640         ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
641             MK_INCLUDES=yes includes
642 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
643         ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
644 .endif
645 _libraries:
646         @echo
647         @echo "--------------------------------------------------------------"
648         @echo ">>> stage 4.2: building libraries"
649         @echo "--------------------------------------------------------------"
650         ${_+_}cd ${.CURDIR}; \
651             ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
652             MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
653 everything:
654         @echo
655         @echo "--------------------------------------------------------------"
656         @echo ">>> stage 4.3: building everything"
657         @echo "--------------------------------------------------------------"
658         ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
659
660 WMAKE_TGTS=
661 WMAKE_TGTS+=    _worldtmp _legacy
662 .if empty(SUBDIR_OVERRIDE)
663 WMAKE_TGTS+=    _bootstrap-tools
664 .endif
665 WMAKE_TGTS+=    _cleanobj _obj _build-tools _cross-tools
666 WMAKE_TGTS+=    _includes _libraries
667 WMAKE_TGTS+=    everything
668 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
669 WMAKE_TGTS+=    build${libcompat}
670 .endif
671
672 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
673 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
674
675 buildworld_prologue:
676         @echo "--------------------------------------------------------------"
677         @echo ">>> World build started on `LC_ALL=C date`"
678         @echo "--------------------------------------------------------------"
679
680 buildworld_epilogue:
681         @echo
682         @echo "--------------------------------------------------------------"
683         @echo ">>> World build completed on `LC_ALL=C date`"
684         @echo "--------------------------------------------------------------"
685
686 #
687 # We need to have this as a target because the indirection between Makefile
688 # and Makefile.inc1 causes the correct PATH to be used, rather than a
689 # modification of the current environment's PATH.  In addition, we need
690 # to quote multiword values.
691 #
692 buildenvvars: .PHONY
693         @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
694
695 .if ${.TARGETS:Mbuildenv}
696 .if ${.MAKEFLAGS:M-j}
697 .error The buildenv target is incompatible with -j
698 .endif
699 .endif
700 BUILDENV_DIR?=  ${.CURDIR}
701 buildenv: .PHONY
702         @echo Entering world for ${TARGET_ARCH}:${TARGET}
703 .if ${BUILDENV_SHELL:M*zsh*}
704         @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
705 .endif
706         @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
707             || true
708
709 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
710 toolchain: ${TOOLCHAIN_TGTS}
711 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
712
713 #
714 # installcheck
715 #
716 # Checks to be sure system is ready for installworld/installkernel.
717 #
718 installcheck: _installcheck_world _installcheck_kernel
719 _installcheck_world:
720 _installcheck_kernel:
721
722 #
723 # Require DESTDIR to be set if installing for a different architecture or
724 # using the user/group database in the source tree.
725 #
726 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
727     defined(DB_FROM_SRC)
728 .if !make(distributeworld)
729 _installcheck_world: __installcheck_DESTDIR
730 _installcheck_kernel: __installcheck_DESTDIR
731 __installcheck_DESTDIR:
732 .if !defined(DESTDIR) || empty(DESTDIR)
733         @echo "ERROR: Please set DESTDIR!"; \
734         false
735 .endif
736 .endif
737 .endif
738
739 .if !defined(DB_FROM_SRC)
740 #
741 # Check for missing UIDs/GIDs.
742 #
743 CHECK_UIDS=     auditdistd
744 CHECK_GIDS=     audit
745 .if ${MK_SENDMAIL} != "no"
746 CHECK_UIDS+=    smmsp
747 CHECK_GIDS+=    smmsp
748 .endif
749 .if ${MK_PF} != "no"
750 CHECK_UIDS+=    proxy
751 CHECK_GIDS+=    proxy authpf
752 .endif
753 .if ${MK_UNBOUND} != "no"
754 CHECK_UIDS+=    unbound
755 CHECK_GIDS+=    unbound
756 .endif
757 _installcheck_world: __installcheck_UGID
758 __installcheck_UGID:
759 .for uid in ${CHECK_UIDS}
760         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
761                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
762                 false; \
763         fi
764 .endfor
765 .for gid in ${CHECK_GIDS}
766         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
767                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
768                 false; \
769         fi
770 .endfor
771 .endif
772
773 #
774 # Required install tools to be saved in a scratch dir for safety.
775 #
776 .if ${MK_ZONEINFO} != "no"
777 _zoneinfo=      zic tzsetup
778 .endif
779
780 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
781         date echo egrep find grep id install ${_install-info} \
782         ln make mkdir mtree mv pwd_mkdb \
783         rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
784         ${LOCAL_ITOOLS}
785
786 # Needed for share/man
787 .if ${MK_MAN} != "no"
788 ITOOLS+=makewhatis
789 .endif
790
791 #
792 # distributeworld
793 #
794 # Distributes everything compiled by a `buildworld'.
795 #
796 # installworld
797 #
798 # Installs everything compiled by a 'buildworld'.
799 #
800
801 # Non-base distributions produced by the base system
802 EXTRA_DISTRIBUTIONS=    doc
803 .if defined(LIBCOMPAT)
804 EXTRA_DISTRIBUTIONS+=   lib${libcompat}
805 .endif
806 .if ${MK_TESTS} != "no"
807 EXTRA_DISTRIBUTIONS+=   tests
808 .endif
809
810 DEBUG_DISTRIBUTIONS=
811 .if ${MK_DEBUG_FILES} != "no"
812 DEBUG_DISTRIBUTIONS+=   base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
813 .endif
814
815 MTREE_MAGIC?=   mtree 2.0
816
817 distributeworld installworld stageworld: _installcheck_world
818         mkdir -p ${INSTALLTMP}
819         progs=$$(for prog in ${ITOOLS}; do \
820                 if progpath=`which $$prog`; then \
821                         echo $$progpath; \
822                 else \
823                         echo "Required tool $$prog not found in PATH." >&2; \
824                         exit 1; \
825                 fi; \
826             done); \
827         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
828             while read line; do \
829                 set -- $$line; \
830                 if [ "$$2 $$3" != "not found" ]; then \
831                         echo $$2; \
832                 else \
833                         echo "Required library $$1 not found." >&2; \
834                         exit 1; \
835                 fi; \
836             done); \
837         cp $$libs $$progs ${INSTALLTMP}
838         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
839 .if defined(NO_ROOT)
840         -mkdir -p ${METALOG:H}
841         echo "#${MTREE_MAGIC}" > ${METALOG}
842 .endif
843 .if make(distributeworld)
844 .for dist in ${EXTRA_DISTRIBUTIONS}
845         -mkdir ${DESTDIR}/${DISTDIR}/${dist}
846         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
847             -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
848         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
849             -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
850         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
851             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
852 .if ${MK_DEBUG_FILES} != "no"
853         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
854             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
855 .endif
856 .if defined(LIBCOMPAT)
857         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
858             -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
859 .if ${MK_DEBUG_FILES} != "no"
860         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
861             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
862 .endif
863 .endif
864 .if ${MK_TESTS} != "no" && ${dist} == "tests"
865         -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
866         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
867             -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
868 .if ${MK_DEBUG_FILES} != "no"
869         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
870             -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
871 .endif
872 .endif
873 .if defined(NO_ROOT)
874         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
875             sed -e 's#^\./#./${dist}/#' >> ${METALOG}
876         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
877             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
878         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
879             sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
880 .if defined(LIBCOMPAT)
881         ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
882             sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
883 .endif
884 .endif
885 .endfor
886         -mkdir ${DESTDIR}/${DISTDIR}/base
887         ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
888             METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
889             DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
890             LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
891 .endif
892         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
893             ${IMAKEENV} rm -rf ${INSTALLTMP}
894 .if make(distributeworld)
895 .for dist in ${EXTRA_DISTRIBUTIONS}
896         find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
897 .endfor
898 .if defined(NO_ROOT)
899 .for dist in base ${EXTRA_DISTRIBUTIONS}
900         @# For each file that exists in this dist, print the corresponding
901         @# line from the METALOG.  This relies on the fact that
902         @# a line containing only the filename will sort immediatly before
903         @# the relevant mtree line.
904         cd ${DESTDIR}/${DISTDIR}; \
905         find ./${dist} | sort -u ${METALOG} - | \
906         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
907         ${DESTDIR}/${DISTDIR}/${dist}.meta
908 .endfor
909 .for dist in ${DEBUG_DISTRIBUTIONS}
910         @# For each file that exists in this dist, print the corresponding
911         @# line from the METALOG.  This relies on the fact that
912         @# a line containing only the filename will sort immediatly before
913         @# the relevant mtree line.
914         cd ${DESTDIR}/${DISTDIR}; \
915         find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
916         awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
917         ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
918 .endfor
919 .endif
920 .endif
921
922 packageworld:
923 .for dist in base ${EXTRA_DISTRIBUTIONS}
924 .if defined(NO_ROOT)
925         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
926             tar cvf - --exclude usr/lib/debug \
927             @${DESTDIR}/${DISTDIR}/${dist}.meta | \
928             ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
929 .else
930         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
931             tar cvf - --exclude usr/lib/debug . | \
932             ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
933 .endif
934 .endfor
935
936 .for dist in ${DEBUG_DISTRIBUTIONS}
937 . if defined(NO_ROOT)
938         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
939             tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
940             ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
941 . else
942         ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
943             tar cvLf - usr/lib/debug | \
944             ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
945 . endif
946 .endfor
947
948 #
949 # reinstall
950 #
951 # If you have a build server, you can NFS mount the source and obj directories
952 # and do a 'make reinstall' on the *client* to install new binaries from the
953 # most recent server build.
954 #
955 reinstall: .MAKE .PHONY
956         @echo "--------------------------------------------------------------"
957         @echo ">>> Making hierarchy"
958         @echo "--------------------------------------------------------------"
959         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
960             LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
961         @echo
962         @echo "--------------------------------------------------------------"
963         @echo ">>> Installing everything"
964         @echo "--------------------------------------------------------------"
965         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
966 .if defined(LIBCOMPAT)
967         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
968 .endif
969
970 restage: .MAKE .PHONY
971         @echo "--------------------------------------------------------------"
972         @echo ">>> Making hierarchy"
973         @echo "--------------------------------------------------------------"
974         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
975             LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
976         @echo
977         @echo "--------------------------------------------------------------"
978         @echo ">>> Installing everything"
979         @echo "--------------------------------------------------------------"
980         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
981 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
982         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
983 .endif
984
985 redistribute: .MAKE .PHONY
986         @echo "--------------------------------------------------------------"
987         @echo ">>> Distributing everything"
988         @echo "--------------------------------------------------------------"
989         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
990 .if defined(LIBCOMPAT)
991         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
992             DISTRIBUTION=lib${libcompat}
993 .endif
994
995 distrib-dirs distribution: .MAKE .PHONY
996         ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
997             ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
998 .if make(distribution)
999         ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1000                 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1001                 METALOG=${METALOG} MK_TESTS=no installconfig
1002 .endif
1003
1004 #
1005 # buildkernel and installkernel
1006 #
1007 # Which kernels to build and/or install is specified by setting
1008 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1009 # Only the existing (depending TARGET) config files are used
1010 # for building kernels and only the first of these is designated
1011 # as the one being installed.
1012 #
1013 # Note that we have to use TARGET instead of TARGET_ARCH when
1014 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1015 # be set to cross-build, we have to make sure TARGET is set
1016 # properly.
1017
1018 .if defined(KERNFAST)
1019 NO_KERNELCLEAN= t
1020 NO_KERNELCONFIG=        t
1021 NO_KERNELOBJ=           t
1022 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1023 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1024 KERNCONF=${KERNFAST}
1025 .endif
1026 .endif
1027 .if ${TARGET_ARCH} == "powerpc64"
1028 KERNCONF?=      GENERIC64
1029 .else
1030 KERNCONF?=      GENERIC
1031 .endif
1032 INSTKERNNAME?=  kernel
1033
1034 KERNSRCDIR?=    ${.CURDIR}/sys
1035 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
1036 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
1037 KERNCONFDIR?=   ${KRNLCONFDIR}
1038
1039 BUILDKERNELS=
1040 INSTALLKERNEL=
1041 .if defined(NO_INSTALLKERNEL)
1042 # All of the BUILDKERNELS loops start at index 1.
1043 BUILDKERNELS+= dummy
1044 .endif
1045 .for _kernel in ${KERNCONF}
1046 .if exists(${KERNCONFDIR}/${_kernel})
1047 BUILDKERNELS+=  ${_kernel}
1048 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1049 INSTALLKERNEL= ${_kernel}
1050 .endif
1051 .endif
1052 .endfor
1053
1054 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1055
1056 #
1057 # buildkernel
1058 #
1059 # Builds all kernels defined by BUILDKERNELS.
1060 #
1061 buildkernel: .MAKE .PHONY
1062 .if empty(BUILDKERNELS:Ndummy)
1063         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1064         false
1065 .endif
1066         @echo
1067 .for _kernel in ${BUILDKERNELS:Ndummy}
1068         @echo "--------------------------------------------------------------"
1069         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1070         @echo "--------------------------------------------------------------"
1071         @echo "===> ${_kernel}"
1072         mkdir -p ${KRNLOBJDIR}
1073 .if !defined(NO_KERNELCONFIG)
1074         @echo
1075         @echo "--------------------------------------------------------------"
1076         @echo ">>> stage 1: configuring the kernel"
1077         @echo "--------------------------------------------------------------"
1078         cd ${KRNLCONFDIR}; \
1079                 PATH=${TMPPATH} \
1080                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1081                         -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1082 .endif
1083 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1084         @echo
1085         @echo "--------------------------------------------------------------"
1086         @echo ">>> stage 2.1: cleaning up the object tree"
1087         @echo "--------------------------------------------------------------"
1088         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1089 .endif
1090 .if !defined(NO_KERNELOBJ)
1091         @echo
1092         @echo "--------------------------------------------------------------"
1093         @echo ">>> stage 2.2: rebuilding the object tree"
1094         @echo "--------------------------------------------------------------"
1095         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1096 .endif
1097         @echo
1098         @echo "--------------------------------------------------------------"
1099         @echo ">>> stage 2.3: build tools"
1100         @echo "--------------------------------------------------------------"
1101         ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1102         @echo
1103         @echo "--------------------------------------------------------------"
1104         @echo ">>> stage 3.1: building everything"
1105         @echo "--------------------------------------------------------------"
1106         ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1107         @echo "--------------------------------------------------------------"
1108         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1109         @echo "--------------------------------------------------------------"
1110 .endfor
1111
1112 #
1113 # installkernel, etc.
1114 #
1115 # Install the kernel defined by INSTALLKERNEL
1116 #
1117 installkernel installkernel.debug \
1118 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1119 .if !defined(NO_INSTALLKERNEL)
1120 .if empty(INSTALLKERNEL)
1121         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1122         false
1123 .endif
1124         @echo "--------------------------------------------------------------"
1125         @echo ">>> Installing kernel ${INSTALLKERNEL}"
1126         @echo "--------------------------------------------------------------"
1127         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1128             ${CROSSENV} PATH=${TMPPATH} \
1129             ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1130 .endif
1131 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1132 .for _kernel in ${BUILDKERNELS:[2..-1]}
1133         @echo "--------------------------------------------------------------"
1134         @echo ">>> Installing kernel ${_kernel}"
1135         @echo "--------------------------------------------------------------"
1136         cd ${KRNLOBJDIR}/${_kernel}; \
1137             ${CROSSENV} PATH=${TMPPATH} \
1138             ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1139 .endfor
1140 .endif
1141
1142 distributekernel distributekernel.debug:
1143 .if !defined(NO_INSTALLKERNEL)
1144 .if empty(INSTALLKERNEL)
1145         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1146         false
1147 .endif
1148         mkdir -p ${DESTDIR}/${DISTDIR}
1149 .if defined(NO_ROOT)
1150         @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1151 .endif
1152         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1153             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1154             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1155             DESTDIR=${INSTALL_DDIR}/kernel \
1156             ${.TARGET:S/distributekernel/install/}
1157 .if defined(NO_ROOT)
1158         @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1159             ${DESTDIR}/${DISTDIR}/kernel.meta
1160 .endif
1161 .endif
1162 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1163 .for _kernel in ${BUILDKERNELS:[2..-1]}
1164 .if defined(NO_ROOT)
1165         @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1166 .endif
1167         cd ${KRNLOBJDIR}/${_kernel}; \
1168             ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1169             ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1170             KERNEL=${INSTKERNNAME}.${_kernel} \
1171             DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1172             ${.TARGET:S/distributekernel/install/}
1173 .if defined(NO_ROOT)
1174         @sed -e "s|^./kernel.${_kernel}|.|" \
1175             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1176             ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1177 .endif
1178 .endfor
1179 .endif
1180
1181 packagekernel:
1182 .if defined(NO_ROOT)
1183 .if !defined(NO_INSTALLKERNEL)
1184         cd ${DESTDIR}/${DISTDIR}/kernel; \
1185             tar cvf - --exclude '*.debug' \
1186             @${DESTDIR}/${DISTDIR}/kernel.meta | \
1187             ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1188 .endif
1189         cd ${DESTDIR}/${DISTDIR}/kernel; \
1190             tar cvf - --include '*/*/*.debug' \
1191             @${DESTDIR}/${DISTDIR}/kernel.meta | \
1192             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1193 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1194 .for _kernel in ${BUILDKERNELS:[2..-1]}
1195         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1196             tar cvf - --exclude '*.debug' \
1197             @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1198             ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1199         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1200             tar cvf - --include '*/*/*.debug' \
1201             @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1202             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1203 .endfor
1204 .endif
1205 .else
1206 .if !defined(NO_INSTALLKERNEL)
1207         cd ${DESTDIR}/${DISTDIR}/kernel; \
1208             tar cvf - --exclude '*.debug' . | \
1209             ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1210 .endif
1211         cd ${DESTDIR}/${DISTDIR}/kernel; \
1212             tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1213             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1214 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1215 .for _kernel in ${BUILDKERNELS:[2..-1]}
1216         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1217             tar cvf - --exclude '*.debug' . | \
1218             ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1219         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1220             tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1221             ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1222 .endfor
1223 .endif
1224 .endif
1225
1226 stagekernel:
1227         ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1228
1229 PORTSDIR?=      /usr/ports
1230 WSTAGEDIR?=     ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1231 KSTAGEDIR?=     ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1232 REPODIR?=       ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1233 PKGSIGNKEY?=    # empty
1234
1235 .ORDER:         stage-packages create-packages
1236 .ORDER:         create-packages create-world-packages
1237 .ORDER:         create-packages create-kernel-packages
1238 .ORDER:         create-packages sign-packages
1239
1240 _pkgbootstrap:
1241 .if !exists(${LOCALBASE}/sbin/pkg)
1242         @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1243 .endif
1244
1245 packages:
1246         ${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1247
1248 package-pkg:
1249         rm -rf /tmp/ports.${TARGET} || :
1250         env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
1251                 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1252                 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1253
1254 real-packages:  stage-packages create-packages sign-packages
1255
1256 stage-packages:
1257         @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1258         ${_+_}@cd ${.CURDIR}; \
1259                 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1260                 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1261
1262 create-packages:        _pkgbootstrap
1263         @mkdir -p ${REPODIR}
1264         ${_+_}@cd ${.CURDIR}; \
1265                 ${MAKE} DESTDIR=${WSTAGEDIR} \
1266                         PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1267                 ${MAKE} DESTDIR=${KSTAGEDIR} \
1268                         PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1269                         create-kernel-packages
1270
1271 create-world-packages:  _pkgbootstrap
1272         @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1273         @cd ${WSTAGEDIR} ; \
1274                 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1275                 ${WSTAGEDIR}/METALOG
1276         @for plist in ${WSTAGEDIR}/*.plist; do \
1277                 plist=$${plist##*/} ; \
1278                 pkgname=$${plist%.plist} ; \
1279                 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1280                         -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1281         done
1282         @for plist in ${WSTAGEDIR}/*.plist; do \
1283                 plist=$${plist##*/} ; \
1284                 pkgname=$${plist%.plist} ; \
1285                 awk -F\" ' \
1286                         /^name/ { printf("===> Creating %s-", $$2); next } \
1287                         /^version/ { print $$2; next } \
1288                         ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1289                 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1290                         create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1291                         -p ${WSTAGEDIR}/$${pkgname}.plist \
1292                         -r ${WSTAGEDIR} \
1293                         -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1294         done
1295
1296 create-kernel-packages: _pkgbootstrap
1297 .if exists(${KSTAGEDIR}/kernel.meta)
1298 .for flavor in "" -debug
1299         @cd ${KSTAGEDIR}/${DISTDIR} ; \
1300         awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1301                 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1302                 ${KSTAGEDIR}/kernel.meta ; \
1303         cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1304         pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1305         sed -e "s/%VERSION%/${PKG_VERSION}/" \
1306                 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1307                 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1308                 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1309                 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1310                 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1311                 ${SRCDIR}/release/packages/kernel.ucl \
1312                 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1313         awk -F\" ' \
1314                 /name/ { printf("===> Creating %s-", $$2); next } \
1315                 /version/ {print $$2; next } ' \
1316                 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1317         pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1318                 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1319                 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1320                 -r ${KSTAGEDIR}/${DISTDIR} \
1321                 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1322 .endfor
1323 .endif
1324 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1325 .for _kernel in ${BUILDKERNELS:[2..-1]}
1326 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1327 .for flavor in "" -debug
1328         @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1329         awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1330                 -v kernel=yes -v _kernconf=${_kernel} \
1331                 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1332         cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1333         pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1334         sed -e "s/%VERSION%/${PKG_VERSION}/" \
1335                 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1336                 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1337                 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1338                 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1339                 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1340                 ${SRCDIR}/release/packages/kernel.ucl \
1341                 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1342         awk -F\" ' \
1343                 /name/ { printf("===> Creating %s-", $$2); next } \
1344                 /version/ {print $$2; next } ' \
1345                 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1346         pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1347                 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1348                 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1349                 -r ${KSTAGEDIR}/kernel.${_kernel} \
1350                 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1351 .endfor
1352 .endif
1353 .endfor
1354 .endif
1355
1356 sign-packages:  _pkgbootstrap
1357         @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1358                 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1359         pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1360                 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1361                 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1362                 ${PKGSIGNKEY} ; \
1363         ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1364                 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1365
1366 #
1367 #
1368 # checkworld
1369 #
1370 # Run test suite on installed world.
1371 #
1372 checkworld: .PHONY
1373         @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1374                 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1375                 exit 1; \
1376         fi
1377         ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1378
1379 #
1380 #
1381 # doxygen
1382 #
1383 # Build the API documentation with doxygen
1384 #
1385 doxygen: .PHONY
1386         @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1387                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1388                 exit 1; \
1389         fi
1390         ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1391
1392 #
1393 # update
1394 #
1395 # Update the source tree(s), by running svn/svnup to update to the
1396 # latest copy.
1397 #
1398 update:
1399 .if defined(SVN_UPDATE)
1400         @echo "--------------------------------------------------------------"
1401         @echo ">>> Updating ${.CURDIR} using Subversion"
1402         @echo "--------------------------------------------------------------"
1403         @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1404 .endif
1405
1406 #
1407 # ------------------------------------------------------------------------
1408 #
1409 # From here onwards are utility targets used by the 'make world' and
1410 # related targets.  If your 'world' breaks, you may like to try to fix
1411 # the problem and manually run the following targets to attempt to
1412 # complete the build.  Beware, this is *not* guaranteed to work, you
1413 # need to have a pretty good grip on the current state of the system
1414 # to attempt to manually finish it.  If in doubt, 'make world' again.
1415 #
1416
1417 #
1418 # legacy: Build compatibility shims for the next three targets. This is a
1419 # minimal set of tools and shims necessary to compensate for older systems
1420 # which don't have the APIs required by the targets built in bootstrap-tools,
1421 # build-tools or cross-tools.
1422 #
1423
1424 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1425 # r296685 fix cross-endian objcopy
1426 .if ${BOOTSTRAPPING} < 1100102
1427 _elftoolchain_libs= lib/libelf lib/libdwarf
1428 .endif
1429
1430 legacy:
1431 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1432         @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1433         false
1434 .endif
1435 .for _tool in tools/build ${_elftoolchain_libs}
1436         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1437             cd ${.CURDIR}/${_tool}; \
1438             ${MAKE} DIRPRFX=${_tool}/ obj; \
1439             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1440             ${MAKE} DIRPRFX=${_tool}/ all; \
1441             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1442 .endfor
1443
1444 #
1445 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1446 # are built to build other binaries in the system. However, the focus of these
1447 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1448 # libraries, augmented by -legacy.
1449 #
1450 _bt=            _bootstrap-tools
1451
1452 .if ${MK_GAMES} != "no"
1453 _strfile=       usr.bin/fortune/strfile
1454 .endif
1455
1456 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1457 _gperf=         gnu/usr.bin/gperf
1458 .endif
1459
1460 .if ${MK_GROFF} != "no"
1461 _groff=         gnu/usr.bin/groff \
1462                 usr.bin/soelim
1463 .endif
1464
1465 .if ${MK_VT} != "no"
1466 _vtfontcvt=     usr.bin/vtfontcvt
1467 .endif
1468
1469 .if ${BOOTSTRAPPING} < 900002
1470 _sed=           usr.bin/sed
1471 .endif
1472
1473 .if ${BOOTSTRAPPING} < 1000033
1474 _libopenbsd=    lib/libopenbsd
1475 _m4=            usr.bin/m4
1476 _lex=           usr.bin/lex
1477
1478 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1479 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1480 .endif
1481
1482 .if ${BOOTSTRAPPING} < 1000026
1483 _nmtree=        lib/libnetbsd \
1484                 usr.sbin/nmtree
1485
1486 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1487 .endif
1488
1489 .if ${BOOTSTRAPPING} < 1000027
1490 _cat=           bin/cat
1491 .endif
1492
1493 # r264059 support for status=
1494 .if ${BOOTSTRAPPING} < 1100017
1495 _dd=            bin/dd
1496 .endif
1497
1498 # r277259 crunchide: Correct 64-bit section header offset
1499 # r281674 crunchide: always include both 32- and 64-bit ELF support
1500 # r285986 crunchen: use STRIPBIN rather than STRIP
1501 .if ${BOOTSTRAPPING} < 1100078
1502 _crunch=        usr.sbin/crunch
1503 .endif
1504
1505 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1506 _awk=           usr.bin/awk
1507 .endif
1508
1509 # r296926 -P keymap search path
1510 .if ${BOOTSTRAPPING} < 1100103
1511 _kbdcontrol=    usr.sbin/kbdcontrol
1512 .endif
1513
1514 _yacc=          lib/liby \
1515                 usr.bin/yacc
1516
1517 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1518
1519 .if ${MK_BSNMP} != "no"
1520 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
1521 .endif
1522
1523 # We need to build tblgen when we're building clang either as
1524 # the bootstrap compiler, or as the part of the normal build.
1525 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1526 _clang_tblgen= \
1527         lib/clang/libllvmsupport \
1528         lib/clang/libllvmtablegen \
1529         usr.bin/clang/llvm-tblgen \
1530         usr.bin/clang/clang-tblgen
1531
1532 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1533 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1534 .endif
1535
1536 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1537 # request it.
1538 _dtc= usr.bin/dtc
1539 .if ${MK_GPL_DTC} != "no"
1540 _dtc= gnu/usr.bin/dtc
1541 .endif
1542
1543 .if ${MK_KERBEROS} != "no"
1544 _kerberos5_bootstrap_tools= \
1545         kerberos5/tools/make-roken \
1546         kerberos5/lib/libroken \
1547         kerberos5/lib/libvers \
1548         kerberos5/tools/asn1_compile \
1549         kerberos5/tools/slc \
1550         usr.bin/compile_et
1551
1552 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1553 .endif
1554
1555 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1556 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1557 _libopenbsd?=   lib/libopenbsd
1558 _makewhatis=    lib/libsqlite3 \
1559                 usr.bin/mandoc
1560 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1561 .endif
1562
1563 bootstrap-tools: .PHONY
1564
1565 #       Please document (add comment) why something is in 'bootstrap-tools'.
1566 #       Try to bound the building of the bootstrap-tool to just the
1567 #       FreeBSD versions that need the tool built at this stage of the build.
1568 .for _tool in \
1569     ${_clang_tblgen} \
1570     ${_kerberos5_bootstrap_tools} \
1571     ${_strfile} \
1572     ${_gperf} \
1573     ${_groff} \
1574     ${_dtc} \
1575     ${_awk} \
1576     ${_cat} \
1577     ${_dd} \
1578     ${_kbdcontrol} \
1579     usr.bin/lorder \
1580     ${_libopenbsd} \
1581     ${_makewhatis} \
1582     usr.bin/rpcgen \
1583     ${_sed} \
1584     ${_yacc} \
1585     ${_m4} \
1586     ${_lex} \
1587     usr.bin/xinstall \
1588     ${_gensnmptree} \
1589     usr.sbin/config \
1590     ${_crunch} \
1591     ${_nmtree} \
1592     ${_vtfontcvt} \
1593     usr.bin/localedef
1594 ${_bt}-${_tool}: .PHONY .MAKE
1595         ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1596                 cd ${.CURDIR}/${_tool}; \
1597                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1598                 ${MAKE} DIRPRFX=${_tool}/ all; \
1599                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1600
1601 bootstrap-tools: ${_bt}-${_tool}
1602 .endfor
1603
1604 #
1605 # build-tools: Build special purpose build tools
1606 #
1607 .if !defined(NO_SHARE)
1608 _share= share/syscons/scrnmaps
1609 .endif
1610
1611 .if ${MK_GCC} != "no"
1612 _gcc_tools= gnu/usr.bin/cc/cc_tools
1613 .endif
1614
1615 .if ${MK_RESCUE} != "no"
1616 # rescue includes programs that have build-tools targets
1617 _rescue=rescue/rescue
1618 .endif
1619
1620 .for _tool in \
1621     bin/csh \
1622     bin/sh \
1623     ${LOCAL_TOOL_DIRS} \
1624     lib/ncurses/ncurses \
1625     lib/ncurses/ncursesw \
1626     ${_rescue} \
1627     ${_share} \
1628     usr.bin/awk \
1629     lib/libmagic \
1630     usr.bin/mkesdb_static \
1631     usr.bin/mkcsmapper_static \
1632     usr.bin/vi/catalog
1633 build-tools_${_tool}: .PHONY
1634         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1635                 cd ${.CURDIR}/${_tool}; \
1636                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1637                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1638 build-tools: build-tools_${_tool}
1639 .endfor
1640 .for _tool in \
1641     ${_gcc_tools}
1642 build-tools_${_tool}: .PHONY
1643         ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1644                 cd ${.CURDIR}/${_tool}; \
1645                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1646                 ${MAKE} DIRPRFX=${_tool}/ all
1647 build-tools: build-tools_${_tool}
1648 .endfor
1649
1650 #
1651 # kernel-tools: Build kernel-building tools
1652 #
1653 kernel-tools:
1654         mkdir -p ${MAKEOBJDIRPREFIX}/usr
1655         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1656             -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1657
1658 #
1659 # cross-tools: All the tools needed to build the rest of the system after
1660 # we get done with the earlier stages. It is the last set of tools needed
1661 # to begin building the target binaries.
1662 #
1663 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1664 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1665 _btxld=         usr.sbin/btxld
1666 .endif
1667 .endif
1668
1669 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1670 # resulting from missing bug fixes or ELF Toolchain updates.
1671 .if ${MK_CDDL} != "no"
1672 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1673     cddl/usr.bin/ctfmerge
1674 .endif
1675
1676 # If we're given an XAS, don't build binutils.
1677 .if ${XAS:M/*} == ""
1678 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1679 _binutils=      gnu/usr.bin/binutils
1680 .endif
1681 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1682 _elftctools=    lib/libelftc \
1683                 lib/libpe \
1684                 usr.bin/elfcopy \
1685                 usr.bin/nm \
1686                 usr.bin/size \
1687                 usr.bin/strings
1688 # These are not required by the build, but can be useful for developers who
1689 # cross-build on a FreeBSD 10 host:
1690 _elftctools+=   usr.bin/addr2line
1691 .endif
1692 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1693 # If cross-building with an external binutils we still need to build strip for
1694 # the target (for at least crunchide).
1695 _elftctools=    lib/libelftc \
1696                 lib/libpe \
1697                 usr.bin/elfcopy
1698 .endif
1699
1700 # If an full path to an external cross compiler is given, don't build
1701 # a cross compiler.
1702 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1703 .if ${MK_CLANG_BOOTSTRAP} != "no"
1704 _clang=         usr.bin/clang
1705 _clang_libs=    lib/clang
1706 .endif
1707 .if ${MK_GCC_BOOTSTRAP} != "no"
1708 _cc=            gnu/usr.bin/cc
1709 .endif
1710 .endif
1711 .if ${MK_USB} != "no"
1712 _usb_tools=     sys/boot/usb/tools
1713 .endif
1714
1715 cross-tools: .MAKE .PHONY
1716 .for _tool in \
1717     ${_clang_libs} \
1718     ${_clang} \
1719     ${_binutils} \
1720     ${_elftctools} \
1721     ${_dtrace_tools} \
1722     ${_cc} \
1723     ${_btxld} \
1724     ${_crunchide} \
1725     ${_usb_tools}
1726         ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1727                 cd ${.CURDIR}/${_tool}; \
1728                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1729                 ${MAKE} DIRPRFX=${_tool}/ all; \
1730                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1731 .endfor
1732
1733 NXBDESTDIR=     ${OBJTREE}/nxb-bin
1734 NXBENV=         MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1735                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1736                 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1737 NXBMAKE=        ${NXBENV} ${MAKE} \
1738                 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1739                 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1740                 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1741                 MK_GDB=no MK_TESTS=no \
1742                 SSP_CFLAGS= \
1743                 MK_HTML=no NO_LINT=yes MK_MAN=no \
1744                 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1745                 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1746                 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1747                 MK_LLDB=no MK_DEBUG_FILES=no
1748
1749 # native-xtools is the current target for qemu-user cross builds of ports
1750 # via poudriere and the imgact_binmisc kernel module.
1751 # For non-clang enabled targets that are still using the in tree gcc
1752 # we must build a gperf binary for one instance of its Makefiles.  On
1753 # clang-enabled systems, the gperf binary is obsolete.
1754 native-xtools: .PHONY
1755 .if ${MK_GCC_BOOTSTRAP} != "no"
1756         mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1757         ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1758         cd ${.CURDIR}/${_gperf}; \
1759         ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1760         ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1761         ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1762 .endif
1763         mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1764         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1765             -p ${NXBDESTDIR}/usr >/dev/null
1766         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1767             -p ${NXBDESTDIR}/usr/include >/dev/null
1768 .if ${MK_DEBUG_FILES} != "no"
1769         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1770             -p ${NXBDESTDIR}/usr/lib >/dev/null
1771 .endif
1772 .for _tool in \
1773     bin/cat \
1774     bin/chmod \
1775     bin/cp \
1776     bin/csh \
1777     bin/echo \
1778     bin/expr \
1779     bin/hostname \
1780     bin/ln \
1781     bin/ls \
1782     bin/mkdir \
1783     bin/mv \
1784     bin/ps \
1785     bin/realpath \
1786     bin/rm \
1787     bin/rmdir \
1788     bin/sh \
1789     bin/sleep \
1790     ${_clang_tblgen} \
1791     usr.bin/ar \
1792     ${_binutils} \
1793     ${_elftctools} \
1794     ${_cc} \
1795     ${_gcc_tools} \
1796     ${_clang_libs} \
1797     ${_clang} \
1798     sbin/md5 \
1799     sbin/sysctl \
1800     gnu/usr.bin/diff \
1801     usr.bin/awk \
1802     usr.bin/basename \
1803     usr.bin/bmake \
1804     usr.bin/bzip2 \
1805     usr.bin/cmp \
1806     usr.bin/dirname \
1807     usr.bin/env \
1808     usr.bin/fetch \
1809     usr.bin/find \
1810     usr.bin/grep \
1811     usr.bin/gzip \
1812     usr.bin/id \
1813     usr.bin/lex \
1814     usr.bin/lorder \
1815     usr.bin/mktemp \
1816     usr.bin/mt \
1817     usr.bin/patch \
1818     usr.bin/sed \
1819     usr.bin/sort \
1820     usr.bin/tar \
1821     usr.bin/touch \
1822     usr.bin/tr \
1823     usr.bin/true \
1824     usr.bin/uniq \
1825     usr.bin/unzip \
1826     usr.bin/xargs \
1827     usr.bin/xinstall \
1828     usr.bin/xz \
1829     usr.bin/yacc \
1830     usr.sbin/chown
1831         ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1832                 cd ${.CURDIR}/${_tool}; \
1833                 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1834                 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1835                 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1836 .endfor
1837
1838 #
1839 # hierarchy - ensure that all the needed directories are present
1840 #
1841 hierarchy hier: .MAKE .PHONY
1842         ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1843
1844 #
1845 # libraries - build all libraries, and install them under ${DESTDIR}.
1846 #
1847 # The list of libraries with dependents (${_prebuild_libs}) and their
1848 # interdependencies (__L) are built automatically by the
1849 # ${.CURDIR}/tools/make_libdeps.sh script.
1850 #
1851 libraries: .MAKE .PHONY
1852         ${_+_}cd ${.CURDIR}; \
1853             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1854             ${MAKE} -f Makefile.inc1 _startup_libs; \
1855             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1856             ${MAKE} -f Makefile.inc1 _generic_libs
1857
1858 #
1859 # static libgcc.a prerequisite for shared libc
1860 #
1861 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1862
1863 # These dependencies are not automatically generated:
1864 #
1865 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1866 # all shared libraries for ELF.
1867 #
1868 _startup_libs=  gnu/lib/csu
1869 _startup_libs+= lib/csu
1870 _startup_libs+= gnu/lib/libgcc
1871 _startup_libs+= lib/libcompiler_rt
1872 _startup_libs+= lib/libc
1873 _startup_libs+= lib/libc_nonshared
1874 .if ${MK_LIBCPLUSPLUS} != "no"
1875 _startup_libs+= lib/libcxxrt
1876 .endif
1877
1878 gnu/lib/libgcc__L: lib/libc__L
1879 gnu/lib/libgcc__L: lib/libc_nonshared__L
1880 .if ${MK_LIBCPLUSPLUS} != "no"
1881 lib/libcxxrt__L: gnu/lib/libgcc__L
1882 .endif
1883
1884 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1885                 ${_kerberos5_lib_libhdb} \
1886                 ${_kerberos5_lib_libheimbase} \
1887                 ${_kerberos5_lib_libheimntlm} \
1888                 ${_libsqlite3} \
1889                 ${_kerberos5_lib_libheimipcc} \
1890                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1891                 ${_kerberos5_lib_libroken} \
1892                 ${_kerberos5_lib_libwind} \
1893                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1894                 lib/libelf lib/libexpat \
1895                 lib/libfigpar \
1896                 ${_lib_libgssapi} \
1897                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1898                 ${_lib_casper} \
1899                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1900                 lib/libopie lib/libpam ${_lib_libthr} \
1901                 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1902                 lib/libgeom \
1903                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1904                 ${_cddl_lib_libuutil} \
1905                 ${_cddl_lib_libavl} \
1906                 ${_cddl_lib_libzfs_core} \
1907                 ${_cddl_lib_libctf} \
1908                 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1909                 ${_secure_lib_libcrypto} ${_lib_libldns} \
1910                 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1911                 gnu/lib/libdialog
1912 .if ${MK_GNUCXX} != "no"
1913 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1914 gnu/lib/libstdc++__L: lib/msun__L
1915 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1916 .endif
1917
1918 .if ${MK_LIBCPLUSPLUS} != "no"
1919 _prebuild_libs+= lib/libc++
1920 .endif
1921
1922 lib/libgeom__L: lib/libexpat__L
1923 lib/libkvm__L: lib/libelf__L
1924
1925 .if ${MK_LIBTHR} != "no"
1926 _lib_libthr=    lib/libthr
1927 .endif
1928
1929 .if ${MK_RADIUS_SUPPORT} != "no"
1930 _lib_libradius= lib/libradius
1931 .endif
1932
1933 .if ${MK_OFED} != "no"
1934 _ofed_lib=              contrib/ofed/usr.lib
1935 _prebuild_libs+=        contrib/ofed/usr.lib/libosmcomp
1936 _prebuild_libs+=        contrib/ofed/usr.lib/libopensm
1937 _prebuild_libs+=        contrib/ofed/usr.lib/libibcommon
1938 _prebuild_libs+=        contrib/ofed/usr.lib/libibverbs
1939 _prebuild_libs+=        contrib/ofed/usr.lib/libibumad
1940
1941 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1942 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1943 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1944 .endif
1945
1946 .if ${MK_CASPER} != "no"
1947 _lib_casper=    lib/libcasper
1948 .endif
1949
1950 lib/libpjdlog__L: lib/libutil__L
1951 lib/libcasper__L: lib/libnv__L
1952 lib/liblzma__L: lib/libthr__L
1953
1954 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1955 .for _DIR in ${LOCAL_LIB_DIRS}
1956 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1957 _generic_libs+= ${_DIR}
1958 .endif
1959 .endfor
1960
1961 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1962
1963 .if ${MK_CDDL} != "no"
1964 _cddl_lib_libumem= cddl/lib/libumem
1965 _cddl_lib_libnvpair= cddl/lib/libnvpair
1966 _cddl_lib_libavl= cddl/lib/libavl
1967 _cddl_lib_libuutil= cddl/lib/libuutil
1968 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1969 _cddl_lib_libctf= cddl/lib/libctf
1970 _cddl_lib= cddl/lib
1971 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1972 cddl/lib/libzfs__L: lib/libgeom__L
1973 cddl/lib/libctf__L: lib/libz__L
1974 .endif
1975 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1976 # on select architectures though (see cddl/lib/Makefile)
1977 .if ${MACHINE_CPUARCH} != "sparc64"
1978 _prebuild_libs+=        lib/libproc lib/librtld_db
1979 .endif
1980
1981 .if ${MK_CRYPT} != "no"
1982 .if ${MK_OPENSSL} != "no"
1983 _secure_lib_libcrypto= secure/lib/libcrypto
1984 _secure_lib_libssl= secure/lib/libssl
1985 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1986 .if ${MK_LDNS} != "no"
1987 _lib_libldns= lib/libldns
1988 lib/libldns__L: secure/lib/libcrypto__L
1989 .endif
1990 .if ${MK_OPENSSH} != "no"
1991 _secure_lib_libssh= secure/lib/libssh
1992 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1993 .if ${MK_LDNS} != "no"
1994 secure/lib/libssh__L: lib/libldns__L
1995 .endif
1996 .if ${MK_KERBEROS_SUPPORT} != "no"
1997 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1998     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1999     lib/libmd__L kerberos5/lib/libroken__L
2000 .endif
2001 .endif
2002 .endif
2003 _secure_lib=    secure/lib
2004 .endif
2005
2006 .if ${MK_KERBEROS} != "no"
2007 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2008 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2009     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2010     kerberos5/lib/libwind__L lib/libsqlite3__L
2011 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2012     kerberos5/lib/libroken__L lib/libcom_err__L
2013 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2014     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2015 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2016     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2017     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2018     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2019 kerberos5/lib/libroken__L: lib/libcrypt__L
2020 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2021 kerberos5/lib/libheimbase__L: lib/libthr__L
2022 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2023 .endif
2024
2025 lib/libsqlite3__L: lib/libthr__L
2026
2027 .if ${MK_GSSAPI} != "no"
2028 _lib_libgssapi= lib/libgssapi
2029 .endif
2030
2031 .if ${MK_KERBEROS} != "no"
2032 _kerberos5_lib= kerberos5/lib
2033 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2034 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2035 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2036 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2037 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2038 _kerberos5_lib_libroken= kerberos5/lib/libroken
2039 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2040 _libsqlite3= lib/libsqlite3
2041 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2042 _kerberos5_lib_libwind= kerberos5/lib/libwind
2043 _libcom_err= lib/libcom_err
2044 .endif
2045
2046 .if ${MK_NIS} != "no"
2047 _lib_libypclnt= lib/libypclnt
2048 .endif
2049
2050 .if ${MK_OPENSSL} == "no"
2051 lib/libradius__L: lib/libmd__L
2052 .endif
2053
2054 lib/libproc__L: \
2055     ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2056 .if ${MK_CXX} != "no"
2057 .if ${MK_LIBCPLUSPLUS} != "no"
2058 lib/libproc__L: lib/libcxxrt__L
2059 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2060 lib/libproc__L: gnu/lib/libsupc++__L
2061 .endif
2062 .endif
2063
2064 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2065
2066 .for _lib in ${_prereq_libs}
2067 ${_lib}__PL: .PHONY .MAKE
2068 .if exists(${.CURDIR}/${_lib})
2069         ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2070                 cd ${.CURDIR}/${_lib}; \
2071                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2072                 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2073                     DIRPRFX=${_lib}/ all; \
2074                 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2075                     DIRPRFX=${_lib}/ install
2076 .endif
2077 .endfor
2078
2079 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2080 ${_lib}__L: .PHONY .MAKE
2081 .if exists(${.CURDIR}/${_lib})
2082         ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2083                 cd ${.CURDIR}/${_lib}; \
2084                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2085                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2086                 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2087 .endif
2088 .endfor
2089
2090 # libpam is special: we need to build static PAM modules before
2091 # static PAM library, and dynamic PAM library before dynamic PAM
2092 # modules.
2093 lib/libpam__L: .PHONY .MAKE
2094         ${_+_}@${ECHODIR} "===> lib/libpam (obj,all,install)"; \
2095                 cd ${.CURDIR}/lib/libpam; \
2096                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2097                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2098                     -D_NO_LIBPAM_SO_YET all; \
2099                 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2100                     -D_NO_LIBPAM_SO_YET install
2101
2102 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2103 _startup_libs: ${_startup_libs:S/$/__L/}
2104 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2105 _generic_libs: ${_generic_libs:S/$/__L/}
2106
2107 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2108 # 'everything' with _PARALLEL_SUBDIR_OK set.  This is because it is unlikely
2109 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2110 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2111 # parallel.  This is safe for the world stage of buildworld though since it has
2112 # already built libraries in a proper order and installed includes into
2113 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2114 # avoid trashing a system if it crashes mid-install.
2115 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2116 SUBDIR_PARALLEL=
2117 .endif
2118
2119 .include <bsd.subdir.mk>
2120
2121 .if make(check-old) || make(check-old-dirs) || \
2122     make(check-old-files) || make(check-old-libs) || \
2123     make(delete-old) || make(delete-old-dirs) || \
2124     make(delete-old-files) || make(delete-old-libs)
2125
2126 #
2127 # check for / delete old files section
2128 #
2129
2130 .include "ObsoleteFiles.inc"
2131
2132 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2133 else you can not start such an application. Consult UPDATING for more \
2134 information regarding how to cope with the removal/revision bump of a \
2135 specific library."
2136
2137 .if !defined(BATCH_DELETE_OLD_FILES)
2138 RM_I=-i
2139 .else
2140 RM_I=-v
2141 .endif
2142
2143 delete-old-files:
2144         @echo ">>> Removing old files (only deletes safe to delete libs)"
2145 # Ask for every old file if the user really wants to remove it.
2146 # It's annoying, but better safe than sorry.
2147 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2148 # argument list will get too long. Using .for/.endfor make "loops" will make
2149 # the Makefile parser segfault.
2150         @exec 3<&0; \
2151         cd ${.CURDIR}; \
2152         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2153             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2154         while read file; do \
2155                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2156                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2157                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2158                 fi; \
2159                 for ext in debug symbols; do \
2160                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2161                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2162                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2163                               <&3; \
2164                   fi; \
2165                 done; \
2166         done
2167 # Remove catpages without corresponding manpages.
2168         @exec 3<&0; \
2169         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2170         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2171         while read catpage; do \
2172                 read manpage; \
2173                 if [ ! -e "$${manpage}" ]; then \
2174                         rm ${RM_I} $${catpage} <&3; \
2175                 fi; \
2176         done
2177         @echo ">>> Old files removed"
2178
2179 check-old-files:
2180         @echo ">>> Checking for old files"
2181         @cd ${.CURDIR}; \
2182         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2183             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2184         while read file; do \
2185                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2186                         echo "${DESTDIR}/$${file}"; \
2187                 fi; \
2188                 for ext in debug symbols; do \
2189                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2190                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2191                   fi; \
2192                 done; \
2193         done
2194 # Check for catpages without corresponding manpages.
2195         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2196         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2197         while read catpage; do \
2198                 read manpage; \
2199                 if [ ! -e "$${manpage}" ]; then \
2200                         echo $${catpage}; \
2201                 fi; \
2202         done
2203
2204 delete-old-libs:
2205         @echo ">>> Removing old libraries"
2206         @echo "${OLD_LIBS_MESSAGE}" | fmt
2207         @exec 3<&0; \
2208         cd ${.CURDIR}; \
2209         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2210             -V OLD_LIBS | xargs -n1 | \
2211         while read file; do \
2212                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2213                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2214                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2215                 fi; \
2216                 for ext in debug symbols; do \
2217                   if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2218                       "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2219                           rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2220                               <&3; \
2221                   fi; \
2222                 done; \
2223         done
2224         @echo ">>> Old libraries removed"
2225
2226 check-old-libs:
2227         @echo ">>> Checking for old libraries"
2228         @cd ${.CURDIR}; \
2229         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2230             -V OLD_LIBS | xargs -n1 | \
2231         while read file; do \
2232                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2233                         echo "${DESTDIR}/$${file}"; \
2234                 fi; \
2235                 for ext in debug symbols; do \
2236                   if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2237                           echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2238                   fi; \
2239                 done; \
2240         done
2241
2242 delete-old-dirs:
2243         @echo ">>> Removing old directories"
2244         @cd ${.CURDIR}; \
2245         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2246             -V OLD_DIRS | xargs -n1 | sort -r | \
2247         while read dir; do \
2248                 if [ -d "${DESTDIR}/$${dir}" ]; then \
2249                         rmdir -v "${DESTDIR}/$${dir}" || true; \
2250                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2251                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2252                 fi; \
2253         done
2254         @echo ">>> Old directories removed"
2255
2256 check-old-dirs:
2257         @echo ">>> Checking for old directories"
2258         @cd ${.CURDIR}; \
2259         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2260             -V OLD_DIRS | xargs -n1 | \
2261         while read dir; do \
2262                 if [ -d "${DESTDIR}/$${dir}" ]; then \
2263                         echo "${DESTDIR}/$${dir}"; \
2264                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2265                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2266                 fi; \
2267         done
2268
2269 delete-old: delete-old-files delete-old-dirs
2270         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2271
2272 check-old: check-old-files check-old-libs check-old-dirs
2273         @echo "To remove old files and directories run '${MAKE} delete-old'."
2274         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2275
2276 .endif
2277
2278 #
2279 # showconfig - show build configuration.
2280 #
2281 showconfig:
2282         @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2283           ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2284
2285 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2286 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2287
2288 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2289 .if exists(${KERNCONFDIR}/${KERNCONF})
2290 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2291         '${KERNCONFDIR}/${KERNCONF}' ; echo
2292 .endif
2293 .endif
2294
2295 .endif
2296
2297 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2298 DTBOUTPUTPATH= ${.CURDIR}
2299 .endif
2300
2301 #
2302 # Build 'standalone' Device Tree Blob
2303 #
2304 builddtb:
2305         @PATH=${TMPPATH} MACHINE=${TARGET} \
2306         ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2307             "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2308
2309 ###############
2310
2311 # cleanworld
2312 # In the following, the first 'rm' in a series will usually remove all
2313 # files and directories.  If it does not, then there are probably some
2314 # files with file flags set, so this unsets them and tries the 'rm' a
2315 # second time.  There are situations where this target will be cleaning
2316 # some directories via more than one method, but that duplication is
2317 # needed to correctly handle all the possible situations.  Removing all
2318 # files without file flags set in the first 'rm' instance saves time,
2319 # because 'chflags' will need to operate on fewer files afterwards.
2320 #
2321 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2322 # created by bsd.obj.mk, except that we don't want to .include that file
2323 # in this makefile.
2324 #
2325 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2326 cleanworld: .PHONY
2327 .if exists(${BW_CANONICALOBJDIR}/)
2328         -rm -rf ${BW_CANONICALOBJDIR}/*
2329         -chflags -R 0 ${BW_CANONICALOBJDIR}
2330         rm -rf ${BW_CANONICALOBJDIR}/*
2331 .endif
2332 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2333         #   To be safe in this case, fall back to a 'make cleandir'
2334         ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2335 .endif
2336
2337 .if defined(TARGET) && defined(TARGET_ARCH)
2338
2339 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2340 XDEV_CPUTYPE?=${CPUTYPE}
2341 .else
2342 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2343 .endif
2344
2345 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2346         MK_MAN=no MK_NLS=no MK_PROFILE=no \
2347         MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2348         TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2349         CPUTYPE=${XDEV_CPUTYPE}
2350
2351 XDDIR=${TARGET_ARCH}-freebsd
2352 XDTP?=/usr/${XDDIR}
2353 .if ${XDTP:N/*}
2354 .error XDTP variable should be an absolute path
2355 .endif
2356
2357 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2358         INSTALL="sh ${.CURDIR}/tools/install.sh"
2359 CDENV= ${CDBENV} \
2360         TOOLS_PREFIX=${XDTP}
2361 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2362         --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2363         -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2364 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2365         CPP="${CPP} ${CD2CFLAGS}" \
2366         MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2367
2368 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2369 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2370 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2371 XDDESTDIR=${DESTDIR}/${XDTP}
2372 .if !defined(OSREL)
2373 OSREL!= uname -r | sed -e 's/[-(].*//'
2374 .endif
2375
2376 .ORDER: xdev-build xdev-install xdev-links
2377 xdev: xdev-build xdev-install
2378
2379 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2380 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2381
2382 _xb-worldtmp: .PHONY
2383         mkdir -p ${CDTMP}/usr
2384         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2385             -p ${CDTMP}/usr >/dev/null
2386
2387 _xb-bootstrap-tools: .PHONY
2388 .for _tool in \
2389     ${_clang_tblgen} \
2390     ${_gperf}
2391         ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2392         cd ${.CURDIR}/${_tool}; \
2393         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2394         ${CDMAKE} DIRPRFX=${_tool}/ all; \
2395         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2396 .endfor
2397
2398 _xb-build-tools: .PHONY
2399         ${_+_}@cd ${.CURDIR}; \
2400         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2401
2402 _xb-cross-tools: .PHONY
2403 .for _tool in \
2404     ${_binutils} \
2405     ${_elftctools} \
2406     usr.bin/ar \
2407     ${_clang_libs} \
2408     ${_clang} \
2409     ${_cc}
2410         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2411         cd ${.CURDIR}/${_tool}; \
2412         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2413         ${CDMAKE} DIRPRFX=${_tool}/ all
2414 .endfor
2415
2416 _xi-mtree: .PHONY
2417         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2418         mkdir -p ${XDDESTDIR}
2419         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2420             -p ${XDDESTDIR} >/dev/null
2421         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2422             -p ${XDDESTDIR}/usr >/dev/null
2423         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2424             -p ${XDDESTDIR}/usr/include >/dev/null
2425 .if defined(LIBCOMPAT)
2426         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2427             -p ${XDDESTDIR}/usr >/dev/null
2428 .endif
2429 .if ${MK_TESTS} != "no"
2430         mkdir -p ${XDDESTDIR}${TESTSBASE}
2431         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2432             -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2433 .endif
2434
2435 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2436 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2437
2438 _xi-cross-tools: .PHONY
2439         @echo "_xi-cross-tools"
2440 .for _tool in \
2441     ${_binutils} \
2442     ${_elftctools} \
2443     usr.bin/ar \
2444     ${_clang_libs} \
2445     ${_clang} \
2446     ${_cc}
2447         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2448         cd ${.CURDIR}/${_tool}; \
2449         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2450 .endfor
2451
2452 _xi-includes: .PHONY
2453         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2454                 DESTDIR=${XDDESTDIR}
2455
2456 _xi-libraries: .PHONY
2457         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2458                 DESTDIR=${XDDESTDIR}
2459
2460 xdev-links: .PHONY
2461         ${_+_}cd ${XDDESTDIR}/usr/bin; \
2462         mkdir -p ../../../../usr/bin; \
2463                 for i in *; do \
2464                         ln -sf ../../${XDTP}/usr/bin/$$i \
2465                             ../../../../usr/bin/${XDDIR}-$$i; \
2466                         ln -sf ../../${XDTP}/usr/bin/$$i \
2467                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2468                 done
2469 .else
2470 xdev xdev-build xdev-install xdev-links:
2471         @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"
2472 .endif