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