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