]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
MFC r177473: link manpage for archive_write_close
[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!=    uname -p
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 .if empty(TARGET_CPUTYPE)
238 LIB32CPUTYPE=   k8
239 .else
240 LIB32CPUTYPE=   ${TARGET_CPUTYPE}
241 .endif
242 LIB32FLAGS=     -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
243                 -iprefix ${LIB32TMP}/usr/ \
244                 -L${LIB32TMP}/usr/lib32 \
245                 -B${LIB32TMP}/usr/lib32
246
247 # Yes, the flags are redundant.
248 LIB32WMAKEENV=  MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
249                 _SHLIBDIRPREFIX=${LIB32TMP} \
250                 MACHINE=i386 \
251                 MACHINE_ARCH=i386 \
252                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
253                 PATH=${TMPPATH} \
254                 CC="${CC} ${LIB32FLAGS}" \
255                 CXX="${CXX} ${LIB32FLAGS}" \
256                 OBJC="${OBJC} ${LIB32FLAGS}" \
257                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
258                 AS="${AS} --32" \
259                 LIBDIR=/usr/lib32 \
260                 SHLIBDIR=/usr/lib32
261
262 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
263                 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML \
264                 DESTDIR=${LIB32TMP}
265 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -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         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
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; ${LIB32WMAKE} ${_t}
435         cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
436         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
437 .if !defined(NO_CRYPT)
438         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
439 .endif
440 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
441         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
442 .endif
443 .endfor
444 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
445         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
446 .endfor
447 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
448         cd ${.CURDIR}/${_dir}; \
449             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
450 .endfor
451         cd ${.CURDIR}; \
452             ${LIB32WMAKE} -f Makefile.inc1 libraries
453 .for _t in obj depend all
454         cd ${.CURDIR}/libexec/rtld-elf; \
455             PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
456 .endfor
457
458 distribute32 install32:
459 .if make(distribute32)
460         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
461 .else
462         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
463 .endif
464         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
465         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
466 .if !defined(NO_CRYPT)
467         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
468 .endif
469         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
470 .endif
471
472
473 WMAKE_TGTS=
474 .if !defined(SUBDIR_OVERRIDE)
475 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
476 .endif
477 WMAKE_TGTS+=    _cleanobj _obj _build-tools
478 .if !defined(SUBDIR_OVERRIDE)
479 WMAKE_TGTS+=    _cross-tools
480 .endif
481 WMAKE_TGTS+=    _includes _libraries _depend everything
482 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
483 WMAKE_TGTS+=    build32
484 .endif
485
486 buildworld: ${WMAKE_TGTS}
487 .ORDER: ${WMAKE_TGTS}
488
489 buildenv:
490         @echo Entering world for ${TARGET_ARCH}:${TARGET}
491         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
492
493 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
494 toolchain: ${TOOLCHAIN_TGTS}
495 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
496
497 #
498 # Use this to add checks to installworld/installkernel targets.
499 #
500 SPECIAL_INSTALLCHECKS=
501
502 #
503 # Require DESTDIR to be set if installing for a different architecture.
504 #
505 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
506 .if !make(distributeworld)
507 SPECIAL_INSTALLCHECKS+= installcheck_DESTDIR
508 installcheck_DESTDIR:
509 .if !defined(DESTDIR) || empty(DESTDIR)
510         @echo "ERROR: Please set DESTDIR!"; \
511         false
512 .endif
513 .endif
514 .endif
515
516 #
517 # installcheck
518 #
519 # Checks to be sure system is ready for installworld
520 #
521 CHECK_UIDS=
522 CHECK_GIDS=     audit
523 .if !defined(NO_SENDMAIL)
524 CHECK_UIDS+=    smmsp
525 CHECK_GIDS+=    smmsp
526 .endif
527 .if !defined(NO_PF)
528 CHECK_UIDS+=    proxy
529 CHECK_GIDS+=    proxy authpf
530 .endif
531 installcheck: ${SPECIAL_INSTALLCHECKS}
532 .for uid in ${CHECK_UIDS}
533         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
534                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
535                 false; \
536         fi
537 .endfor
538 .for gid in ${CHECK_GIDS}
539         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
540                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
541                 false; \
542         fi
543 .endfor
544
545 #
546 # distributeworld
547 #
548 # Distributes everything compiled by a `buildworld'.
549 #
550 # installworld
551 #
552 # Installs everything compiled by a 'buildworld'.
553 #
554 distributeworld installworld: installcheck
555         mkdir -p ${INSTALLTMP}
556         for prog in [ awk cap_mkdb cat chflags chmod chown \
557             date echo egrep find grep install-info \
558             ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
559             test true uname wc zic; do \
560                 cp `which $$prog` ${INSTALLTMP}; \
561         done
562         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
563         rm -rf ${INSTALLTMP}
564
565 #
566 # reinstall
567 #
568 # If you have a build server, you can NFS mount the source and obj directories
569 # and do a 'make reinstall' on the *client* to install new binaries from the
570 # most recent server build.
571 #
572 reinstall: ${SPECIAL_INSTALLCHECKS}
573         @echo "--------------------------------------------------------------"
574         @echo ">>> Making hierarchy"
575         @echo "--------------------------------------------------------------"
576         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
577         @echo
578         @echo "--------------------------------------------------------------"
579         @echo ">>> Installing everything"
580         @echo "--------------------------------------------------------------"
581         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
582 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
583         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
584 .endif
585
586 redistribute:
587         @echo "--------------------------------------------------------------"
588         @echo ">>> Distributing everything"
589         @echo "--------------------------------------------------------------"
590         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
591 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
592         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
593 .endif
594
595 distrib-dirs distribution:
596         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
597
598 #
599 # buildkernel and installkernel
600 #
601 # Which kernels to build and/or install is specified by setting
602 # KERNCONF. If not defined a GENERIC kernel is built/installed.
603 # Only the existing (depending TARGET) config files are used
604 # for building kernels and only the first of these is designated
605 # as the one being installed.
606 #
607 # Note that we have to use TARGET instead of TARGET_ARCH when
608 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
609 # be set to cross-build, we have to make sure TARGET is set
610 # properly.
611
612 .if !defined(KERNCONF) && defined(KERNEL)
613 KERNCONF=       ${KERNEL}
614 KERNWARN=
615 .else
616 KERNCONF?=      GENERIC
617 .endif
618 INSTKERNNAME?=  kernel
619
620 KERNSRCDIR?=    ${.CURDIR}/sys
621 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
622 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
623 KERNCONFDIR?=   ${KRNLCONFDIR}
624
625 BUILDKERNELS=
626 INSTALLKERNEL=
627 .for _kernel in ${KERNCONF}
628 .if exists(${KERNCONFDIR}/${_kernel})
629 BUILDKERNELS+=  ${_kernel}
630 .if empty(INSTALLKERNEL)
631 INSTALLKERNEL= ${_kernel}
632 .endif
633 .endif
634 .endfor
635
636 #
637 # buildkernel
638 #
639 # Builds all kernels defined by BUILDKERNELS.
640 #
641 buildkernel:
642 .if empty(BUILDKERNELS)
643         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
644         false
645 .endif
646 .if defined(KERNWARN)
647         @echo "--------------------------------------------------------------"
648         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
649         @echo "--------------------------------------------------------------"
650         @sleep 3
651 .endif
652         @echo
653 .for _kernel in ${BUILDKERNELS}
654         @echo "--------------------------------------------------------------"
655         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
656         @echo "--------------------------------------------------------------"
657         @echo "===> ${_kernel}"
658         mkdir -p ${KRNLOBJDIR}
659 .if !defined(NO_KERNELCONFIG)
660         @echo
661         @echo "--------------------------------------------------------------"
662         @echo ">>> stage 1: configuring the kernel"
663         @echo "--------------------------------------------------------------"
664         cd ${KRNLCONFDIR}; \
665                 PATH=${TMPPATH} \
666                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
667                         ${KERNCONFDIR}/${_kernel}
668 .endif
669 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
670         @echo
671         @echo "--------------------------------------------------------------"
672         @echo ">>> stage 2.1: cleaning up the object tree"
673         @echo "--------------------------------------------------------------"
674         cd ${KRNLOBJDIR}/${_kernel}; \
675             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
676 .endif
677         @echo
678         @echo "--------------------------------------------------------------"
679         @echo ">>> stage 2.2: rebuilding the object tree"
680         @echo "--------------------------------------------------------------"
681         cd ${KRNLOBJDIR}/${_kernel}; \
682             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
683         @echo
684         @echo "--------------------------------------------------------------"
685         @echo ">>> stage 2.3: build tools"
686         @echo "--------------------------------------------------------------"
687         cd ${KRNLOBJDIR}/${_kernel}; \
688             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
689             ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
690 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
691 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
692 .for target in obj depend all
693         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
694             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
695             ${MAKE} -DNO_CPU_CFLAGS ${target}
696 .endfor
697 .endif
698 .if !defined(NO_KERNELDEPEND)
699         @echo
700         @echo "--------------------------------------------------------------"
701         @echo ">>> stage 3.1: making dependencies"
702         @echo "--------------------------------------------------------------"
703         cd ${KRNLOBJDIR}/${_kernel}; \
704             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
705 .endif
706         @echo
707         @echo "--------------------------------------------------------------"
708         @echo ">>> stage 3.2: building everything"
709         @echo "--------------------------------------------------------------"
710         cd ${KRNLOBJDIR}/${_kernel}; \
711             ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
712         @echo "--------------------------------------------------------------"
713         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
714         @echo "--------------------------------------------------------------"
715 .endfor
716
717 #
718 # installkernel, etc.
719 #
720 # Install the kernel defined by INSTALLKERNEL
721 #
722 installkernel installkernel.debug \
723 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
724 .if empty(INSTALLKERNEL)
725         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
726         false
727 .endif
728         @echo "--------------------------------------------------------------"
729         @echo ">>> Installing kernel"
730         @echo "--------------------------------------------------------------"
731         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
732             ${CROSSENV} PATH=${TMPPATH} \
733             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
734
735 #
736 # update
737 #
738 # Update the source tree, by running cvsup and/or running cvs to update to the
739 # latest copy.
740 #
741 update:
742 .if defined(SUP_UPDATE)
743         @echo "--------------------------------------------------------------"
744         @echo ">>> Running ${SUP}"
745         @echo "--------------------------------------------------------------"
746 .if defined(SUPFILE)
747         @${SUP} ${SUPFLAGS} ${SUPFILE}
748 .endif
749 .if defined(SUPFILE1)
750         @${SUP} ${SUPFLAGS} ${SUPFILE1}
751 .endif
752 .if defined(SUPFILE2)
753         @${SUP} ${SUPFLAGS} ${SUPFILE2}
754 .endif
755 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
756         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
757 .endif
758 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
759         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
760 .endif
761 .endif
762 .if defined(CVS_UPDATE)
763         @echo "--------------------------------------------------------------"
764         @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
765         @echo "--------------------------------------------------------------"
766         cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
767 .endif
768
769 #
770 # ------------------------------------------------------------------------
771 #
772 # From here onwards are utility targets used by the 'make world' and
773 # related targets.  If your 'world' breaks, you may like to try to fix
774 # the problem and manually run the following targets to attempt to
775 # complete the build.  Beware, this is *not* guaranteed to work, you
776 # need to have a pretty good grip on the current state of the system
777 # to attempt to manually finish it.  If in doubt, 'make world' again.
778 #
779
780 #
781 # legacy: Build compatibility shims for the next three targets
782 #
783 legacy:
784 .if ${BOOTSTRAPPING} < 503000
785         @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
786         false
787 .endif
788 .for _tool in tools/build
789         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
790             cd ${.CURDIR}/${_tool}; \
791             ${MAKE} DIRPRFX=${_tool}/ obj; \
792             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
793             ${MAKE} DIRPRFX=${_tool}/ depend; \
794             ${MAKE} DIRPRFX=${_tool}/ all; \
795             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
796 .endfor
797
798 #
799 # bootstrap-tools: Build tools needed for compatibility
800 #
801 .if !defined(NO_GAMES)
802 _strfile=       games/fortune/strfile
803 .endif
804
805 .if !defined(NO_CXX)
806 _gperf=         gnu/usr.bin/gperf
807 .if ${BOOTSTRAPPING} < 600101
808 _groff=         gnu/usr.bin/groff
809 .else
810 _groff=         gnu/usr.bin/groff/tmac
811 .endif
812 .endif
813
814 .if ${BOOTSTRAPPING} < 600029
815 _texinfo=       gnu/usr.bin/texinfo
816 .endif
817
818 .if ${BOOTSTRAPPING} < 600015
819 _cap_mkdb=      usr.bin/cap_mkdb
820 .endif
821
822 .if ${BOOTSTRAPPING} < 600018
823 _colldef=       usr.bin/colldef
824 .endif
825
826 .if ${BOOTSTRAPPING} < 600017
827 _gencat=        usr.bin/gencat
828 .endif
829
830 .if ${BOOTSTRAPPING} < 600016
831 _mklocale=      usr.bin/mklocale
832 .endif
833
834 .if ${BOOTSTRAPPING} < 602106
835 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
836 .endif
837
838 .if !defined(NO_RESCUE) && \
839     ${BOOTSTRAPPING} < 600008
840 _crunchgen=     usr.sbin/crunch/crunchgen
841 .endif
842
843 .if ${BOOTSTRAPPING} < 600020
844 _pwd_mkdb=      usr.sbin/pwd_mkdb
845 .endif
846
847 bootstrap-tools:
848 .for _tool in \
849     ${_strfile} \
850     ${_gperf} \
851     ${_groff} \
852     ${_texinfo} \
853     ${_cap_mkdb} \
854     ${_colldef} \
855     ${_gencat} \
856     usr.bin/lorder \
857     usr.bin/makewhatis \
858     ${_mklocale} \
859     usr.bin/rpcgen \
860     usr.bin/xinstall \
861     ${_gensnmptree} \
862     usr.sbin/config \
863     ${_crunchgen} \
864     ${_pwd_mkdb}
865         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
866                 cd ${.CURDIR}/${_tool}; \
867                 ${MAKE} DIRPRFX=${_tool}/ obj; \
868                 ${MAKE} DIRPRFX=${_tool}/ depend; \
869                 ${MAKE} DIRPRFX=${_tool}/ all; \
870                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
871 .endfor
872
873 #
874 # build-tools: Build special purpose build tools
875 #
876 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
877 _aicasm= sys/modules/aic7xxx/aicasm
878 .endif
879
880 .if !defined(NO_SHARE)
881 _share= share/syscons/scrnmaps
882 .endif
883
884 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
885 _kerberos5_tools= kerberos5/tools
886 .endif
887
888 .if !defined(NO_RESCUE)
889 _rescue= rescue/rescue
890 .endif
891
892 build-tools:
893 .for _tool in \
894     bin/csh \
895     bin/sh \
896     ${_rescue} \
897     lib/ncurses/ncurses \
898     lib/ncurses/ncursesw \
899     ${_share} \
900     ${_aicasm} \
901     usr.bin/awk \
902     lib/libmagic \
903     usr.sbin/sysinstall
904         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
905                 cd ${.CURDIR}/${_tool}; \
906                 ${MAKE} DIRPRFX=${_tool}/ obj; \
907                 ${MAKE} DIRPRFX=${_tool}/ build-tools
908 .endfor
909 .for _tool in \
910     gnu/usr.bin/cc/cc_tools \
911     ${_kerberos5_tools}
912         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
913                 cd ${.CURDIR}/${_tool}; \
914                 ${MAKE} DIRPRFX=${_tool}/ obj; \
915                 ${MAKE} DIRPRFX=${_tool}/ depend; \
916                 ${MAKE} DIRPRFX=${_tool}/ all
917 .endfor
918
919 #
920 # cross-tools: Build cross-building tools
921 #
922 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
923     ${TARGET_ARCH} != ${MACHINE_ARCH}
924 _btxld=         usr.sbin/btxld
925 .endif
926
927 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
928     ${TARGET_ARCH} != ${MACHINE_ARCH}
929 _crunchide=     usr.sbin/crunch/crunchide
930 .endif
931
932 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
933 _elf2exe=       usr.sbin/elf2exe
934 .endif
935
936 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
937     defined(RELEASEDIR)
938 _kgzip=         usr.sbin/kgzip
939 .endif
940
941 cross-tools:
942 .for _tool in \
943     gnu/usr.bin/binutils \
944     gnu/usr.bin/cc \
945     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
946     ${_btxld} \
947     ${_crunchide} \
948     ${_elf2exe} \
949     ${_kgzip}
950         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
951                 cd ${.CURDIR}/${_tool}; \
952                 ${MAKE} DIRPRFX=${_tool}/ obj; \
953                 ${MAKE} DIRPRFX=${_tool}/ depend; \
954                 ${MAKE} DIRPRFX=${_tool}/ all; \
955                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
956 .endfor
957
958 #
959 # hierarchy - ensure that all the needed directories are present
960 #
961 hierarchy:
962         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
963
964 #
965 # libraries - build all libraries, and install them under ${DESTDIR}.
966 #
967 # The list of libraries with dependents (${_prebuild_libs}) and their
968 # interdependencies (__L) are built automatically by the
969 # ${.CURDIR}/tools/make_libdeps.sh script.
970 #
971 libraries:
972         cd ${.CURDIR}; \
973             ${MAKE} -f Makefile.inc1 _startup_libs; \
974             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
975             ${MAKE} -f Makefile.inc1 _generic_libs;
976
977 # These dependencies are not automatically generated:
978 #
979 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
980 # shared libraries for ELF.
981 #
982 _startup_libs=  gnu/lib/csu gnu/lib/libgcc
983 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
984 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
985 .else
986 _startup_libs+= lib/csu/${MACHINE_ARCH}
987 .endif
988
989 _prebuild_libs=
990
991 _generic_libs=  gnu/lib
992
993 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
994 _prebuild_libs+=        kerberos5/lib/libasn1
995 _prebuild_libs+=        kerberos5/lib/libgssapi
996 _prebuild_libs+=        kerberos5/lib/libkrb5
997 _prebuild_libs+=        kerberos5/lib/libroken
998 _generic_libs+= kerberos5/lib
999 .endif
1000
1001 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1002                 lib/libkvm lib/libmd \
1003                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1004                 lib/libnetgraph lib/libopie lib/libpam \
1005                 lib/libradius \
1006                 lib/libsbuf lib/libtacplus lib/libutil \
1007                 lib/libz lib/msun
1008
1009 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1010
1011 _generic_libs+= lib
1012
1013 .if !defined(NO_CRYPT)
1014 .if !defined(NO_OPENSSL)
1015 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
1016 lib/libradius__L: secure/lib/libssl__L
1017 secure/lib/libssl__L: secure/lib/libcrypto__L
1018 .if !defined(NO_OPENSSH)
1019 _prebuild_libs+=        secure/lib/libssh
1020 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L \
1021     lib/libmd__L
1022 .if !defined(NO_KERBEROS)
1023 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1024     kerberos5/lib/libasn1__L lib/libcom_err__L \
1025     kerberos5/lib/libroken__L
1026 .endif
1027 .endif
1028 .endif
1029 _generic_libs+= secure/lib
1030 .endif
1031
1032 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1033 lib/libradius__L: lib/libmd__L
1034 .endif
1035
1036 .if !defined(NO_NIS)
1037 _prebuild_libs+=        lib/libypclnt
1038 .endif
1039
1040 _generic_libs+= usr.bin/lex/lib
1041
1042 .if ${MACHINE} == "i386"
1043 _generic_libs+= usr.sbin/pcvt/keycap
1044 .endif
1045
1046 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1047 ${_lib}__L: .PHONY
1048 .if exists(${.CURDIR}/${_lib})
1049         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1050                 cd ${.CURDIR}/${_lib}; \
1051                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1052                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1053                 ${MAKE} DIRPRFX=${_lib}/ all; \
1054                 ${MAKE} DIRPRFX=${_lib}/ install
1055 .endif
1056 .endfor
1057
1058 # libpam is special: we need to build static PAM modules before
1059 # static PAM library, and dynamic PAM library before dynamic PAM
1060 # modules.
1061 lib/libpam__L: .PHONY
1062         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1063                 cd ${.CURDIR}/lib/libpam; \
1064                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1065                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1066                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1067                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1068
1069 _startup_libs: ${_startup_libs:S/$/__L/}
1070 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1071 _generic_libs: ${_generic_libs:S/$/__L/}
1072
1073 .for __target in all clean cleandepend cleandir depend includes obj
1074 .for entry in ${SUBDIR}
1075 ${entry}.${__target}__D: .PHONY
1076         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1077                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1078                 edir=${entry}.${MACHINE_ARCH}; \
1079                 cd ${.CURDIR}/$${edir}; \
1080         else \
1081                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1082                 edir=${entry}; \
1083                 cd ${.CURDIR}/$${edir}; \
1084         fi; \
1085         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1086 .endfor
1087 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1088 .endfor
1089
1090 .include <bsd.subdir.mk>
1091
1092 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1093
1094 #
1095 # check for / delete old files section
1096 #
1097
1098 .include "ObsoleteFiles.inc"
1099
1100 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1101 else you can not start such an application. Consult UPDATING for more \
1102 information regarding how to cope with the removal/revision bump of a \
1103 specific library."
1104
1105 .if !defined(BATCH_DELETE_OLD_FILES)
1106 RM_I=-i
1107 .else
1108 RM_I=-v
1109 .endif
1110
1111 delete-old-files:
1112         @echo ">>> Removing old files (only deletes safe to delete libs)"
1113 .for file in ${OLD_FILES}
1114 # Ask for every old file if the user really wants to remove it.
1115 # It's annoying, but better safe than sorry.
1116         @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1117                 ||  ([ -f "${DESTDIR}/${file}" ] \
1118                         && echo "Removing schg flag on ${DESTDIR}/${file}" \
1119                         && chflags noschg "${DESTDIR}/${file}" \
1120                         && rm ${RM_I} "${DESTDIR}/${file}"))
1121 .endfor
1122 # Remove catpages without corresponding manpages.
1123         @3<&0; \
1124         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1125         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1126         while read catpage; do \
1127                 read manpage; \
1128                 if [ ! -e "$${manpage}" ]; then \
1129                         rm ${RM_I} $${catpage} <&3 ; \
1130                 fi; \
1131         done
1132         @echo ">>> Old files removed"
1133
1134 check-old-files:
1135         @echo ">>> Checking for old files"
1136 .for file in ${OLD_FILES}
1137         @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1138 .endfor
1139 # Check for catpages without corresponding manpages.
1140         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1141         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1142         while read catpage; do \
1143                 read manpage; \
1144                 if [ ! -e "$${manpage}" ]; then \
1145                         echo $${catpage} ; \
1146                 fi; \
1147         done
1148
1149 delete-old-libs:
1150         @echo ">>> Removing old libraries"
1151         @echo "${OLD_LIBS_MESSAGE}" | fmt
1152 .for file in ${OLD_LIBS}
1153         @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1154                 ||  ([ -f "${DESTDIR}/${file}" ] \
1155                         && echo "Removing schg flag on ${DESTDIR}/${file}" \
1156                         && chflags noschg "${DESTDIR}/${file}" \
1157                         && rm ${RM_I} "${DESTDIR}/${file}"))
1158 .endfor
1159         @echo ">>> Old libraries removed"
1160
1161 check-old-libs:
1162         @echo ">>> Checking for old libraries"
1163 .for file in ${OLD_LIBS}
1164         @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1165 .endfor
1166
1167 delete-old-dirs:
1168         @echo ">>> Removing old directories"
1169 .for dir in ${OLD_DIRS}
1170 # Don't fail if an old directory isn't empty.
1171         @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1172 .endfor
1173         @echo ">>> Old directories removed"
1174
1175 check-old-dirs:
1176         @echo ">>> Checking for old directories"
1177 .for dir in ${OLD_DIRS}
1178         @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1179 .endfor
1180
1181 delete-old: delete-old-files delete-old-dirs
1182         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1183
1184 check-old: check-old-files check-old-libs check-old-dirs
1185         @echo "To remove old files and directories run '${MAKE} delete-old'."
1186         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1187
1188 .endif
1189