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