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