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