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