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