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