]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
merge from head, part 9 of many
[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                 MACHINE_CPU="i686 mmx sse sse2" \
285                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
286                 PATH=${TMPPATH} \
287                 CC="${CC} ${LIB32FLAGS}" \
288                 CXX="${CXX} ${LIB32FLAGS}" \
289                 OBJC="${OBJC} ${LIB32FLAGS}" \
290                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
291                 AS="${AS} --32" \
292                 LIBDIR=/usr/lib32 \
293                 SHLIBDIR=/usr/lib32
294
295 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
296                 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
297                 -DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
298 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
299 .endif
300
301 # install stage
302 IMAKEENV=       ${CROSSENV}
303 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
304 .if empty(.MAKEFLAGS:M-n)
305 IMAKEENV+=      PATH=${STRICTTMPPATH}:${INSTALLTMP} \
306                 LD_LIBRARY_PATH=${INSTALLTMP} \
307                 PATH_LOCALE=${INSTALLTMP}/locale
308 IMAKE+=         __MAKE_SHELL=${INSTALLTMP}/sh
309 .else
310 IMAKEENV+=      PATH=${TMPPATH}:${INSTALLTMP}
311 .endif
312
313 # kernel stage
314 KMAKEENV=       ${WMAKEENV}
315 KMAKE=          ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
316
317 #
318 # buildworld
319 #
320 # Attempt to rebuild the entire system, with reasonable chance of
321 # success, regardless of how old your existing system is.
322 #
323 _worldtmp:
324 .if ${.CURDIR:C/[^,]//g} != ""
325 #       The m4 build of sendmail files doesn't like it if ',' is used
326 #       anywhere in the path of it's files.
327         @echo
328         @echo "*** Error: path to source tree contains a comma ','"
329         @echo
330         false
331 .endif
332         @echo
333         @echo "--------------------------------------------------------------"
334         @echo ">>> Rebuilding the temporary build tree"
335         @echo "--------------------------------------------------------------"
336 .if !defined(NO_CLEAN)
337         rm -rf ${WORLDTMP}
338 .if ${TARGET_ARCH} == "amd64"
339         rm -rf ${LIB32TMP}
340 .endif
341 .else
342         rm -rf ${WORLDTMP}/legacy/usr/include
343 #       XXX - These three can depend on any header file.
344         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
345         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
346         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
347 .endif
348 .for _dir in \
349     lib usr legacy/usr
350         mkdir -p ${WORLDTMP}/${_dir}
351 .endfor
352         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
353             -p ${WORLDTMP}/legacy/usr >/dev/null
354         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
355             -p ${WORLDTMP}/usr >/dev/null
356         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
357             -p ${WORLDTMP}/usr/include >/dev/null
358         ln -sf ${.CURDIR}/sys ${WORLDTMP}
359 .if ${MK_BIND_LIBS} != "no"
360         mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
361             -p ${WORLDTMP}/usr/include >/dev/null
362 .endif
363 _legacy:
364         @echo
365         @echo "--------------------------------------------------------------"
366         @echo ">>> stage 1.1: legacy release compatibility shims"
367         @echo "--------------------------------------------------------------"
368         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
369 _bootstrap-tools:
370         @echo
371         @echo "--------------------------------------------------------------"
372         @echo ">>> stage 1.2: bootstrap tools"
373         @echo "--------------------------------------------------------------"
374         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
375 _cleanobj:
376 .if !defined(NO_CLEAN)
377         @echo
378         @echo "--------------------------------------------------------------"
379         @echo ">>> stage 2.1: cleaning up the object tree"
380         @echo "--------------------------------------------------------------"
381         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
382 .if ${TARGET_ARCH} == "amd64"
383         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
384 .endif
385 .endif
386 _obj:
387         @echo
388         @echo "--------------------------------------------------------------"
389         @echo ">>> stage 2.2: rebuilding the object tree"
390         @echo "--------------------------------------------------------------"
391         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
392 _build-tools:
393         @echo
394         @echo "--------------------------------------------------------------"
395         @echo ">>> stage 2.3: build tools"
396         @echo "--------------------------------------------------------------"
397         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
398 _cross-tools:
399         @echo
400         @echo "--------------------------------------------------------------"
401         @echo ">>> stage 3: cross tools"
402         @echo "--------------------------------------------------------------"
403         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
404 _includes:
405         @echo
406         @echo "--------------------------------------------------------------"
407         @echo ">>> stage 4.1: building includes"
408         @echo "--------------------------------------------------------------"
409         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
410 _libraries:
411         @echo
412         @echo "--------------------------------------------------------------"
413         @echo ">>> stage 4.2: building libraries"
414         @echo "--------------------------------------------------------------"
415         ${_+_}cd ${.CURDIR}; \
416             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
417             -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
418 _depend:
419         @echo
420         @echo "--------------------------------------------------------------"
421         @echo ">>> stage 4.3: make dependencies"
422         @echo "--------------------------------------------------------------"
423         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
424 everything:
425         @echo
426         @echo "--------------------------------------------------------------"
427         @echo ">>> stage 4.4: building everything"
428         @echo "--------------------------------------------------------------"
429         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
430 .if ${TARGET_ARCH} == "amd64"
431 build32:
432         @echo
433         @echo "--------------------------------------------------------------"
434         @echo ">>> stage 5.1: building 32 bit shim libraries"
435         @echo "--------------------------------------------------------------"
436         mkdir -p ${LIB32TMP}/usr/lib32
437         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
438             -p ${LIB32TMP}/usr >/dev/null
439         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
440             -p ${LIB32TMP}/usr/include >/dev/null
441         mkdir -p ${WORLDTMP}
442         ln -sf ${.CURDIR}/sys ${WORLDTMP}
443 .if ${MK_KERBEROS} != "no"
444 .for _t in obj depend all
445         cd ${.CURDIR}/kerberos5/tools; \
446             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
447             ${_t}
448 .endfor
449 .endif
450 .for _t in obj includes
451         cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
452         cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
453 .if ${MK_CDDL} != "no"
454         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
455 .endif
456         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
457 .if ${MK_CRYPT} != "no"
458         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
459 .endif
460 .if ${MK_KERBEROS} != "no"
461         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
462 .endif
463 .endfor
464 .for _dir in usr.bin/lex/lib
465         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
466 .endfor
467 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
468         cd ${.CURDIR}/${_dir}; \
469             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
470             build-tools
471 .endfor
472         cd ${.CURDIR}; \
473             ${LIB32WMAKE} -f Makefile.inc1 libraries
474 .for _t in obj depend all
475         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
476         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
477 .endfor
478
479 distribute32 install32:
480 .if make(distribute32)
481         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
482         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace    # XXX add to mtree
483 .else
484         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
485         mkdir -p ${DESTDIR}/usr/lib32/dtrace            # XXX add to mtree
486 .endif
487         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
488 .if ${MK_CDDL} != "no"
489         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
490 .endif
491         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
492 .if ${MK_CRYPT} != "no"
493         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
494 .endif
495 .if ${MK_KERBEROS} != "no"
496         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
497 .endif
498         cd ${.CURDIR}/libexec/rtld-elf; \
499             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
500         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
501 .endif
502
503 WMAKE_TGTS=
504 .if !defined(SUBDIR_OVERRIDE)
505 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
506 .endif
507 WMAKE_TGTS+=    _cleanobj _obj _build-tools
508 .if !defined(SUBDIR_OVERRIDE)
509 WMAKE_TGTS+=    _cross-tools
510 .endif
511 WMAKE_TGTS+=    _includes _libraries _depend everything
512 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
513 WMAKE_TGTS+=    build32
514 .endif
515
516 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
517 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
518
519 buildworld_prologue:
520         @echo "--------------------------------------------------------------"
521         @echo ">>> World build started on `LC_ALL=C date`"
522         @echo "--------------------------------------------------------------"
523
524 buildworld_epilogue:
525         @echo
526         @echo "--------------------------------------------------------------"
527         @echo ">>> World build completed on `LC_ALL=C date`"
528         @echo "--------------------------------------------------------------"
529
530 #
531 # We need to have this as a target because the indirection between Makefile
532 # and Makefile.inc1 causes the correct PATH to be used, rather than a
533 # modification of the current environment's PATH.  In addition, we need
534 # to quote multiword values.
535 #
536 buildenvvars:
537         @echo ${WMAKEENV:Q}
538
539 buildenv:
540         @echo Entering world for ${TARGET_ARCH}:${TARGET}
541         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
542
543 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
544 toolchain: ${TOOLCHAIN_TGTS}
545 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
546
547 #
548 # installcheck
549 #
550 # Checks to be sure system is ready for installworld/installkernel.
551 #
552 installcheck:
553
554 #
555 # Require DESTDIR to be set if installing for a different architecture.
556 #
557 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
558 .if !make(distributeworld)
559 installcheck: installcheck_DESTDIR
560 installcheck_DESTDIR:
561 .if !defined(DESTDIR) || empty(DESTDIR)
562         @echo "ERROR: Please set DESTDIR!"; \
563         false
564 .endif
565 .endif
566 .endif
567
568 #
569 # Check for missing UIDs/GIDs.
570 #
571 CHECK_UIDS=
572 CHECK_GIDS=     audit
573 .if ${MK_SENDMAIL} != "no"
574 CHECK_UIDS+=    smmsp
575 CHECK_GIDS+=    smmsp
576 .endif
577 .if ${MK_PF} != "no"
578 CHECK_UIDS+=    proxy
579 CHECK_GIDS+=    proxy authpf
580 .endif
581 installcheck: installcheck_UGID
582 installcheck_UGID:
583 .for uid in ${CHECK_UIDS}
584         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
585                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
586                 false; \
587         fi
588 .endfor
589 .for gid in ${CHECK_GIDS}
590         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
591                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
592                 false; \
593         fi
594 .endfor
595
596 #
597 # Required install tools to be saved in a scratch dir for safety.
598 #
599 .if ${MK_INFO} != "no"
600 _install-info=  install-info
601 .endif
602 .if ${MK_ZONEINFO} != "no"
603 _zoneinfo=      zic tzsetup
604 .endif
605
606 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
607         date echo egrep find grep ${_install-info} \
608         ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
609         test true uname wc ${_zoneinfo}
610
611 #
612 # distributeworld
613 #
614 # Distributes everything compiled by a `buildworld'.
615 #
616 # installworld
617 #
618 # Installs everything compiled by a 'buildworld'.
619 #
620 distributeworld installworld: installcheck
621         mkdir -p ${INSTALLTMP}
622         progs=$$(for prog in ${ITOOLS}; do \
623                 if progpath=`which $$prog`; then \
624                         echo $$progpath; \
625                 else \
626                         echo "Required tool $$prog not found in PATH." >&2; \
627                         exit 1; \
628                 fi; \
629             done); \
630         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
631             while read line; do \
632                 set -- $$line; \
633                 if [ "$$2 $$3" != "not found" ]; then \
634                         echo $$2; \
635                 else \
636                         echo "Required library $$1 not found." >&2; \
637                         exit 1; \
638                 fi; \
639             done); \
640         cp $$libs $$progs ${INSTALLTMP}
641         cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
642         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
643             ${IMAKEENV} rm -rf ${INSTALLTMP}
644
645 #
646 # reinstall
647 #
648 # If you have a build server, you can NFS mount the source and obj directories
649 # and do a 'make reinstall' on the *client* to install new binaries from the
650 # most recent server build.
651 #
652 reinstall:
653         @echo "--------------------------------------------------------------"
654         @echo ">>> Making hierarchy"
655         @echo "--------------------------------------------------------------"
656         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
657         @echo
658         @echo "--------------------------------------------------------------"
659         @echo ">>> Installing everything"
660         @echo "--------------------------------------------------------------"
661         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
662 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
663         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
664 .endif
665
666 redistribute:
667         @echo "--------------------------------------------------------------"
668         @echo ">>> Distributing everything"
669         @echo "--------------------------------------------------------------"
670         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
671 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
672         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
673             DISTRIBUTION=lib32
674 .endif
675
676 distrib-dirs distribution:
677         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
678
679 #
680 # buildkernel and installkernel
681 #
682 # Which kernels to build and/or install is specified by setting
683 # KERNCONF. If not defined a GENERIC kernel is built/installed.
684 # Only the existing (depending TARGET) config files are used
685 # for building kernels and only the first of these is designated
686 # as the one being installed.
687 #
688 # Note that we have to use TARGET instead of TARGET_ARCH when
689 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
690 # be set to cross-build, we have to make sure TARGET is set
691 # properly.
692
693 .if defined(KERNFAST)
694 NO_KERNELCLEAN= t
695 NO_KERNELCONFIG=        t
696 NO_KERNELDEPEND=        t
697 NO_KERNELOBJ=           t
698 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
699 .if !defined(KERNCONF) && ${KERNFAST} != "1"
700 KERNCONF=${KERNFAST}
701 .endif
702 .endif
703 .if !defined(KERNCONF) && defined(KERNEL)
704 KERNCONF=       ${KERNEL}
705 KERNWARN=
706 .else
707 KERNCONF?=      GENERIC
708 .endif
709 INSTKERNNAME?=  kernel
710
711 KERNSRCDIR?=    ${.CURDIR}/sys
712 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
713 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
714 KERNCONFDIR?=   ${KRNLCONFDIR}
715
716 BUILDKERNELS=
717 INSTALLKERNEL=
718 .for _kernel in ${KERNCONF}
719 .if exists(${KERNCONFDIR}/${_kernel})
720 BUILDKERNELS+=  ${_kernel}
721 .if empty(INSTALLKERNEL)
722 INSTALLKERNEL= ${_kernel}
723 .endif
724 .endif
725 .endfor
726
727 #
728 # buildkernel
729 #
730 # Builds all kernels defined by BUILDKERNELS.
731 #
732 buildkernel:
733 .if empty(BUILDKERNELS)
734         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
735         false
736 .endif
737 .if defined(KERNWARN)
738         @echo "--------------------------------------------------------------"
739         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
740         @echo "--------------------------------------------------------------"
741         @sleep 3
742 .endif
743         @echo
744 .for _kernel in ${BUILDKERNELS}
745         @echo "--------------------------------------------------------------"
746         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
747         @echo "--------------------------------------------------------------"
748         @echo "===> ${_kernel}"
749         mkdir -p ${KRNLOBJDIR}
750 .if !defined(NO_KERNELCONFIG)
751         @echo
752         @echo "--------------------------------------------------------------"
753         @echo ">>> stage 1: configuring the kernel"
754         @echo "--------------------------------------------------------------"
755         cd ${KRNLCONFDIR}; \
756                 PATH=${TMPPATH} \
757                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
758                         ${KERNCONFDIR}/${_kernel}
759 .endif
760 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
761         @echo
762         @echo "--------------------------------------------------------------"
763         @echo ">>> stage 2.1: cleaning up the object tree"
764         @echo "--------------------------------------------------------------"
765         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
766 .endif
767 .if !defined(NO_KERNELOBJ)
768         @echo
769         @echo "--------------------------------------------------------------"
770         @echo ">>> stage 2.2: rebuilding the object tree"
771         @echo "--------------------------------------------------------------"
772         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
773 .endif
774         @echo
775         @echo "--------------------------------------------------------------"
776         @echo ">>> stage 2.3: build tools"
777         @echo "--------------------------------------------------------------"
778         cd ${KRNLOBJDIR}/${_kernel}; \
779             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
780             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \
781             -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
782 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
783 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
784 .for target in obj depend all
785         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
786             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
787             ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
788 .endfor
789 .endif
790 .if !defined(NO_KERNELDEPEND)
791         @echo
792         @echo "--------------------------------------------------------------"
793         @echo ">>> stage 3.1: making dependencies"
794         @echo "--------------------------------------------------------------"
795         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
796 .endif
797         @echo
798         @echo "--------------------------------------------------------------"
799         @echo ">>> stage 3.2: building everything"
800         @echo "--------------------------------------------------------------"
801         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
802         @echo "--------------------------------------------------------------"
803         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
804         @echo "--------------------------------------------------------------"
805 .endfor
806
807 #
808 # installkernel, etc.
809 #
810 # Install the kernel defined by INSTALLKERNEL
811 #
812 installkernel installkernel.debug \
813 reinstallkernel reinstallkernel.debug: installcheck
814 .if empty(INSTALLKERNEL)
815         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
816         false
817 .endif
818         @echo "--------------------------------------------------------------"
819         @echo ">>> Installing kernel"
820         @echo "--------------------------------------------------------------"
821         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
822             ${CROSSENV} PATH=${TMPPATH} \
823             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
824
825 #
826 # doxygen
827 #
828 # Build the API documentation with doxygen
829 #
830 doxygen:
831         @if [ ! -x `/usr/bin/which doxygen` ]; then \
832                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
833                 exit 1; \
834         fi
835         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
836
837 #
838 # update
839 #
840 # Update the source tree, by running cvsup and/or running cvs to update to the
841 # latest copy.
842 #
843 update:
844 .if defined(SUP_UPDATE)
845         @echo "--------------------------------------------------------------"
846         @echo ">>> Running ${SUP}"
847         @echo "--------------------------------------------------------------"
848 .if defined(SUPFILE)
849         @${SUP} ${SUPFLAGS} ${SUPFILE}
850 .endif
851 .if defined(SUPFILE1)
852         @${SUP} ${SUPFLAGS} ${SUPFILE1}
853 .endif
854 .if defined(SUPFILE2)
855         @${SUP} ${SUPFLAGS} ${SUPFILE2}
856 .endif
857 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
858         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
859 .endif
860 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
861         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
862 .endif
863 .endif
864 .if defined(CVS_UPDATE)
865         @cd ${.CURDIR} ; \
866         if [ -d CVS ] ; then \
867                 echo "--------------------------------------------------------------" ; \
868                 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
869                 echo "--------------------------------------------------------------" ; \
870                 echo ${CVS} -R -q update ${CVSFLAGS} ; \
871                 ${CVS} -R -q update ${CVSFLAGS} ; \
872         fi
873 .endif
874 .if defined(SVN_UPDATE)
875         @cd ${.CURDIR} ; \
876         if [ -d .svn ] ; then \
877                 echo "--------------------------------------------------------------" ; \
878                 echo ">>> Updating ${.CURDIR} using Subversion" ; \
879                 echo "--------------------------------------------------------------" ; \
880                 echo ${SVN} update ${SVNFLAGS} ; \
881                 ${SVN} update ${SVNFLAGS} ; \
882         fi
883 .endif
884
885 #
886 # ------------------------------------------------------------------------
887 #
888 # From here onwards are utility targets used by the 'make world' and
889 # related targets.  If your 'world' breaks, you may like to try to fix
890 # the problem and manually run the following targets to attempt to
891 # complete the build.  Beware, this is *not* guaranteed to work, you
892 # need to have a pretty good grip on the current state of the system
893 # to attempt to manually finish it.  If in doubt, 'make world' again.
894 #
895
896 #
897 # legacy: Build compatibility shims for the next three targets
898 #
899 legacy:
900 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
901         @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
902         false
903 .endif
904 .for _tool in tools/build
905         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
906             cd ${.CURDIR}/${_tool}; \
907             ${MAKE} DIRPRFX=${_tool}/ obj; \
908             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
909             ${MAKE} DIRPRFX=${_tool}/ depend; \
910             ${MAKE} DIRPRFX=${_tool}/ all; \
911             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
912 .endfor
913
914 #
915 # bootstrap-tools: Build tools needed for compatibility
916 #
917 .if ${MK_GAMES} != "no"
918 _strfile=       games/fortune/strfile
919 .endif
920
921 .if ${MK_CXX} != "no"
922 _gperf=         gnu/usr.bin/gperf
923 .if ${BOOTSTRAPPING} < 700004
924 _groff=         gnu/usr.bin/groff
925 .else
926 _groff=         gnu/usr.bin/groff/tmac
927 .endif
928 .endif
929
930 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
931 _ar=            usr.bin/ar
932 .endif
933
934 .if ${BOOTSTRAPPING} < 800013
935 _mklocale=      usr.bin/mklocale
936 .endif
937
938 .if ${BOOTSTRAPPING} < 900002
939 _sed=           usr.bin/sed
940 .endif
941
942 .if ${BOOTSTRAPPING} < 900006
943 _lex=           usr.bin/lex
944 _yacc=          usr.bin/yacc
945 .endif
946
947 .if ${BOOTSTRAPPING} < 700018
948 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
949 .endif
950
951 .if ${MK_RESCUE} != "no" && \
952     ${BOOTSTRAPPING} < 700026
953 _crunchgen=     usr.sbin/crunch/crunchgen
954 .endif
955
956 .if ${MK_CDDL} != "no"
957 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
958     lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
959 .endif
960
961 bootstrap-tools:
962 .for _tool in \
963     ${_dtrace_tools} \
964     ${_strfile} \
965     ${_gperf} \
966     ${_groff} \
967     ${_ar} \
968     usr.bin/lorder \
969     usr.bin/makewhatis \
970     ${_mklocale} \
971     usr.bin/rpcgen \
972     ${_sed} \
973     ${_lex} \
974     ${_yacc} \
975     usr.bin/xinstall \
976     ${_gensnmptree} \
977     usr.sbin/config \
978     ${_crunchgen}
979         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
980                 cd ${.CURDIR}/${_tool}; \
981                 ${MAKE} DIRPRFX=${_tool}/ obj; \
982                 ${MAKE} DIRPRFX=${_tool}/ depend; \
983                 ${MAKE} DIRPRFX=${_tool}/ all; \
984                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
985 .endfor
986
987 #
988 # build-tools: Build special purpose build tools
989 #
990 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
991 _aicasm= sys/modules/aic7xxx/aicasm
992 .endif
993
994 .if !defined(NO_SHARE)
995 _share= share/syscons/scrnmaps
996 .endif
997
998 .if ${MK_KERBEROS} != "no"
999 _kerberos5_tools= kerberos5/tools
1000 .endif
1001
1002 .if ${MK_RESCUE} != "no"
1003 _rescue= rescue/rescue
1004 .endif
1005
1006 build-tools:
1007 .for _tool in \
1008     bin/csh \
1009     bin/sh \
1010     ${_rescue} \
1011     lib/ncurses/ncurses \
1012     lib/ncurses/ncursesw \
1013     ${_share} \
1014     ${_aicasm} \
1015     usr.bin/awk \
1016     lib/libmagic \
1017     usr.sbin/sysinstall
1018         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1019                 cd ${.CURDIR}/${_tool}; \
1020                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1021                 ${MAKE} DIRPRFX=${_tool}/ build-tools
1022 .endfor
1023 .for _tool in \
1024     gnu/usr.bin/cc/cc_tools \
1025     ${_kerberos5_tools}
1026         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1027                 cd ${.CURDIR}/${_tool}; \
1028                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1029                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1030                 ${MAKE} DIRPRFX=${_tool}/ all
1031 .endfor
1032
1033 #
1034 # cross-tools: Build cross-building tools
1035 #
1036 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1037 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1038 _btxld=         usr.sbin/btxld
1039 .endif
1040 .endif
1041 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1042 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1043 _crunchide=     usr.sbin/crunch/crunchide
1044 .endif
1045 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1046 _kgzip=         usr.sbin/kgzip
1047 .endif
1048 .endif
1049
1050 cross-tools:
1051 .for _tool in \
1052     gnu/usr.bin/binutils \
1053     gnu/usr.bin/cc \
1054     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1055     ${_btxld} \
1056     ${_crunchide} \
1057     ${_kgzip}
1058         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1059                 cd ${.CURDIR}/${_tool}; \
1060                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1061                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1062                 ${MAKE} DIRPRFX=${_tool}/ all; \
1063                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1064 .endfor
1065
1066 #
1067 # hierarchy - ensure that all the needed directories are present
1068 #
1069 hierarchy:
1070         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
1071
1072 #
1073 # libraries - build all libraries, and install them under ${DESTDIR}.
1074 #
1075 # The list of libraries with dependents (${_prebuild_libs}) and their
1076 # interdependencies (__L) are built automatically by the
1077 # ${.CURDIR}/tools/make_libdeps.sh script.
1078 #
1079 libraries:
1080         cd ${.CURDIR}; \
1081             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1082             ${MAKE} -f Makefile.inc1 _startup_libs; \
1083             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1084             ${MAKE} -f Makefile.inc1 _generic_libs;
1085
1086 #
1087 # static libgcc.a prerequisite for shared libc
1088 #
1089 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc
1090
1091 # These dependencies are not automatically generated:
1092 #
1093 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1094 # all shared libraries for ELF.
1095 #
1096 _startup_libs=  gnu/lib/csu
1097 .if exists(${.CURDIR}/lib/csu/${MACHINE_CPUARCH}-elf)
1098 _startup_libs+= lib/csu/${MACHINE_CPUARCH}-elf
1099 .else
1100 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1101 .endif
1102 _startup_libs+= gnu/lib/libgcc
1103 _startup_libs+= lib/libc
1104
1105 gnu/lib/libgcc__L: lib/libc__L
1106
1107 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1108                 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1109                 ${_kerberos5_lib_libroken} \
1110                 lib/libbz2 lib/libcom_err lib/libcrypt \
1111                 lib/libexpat \
1112                 ${_lib_libgssapi} ${_lib_libipx} \
1113                 lib/libkiconv lib/libkvm lib/libmd \
1114                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1115                 lib/libopie lib/libpam ${_lib_libthr} \
1116                 lib/libradius lib/libsbuf lib/libtacplus \
1117                 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1118                 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1119                 ${_secure_lib_libssl}
1120
1121 .if ${MK_LIBTHR} != "no"
1122 _lib_libthr=    lib/libthr
1123 .endif
1124
1125 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1126
1127 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1128
1129 .if ${MK_CDDL} != "no"
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} ${OLD_FILES:Musr/share/*.gz:R}; 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} ${OLD_FILES:Musr/share/*.gz:R}; 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