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