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