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