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