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