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