]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Rather than having an ifdef for mips in the top level makefile, create
[FreeBSD/FreeBSD.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 #       TARGET_ARCH= may be required when a TARGET supports multiple endians.
19
20 #
21 # The intended user-driven targets are:
22 # buildworld  - rebuild *everything*, including glue to help do upgrades
23 # installworld- install everything built by "buildworld"
24 # doxygen     - build API documentation of the kernel
25 # update      - convenient way to update your source tree (eg: cvsup/cvs)
26 #
27 # Standard targets (not defined here) are documented in the makefiles in
28 # /usr/share/mk.  These include:
29 #               obj depend all install clean cleandepend cleanobj
30
31 .include <bsd.own.mk>
32 .include <bsd.arch.inc.mk>
33
34 # We must do share/info early so that installation of info `dir'
35 # entries works correctly.  Do it first since it is less likely to
36 # grow dependencies on include and lib than vice versa.
37 #
38 # We must do lib/ and libexec/ before bin/, because if installworld
39 # installs a new /bin/sh, the 'make' command will *immediately*
40 # use that new version.  And the new (dynamically-linked) /bin/sh
41 # will expect to find appropriate libraries in /lib and /libexec.
42 #
43 SUBDIR= share/info lib libexec
44 SUBDIR+=bin
45 .if ${MK_GAMES} != "no"
46 SUBDIR+=games
47 .endif
48 .if ${MK_CDDL} != "no"
49 SUBDIR+=cddl
50 .else
51 NO_CTF=1
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?=      -A -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/:S/mips/mipsel/}
122 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
123     ${TARGET_ARCH} != ${MACHINE_ARCH}
124 TARGET=         ${TARGET_ARCH:C/mipse[lb]/mips/:C/armeb/arm}
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 armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/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}.${TARGET_ARCH}
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                 VERSION="${VERSION}" \
257                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
258                 PATH=${TMPPATH}
259 .if ${MK_CDDL} == "no" || defined(NO_CTF)
260 WMAKEENV+=      NO_CTF=1
261 .endif
262 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
263
264 .if ${TARGET_ARCH} == "amd64"
265 # 32 bit world
266 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
267
268 .if empty(TARGET_CPUTYPE)
269 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
270 .else
271 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
272 .endif
273 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -mfancy-math-387 -DCOMPAT_32BIT \
274                 -isystem ${LIB32TMP}/usr/include/ \
275                 -L${LIB32TMP}/usr/lib32 \
276                 -B${LIB32TMP}/usr/lib32
277
278 # Yes, the flags are redundant.
279 LIB32WMAKEENV=  MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
280                 _SHLIBDIRPREFIX=${LIB32TMP} \
281                 VERSION="${VERSION}" \
282                 MACHINE=i386 \
283                 MACHINE_ARCH=i386 \
284                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
285                 PATH=${TMPPATH} \
286                 CC="${CC} ${LIB32FLAGS}" \
287                 CXX="${CXX} ${LIB32FLAGS}" \
288                 OBJC="${OBJC} ${LIB32FLAGS}" \
289                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
290                 AS="${AS} --32" \
291                 LIBDIR=/usr/lib32 \
292                 SHLIBDIR=/usr/lib32
293
294 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
295                 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
296                 -DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
297 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
298 .endif
299
300 # install stage
301 IMAKEENV=       ${CROSSENV}
302 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
303 .if empty(.MAKEFLAGS:M-n)
304 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
305                 LD_LIBRARY_PATH=${INSTALLTMP} \
306                 PATH_LOCALE=${INSTALLTMP}/locale
307 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
308 .else
309 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
310 .endif
311
312 # kernel stage
313 KMAKEENV=       ${WMAKEENV}
314 KMAKE=          ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
315
316 #
317 # buildworld
318 #
319 # Attempt to rebuild the entire system, with reasonable chance of
320 # success, regardless of how old your existing system is.
321 #
322 _worldtmp:
323 .if ${.CURDIR:C/[^,]//g} != ""
324 #       The m4 build of sendmail files doesn't like it if ',' is used
325 #       anywhere in the path of it's files.
326         @echo
327         @echo "*** Error: path to source tree contains a comma ','"
328         @echo
329         false
330 .endif
331         @echo
332         @echo "--------------------------------------------------------------"
333         @echo ">>> Rebuilding the temporary build tree"
334         @echo "--------------------------------------------------------------"
335 .if !defined(NO_CLEAN)
336         rm -rf ${WORLDTMP}
337 .if ${TARGET_ARCH} == "amd64"
338         rm -rf ${LIB32TMP}
339 .endif
340 .else
341         rm -rf ${WORLDTMP}/legacy/usr/include
342 #       XXX - These three can depend on any header file.
343         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
344         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
345         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
346 .endif
347 .for _dir in \
348     lib usr legacy/usr
349         mkdir -p ${WORLDTMP}/${_dir}
350 .endfor
351         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
352             -p ${WORLDTMP}/legacy/usr >/dev/null
353         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
354             -p ${WORLDTMP}/usr >/dev/null
355         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
356             -p ${WORLDTMP}/usr/include >/dev/null
357         ln -sf ${.CURDIR}/sys ${WORLDTMP}
358 .if ${MK_BIND_LIBS} != "no"
359         mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
360             -p ${WORLDTMP}/usr/include >/dev/null
361 .endif
362 _legacy:
363         @echo
364         @echo "--------------------------------------------------------------"
365         @echo ">>> stage 1.1: legacy release compatibility shims"
366         @echo "--------------------------------------------------------------"
367         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
368 _bootstrap-tools:
369         @echo
370         @echo "--------------------------------------------------------------"
371         @echo ">>> stage 1.2: bootstrap tools"
372         @echo "--------------------------------------------------------------"
373         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
374 _cleanobj:
375 .if !defined(NO_CLEAN)
376         @echo
377         @echo "--------------------------------------------------------------"
378         @echo ">>> stage 2.1: cleaning up the object tree"
379         @echo "--------------------------------------------------------------"
380         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
381 .if ${TARGET_ARCH} == "amd64"
382         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
383 .endif
384 .endif
385 _obj:
386         @echo
387         @echo "--------------------------------------------------------------"
388         @echo ">>> stage 2.2: rebuilding the object tree"
389         @echo "--------------------------------------------------------------"
390         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
391 _build-tools:
392         @echo
393         @echo "--------------------------------------------------------------"
394         @echo ">>> stage 2.3: build tools"
395         @echo "--------------------------------------------------------------"
396         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
397 _cross-tools:
398         @echo
399         @echo "--------------------------------------------------------------"
400         @echo ">>> stage 3: cross tools"
401         @echo "--------------------------------------------------------------"
402         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
403 _includes:
404         @echo
405         @echo "--------------------------------------------------------------"
406         @echo ">>> stage 4.1: building includes"
407         @echo "--------------------------------------------------------------"
408         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
409 _libraries:
410         @echo
411         @echo "--------------------------------------------------------------"
412         @echo ">>> stage 4.2: building libraries"
413         @echo "--------------------------------------------------------------"
414         ${_+_}cd ${.CURDIR}; \
415             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
416             -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
417 _depend:
418         @echo
419         @echo "--------------------------------------------------------------"
420         @echo ">>> stage 4.3: make dependencies"
421         @echo "--------------------------------------------------------------"
422         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
423 everything:
424         @echo
425         @echo "--------------------------------------------------------------"
426         @echo ">>> stage 4.4: building everything"
427         @echo "--------------------------------------------------------------"
428         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
429 .if ${TARGET_ARCH} == "amd64"
430 build32:
431         @echo
432         @echo "--------------------------------------------------------------"
433         @echo ">>> stage 5.1: building 32 bit shim libraries"
434         @echo "--------------------------------------------------------------"
435         mkdir -p ${LIB32TMP}/usr/lib32
436         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
437             -p ${LIB32TMP}/usr >/dev/null
438         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
439             -p ${LIB32TMP}/usr/include >/dev/null
440         mkdir -p ${WORLDTMP}
441         ln -sf ${.CURDIR}/sys ${WORLDTMP}
442 .if ${MK_KERBEROS} != "no"
443 .for _t in obj depend all
444         cd ${.CURDIR}/kerberos5/tools; \
445             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
446             ${_t}
447 .endfor
448 .endif
449 .for _t in obj includes
450         cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
451         cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
452 .if ${MK_CDDL} != "no"
453         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
454 .endif
455         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
456 .if ${MK_CRYPT} != "no"
457         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
458 .endif
459 .if ${MK_KERBEROS} != "no"
460         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
461 .endif
462 .endfor
463 .for _dir in usr.bin/lex/lib
464         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
465 .endfor
466 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
467         cd ${.CURDIR}/${_dir}; \
468             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
469             build-tools
470 .endfor
471         cd ${.CURDIR}; \
472             ${LIB32WMAKE} -f Makefile.inc1 libraries
473 .for _t in obj depend all
474         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
475         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
476 .endfor
477
478 distribute32 install32:
479 .if make(distribute32)
480         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
481         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace    # XXX add to mtree
482 .else
483         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
484         mkdir -p ${DESTDIR}/usr/lib32/dtrace            # XXX add to mtree
485 .endif
486         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
487 .if ${MK_CDDL} != "no"
488         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
489 .endif
490         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
491 .if ${MK_CRYPT} != "no"
492         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
493 .endif
494 .if ${MK_KERBEROS} != "no"
495         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
496 .endif
497         cd ${.CURDIR}/libexec/rtld-elf; \
498             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
499         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
500 .endif
501
502 WMAKE_TGTS=
503 .if !defined(SUBDIR_OVERRIDE)
504 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
505 .endif
506 WMAKE_TGTS+=    _cleanobj _obj _build-tools
507 .if !defined(SUBDIR_OVERRIDE)
508 WMAKE_TGTS+=    _cross-tools
509 .endif
510 WMAKE_TGTS+=    _includes _libraries _depend everything
511 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
512 WMAKE_TGTS+=    build32
513 .endif
514
515 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
516 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
517
518 buildworld_prologue:
519         @echo "--------------------------------------------------------------"
520         @echo ">>> World build started on `LC_ALL=C date`"
521         @echo "--------------------------------------------------------------"
522
523 buildworld_epilogue:
524         @echo
525         @echo "--------------------------------------------------------------"
526         @echo ">>> World build completed on `LC_ALL=C date`"
527         @echo "--------------------------------------------------------------"
528
529 #
530 # We need to have this as a target because the indirection between Makefile
531 # and Makefile.inc1 causes the correct PATH to be used, rather than a
532 # modification of the current environment's PATH.  In addition, we need
533 # to quote multiword values.
534 #
535 buildenvvars:
536         @echo ${WMAKEENV:Q}
537
538 buildenv:
539         @echo Entering world for ${TARGET_ARCH}:${TARGET}
540         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
541
542 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
543 toolchain: ${TOOLCHAIN_TGTS}
544 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
545
546 #
547 # installcheck
548 #
549 # Checks to be sure system is ready for installworld/installkernel.
550 #
551 installcheck:
552
553 #
554 # Require DESTDIR to be set if installing for a different architecture.
555 #
556 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
557 .if !make(distributeworld)
558 installcheck: installcheck_DESTDIR
559 installcheck_DESTDIR:
560 .if !defined(DESTDIR) || empty(DESTDIR)
561         @echo "ERROR: Please set DESTDIR!"; \
562         false
563 .endif
564 .endif
565 .endif
566
567 #
568 # Check for missing UIDs/GIDs.
569 #
570 CHECK_UIDS=
571 CHECK_GIDS=     audit
572 .if ${MK_SENDMAIL} != "no"
573 CHECK_UIDS+=    smmsp
574 CHECK_GIDS+=    smmsp
575 .endif
576 .if ${MK_PF} != "no"
577 CHECK_UIDS+=    proxy
578 CHECK_GIDS+=    proxy authpf
579 .endif
580 installcheck: installcheck_UGID
581 installcheck_UGID:
582 .for uid in ${CHECK_UIDS}
583         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
584                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
585                 false; \
586         fi
587 .endfor
588 .for gid in ${CHECK_GIDS}
589         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
590                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
591                 false; \
592         fi
593 .endfor
594
595 #
596 # Required install tools to be saved in a scratch dir for safety.
597 #
598 .if ${MK_INFO} != "no"
599 _install-info=  install-info
600 .endif
601 .if ${MK_ZONEINFO} != "no"
602 _zoneinfo=      zic tzsetup
603 .endif
604
605 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
606         date echo egrep find grep ${_install-info} \
607         ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
608         test true uname wc ${_zoneinfo}
609
610 #
611 # distributeworld
612 #
613 # Distributes everything compiled by a `buildworld'.
614 #
615 # installworld
616 #
617 # Installs everything compiled by a 'buildworld'.
618 #
619 distributeworld installworld: installcheck
620         mkdir -p ${INSTALLTMP}
621         progs=$$(for prog in ${ITOOLS}; do \
622                 if progpath=`which $$prog`; then \
623                         echo $$progpath; \
624                 else \
625                         echo "Required tool $$prog not found in PATH." >&2; \
626                         exit 1; \
627                 fi; \
628             done); \
629         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
630             while read line; do \
631                 set -- $$line; \
632                 if [ "$$2 $$3" != "not found" ]; then \
633                         echo $$2; \
634                 else \
635                         echo "Required library $$1 not found." >&2; \
636                         exit 1; \
637                 fi; \
638             done); \
639         cp $$libs $$progs ${INSTALLTMP}
640         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
641         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
642             ${IMAKEENV} rm -rf ${INSTALLTMP}
643
644 #
645 # reinstall
646 #
647 # If you have a build server, you can NFS mount the source and obj directories
648 # and do a 'make reinstall' on the *client* to install new binaries from the
649 # most recent server build.
650 #
651 reinstall:
652         @echo "--------------------------------------------------------------"
653         @echo ">>> Making hierarchy"
654         @echo "--------------------------------------------------------------"
655         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
656         @echo
657         @echo "--------------------------------------------------------------"
658         @echo ">>> Installing everything"
659         @echo "--------------------------------------------------------------"
660         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
661 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
662         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
663 .endif
664
665 redistribute:
666         @echo "--------------------------------------------------------------"
667         @echo ">>> Distributing everything"
668         @echo "--------------------------------------------------------------"
669         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
670 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
671         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
672             DISTRIBUTION=lib32
673 .endif
674
675 distrib-dirs distribution:
676         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
677
678 #
679 # buildkernel and installkernel
680 #
681 # Which kernels to build and/or install is specified by setting
682 # KERNCONF. If not defined a GENERIC kernel is built/installed.
683 # Only the existing (depending TARGET) config files are used
684 # for building kernels and only the first of these is designated
685 # as the one being installed.
686 #
687 # Note that we have to use TARGET instead of TARGET_ARCH when
688 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
689 # be set to cross-build, we have to make sure TARGET is set
690 # properly.
691
692 .if defined(KERNFAST)
693 NO_KERNELCLEAN= t
694 NO_KERNELCONFIG=        t
695 NO_KERNELDEPEND=        t
696 NO_KERNELOBJ=           t
697 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
698 .if !defined(KERNCONF) && ${KERNFAST} != "1"
699 KERNCONF=${KERNFAST}
700 .endif
701 .endif
702 .if !defined(KERNCONF) && defined(KERNEL)
703 KERNCONF=       ${KERNEL}
704 KERNWARN=
705 .else
706 KERNCONF?=      GENERIC
707 .endif
708 INSTKERNNAME?=  kernel
709
710 KERNSRCDIR?=    ${.CURDIR}/sys
711 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
712 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
713 KERNCONFDIR?=   ${KRNLCONFDIR}
714
715 BUILDKERNELS=
716 INSTALLKERNEL=
717 .for _kernel in ${KERNCONF}
718 .if exists(${KERNCONFDIR}/${_kernel})
719 BUILDKERNELS+=  ${_kernel}
720 .if empty(INSTALLKERNEL)
721 INSTALLKERNEL= ${_kernel}
722 .endif
723 .endif
724 .endfor
725
726 #
727 # buildkernel
728 #
729 # Builds all kernels defined by BUILDKERNELS.
730 #
731 buildkernel:
732 .if empty(BUILDKERNELS)
733         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
734         false
735 .endif
736 .if defined(KERNWARN)
737         @echo "--------------------------------------------------------------"
738         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
739         @echo "--------------------------------------------------------------"
740         @sleep 3
741 .endif
742         @echo
743 .for _kernel in ${BUILDKERNELS}
744         @echo "--------------------------------------------------------------"
745         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
746         @echo "--------------------------------------------------------------"
747         @echo "===> ${_kernel}"
748         mkdir -p ${KRNLOBJDIR}
749 .if !defined(NO_KERNELCONFIG)
750         @echo
751         @echo "--------------------------------------------------------------"
752         @echo ">>> stage 1: configuring the kernel"
753         @echo "--------------------------------------------------------------"
754         cd ${KRNLCONFDIR}; \
755                 PATH=${TMPPATH} \
756                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
757                         ${KERNCONFDIR}/${_kernel}
758 .endif
759 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
760         @echo
761         @echo "--------------------------------------------------------------"
762         @echo ">>> stage 2.1: cleaning up the object tree"
763         @echo "--------------------------------------------------------------"
764         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
765 .endif
766 .if !defined(NO_KERNELOBJ)
767         @echo
768         @echo "--------------------------------------------------------------"
769         @echo ">>> stage 2.2: rebuilding the object tree"
770         @echo "--------------------------------------------------------------"
771         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
772 .endif
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"
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} < 800013
934 _mklocale=      usr.bin/mklocale
935 .endif
936
937 .if ${BOOTSTRAPPING} < 900002
938 _sed=           usr.bin/sed
939 .endif
940
941 .if ${BOOTSTRAPPING} < 900006
942 _lex=           usr.bin/lex
943 _yacc=          usr.bin/yacc
944 .endif
945
946 .if ${BOOTSTRAPPING} < 700018
947 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
948 .endif
949
950 .if ${MK_RESCUE} != "no" && \
951     ${BOOTSTRAPPING} < 700026
952 _crunchgen=     usr.sbin/crunch/crunchgen
953 .endif
954
955 .if ${MK_CDDL} != "no"
956 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
957     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
958 .endif
959
960 bootstrap-tools:
961 .for _tool in \
962     ${_dtrace_tools} \
963     ${_strfile} \
964     ${_gperf} \
965     ${_groff} \
966     ${_ar} \
967     usr.bin/lorder \
968     usr.bin/makewhatis \
969     ${_mklocale} \
970     usr.bin/rpcgen \
971     ${_sed} \
972     ${_lex} \
973     ${_yacc} \
974     usr.bin/xinstall \
975     ${_gensnmptree} \
976     usr.sbin/config \
977     ${_crunchgen}
978         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
979                 cd ${.CURDIR}/${_tool}; \
980                 ${MAKE} DIRPRFX=${_tool}/ obj; \
981                 ${MAKE} DIRPRFX=${_tool}/ depend; \
982                 ${MAKE} DIRPRFX=${_tool}/ all; \
983                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
984 .endfor
985
986 #
987 # build-tools: Build special purpose build tools
988 #
989 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
990 _aicasm= sys/modules/aic7xxx/aicasm
991 .endif
992
993 .if !defined(NO_SHARE)
994 _share= share/syscons/scrnmaps
995 .endif
996
997 .if ${MK_KERBEROS} != "no"
998 _kerberos5_tools= kerberos5/tools
999 .endif
1000
1001 .if ${MK_RESCUE} != "no"
1002 _rescue= rescue/rescue
1003 .endif
1004
1005 build-tools:
1006 .for _tool in \
1007     bin/csh \
1008     bin/sh \
1009     ${_rescue} \
1010     lib/ncurses/ncurses \
1011     lib/ncurses/ncursesw \
1012     ${_share} \
1013     ${_aicasm} \
1014     usr.bin/awk \
1015     lib/libmagic \
1016     usr.sbin/sysinstall
1017         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1018                 cd ${.CURDIR}/${_tool}; \
1019                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1020                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1021 .endfor
1022 .for _tool in \
1023     gnu/usr.bin/cc/cc_tools \
1024     ${_kerberos5_tools}
1025         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1026                 cd ${.CURDIR}/${_tool}; \
1027                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1028                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1029                 ${MAKE} DIRPRFX=${_tool}/ all
1030 .endfor
1031
1032 #
1033 # cross-tools: Build cross-building tools
1034 #
1035 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1036 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1037 _btxld=         usr.sbin/btxld
1038 .endif
1039 .endif
1040 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1041 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1042 _crunchide=     usr.sbin/crunch/crunchide
1043 .endif
1044 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1045 _kgzip=         usr.sbin/kgzip
1046 .endif
1047 .endif
1048
1049 cross-tools:
1050 .for _tool in \
1051     gnu/usr.bin/binutils \
1052     gnu/usr.bin/cc \
1053     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1054     ${_btxld} \
1055     ${_crunchide} \
1056     ${_kgzip}
1057         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1058                 cd ${.CURDIR}/${_tool}; \
1059                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1060                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1061                 ${MAKE} DIRPRFX=${_tool}/ all; \
1062                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1063 .endfor
1064
1065 #
1066 # hierarchy - ensure that all the needed directories are present
1067 #
1068 hierarchy:
1069         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
1070
1071 #
1072 # libraries - build all libraries, and install them under ${DESTDIR}.
1073 #
1074 # The list of libraries with dependents (${_prebuild_libs}) and their
1075 # interdependencies (__L) are built automatically by the
1076 # ${.CURDIR}/tools/make_libdeps.sh script.
1077 #
1078 libraries:
1079         cd ${.CURDIR}; \
1080             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1081             ${MAKE} -f Makefile.inc1 _startup_libs; \
1082             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1083             ${MAKE} -f Makefile.inc1 _generic_libs;
1084
1085 #
1086 # static libgcc.a prerequisite for shared libc
1087 #
1088 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc
1089
1090 # These dependencies are not automatically generated:
1091 #
1092 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1093 # all shared libraries for ELF.
1094 #
1095 _startup_libs=  gnu/lib/csu
1096 .if exists(${.CURDIR}/lib/csu/${MACHINE_CPUARCH}-elf)
1097 _startup_libs+= lib/csu/${MACHINE_CPUARCH}-elf
1098 .else
1099 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1100 .endif
1101 _startup_libs+= gnu/lib/libgcc
1102 _startup_libs+= lib/libc
1103
1104 gnu/lib/libgcc__L: lib/libc__L
1105
1106 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1107                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1108                 ${_kerberos5_lib_libroken} \
1109                 lib/libbz2 lib/libcom_err lib/libcrypt \
1110                 lib/libexpat \
1111                 ${_lib_libgssapi} ${_lib_libipx} \
1112                 lib/libkiconv lib/libkvm lib/libmd \
1113                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1114                 lib/libopie lib/libpam ${_lib_libthr} \
1115                 lib/libradius lib/libsbuf lib/libtacplus \
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= cddl/lib
1130 .endif
1131
1132 .if ${MK_CRYPT} != "no"
1133 .if ${MK_OPENSSL} != "no"
1134 _secure_lib_libcrypto= secure/lib/libcrypto
1135 _secure_lib_libssl= secure/lib/libssl
1136 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1137 .if ${MK_OPENSSH} != "no"
1138 _secure_lib_libssh= secure/lib/libssh
1139 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1140 .if ${MK_KERBEROS_SUPPORT} != "no"
1141 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1142     kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1143     lib/libmd__L kerberos5/lib/libroken__L
1144 .endif
1145 .endif
1146 .endif
1147 _secure_lib=    secure/lib
1148 .endif
1149
1150 .if ${MK_GSSAPI} != "no"
1151 _lib_libgssapi= lib/libgssapi
1152 .endif
1153
1154 .if ${MK_IPX} != "no"
1155 _lib_libipx=    lib/libipx
1156 .endif
1157
1158 .if ${MK_KERBEROS} != "no"
1159 _kerberos5_lib= kerberos5/lib
1160 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1161 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1162 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1163 _kerberos5_lib_libroken= kerberos5/lib/libroken
1164 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1165 .endif
1166
1167 .if ${MK_NIS} != "no"
1168 _lib_libypclnt= lib/libypclnt
1169 .endif
1170
1171 .if ${MK_OPENSSL} == "no"
1172 lib/libradius__L: lib/libmd__L
1173 .endif
1174
1175 .for _lib in ${_prereq_libs}
1176 ${_lib}__PL: .PHONY
1177 .if exists(${.CURDIR}/${_lib})
1178         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1179                 cd ${.CURDIR}/${_lib}; \
1180                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1181                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1182                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1183                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1184 .endif
1185 .endfor
1186
1187 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1188 ${_lib}__L: .PHONY
1189 .if exists(${.CURDIR}/${_lib})
1190         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1191                 cd ${.CURDIR}/${_lib}; \
1192                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1193                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1194                 ${MAKE} DIRPRFX=${_lib}/ all; \
1195                 ${MAKE} DIRPRFX=${_lib}/ install
1196 .endif
1197 .endfor
1198
1199 # libpam is special: we need to build static PAM modules before
1200 # static PAM library, and dynamic PAM library before dynamic PAM
1201 # modules.
1202 lib/libpam__L: .PHONY
1203         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1204                 cd ${.CURDIR}/lib/libpam; \
1205                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1206                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1207                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1208                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1209
1210 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1211 _startup_libs: ${_startup_libs:S/$/__L/}
1212 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1213 _generic_libs: ${_generic_libs:S/$/__L/}
1214
1215 .for __target in all clean cleandepend cleandir depend includes obj
1216 .for entry in ${SUBDIR}
1217 ${entry}.${__target}__D: .PHONY
1218         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1219                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1220                 edir=${entry}.${MACHINE_ARCH}; \
1221                 cd ${.CURDIR}/$${edir}; \
1222         else \
1223                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1224                 edir=${entry}; \
1225                 cd ${.CURDIR}/$${edir}; \
1226         fi; \
1227         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1228 .endfor
1229 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1230 .endfor
1231
1232 .include <bsd.subdir.mk>
1233
1234 .if make(check-old) || make(check-old-dirs) || \
1235     make(check-old-files) || make(check-old-libs) || \
1236     make(delete-old) || make(delete-old-dirs) || \
1237     make(delete-old-files) || make(delete-old-libs)
1238
1239 #
1240 # check for / delete old files section
1241 #
1242
1243 .include "ObsoleteFiles.inc"
1244
1245 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1246 else you can not start such an application. Consult UPDATING for more \
1247 information regarding how to cope with the removal/revision bump of a \
1248 specific library."
1249
1250 .if !defined(BATCH_DELETE_OLD_FILES)
1251 RM_I=-i
1252 .else
1253 RM_I=-v
1254 .endif
1255
1256 delete-old-files:
1257         @echo ">>> Removing old files (only deletes safe to delete libs)"
1258 # Ask for every old file if the user really wants to remove it.
1259 # It's annoying, but better safe than sorry.
1260         @for file in ${OLD_FILES}; do \
1261                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1262                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1263                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1264                 fi; \
1265         done
1266 # Remove catpages without corresponding manpages.
1267         @exec 3<&0; \
1268         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1269         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1270         while read catpage; do \
1271                 read manpage; \
1272                 if [ ! -e "$${manpage}" ]; then \
1273                         rm ${RM_I} $${catpage} <&3 ; \
1274                 fi; \
1275         done
1276         @echo ">>> Old files removed"
1277
1278 check-old-files:
1279         @echo ">>> Checking for old files"
1280         @for file in ${OLD_FILES}; do \
1281                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1282                         echo "${DESTDIR}/$${file}"; \
1283                 fi; \
1284         done
1285 # Check for catpages without corresponding manpages.
1286         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1287         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1288         while read catpage; do \
1289                 read manpage; \
1290                 if [ ! -e "$${manpage}" ]; then \
1291                         echo $${catpage} ; \
1292                 fi; \
1293         done
1294
1295 delete-old-libs:
1296         @echo ">>> Removing old libraries"
1297         @echo "${OLD_LIBS_MESSAGE}" | fmt
1298         @for file in ${OLD_LIBS}; do \
1299                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1300                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1301                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1302                 fi; \
1303         done
1304         @echo ">>> Old libraries removed"
1305
1306 check-old-libs:
1307         @echo ">>> Checking for old libraries"
1308         @for file in ${OLD_LIBS}; do \
1309                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1310                         echo "${DESTDIR}/$${file}"; \
1311                 fi; \
1312         done
1313
1314 delete-old-dirs:
1315         @echo ">>> Removing old directories"
1316         @for dir in ${OLD_DIRS}; do \
1317                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1318                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1319                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1320                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1321                 fi; \
1322         done
1323         @echo ">>> Old directories removed"
1324
1325 check-old-dirs:
1326         @echo ">>> Checking for old directories"
1327         @for dir in ${OLD_DIRS}; do \
1328                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1329                         echo "${DESTDIR}/$${dir}"; \
1330                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1331                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1332                 fi; \
1333         done
1334
1335 delete-old: delete-old-files delete-old-dirs
1336         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1337
1338 check-old: check-old-files check-old-libs check-old-dirs
1339         @echo "To remove old files and directories run '${MAKE} delete-old'."
1340         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1341
1342 .endif
1343
1344 #
1345 # showconfig - show build configuration.
1346 #
1347 showconfig:
1348         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1349
1350
1351 ###############
1352
1353 .if defined(XDEV) && defined(XDEV_ARCH)
1354
1355 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1356         -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1357         -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS
1358
1359 XDDIR=${XDEV}-freebsd
1360 XDTP=/usr/${XDDIR}
1361 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1362         TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH}
1363 CDENV= ${CDBENV} \
1364         _SHLIBDIRPREFIX=${XDTP} \
1365         TOOLS_PREFIX=${XDTP}
1366 CD2ENV=${CDENV} \
1367         MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1368
1369 CDTMP=  ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1370 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1371 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1372 XDDESTDIR=${DESTDIR}${XDTP}
1373 .if !defined(OSREL)
1374 OSREL!= uname -r | sed -e 's/[-(].*//'
1375 .endif
1376
1377 .ORDER: xdev-build xdev-install
1378 xdev: xdev-build xdev-install
1379
1380 .ORDER: _xb-build-tools _xb-cross-tools
1381 xdev-build: _xb-build-tools _xb-cross-tools
1382
1383 _xb-build-tools:
1384         ${_+_}cd ${.CURDIR}; \
1385         ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1386
1387 _xb-cross-tools:
1388 .for _tool in \
1389     gnu/usr.bin/binutils \
1390     gnu/usr.bin/cc
1391         ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1392         cd ${.CURDIR}/${_tool}; \
1393         ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1394         ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1395         ${CDMAKE} DIRPRFX=${_tool}/ all
1396 .endfor
1397
1398 _xi-mtree:
1399         ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1400         mkdir -p ${XDDESTDIR}
1401         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1402             -p ${XDDESTDIR} >/dev/null
1403         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1404             -p ${XDDESTDIR}/usr >/dev/null
1405         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1406             -p ${XDDESTDIR}/usr/include >/dev/null
1407
1408 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1409 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1410
1411 _xi-cross-tools:
1412         @echo "_xi-cross-tools"
1413 .for _tool in \
1414     gnu/usr.bin/binutils \
1415     gnu/usr.bin/cc
1416         ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1417         cd ${.CURDIR}/${_tool}; \
1418         ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1419 .endfor
1420
1421 _xi-includes:
1422         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1423                 DESTDIR=${XDDESTDIR}
1424
1425 _xi-libraries:
1426         ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1427                 DESTDIR=${XDDESTDIR}
1428
1429 _xi-links:
1430         ${_+_}cd ${XDDESTDIR}/usr/bin; \
1431                 for i in *; do \
1432                         ln -sf ../../${XDTP}/usr/bin/$$i \
1433                             ../../../../usr/bin/${XDDIR}-$$i; \
1434                         ln -sf ../../${XDTP}/usr/bin/$$i \
1435                             ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1436                 done
1437 .endif