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