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