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