]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
To make sure build of newer RELENG_6 on older ones work,
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6 #       -DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7 #       -DNO_RESCUE do not build rescue binaries
8 #       -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9 #       -DNO_CLEAN do not clean at all
10 #       -DNO_CRYPT will prevent building of crypt versions
11 #       -DNO_MAN do not build the manual pages
12 #       -DNO_NLS do not build Native Language Support files
13 #       -DNO_PROFILE do not build profiled libraries
14 #       -DNO_GAMES do not go into games subdir
15 #       -DNO_SHARE do not go into share subdir
16 #       -DNO_INFO do not make or install info files
17 #       -DNO_LIBC_R do not build libc_r.
18 #       -DNO_FORTRAN do not build g77 and related libraries.
19 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
20 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
21 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
22 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
23 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
24 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
25 #       TARGET="machine" to crossbuild world for a different machine type
26
27 #
28 # The intended user-driven targets are:
29 # buildworld  - rebuild *everything*, including glue to help do upgrades
30 # installworld- install everything built by "buildworld"
31 # update      - convenient way to update your source tree (eg: cvsup/cvs)
32 #
33 # Standard targets (not defined here) are documented in the makefiles in
34 # /usr/share/mk.  These include:
35 #               obj depend all install clean cleandepend cleanobj
36
37 # We must do share/info early so that installation of info `dir'
38 # entries works correctly.  Do it first since it is less likely to
39 # grow dependencies on include and lib than vice versa.
40 #
41 # We must do lib and libexec before bin, because if installworld
42 # installs a new /bin/sh, the 'make' command will *immediately*
43 # use that new version.  And the new (dynamically-linked) /bin/sh
44 # will expect to find appropriate libraries in /lib and /libexec.
45 #
46 # We must do etc last for install/distribute to work.
47 #
48 SUBDIR= share/info include lib libexec bin
49 .if !defined(NO_GAMES)
50 SUBDIR+=games
51 .endif
52 SUBDIR+=gnu
53 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
54 SUBDIR+=kerberos5
55 .endif
56 .if !defined(NO_RESCUE)
57 SUBDIR+=rescue
58 .endif
59 SUBDIR+=sbin
60 .if !defined(NO_CRYPT)
61 SUBDIR+=secure
62 .endif
63 .if !defined(NO_SHARE)
64 SUBDIR+=share
65 .endif
66 SUBDIR+=sys usr.bin usr.sbin etc
67
68 # These are last, since it is nice to at least get the base system
69 # rebuilt before you do them.
70 .for _DIR in ${LOCAL_DIRS}
71 .if exists(${.CURDIR}/${_DIR}/Makefile)
72 SUBDIR+= ${_DIR}
73 .endif
74 .endfor
75
76 .if defined(SUBDIR_OVERRIDE)
77 SUBDIR=         ${SUBDIR_OVERRIDE}
78 .endif
79
80 .if defined(NOCLEAN)
81 NO_CLEAN=       ${NOCLEAN}
82 .endif
83 .if defined(NO_CLEANDIR)
84 CLEANDIR=       clean cleandepend
85 .else
86 CLEANDIR=       cleandir
87 .endif
88
89 CVS?=           cvs
90 CVSFLAGS?=      -r RELENG_6 -P -d -I!
91 SUP?=           /usr/bin/csup
92 SUPFLAGS?=      -g -L 2
93 .if defined(SUPHOST)
94 SUPFLAGS+=      -h ${SUPHOST}
95 .endif
96
97 MAKEOBJDIRPREFIX?=      /usr/obj
98 .if !defined(OSRELDATE)
99 .if exists(/usr/include/osreldate.h)
100 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
101                 /usr/include/osreldate.h
102 .else
103 OSRELDATE=      0
104 .endif
105 .endif
106
107 # Guess machine architecture from machine type, and vice versa.
108 .if !defined(TARGET_ARCH) && defined(TARGET)
109 TARGET_ARCH=    ${TARGET:S/pc98/i386/}
110 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
111     ${TARGET_ARCH} != ${MACHINE_ARCH}
112 TARGET=         ${TARGET_ARCH}
113 .endif
114 # Otherwise, default to current machine type and architecture.
115 TARGET?=        ${MACHINE}
116 TARGET_ARCH?=   ${MACHINE_ARCH}
117
118 KNOWN_ARCHES?=  alpha amd64 arm i386 i386/pc98 ia64 powerpc sparc64
119 .if ${TARGET} == ${TARGET_ARCH}
120 _t=             ${TARGET}
121 .else
122 _t=             ${TARGET_ARCH}/${TARGET}
123 .endif
124 .for _t in ${_t}
125 .if empty(KNOWN_ARCHES:M${_t})
126 .error Unknown target ${TARGET_ARCH}:${TARGET}.
127 .endif
128 .endfor
129
130 .if ${TARGET} == ${MACHINE}
131 TARGET_CPUTYPE?=${CPUTYPE}
132 .else
133 TARGET_CPUTYPE?=
134 .endif
135
136 .if !empty(TARGET_CPUTYPE)
137 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
138 .else
139 _TARGET_CPUTYPE=dummy
140 .endif
141 _CPUTYPE!=      MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
142                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
143 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
144 .error CPUTYPE global should be set with ?=.
145 .endif
146 .if make(buildworld)
147 BUILD_ARCH!=    sysctl -n hw.machine_arch
148 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
149 .error To cross-build, set TARGET_ARCH.
150 .endif
151 .endif
152 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
153 OBJTREE=        ${MAKEOBJDIRPREFIX}
154 .else
155 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
156 .endif
157 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
158 # /usr/games added for fortune which depend on strfile
159 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
160 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
161 STRICTTMPPATH=  ${BPATH}:${XPATH}
162 TMPPATH=        ${STRICTTMPPATH}:${PATH}
163
164 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
165
166 #
167 # Building a world goes through the following stages
168 #
169 # 1. legacy stage [BMAKE]
170 #       This stage is responsible for creating compatibility
171 #       shims that are needed by the bootstrap-tools,
172 #       build-tools and cross-tools stages.
173 # 1. bootstrap-tools stage [BMAKE]
174 #       This stage is responsible for creating programs that
175 #       are needed for backward compatibility reasons. They
176 #       are not built as cross-tools.
177 # 2. build-tools stage [TMAKE]
178 #       This stage is responsible for creating the object
179 #       tree and building any tools that are needed during
180 #       the build process.
181 # 3. cross-tools stage [XMAKE]
182 #       This stage is responsible for creating any tools that
183 #       are needed for cross-builds. A cross-compiler is one
184 #       of them.
185 # 4. world stage [WMAKE]
186 #       This stage actually builds the world.
187 # 5. install stage (optional) [IMAKE]
188 #       This stage installs a previously built world.
189 #
190
191 BOOTSTRAPPING?= 0
192
193 # Common environment for world related stages
194 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
195                 MACHINE_ARCH=${TARGET_ARCH} \
196                 MACHINE=${TARGET} \
197                 CPUTYPE=${TARGET_CPUTYPE} \
198                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
199                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
200                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
201
202 # bootstrap-tools stage
203 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
204                 PATH=${BPATH}:${PATH} \
205                 WORLDTMP=${WORLDTMP} \
206                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
207 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
208                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
209                 DESTDIR= \
210                 BOOTSTRAPPING=${OSRELDATE} \
211                 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
212                 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
213
214 # build-tools stage
215 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
216                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
217                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
218                 DESTDIR= \
219                 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
220
221 # cross-tools stage
222 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
223                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
224                 -DNO_FORTRAN -DNO_GDB
225
226 # world stage
227 WMAKEENV=       ${CROSSENV} \
228                 _SHLIBDIRPREFIX=${WORLDTMP} \
229                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
230                 PATH=${TMPPATH}
231 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
232
233 .if ${TARGET_ARCH} == "amd64"
234 # 32 bit world
235 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
236
237 LIB32PREFLAGS=  -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
238 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
239                 -L${LIB32TMP}/usr/lib32 \
240                 -B${LIB32TMP}/usr/lib32
241 LIB32CC=        ${LIB32PREFLAGS} \
242                 ${LIB32POSTFLAGS}
243 LIB32CXX=       ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
244                 ${LIB32POSTFLAGS}
245 LIB32OBJC=      ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
246                 ${LIB32POSTFLAGS}
247
248 # Yes, the flags are redundant.
249 LIB32MAKEENV=   MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
250                 _SHLIBDIRPREFIX=${LIB32TMP} \
251                 MACHINE=i386 \
252                 MACHINE_ARCH=i386 \
253                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
254                 PATH=${TMPPATH} \
255                 CC="${CC} ${LIB32CC}" \
256                 CXX="${CXX} ${LIB32CXX}" \
257                 OBJC="${OBJC} ${LIB32OBJC}" \
258                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
259                 AS="${AS} --32" \
260                 LIBDIR=/usr/lib32 \
261                 SHLIBDIR=/usr/lib32
262
263 LIB32MAKE=      ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
264                 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
265 LIB32IMAKE=     ${LIB32MAKE:NINSTALL=*} -DNO_INCS
266 .endif
267
268 # install stage
269 .if empty(.MAKEFLAGS:M-n)
270 IMAKEENV=       ${CROSSENV} \
271                 PATH=${STRICTTMPPATH}:${INSTALLTMP}
272 .else
273 IMAKEENV=       ${CROSSENV} \
274                 PATH=${TMPPATH}:${INSTALLTMP}
275 .endif
276 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
277
278 # kernel stage
279 KMAKEENV=       ${WMAKEENV}
280
281 #
282 # buildworld
283 #
284 # Attempt to rebuild the entire system, with reasonable chance of
285 # success, regardless of how old your existing system is.
286 #
287 _worldtmp:
288 .if ${.CURDIR:C/[^,]//g} != ""
289 #       The m4 build of sendmail files doesn't like it if ',' is used
290 #       anywhere in the path of it's files.
291         @echo
292         @echo "*** Error: path to source tree contains a comma ','"
293         @echo
294         false
295 .endif
296         @echo
297         @echo "--------------------------------------------------------------"
298         @echo ">>> Rebuilding the temporary build tree"
299         @echo "--------------------------------------------------------------"
300 .if !defined(NO_CLEAN)
301         rm -rf ${WORLDTMP}
302 .if ${TARGET_ARCH} == "amd64"
303         rm -rf ${LIB32TMP}
304 .endif
305 .else
306         rm -rf ${WORLDTMP}/legacy/usr/include
307         # XXX - These two can depend on any header file.
308         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
309         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
310 .endif
311 .for _dir in \
312     usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
313     usr/libexec usr/sbin usr/share/dict \
314     usr/share/groff_font/devX100 \
315     usr/share/groff_font/devX100-12 \
316     usr/share/groff_font/devX75 \
317     usr/share/groff_font/devX75-12 \
318     usr/share/groff_font/devascii \
319     usr/share/groff_font/devcp1047 \
320     usr/share/groff_font/devdvi \
321     usr/share/groff_font/devhtml \
322     usr/share/groff_font/devkoi8-r \
323     usr/share/groff_font/devlatin1 \
324     usr/share/groff_font/devlbp \
325     usr/share/groff_font/devlj4 \
326     usr/share/groff_font/devps \
327     usr/share/groff_font/devutf8 \
328     usr/share/tmac/mdoc usr/share/tmac/mm
329         mkdir -p ${WORLDTMP}/legacy/${_dir}
330 .endfor
331 .for _dir in \
332     lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
333     usr/libexec usr/sbin usr/share/misc \
334     usr/share/snmp/defs usr/share/snmp/mibs
335         mkdir -p ${WORLDTMP}/${_dir}
336 .endfor
337         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
338             -p ${WORLDTMP}/usr/include >/dev/null
339         ln -sf ${.CURDIR}/sys ${WORLDTMP}
340 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
341         mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
342             -p ${WORLDTMP}/usr/include >/dev/null
343 .endif
344 _legacy:
345         @echo
346         @echo "--------------------------------------------------------------"
347         @echo ">>> stage 1.1: legacy release compatibility shims"
348         @echo "--------------------------------------------------------------"
349         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
350 _bootstrap-tools:
351         @echo
352         @echo "--------------------------------------------------------------"
353         @echo ">>> stage 1.2: bootstrap tools"
354         @echo "--------------------------------------------------------------"
355         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
356 _cleanobj:
357 .if !defined(NO_CLEAN)
358         @echo
359         @echo "--------------------------------------------------------------"
360         @echo ">>> stage 2.1: cleaning up the object tree"
361         @echo "--------------------------------------------------------------"
362         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
363 .if ${TARGET_ARCH} == "amd64"
364         rm -rf ${OBJTREE}/lib32
365 .endif
366 .endif
367 _obj:
368         @echo
369         @echo "--------------------------------------------------------------"
370         @echo ">>> stage 2.2: rebuilding the object tree"
371         @echo "--------------------------------------------------------------"
372         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
373 _build-tools:
374         @echo
375         @echo "--------------------------------------------------------------"
376         @echo ">>> stage 2.3: build tools"
377         @echo "--------------------------------------------------------------"
378         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
379 _cross-tools:
380         @echo
381         @echo "--------------------------------------------------------------"
382         @echo ">>> stage 3: cross tools"
383         @echo "--------------------------------------------------------------"
384         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
385 _includes:
386         @echo
387         @echo "--------------------------------------------------------------"
388         @echo ">>> stage 4.1: building includes"
389         @echo "--------------------------------------------------------------"
390         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
391 _libraries:
392         @echo
393         @echo "--------------------------------------------------------------"
394         @echo ">>> stage 4.2: building libraries"
395         @echo "--------------------------------------------------------------"
396         ${_+_}cd ${.CURDIR}; \
397             ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
398             -DNO_NLS -DNO_PROFILE libraries
399 _depend:
400         @echo
401         @echo "--------------------------------------------------------------"
402         @echo ">>> stage 4.3: make dependencies"
403         @echo "--------------------------------------------------------------"
404         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
405 everything:
406         @echo
407         @echo "--------------------------------------------------------------"
408         @echo ">>> stage 4.4: building everything"
409         @echo "--------------------------------------------------------------"
410         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
411 .if ${TARGET_ARCH} == "amd64"
412 build32:
413         @echo
414         @echo "--------------------------------------------------------------"
415         @echo ">>> stage 5.1: building 32 bit shim libraries"
416         @echo "--------------------------------------------------------------"
417 .for _dir in \
418     lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
419     usr/libexec usr/sbin usr/share/misc \
420     usr/share/snmp/defs usr/share/snmp/mibs
421         mkdir -p ${LIB32TMP}/${_dir}
422 .endfor
423         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
424             -p ${LIB32TMP}/usr/include >/dev/null
425         mkdir -p ${WORLDTMP}
426         ln -sf ${.CURDIR}/sys ${WORLDTMP}
427 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
428 .for _t in obj depend all
429         cd ${.CURDIR}/kerberos5/tools; \
430             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
431 .endfor
432 .endif
433 .for _t in obj includes
434         cd ${.CURDIR}/include; \
435             ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
436         cd ${.CURDIR}/lib; \
437             ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
438         cd ${.CURDIR}/gnu/lib; \
439             ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
440 .if !defined(NO_CRYPT)
441         cd ${.CURDIR}/secure/lib; \
442             ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
443 .endif
444 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
445         cd ${.CURDIR}/kerberos5/lib; \
446             ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
447 .endif
448 .endfor
449 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
450         cd ${.CURDIR}/${_dir}; \
451             ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
452 .endfor
453 .for _dir in lib/libncurses lib/libmagic
454         cd ${.CURDIR}/${_dir}; \
455             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
456 .endfor
457         cd ${.CURDIR}; \
458             ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
459 .for _t in obj depend all
460         cd ${.CURDIR}/libexec/rtld-elf; \
461             PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
462 .endfor
463
464 distribute32 install32:
465 .if make(distribute32)
466         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
467 .else
468         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
469 .endif
470         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
471         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
472 .if !defined(NO_CRYPT)
473         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
474 .endif
475         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
476 .endif
477
478
479 WMAKE_TGTS=
480 .if !defined(SUBDIR_OVERRIDE)
481 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
482 .endif
483 WMAKE_TGTS+=    _cleanobj _obj _build-tools
484 .if !defined(SUBDIR_OVERRIDE)
485 WMAKE_TGTS+=    _cross-tools
486 .endif
487 WMAKE_TGTS+=    _includes _libraries _depend everything
488 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
489 WMAKE_TGTS+=    build32
490 .endif
491
492 buildworld: ${WMAKE_TGTS}
493 .ORDER: ${WMAKE_TGTS}
494
495 buildenv:
496         @echo Entering world for ${TARGET_ARCH}:${TARGET}
497         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
498
499 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
500 toolchain: ${TOOLCHAIN_TGTS}
501 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
502
503 #
504 # Use this to add checks to installworld/installkernel targets.
505 #
506 SPECIAL_INSTALLCHECKS=
507
508 #
509 # Require DESTDIR to be set if installing for a different architecture.
510 #
511 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
512 .if !make(distributeworld)
513 SPECIAL_INSTALLCHECKS+= installcheck_DESTDIR
514 installcheck_DESTDIR:
515 .if !defined(DESTDIR) || empty(DESTDIR)
516         @echo "ERROR: Please set DESTDIR!"; \
517         false
518 .endif
519 .endif
520 .endif
521
522 #
523 # installcheck
524 #
525 # Checks to be sure system is ready for installworld
526 #
527 CHECK_UIDS=
528 CHECK_GIDS=     audit
529 .if !defined(NO_SENDMAIL)
530 CHECK_UIDS+=    smmsp
531 CHECK_GIDS+=    smmsp
532 .endif
533 .if !defined(NO_PF)
534 CHECK_UIDS+=    proxy
535 CHECK_GIDS+=    proxy authpf
536 .endif
537 installcheck: ${SPECIAL_INSTALLCHECKS}
538 .for uid in ${CHECK_UIDS}
539         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
540                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
541                 false; \
542         fi
543 .endfor
544 .for gid in ${CHECK_GIDS}
545         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
546                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
547                 false; \
548         fi
549 .endfor
550
551 #
552 # distributeworld
553 #
554 # Distributes everything compiled by a `buildworld'.
555 #
556 # installworld
557 #
558 # Installs everything compiled by a 'buildworld'.
559 #
560 distributeworld installworld: installcheck
561         mkdir -p ${INSTALLTMP}
562         for prog in [ awk cap_mkdb cat chflags chmod chown \
563             date echo egrep find grep install-info \
564             ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
565             test true uname wc zic; do \
566                 cp `which $$prog` ${INSTALLTMP}; \
567         done
568         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
569         rm -rf ${INSTALLTMP}
570
571 #
572 # reinstall
573 #
574 # If you have a build server, you can NFS mount the source and obj directories
575 # and do a 'make reinstall' on the *client* to install new binaries from the
576 # most recent server build.
577 #
578 reinstall: ${SPECIAL_INSTALLCHECKS}
579         @echo "--------------------------------------------------------------"
580         @echo ">>> Making hierarchy"
581         @echo "--------------------------------------------------------------"
582         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
583         @echo
584         @echo "--------------------------------------------------------------"
585         @echo ">>> Installing everything"
586         @echo "--------------------------------------------------------------"
587         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
588 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
589         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
590 .endif
591
592 redistribute:
593         @echo "--------------------------------------------------------------"
594         @echo ">>> Distributing everything"
595         @echo "--------------------------------------------------------------"
596         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
597 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
598         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
599 .endif
600
601 distrib-dirs distribution:
602         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
603
604 #
605 # buildkernel and installkernel
606 #
607 # Which kernels to build and/or install is specified by setting
608 # KERNCONF. If not defined a GENERIC kernel is built/installed.
609 # Only the existing (depending TARGET) config files are used
610 # for building kernels and only the first of these is designated
611 # as the one being installed.
612 #
613 # Note that we have to use TARGET instead of TARGET_ARCH when
614 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
615 # be set to cross-build, we have to make sure TARGET is set
616 # properly.
617
618 .if !defined(KERNCONF) && defined(KERNEL)
619 KERNCONF=       ${KERNEL}
620 KERNWARN=
621 .else
622 KERNCONF?=      GENERIC
623 .endif
624 INSTKERNNAME?=  kernel
625
626 KERNSRCDIR?=    ${.CURDIR}/sys
627 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
628 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
629 KERNCONFDIR?=   ${KRNLCONFDIR}
630
631 BUILDKERNELS=
632 INSTALLKERNEL=
633 .for _kernel in ${KERNCONF}
634 .if exists(${KERNCONFDIR}/${_kernel})
635 BUILDKERNELS+=  ${_kernel}
636 .if empty(INSTALLKERNEL)
637 INSTALLKERNEL= ${_kernel}
638 .endif
639 .endif
640 .endfor
641
642 #
643 # buildkernel
644 #
645 # Builds all kernels defined by BUILDKERNELS.
646 #
647 buildkernel:
648 .if empty(BUILDKERNELS)
649         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
650         false
651 .endif
652 .if defined(KERNWARN)
653         @echo "--------------------------------------------------------------"
654         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
655         @echo "--------------------------------------------------------------"
656         @sleep 3
657 .endif
658         @echo
659 .for _kernel in ${BUILDKERNELS}
660         @echo "--------------------------------------------------------------"
661         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
662         @echo "--------------------------------------------------------------"
663         @echo "===> ${_kernel}"
664         mkdir -p ${KRNLOBJDIR}
665 .if !defined(NO_KERNELCONFIG)
666         @echo
667         @echo "--------------------------------------------------------------"
668         @echo ">>> stage 1: configuring the kernel"
669         @echo "--------------------------------------------------------------"
670         cd ${KRNLCONFDIR}; \
671                 PATH=${TMPPATH} \
672                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
673                         ${KERNCONFDIR}/${_kernel}
674 .endif
675 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
676         @echo
677         @echo "--------------------------------------------------------------"
678         @echo ">>> stage 2.1: cleaning up the object tree"
679         @echo "--------------------------------------------------------------"
680         cd ${KRNLOBJDIR}/${_kernel}; \
681             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
682 .endif
683         @echo
684         @echo "--------------------------------------------------------------"
685         @echo ">>> stage 2.2: rebuilding the object tree"
686         @echo "--------------------------------------------------------------"
687         cd ${KRNLOBJDIR}/${_kernel}; \
688             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
689         @echo
690         @echo "--------------------------------------------------------------"
691         @echo ">>> stage 2.3: build tools"
692         @echo "--------------------------------------------------------------"
693         cd ${KRNLOBJDIR}/${_kernel}; \
694             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
695             ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
696 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
697 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
698 .for target in obj depend all
699         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
700             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
701             ${MAKE} -DNO_CPU_CFLAGS ${target}
702 .endfor
703 .endif
704 .if !defined(NO_KERNELDEPEND)
705         @echo
706         @echo "--------------------------------------------------------------"
707         @echo ">>> stage 3.1: making dependencies"
708         @echo "--------------------------------------------------------------"
709         cd ${KRNLOBJDIR}/${_kernel}; \
710             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
711 .endif
712         @echo
713         @echo "--------------------------------------------------------------"
714         @echo ">>> stage 3.2: building everything"
715         @echo "--------------------------------------------------------------"
716         cd ${KRNLOBJDIR}/${_kernel}; \
717             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
718         @echo "--------------------------------------------------------------"
719         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
720         @echo "--------------------------------------------------------------"
721 .endfor
722
723 #
724 # installkernel, etc.
725 #
726 # Install the kernel defined by INSTALLKERNEL
727 #
728 installkernel installkernel.debug \
729 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
730 .if empty(INSTALLKERNEL)
731         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
732         false
733 .endif
734         @echo "--------------------------------------------------------------"
735         @echo ">>> Installing kernel"
736         @echo "--------------------------------------------------------------"
737         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
738             ${CROSSENV} PATH=${TMPPATH} \
739             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
740
741 #
742 # update
743 #
744 # Update the source tree, by running cvsup and/or running cvs to update to the
745 # latest copy.
746 #
747 update:
748 .if defined(SUP_UPDATE)
749         @echo "--------------------------------------------------------------"
750         @echo ">>> Running ${SUP}"
751         @echo "--------------------------------------------------------------"
752 .if defined(SUPFILE)
753         @${SUP} ${SUPFLAGS} ${SUPFILE}
754 .endif
755 .if defined(SUPFILE1)
756         @${SUP} ${SUPFLAGS} ${SUPFILE1}
757 .endif
758 .if defined(SUPFILE2)
759         @${SUP} ${SUPFLAGS} ${SUPFILE2}
760 .endif
761 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
762         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
763 .endif
764 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
765         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
766 .endif
767 .endif
768 .if defined(CVS_UPDATE)
769         @echo "--------------------------------------------------------------"
770         @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
771         @echo "--------------------------------------------------------------"
772         cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
773 .endif
774
775 #
776 # ------------------------------------------------------------------------
777 #
778 # From here onwards are utility targets used by the 'make world' and
779 # related targets.  If your 'world' breaks, you may like to try to fix
780 # the problem and manually run the following targets to attempt to
781 # complete the build.  Beware, this is *not* guaranteed to work, you
782 # need to have a pretty good grip on the current state of the system
783 # to attempt to manually finish it.  If in doubt, 'make world' again.
784 #
785
786 #
787 # legacy: Build compatibility shims for the next three targets
788 #
789 legacy:
790 .if ${BOOTSTRAPPING} < 503000
791         @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
792         false
793 .endif
794 .for _tool in tools/build
795         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
796             cd ${.CURDIR}/${_tool}; \
797             ${MAKE} DIRPRFX=${_tool}/ obj; \
798             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
799             ${MAKE} DIRPRFX=${_tool}/ depend; \
800             ${MAKE} DIRPRFX=${_tool}/ all; \
801             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
802 .endfor
803
804 #
805 # bootstrap-tools: Build tools needed for compatibility
806 #
807 .if !defined(NO_GAMES)
808 _strfile=       games/fortune/strfile
809 .endif
810
811 .if !defined(NO_CXX)
812 _gperf=         gnu/usr.bin/gperf
813 .if ${BOOTSTRAPPING} < 600101
814 _groff=         gnu/usr.bin/groff
815 .else
816 _groff=         gnu/usr.bin/groff/tmac
817 .endif
818 .endif
819
820 .if ${BOOTSTRAPPING} < 600029
821 _texinfo=       gnu/usr.bin/texinfo
822 .endif
823
824 .if ${BOOTSTRAPPING} < 600015
825 _cap_mkdb=      usr.bin/cap_mkdb
826 .endif
827
828 .if ${BOOTSTRAPPING} < 600018
829 _colldef=       usr.bin/colldef
830 .endif
831
832 .if ${BOOTSTRAPPING} < 600017
833 _gencat=        usr.bin/gencat
834 .endif
835
836 .if ${BOOTSTRAPPING} < 600016
837 _mklocale=      usr.bin/mklocale
838 .endif
839
840 .if ${BOOTSTRAPPING} < 602106
841 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
842 .endif
843
844 .if !defined(NO_RESCUE) && \
845     ${BOOTSTRAPPING} < 600008
846 _crunchgen=     usr.sbin/crunch/crunchgen
847 .endif
848
849 .if ${BOOTSTRAPPING} < 600020
850 _pwd_mkdb=      usr.sbin/pwd_mkdb
851 .endif
852
853 bootstrap-tools:
854 .for _tool in \
855     ${_strfile} \
856     ${_gperf} \
857     ${_groff} \
858     ${_texinfo} \
859     ${_cap_mkdb} \
860     ${_colldef} \
861     ${_gencat} \
862     usr.bin/lorder \
863     usr.bin/makewhatis \
864     ${_mklocale} \
865     usr.bin/rpcgen \
866     usr.bin/xinstall \
867     ${_gensnmptree} \
868     usr.sbin/config \
869     ${_crunchgen} \
870     ${_pwd_mkdb}
871         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
872                 cd ${.CURDIR}/${_tool}; \
873                 ${MAKE} DIRPRFX=${_tool}/ obj; \
874                 ${MAKE} DIRPRFX=${_tool}/ depend; \
875                 ${MAKE} DIRPRFX=${_tool}/ all; \
876                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
877 .endfor
878
879 #
880 # build-tools: Build special purpose build tools
881 #
882 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
883 _aicasm= sys/modules/aic7xxx/aicasm
884 .endif
885
886 .if !defined(NO_SHARE)
887 _share= share/syscons/scrnmaps
888 .endif
889
890 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
891 _kerberos5_tools= kerberos5/tools
892 .endif
893
894 .if !defined(NO_RESCUE)
895 _rescue= rescue/rescue
896 .endif
897
898 build-tools:
899 .for _tool in \
900     bin/csh \
901     bin/sh \
902     ${_rescue} \
903     lib/libncurses \
904     ${_share} \
905     ${_aicasm} \
906     usr.bin/awk \
907     lib/libmagic \
908     usr.sbin/sysinstall
909         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
910                 cd ${.CURDIR}/${_tool}; \
911                 ${MAKE} DIRPRFX=${_tool}/ obj; \
912                 ${MAKE} DIRPRFX=${_tool}/ build-tools
913 .endfor
914 .for _tool in \
915     gnu/usr.bin/cc/cc_tools \
916     ${_kerberos5_tools}
917         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
918                 cd ${.CURDIR}/${_tool}; \
919                 ${MAKE} DIRPRFX=${_tool}/ obj; \
920                 ${MAKE} DIRPRFX=${_tool}/ depend; \
921                 ${MAKE} DIRPRFX=${_tool}/ all
922 .endfor
923
924 #
925 # cross-tools: Build cross-building tools
926 #
927 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
928     ${TARGET_ARCH} != ${MACHINE_ARCH}
929 _btxld=         usr.sbin/btxld
930 .endif
931
932 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
933     ${TARGET_ARCH} != ${MACHINE_ARCH}
934 _crunchide=     usr.sbin/crunch/crunchide
935 .endif
936
937 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
938 _elf2exe=       usr.sbin/elf2exe
939 .endif
940
941 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
942     defined(RELEASEDIR)
943 _kgzip=         usr.sbin/kgzip
944 .endif
945
946 cross-tools:
947 .for _tool in \
948     gnu/usr.bin/binutils \
949     gnu/usr.bin/cc \
950     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
951     ${_btxld} \
952     ${_crunchide} \
953     ${_elf2exe} \
954     ${_kgzip}
955         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
956                 cd ${.CURDIR}/${_tool}; \
957                 ${MAKE} DIRPRFX=${_tool}/ obj; \
958                 ${MAKE} DIRPRFX=${_tool}/ depend; \
959                 ${MAKE} DIRPRFX=${_tool}/ all; \
960                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
961 .endfor
962
963 #
964 # hierarchy - ensure that all the needed directories are present
965 #
966 hierarchy:
967         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
968
969 #
970 # libraries - build all libraries, and install them under ${DESTDIR}.
971 #
972 # The list of libraries with dependents (${_prebuild_libs}) and their
973 # interdependencies (__L) are built automatically by the
974 # ${.CURDIR}/tools/make_libdeps.sh script.
975 #
976 libraries:
977         cd ${.CURDIR}; \
978             ${MAKE} -f Makefile.inc1 _startup_libs; \
979             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
980             ${MAKE} -f Makefile.inc1 _generic_libs;
981
982 # These dependencies are not automatically generated:
983 #
984 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
985 # shared libraries for ELF.
986 #
987 _startup_libs=  gnu/lib/csu gnu/lib/libgcc
988 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
989 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
990 .else
991 _startup_libs+= lib/csu/${MACHINE_ARCH}
992 .endif
993
994 _prebuild_libs=
995
996 _generic_libs=  gnu/lib
997
998 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
999 _prebuild_libs+=        kerberos5/lib/libasn1
1000 _prebuild_libs+=        kerberos5/lib/libgssapi
1001 _prebuild_libs+=        kerberos5/lib/libkrb5
1002 _prebuild_libs+=        kerberos5/lib/libroken
1003 _generic_libs+= kerberos5/lib
1004 .endif
1005
1006 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1007                 lib/libkvm lib/libmd \
1008                 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1009                 lib/libradius \
1010                 lib/libsbuf lib/libtacplus lib/libutil \
1011                 lib/libz lib/msun
1012
1013 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1014
1015 _generic_libs+= lib
1016
1017 .if !defined(NO_CRYPT)
1018 .if !defined(NO_OPENSSL)
1019 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
1020 lib/libradius__L: secure/lib/libssl__L
1021 secure/lib/libssl__L: secure/lib/libcrypto__L
1022 .if !defined(NO_OPENSSH)
1023 _prebuild_libs+=        secure/lib/libssh
1024 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L \
1025     lib/libmd__L
1026 .if !defined(NO_KERBEROS)
1027 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1028     kerberos5/lib/libasn1__L lib/libcom_err__L \
1029     kerberos5/lib/libroken__L
1030 .endif
1031 .endif
1032 .endif
1033 _generic_libs+= secure/lib
1034 .endif
1035
1036 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1037 lib/libradius__L: lib/libmd__L
1038 .endif
1039
1040 .if !defined(NO_NIS)
1041 _prebuild_libs+=        lib/libypclnt
1042 .endif
1043
1044 _generic_libs+= usr.bin/lex/lib
1045
1046 .if ${MACHINE} == "i386"
1047 _generic_libs+= usr.sbin/pcvt/keycap
1048 .endif
1049
1050 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1051 ${_lib}__L: .PHONY
1052 .if exists(${.CURDIR}/${_lib})
1053         ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1054                 cd ${.CURDIR}/${_lib}; \
1055                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1056                 ${MAKE} DIRPRFX=${_lib}/ all; \
1057                 ${MAKE} DIRPRFX=${_lib}/ install
1058 .endif
1059 .endfor
1060
1061 # libpam is special: we need to build static PAM modules before
1062 # static PAM library, and dynamic PAM library before dynamic PAM
1063 # modules.
1064 lib/libpam__L: .PHONY
1065         ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1066                 cd ${.CURDIR}/lib/libpam; \
1067                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1068                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1069                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1070
1071 _startup_libs: ${_startup_libs:S/$/__L/}
1072 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1073 _generic_libs: ${_generic_libs:S/$/__L/}
1074
1075 .for __target in all clean cleandepend cleandir depend includes obj
1076 .for entry in ${SUBDIR}
1077 ${entry}.${__target}__D: .PHONY
1078         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1079                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1080                 edir=${entry}.${MACHINE_ARCH}; \
1081                 cd ${.CURDIR}/$${edir}; \
1082         else \
1083                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1084                 edir=${entry}; \
1085                 cd ${.CURDIR}/$${edir}; \
1086         fi; \
1087         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1088 .endfor
1089 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1090 .endfor
1091
1092 .include <bsd.subdir.mk>
1093
1094 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1095
1096 #
1097 # check for / delete old files section
1098 #
1099
1100 .include "ObsoleteFiles.inc"
1101
1102 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1103 else you can not start such an application. Consult UPDATING for more \
1104 information regarding how to cope with the removal/revision bump of a \
1105 specific library."
1106
1107 .if !defined(BATCH_DELETE_OLD_FILES)
1108 RM_I=-i
1109 .else
1110 RM_I=-v
1111 .endif
1112
1113 delete-old-files:
1114         @echo ">>> Removing old files (only deletes safe to delete libs)"
1115 .for file in ${OLD_FILES}
1116 # Ask for every old file if the user really wants to remove it.
1117 # It's annoying, but better safe than sorry.
1118         @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1119                 ||  ([ -f "${DESTDIR}/${file}" ] \
1120                         && echo "Removing schg flag on ${DESTDIR}/${file}" \
1121                         && chflags noschg "${DESTDIR}/${file}" \
1122                         && rm ${RM_I} "${DESTDIR}/${file}"))
1123 .endfor
1124 # Remove catpages without corresponding manpages.
1125         @3<&0; \
1126         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1127         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1128         while read catpage; do \
1129                 read manpage; \
1130                 if [ ! -e "$${manpage}" ]; then \
1131                         rm ${RM_I} $${catpage} <&3 ; \
1132                 fi; \
1133         done
1134         @echo ">>> Old files removed"
1135
1136 check-old-files:
1137         @echo ">>> Checking for old files"
1138 .for file in ${OLD_FILES}
1139         @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1140 .endfor
1141 # Check for catpages without corresponding manpages.
1142         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1143         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1144         while read catpage; do \
1145                 read manpage; \
1146                 if [ ! -e "$${manpage}" ]; then \
1147                         echo $${catpage} ; \
1148                 fi; \
1149         done
1150
1151 delete-old-libs:
1152         @echo ">>> Removing old libraries"
1153         @echo "${OLD_LIBS_MESSAGE}" | fmt
1154 .for file in ${OLD_LIBS}
1155         @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1156                 ||  ([ -f "${DESTDIR}/${file}" ] \
1157                         && echo "Removing schg flag on ${DESTDIR}/${file}" \
1158                         && chflags noschg "${DESTDIR}/${file}" \
1159                         && rm ${RM_I} "${DESTDIR}/${file}"))
1160 .endfor
1161         @echo ">>> Old libraries removed"
1162
1163 check-old-libs:
1164         @echo ">>> Checking for old libraries"
1165 .for file in ${OLD_LIBS}
1166         @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1167 .endfor
1168
1169 delete-old-dirs:
1170         @echo ">>> Removing old directories"
1171 .for dir in ${OLD_DIRS}
1172 # Don't fail if an old directory isn't empty.
1173         @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1174 .endfor
1175         @echo ">>> Old directories removed"
1176
1177 check-old-dirs:
1178         @echo ">>> Checking for old directories"
1179 .for dir in ${OLD_DIRS}
1180         @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1181 .endfor
1182
1183 delete-old: delete-old-files delete-old-dirs
1184         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1185
1186 check-old: check-old-files check-old-libs check-old-dirs
1187         @echo "To remove old files and directories run '${MAKE} delete-old'."
1188         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1189
1190 .endif
1191