]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Add support for an external cross compiler. The cross compiler is
[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         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1027             ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1028             DESTDIR=${DESTDIR}/${DISTDIR}/kernel \
1029             ${.TARGET:S/distributekernel/install/}
1030 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1031         cd ${KRNLOBJDIR}/${_kernel}; \
1032             ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1033             KERNEL=${INSTKERNNAME}.${_kernel} \
1034             DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
1035             ${.TARGET:S/distributekernel/install/}
1036 .endfor
1037
1038 packagekernel:
1039         cd ${DESTDIR}/${DISTDIR}/kernel; \
1040             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1041 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1042         cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1043             tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1044 .endfor
1045
1046 #
1047 # doxygen
1048 #
1049 # Build the API documentation with doxygen
1050 #
1051 doxygen:
1052         @if [ ! -x `/usr/bin/which doxygen` ]; then \
1053                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1054                 exit 1; \
1055         fi
1056         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1057
1058 #
1059 # update
1060 #
1061 # Update the source tree(s), by running cvsup/cvs/svn to update to the
1062 # latest copy.
1063 #
1064 update:
1065 .if defined(SUP_UPDATE)
1066         @echo "--------------------------------------------------------------"
1067         @echo ">>> Running ${SUP}"
1068         @echo "--------------------------------------------------------------"
1069         @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
1070         @echo "!! Update methods with ${SUP} are deprecated."
1071         @echo "!! Please see http://www.freebsd.org/handbook/svn.html"
1072         @echo "!! and convert your update method to SVN_UPDATE or"
1073         @echo "!! freebsd-update(8)."
1074         @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
1075         @sleep 5
1076 .if defined(SUPFILE)
1077         @${SUP} ${SUPFLAGS} ${SUPFILE}
1078 .endif
1079 .if defined(SUPFILE1)
1080         @${SUP} ${SUPFLAGS} ${SUPFILE1}
1081 .endif
1082 .if defined(SUPFILE2)
1083         @${SUP} ${SUPFLAGS} ${SUPFILE2}
1084 .endif
1085 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
1086         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
1087 .endif
1088 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
1089         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
1090 .endif
1091 .endif
1092 .if defined(CVS_UPDATE)
1093         @cd ${.CURDIR} ; \
1094         if [ -d CVS ] ; then \
1095                 echo "--------------------------------------------------------------" ; \
1096                 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
1097                 echo "--------------------------------------------------------------" ; \
1098                 echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
1099                 echo "!! Update methods with CVS are deprecated." ; \
1100                 echo "!! Please see http://www.freebsd.org/handbook/svn.html" ; \
1101                 echo "!! and convert your update method to SVN_UPDATE or" ; \
1102                 echo "!! freebsd-update(8)." ; \
1103                 echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
1104                 sleep 5 ; \
1105                 echo ${CVS} -R -q update ${CVSFLAGS} ; \
1106                 ${CVS} -R -q update ${CVSFLAGS} ; \
1107         fi
1108 .endif
1109 .if defined(SVN_UPDATE)
1110         @cd ${.CURDIR} ; \
1111         if [ -d .svn ] ; then \
1112                 echo "--------------------------------------------------------------" ; \
1113                 echo ">>> Updating ${.CURDIR} using Subversion" ; \
1114                 echo "--------------------------------------------------------------" ; \
1115                 echo ${SVN} update ${SVNFLAGS} ; \
1116                 ${SVN} update ${SVNFLAGS} ; \
1117         fi
1118 .endif
1119
1120 #
1121 # ------------------------------------------------------------------------
1122 #
1123 # From here onwards are utility targets used by the 'make world' and
1124 # related targets.  If your 'world' breaks, you may like to try to fix
1125 # the problem and manually run the following targets to attempt to
1126 # complete the build.  Beware, this is *not* guaranteed to work, you
1127 # need to have a pretty good grip on the current state of the system
1128 # to attempt to manually finish it.  If in doubt, 'make world' again.
1129 #
1130
1131 #
1132 # legacy: Build compatibility shims for the next three targets
1133 #
1134 legacy:
1135 .if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0
1136         @echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \
1137         false
1138 .endif
1139 .for _tool in tools/build
1140         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1141             cd ${.CURDIR}/${_tool}; \
1142             ${MAKE} DIRPRFX=${_tool}/ obj; \
1143             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1144             ${MAKE} DIRPRFX=${_tool}/ depend; \
1145             ${MAKE} DIRPRFX=${_tool}/ all; \
1146             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1147 .endfor
1148
1149 #
1150 # bootstrap-tools: Build tools needed for compatibility
1151 #
1152 .if ${MK_GAMES} != "no"
1153 _strfile=       games/fortune/strfile
1154 .endif
1155
1156 .if ${MK_CXX} != "no"
1157 _gperf=         gnu/usr.bin/gperf
1158 .endif
1159
1160 .if ${MK_GROFF} != "no"
1161 _groff=         gnu/usr.bin/groff
1162 .endif
1163
1164 .if ${BOOTSTRAPPING} < 800022
1165 _ar=            usr.bin/ar
1166 .endif
1167
1168 .if ${BOOTSTRAPPING} < 800013
1169 _mklocale=      usr.bin/mklocale
1170 .endif
1171
1172 .if ${BOOTSTRAPPING} < 900002
1173 _sed=           usr.bin/sed
1174 .endif
1175
1176 .if ${BOOTSTRAPPING} < 900006
1177 _lex=           usr.bin/lex
1178 .endif
1179
1180 .if ${BOOTSTRAPPING} < 1000013
1181 _yacc=          lib/liby \
1182                 usr.bin/yacc
1183 .endif
1184
1185 .if ${BOOTSTRAPPING} < 1000026
1186 _nmtree=        lib/libnetbsd \
1187                 usr.sbin/nmtree
1188 .endif
1189
1190 .if ${BOOTSTRAPPING} < 1000027
1191 _cat=           bin/cat
1192 .endif
1193
1194 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1195 _awk=           usr.bin/awk
1196 .endif
1197
1198 .if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree)
1199 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
1200 .endif
1201
1202 .if ${MK_CLANG} != "no"
1203 _clang_tblgen= \
1204         lib/clang/libllvmsupport \
1205         lib/clang/libllvmtablegen \
1206         usr.bin/clang/tblgen \
1207         usr.bin/clang/clang-tblgen
1208 .endif
1209
1210 # dtrace tools are required for older bootstrap env and cross-build
1211 .if ${MK_CDDL} != "no" && \
1212     ((${BOOTSTRAPPING} < 800038 && \
1213           !(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)) \
1214       || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1215 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1216     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1217 .endif
1218
1219 # Default to building the BSDL DTC, but build the GPL one if users explicitly
1220 # request it.
1221 _dtc= usr.bin/dtc
1222 .if ${MK_GPL_DTC} != "no"
1223 _dtc= gnu/usr.bin/dtc
1224 .endif
1225
1226 .if ${MK_KERBEROS} != "no"
1227 _kerberos5_bootstrap_tools= \
1228         kerberos5/tools/make-roken \
1229         kerberos5/lib/libroken \
1230         kerberos5/lib/libvers \
1231         kerberos5/tools/asn1_compile \
1232         kerberos5/tools/slc \
1233         usr.bin/compile_et
1234 .endif
1235
1236 #       Please document (add comment) why something is in 'bootstrap-tools'.
1237 #       Try to bound the building of the bootstrap-tool to just the
1238 #       FreeBSD versions that need the tool built at this stage of the build.
1239 bootstrap-tools:
1240 .for _tool in \
1241     ${_clang_tblgen} \
1242     ${_kerberos5_bootstrap_tools} \
1243     ${_dtrace_tools} \
1244     ${_strfile} \
1245     ${_gperf} \
1246     ${_groff} \
1247     ${_ar} \
1248     ${_dtc} \
1249     ${_awk} \
1250     ${_cat} \
1251     usr.bin/lorder \
1252     usr.bin/makewhatis \
1253     ${_mklocale} \
1254     usr.bin/rpcgen \
1255     ${_sed} \
1256     ${_yacc} \
1257     ${_lex} \
1258     lib/libmd \
1259     usr.bin/xinstall \
1260     ${_gensnmptree} \
1261     usr.sbin/config \
1262     ${_nmtree}
1263         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1264                 cd ${.CURDIR}/${_tool}; \
1265                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1266                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1267                 ${MAKE} DIRPRFX=${_tool}/ all; \
1268                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1269 .endfor
1270
1271 #
1272 # build-tools: Build special purpose build tools
1273 #
1274 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1275 _aicasm= sys/modules/aic7xxx/aicasm
1276 .endif
1277
1278 .if !defined(NO_SHARE)
1279 _share= share/syscons/scrnmaps
1280 .endif
1281
1282 .if ${MK_GCC} != "no"
1283 _gcc_tools= gnu/usr.bin/cc/cc_tools
1284 .endif
1285
1286 .if ${MK_RESCUE} != "no"
1287 _rescue= rescue/rescue
1288 .endif
1289
1290 build-tools:
1291 .for _tool in \
1292     bin/csh \
1293     bin/sh \
1294     ${_rescue} \
1295     ${LOCAL_TOOL_DIRS} \
1296     lib/ncurses/ncurses \
1297     lib/ncurses/ncursesw \
1298     ${_share} \
1299     ${_aicasm} \
1300     usr.bin/awk \
1301     lib/libmagic \
1302     usr.bin/mkesdb_static \
1303     usr.bin/mkcsmapper_static
1304         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1305                 cd ${.CURDIR}/${_tool}; \
1306                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1307                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1308 .endfor
1309 .for _tool in \
1310     ${_gcc_tools}
1311         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1312                 cd ${.CURDIR}/${_tool}; \
1313                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1314                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1315                 ${MAKE} DIRPRFX=${_tool}/ all
1316 .endfor
1317
1318 #
1319 # cross-tools: Build cross-building tools
1320 #
1321 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1322 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1323 _btxld=         usr.sbin/btxld
1324 .endif
1325 .endif
1326 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1327 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1328 _crunchide=     usr.sbin/crunch/crunchide
1329 .endif
1330 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1331 _kgzip=         usr.sbin/kgzip
1332 .endif
1333 .endif
1334
1335 .if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
1336 _binutils=      gnu/usr.bin/binutils
1337 .endif
1338
1339 # If an full path to an external cross compiler is given, don't build
1340 # a cross compiler.
1341 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1342 .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1343 _clang=         usr.bin/clang
1344 _clang_libs=    lib/clang
1345 .endif
1346
1347 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1348 _cc=            gnu/usr.bin/cc
1349 .endif
1350 .endif
1351
1352 cross-tools:
1353 .for _tool in \
1354     ${_clang_libs} \
1355     ${_clang} \
1356     ${_binutils} \
1357     ${_cc} \
1358     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1359     ${_btxld} \
1360     ${_crunchide} \
1361     ${_kgzip}
1362         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1363                 cd ${.CURDIR}/${_tool}; \
1364                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1365                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1366                 ${MAKE} DIRPRFX=${_tool}/ all; \
1367                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1368 .endfor
1369
1370 #
1371 # hierarchy - ensure that all the needed directories are present
1372 #
1373 hierarchy hier:
1374 .if defined(NO_ROOT)
1375         cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} \
1376             -DNO_ROOT METALOG=${METALOG} distrib-dirs
1377 .else
1378         cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
1379 .endif
1380
1381 #
1382 # libraries - build all libraries, and install them under ${DESTDIR}.
1383 #
1384 # The list of libraries with dependents (${_prebuild_libs}) and their
1385 # interdependencies (__L) are built automatically by the
1386 # ${.CURDIR}/tools/make_libdeps.sh script.
1387 #
1388 libraries:
1389         cd ${.CURDIR}; \
1390             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1391             ${MAKE} -f Makefile.inc1 _startup_libs; \
1392             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1393             ${MAKE} -f Makefile.inc1 _generic_libs;
1394
1395 #
1396 # static libgcc.a prerequisite for shared libc
1397 #
1398 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1399
1400 # These dependencies are not automatically generated:
1401 #
1402 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1403 # all shared libraries for ELF.
1404 #
1405 _startup_libs=  gnu/lib/csu
1406 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1407 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1408 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1409 _startup_libs+= lib/csu/${MACHINE_ARCH}
1410 .else
1411 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1412 .endif
1413 _startup_libs+= gnu/lib/libgcc
1414 _startup_libs+= lib/libcompiler_rt
1415 _startup_libs+= lib/libc
1416 .if ${MK_LIBCPLUSPLUS} != "no"
1417 _startup_libs+= lib/libcxxrt
1418 .endif
1419
1420 gnu/lib/libgcc__L: lib/libc__L
1421 .if ${MK_LIBCPLUSPLUS} != "no"
1422 lib/libcxxrt__L: gnu/lib/libgcc__L
1423 .endif
1424
1425 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1426                 ${_kerberos5_lib_libhdb} \
1427                 ${_kerberos5_lib_libheimbase} \
1428                 ${_kerberos5_lib_libheimntlm} \
1429                 ${_kerberos5_lib_libheimsqlite} \
1430                 ${_kerberos5_lib_libheimipcc} \
1431                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1432                 ${_kerberos5_lib_libroken} \
1433                 ${_kerberos5_lib_libwind} \
1434                 ${_lib_atf_libatf_c} \
1435                 lib/libbz2 ${_libcom_err} lib/libcrypt \
1436                 lib/libelf lib/libexpat \
1437                 ${_lib_libgssapi} ${_lib_libipx} \
1438                 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1439                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1440                 lib/libopie lib/libpam ${_lib_libthr} \
1441                 lib/libradius lib/libsbuf lib/libtacplus \
1442                 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1443                 ${_cddl_lib_libzfs_core} \
1444                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1445                 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1446                 ${_secure_lib_libssl}
1447
1448 .if ${MK_ATF} != "no"
1449 _lib_atf_libatf_c=      lib/atf/libatf-c
1450 .endif
1451
1452 .if ${MK_LIBTHR} != "no"
1453 _lib_libthr=    lib/libthr
1454 .endif
1455
1456 .if ${MK_OFED} != "no"
1457 _ofed_lib=      contrib/ofed/usr.lib/
1458 .endif
1459
1460 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1461 .for _DIR in ${LOCAL_LIB_DIRS}
1462 .if exists(${.CURDIR}/${_DIR}/Makefile)
1463 _generic_libs+= ${_DIR}
1464 .endif
1465 .endfor
1466
1467 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1468
1469 .if ${MK_CDDL} != "no"
1470 _cddl_lib_libumem= cddl/lib/libumem
1471 _cddl_lib_libnvpair= cddl/lib/libnvpair
1472 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1473 _cddl_lib= cddl/lib
1474 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1475 .endif
1476
1477 .if ${MK_CRYPT} != "no"
1478 .if ${MK_OPENSSL} != "no"
1479 _secure_lib_libcrypto= secure/lib/libcrypto
1480 _secure_lib_libssl= secure/lib/libssl
1481 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1482 .if ${MK_OPENSSH} != "no"
1483 _secure_lib_libssh= secure/lib/libssh
1484 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1485 .if ${MK_KERBEROS_SUPPORT} != "no"
1486 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1487     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1488     lib/libmd__L kerberos5/lib/libroken__L
1489 .endif
1490 .endif
1491 .endif
1492 _secure_lib=    secure/lib
1493 .endif
1494
1495 .if ${MK_KERBEROS} != "no"
1496 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1497 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1498     kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1499     kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L 
1500 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1501     kerberos5/lib/libroken__L lib/libcom_err__L
1502 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1503     secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1504 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1505     lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1506     kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1507     kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1508 kerberos5/lib/libroken__L: lib/libcrypt__L
1509 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1510 kerberos5/lib/libheimbase__L: lib/libthr__L
1511 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1512 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1513 .endif
1514
1515 .if ${MK_GSSAPI} != "no"
1516 _lib_libgssapi= lib/libgssapi
1517 .endif
1518
1519 .if ${MK_IPX} != "no"
1520 _lib_libipx=    lib/libipx
1521 .endif
1522
1523 .if ${MK_KERBEROS} != "no"
1524 _kerberos5_lib= kerberos5/lib
1525 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1526 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1527 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1528 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1529 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1530 _kerberos5_lib_libroken= kerberos5/lib/libroken
1531 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1532 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1533 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1534 _kerberos5_lib_libwind= kerberos5/lib/libwind
1535 _libcom_err= lib/libcom_err
1536 .endif
1537
1538 .if ${MK_NIS} != "no"
1539 _lib_libypclnt= lib/libypclnt
1540 .endif
1541
1542 .if ${MK_OPENSSL} == "no"
1543 lib/libradius__L: lib/libmd__L
1544 .endif
1545
1546 .for _lib in ${_prereq_libs}
1547 ${_lib}__PL: .PHONY
1548 .if exists(${.CURDIR}/${_lib})
1549         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1550                 cd ${.CURDIR}/${_lib}; \
1551                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1552                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1553                 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1554                 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1555 .endif
1556 .endfor
1557
1558 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1559 ${_lib}__L: .PHONY
1560 .if exists(${.CURDIR}/${_lib})
1561         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1562                 cd ${.CURDIR}/${_lib}; \
1563                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1564                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1565                 ${MAKE} DIRPRFX=${_lib}/ all; \
1566                 ${MAKE} DIRPRFX=${_lib}/ install
1567 .endif
1568 .endfor
1569
1570 # libpam is special: we need to build static PAM modules before
1571 # static PAM library, and dynamic PAM library before dynamic PAM
1572 # modules.
1573 lib/libpam__L: .PHONY
1574         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1575                 cd ${.CURDIR}/lib/libpam; \
1576                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1577                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1578                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1579                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1580
1581 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1582 _startup_libs: ${_startup_libs:S/$/__L/}
1583 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1584 _generic_libs: ${_generic_libs:S/$/__L/}
1585
1586 .for __target in all clean cleandepend cleandir depend includes obj
1587 .for entry in ${SUBDIR}
1588 ${entry}.${__target}__D: .PHONY
1589         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1590                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1591                 edir=${entry}.${MACHINE_ARCH}; \
1592                 cd ${.CURDIR}/$${edir}; \
1593         else \
1594                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1595                 edir=${entry}; \
1596                 cd ${.CURDIR}/$${edir}; \
1597         fi; \
1598         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1599 .endfor
1600 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1601 .endfor
1602
1603 .include <bsd.subdir.mk>
1604
1605 .if make(check-old) || make(check-old-dirs) || \
1606     make(check-old-files) || make(check-old-libs) || \
1607     make(delete-old) || make(delete-old-dirs) || \
1608     make(delete-old-files) || make(delete-old-libs)
1609
1610 #
1611 # check for / delete old files section
1612 #
1613
1614 .include "ObsoleteFiles.inc"
1615
1616 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1617 else you can not start such an application. Consult UPDATING for more \
1618 information regarding how to cope with the removal/revision bump of a \
1619 specific library."
1620
1621 .if !defined(BATCH_DELETE_OLD_FILES)
1622 RM_I=-i
1623 .else
1624 RM_I=-v
1625 .endif
1626
1627 delete-old-files:
1628         @echo ">>> Removing old files (only deletes safe to delete libs)"
1629 # Ask for every old file if the user really wants to remove it.
1630 # It's annoying, but better safe than sorry.
1631 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1632 # argument list will get too long. Using .for/.endfor make "loops" will make
1633 # the Makefile parser segfault.
1634         @exec 3<&0; \
1635         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1636             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1637         while read file; do \
1638                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1639                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1640                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1641                 fi; \
1642         done
1643 # Remove catpages without corresponding manpages.
1644         @exec 3<&0; \
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                         rm ${RM_I} $${catpage} <&3; \
1651                 fi; \
1652         done
1653         @echo ">>> Old files removed"
1654
1655 check-old-files:
1656         @echo ">>> Checking for old files"
1657         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1658             -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1659         while read file; do \
1660                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1661                         echo "${DESTDIR}/$${file}"; \
1662                 fi; \
1663         done
1664 # Check for catpages without corresponding manpages.
1665         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1666         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1667         while read catpage; do \
1668                 read manpage; \
1669                 if [ ! -e "$${manpage}" ]; then \
1670                         echo $${catpage}; \
1671                 fi; \
1672         done
1673
1674 delete-old-libs:
1675         @echo ">>> Removing old libraries"
1676         @echo "${OLD_LIBS_MESSAGE}" | fmt
1677         @exec 3<&0; \
1678         ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1679             -V OLD_LIBS | xargs -n1 | \
1680         while read file; do \
1681                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1682                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1683                         rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1684                 fi; \
1685         done
1686         @echo ">>> Old libraries removed"
1687
1688 check-old-libs:
1689         @echo ">>> Checking for old libraries"
1690         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1691             -V OLD_LIBS | xargs -n1 | \
1692         while read file; do \
1693                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1694                         echo "${DESTDIR}/$${file}"; \
1695                 fi; \
1696         done
1697
1698 delete-old-dirs:
1699         @echo ">>> Removing old directories"
1700         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1701             -V OLD_DIRS | xargs -n1 | \
1702         while read dir; do \
1703                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1704                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1705                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1706                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1707                 fi; \
1708         done
1709         @echo ">>> Old directories removed"
1710
1711 check-old-dirs:
1712         @echo ">>> Checking for old directories"
1713         @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1714             -V OLD_DIRS | xargs -n1 | \
1715         while read dir; do \
1716                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1717                         echo "${DESTDIR}/$${dir}"; \
1718                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1719                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1720                 fi; \
1721         done
1722
1723 delete-old: delete-old-files delete-old-dirs
1724         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1725
1726 check-old: check-old-files check-old-libs check-old-dirs
1727         @echo "To remove old files and directories run '${MAKE} delete-old'."
1728         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1729
1730 .endif
1731
1732 #
1733 # showconfig - show build configuration.
1734 #
1735 showconfig:
1736         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1737
1738 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1739 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1740
1741 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1742 .if exists(${KERNCONFDIR}/${KERNCONF})
1743 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1744         ${KERNCONFDIR}/${KERNCONF} ; echo
1745 .endif
1746 .endif
1747
1748 .endif
1749
1750 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1751 DTBOUTPUTPATH= ${.CURDIR}
1752 .endif
1753
1754 #
1755 # Build 'standalone' Device Tree Blob
1756 #
1757 builddtb:
1758         @if [ "${FDT_DTS_FILE}" = "" ]; then \
1759                 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1760                 exit 1; \
1761         fi;     \
1762         if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1763                 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1764                         exist!"; \
1765                 exit 1; \
1766         fi;     \
1767         if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then  \
1768                 echo "WARNING: DTB will be placed in the current working \
1769                         directory"; \
1770         fi
1771         @PATH=${TMPPATH} \
1772         dtc -O dtb -o \
1773             ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1774             -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1775
1776 ###############
1777
1778 .if defined(XDEV) && defined(XDEV_ARCH)
1779
1780 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1781 XDEV_CPUTYPE?=${CPUTYPE}
1782 .else
1783 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1784 .endif
1785
1786 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1787         -DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1788         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1789         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1790         CPUTYPE=${XDEV_CPUTYPE}
1791
1792 XDDIR=${XDEV_ARCH}-freebsd
1793 XDTP=/usr/${XDDIR}
1794 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1795         INSTALL="sh ${.CURDIR}/tools/install.sh"
1796 CDENV= ${CDBENV} \
1797         _SHLIBDIRPREFIX=${XDDESTDIR} \
1798         TOOLS_PREFIX=${XDDESTDIR}
1799 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1800         -B${XDDESTDIR}/usr/lib
1801 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" \
1802         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1803
1804 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1805 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1806 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1807 XDDESTDIR=${DESTDIR}${XDTP}
1808 .if !defined(OSREL)
1809 OSREL!= uname -r | sed -e 's/[-(].*//'
1810 .endif
1811
1812 .ORDER: xdev-build xdev-install
1813 xdev: xdev-build xdev-install
1814
1815 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1816 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1817
1818 _xb-worldtmp:
1819         mkdir -p ${CDTMP}/usr
1820         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1821             -p ${CDTMP}/usr >/dev/null
1822
1823 _xb-bootstrap-tools:
1824 .for _tool in \
1825     ${_clang_tblgen}
1826         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1827         cd ${.CURDIR}/${_tool}; \
1828         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1829         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1830         ${CDMAKE} DIRPRFX=${_tool}/ all; \
1831         ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1832 .endfor
1833
1834 _xb-build-tools:
1835         ${_+_}@cd ${.CURDIR}; \
1836         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1837
1838 _xb-cross-tools:
1839 .for _tool in \
1840     gnu/usr.bin/binutils \
1841     gnu/usr.bin/cc \
1842     usr.bin/ar \
1843     ${_clang_libs} \
1844     ${_clang}
1845         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1846         cd ${.CURDIR}/${_tool}; \
1847         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1848         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1849         ${CDMAKE} DIRPRFX=${_tool}/ all
1850 .endfor
1851
1852 _xi-mtree:
1853         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1854         mkdir -p ${XDDESTDIR}
1855         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1856             -p ${XDDESTDIR} >/dev/null
1857         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1858             -p ${XDDESTDIR}/usr >/dev/null
1859         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1860             -p ${XDDESTDIR}/usr/include >/dev/null
1861
1862 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1863 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1864
1865 _xi-cross-tools:
1866         @echo "_xi-cross-tools"
1867 .for _tool in \
1868     gnu/usr.bin/binutils \
1869     gnu/usr.bin/cc \
1870     usr.bin/ar \
1871     ${_clang}
1872         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1873         cd ${.CURDIR}/${_tool}; \
1874         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1875 .endfor
1876
1877 _xi-includes:
1878         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1879                 DESTDIR=${XDDESTDIR}
1880
1881 _xi-libraries:
1882         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1883                 DESTDIR=${XDDESTDIR}
1884
1885 _xi-links:
1886         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1887                 for i in *; do \
1888                         ln -sf ../../${XDTP}/usr/bin/$$i \
1889                             ../../../../usr/bin/${XDDIR}-$$i; \
1890                         ln -sf ../../${XDTP}/usr/bin/$$i \
1891                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1892                 done
1893 .else
1894 xdev xdev-build xdev-install:
1895         @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
1896 .endif