Annotation of src/distrib/sets/sets.subr, Revision 1.52
1.52 ! lukem 1: # $NetBSD: sets.subr,v 1.51 2006/06/24 05:11:40 mrg Exp $
1.1 dyoung 2: #
1.9 lukem 3:
4: #
1.11 lukem 5: # The following variables contain defaults for sets.subr functions and callers:
1.9 lukem 6: # setsdir path to src/distrib/sets
7: # nlists list of base sets
8: # xlists list of x11 sets
9: # obsolete controls if obsolete files are selected instead
10: # lkm if != "no", enable LKM sets
11: # shlib shared library format (a.out, elf, or "")
12: # stlib static library format (a.out, elf)
1.20 lukem 13: # x11_version version of XFree86. one of:
14: # "" cross built from src/x11
15: # 3 XFree86 3.x from xsrc/xc
16: # 4 XFree86 4.x from xsrc/xfree/xc
1.11 lukem 17: #
18: # The following <bsd.own.mk> variables are exported to the environment:
19: # MACHINE
20: # MACHINE_ARCH
21: # MACHINE_CPU
1.48 mrg 22: # HAVE_GCC
1.52 ! lukem 23: # HAVE_GDB
1.11 lukem 24: # TOOLCHAIN_MISSING
25: # OBJECT_FMT
1.22 lukem 26: # as well as:
27: #
28: MKVARS="\
29: MKBFD \
30: MKCATPAGES \
31: MKCRYPTO \
32: MKCRYPTO_IDEA \
33: MKCRYPTO_MDC2 \
34: MKCRYPTO_RC5 \
35: MKCVS \
1.52 ! lukem 36: MKGCC \
1.36 matt 37: MKGCCCMDS \
1.23 lukem 38: MKDOC \
1.32 scw 39: MKGDB \
1.22 lukem 40: MKHESIOD \
1.23 lukem 41: MKINFO \
1.39 peter 42: MKIPFILTER \
1.38 lukem 43: MKINET6 \
1.51 mrg 44: MKISCSI \
1.22 lukem 45: MKKERBEROS \
46: MKLINT \
47: MKMAN \
1.33 jmc 48: MKMANPAGES \
1.22 lukem 49: MKMANZ \
1.23 lukem 50: MKNLS \
1.37 he 51: MKPAM \
1.39 peter 52: MKPF \
1.30 matt 53: MKPIC \
1.22 lukem 54: MKPOSTFIX \
55: MKPROFILE \
56: MKSENDMAIL \
1.24 lukem 57: MKSHARE \
1.22 lukem 58: MKSKEY \
1.25 lukem 59: MKUUCP \
1.40 tron 60: MKX11 \
1.22 lukem 61: MKYP \
1.41 lukem 62: USE_INET6 \
63: USE_KERBEROS \
64: USE_YP \
1.22 lukem 65: "
1.42 apb 66: #
67: # The following variables refer to tools that are used when building sets:
68: #
1.43 apb 69: : ${AWK:=awk}
1.42 apb 70: : ${CKSUM:=cksum}
1.43 apb 71: : ${COMM:=comm}
1.44 apb 72: : ${DATE:=date}
1.43 apb 73: : ${DB:=db}
74: : ${EGREP:=egrep}
75: : ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc.
1.44 apb 76: : ${FGREP:=fgrep}
1.43 apb 77: : ${FIND:=find}
1.44 apb 78: : ${GREP:=grep}
1.43 apb 79: : ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1)
1.44 apb 80: : ${HOSTNAME:=hostname}
1.42 apb 81: : ${HOST_SH:=sh}
1.43 apb 82: : ${IDENT:=ident}
83: : ${JOIN:=join}
84: : ${LS:=ls}
85: : ${MAKE:=make}
1.42 apb 86: : ${MKTEMP:=mktemp}
1.43 apb 87: : ${MTREE:=mtree}
88: : ${PASTE:=paste}
1.42 apb 89: : ${PAX:=pax}
1.43 apb 90: : ${PKG_CREATE:=pkg_create}
91: : ${PRINTF:=printf}
92: : ${SED:=sed}
93: : ${SORT:=sort}
1.44 apb 94: : ${STAT:=stat}
95: : ${TSORT:=tsort}
1.43 apb 96: : ${UNAME:=uname}
97: : ${WC:=wc}
98:
1.45 apb 99: #
100: # If printf is a shell builtin command, then we can
101: # implement cheaper versions of basename and dirname
102: # that do not involve any fork/exec overhead.
103: # If printf is not builtin, approximate it using echo,
104: # and hope there are no weird file names that cause
105: # some versions of echo to do the wrong thing.
106: # (Converting to this version of dirname speeded up the
107: # syspkgdeps script by an order of magnitude, from 68
108: # seconds to 6.3 seconds on one particular host.)
109: #
110: # Note that naive approximations for dirname
111: # using ${foo%/*} do not do the right thing in cases
112: # where the result should be "/" or ".".
113: #
114: case "$(type printf)" in
115: *builtin*)
116: basename ()
117: {
118: local bn
119: bn="${1##*/}"
120: bn="${bn%$2}"
121: printf "%s\n" "$bn"
122: }
123: dirname ()
124: {
125: local dn
126: case "$1" in
127: ?*/*) dn="${1%/*}" ;;
128: /*) dn=/ ;;
129: *) dn=. ;;
130: esac
131: printf "%s\n" "$dn"
132: }
133: ;;
134: *)
135: basename ()
136: {
137: local bn
138: bn="${1##*/}"
139: bn="${bn%$2}"
140: echo "$bn"
141: }
142: dirname ()
143: {
144: local dn
145: case "$1" in
146: ?*/*) dn="${1%/*}" ;;
147: /*) dn=/ ;;
148: *) dn=. ;;
149: esac
150: echo "$dn"
151: }
152: ;;
153: esac
154:
1.9 lukem 155: oIFS=$IFS
156: IFS="
157: "
158: for x in $(
1.43 apb 159: ${MAKE} -B -f- all <<EOMAKE
1.9 lukem 160: .include <bsd.own.mk>
1.33 jmc 161: .if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
162: MKMANPAGES=no
163: .else
164: MKMANPAGES=yes
165: .endif
1.9 lukem 166: all:
1.11 lukem 167: .for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1.52 ! lukem 168: HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1.12 lukem 169: ${MKVARS}
170: @echo "export \$i=\${\$i}"
1.11 lukem 171: .endfor
1.20 lukem 172: .if (\${MKX11:Uno} != "no")
173: @echo x11_version=""
1.35 tron 174: .else
1.9 lukem 175: @echo x11_version=4
176: .endif
177:
1.12 lukem 178: EOMAKE
1.9 lukem 179: ); do
1.11 lukem 180: # echo 1>&2 "DEBUG: read $x"
1.9 lukem 181: eval $x
182: done
183: IFS=$oIFS
184:
1.34 erh 185: setsdir=${0%/*}
1.9 lukem 186: nlists="base comp etc games man misc text"
187: case $x11_version in
1.20 lukem 188: 3) xlists="xbase3 xcomp3 xcontrib3 xfont3 xmisc3 xserver3" ;;
189: 4) xlists="xbase4 xcomp4 xcontrib4 xfont4 xmisc4 xserver4" ;;
1.28 lukem 190: "") xlists="xbase xcomp xetc xfont xserver" ;;
1.20 lukem 191: *) xlists="" ;; # unknown!
1.9 lukem 192: esac
193: obsolete=0
194: lkm=yes
1.11 lukem 195: if [ "${MACHINE}" = "evbppc" ]; then
1.9 lukem 196: lkm=no # Turn off LKMs for some ports.
197: fi
1.31 jmc 198: # Determine lib type. Do this first so stlib also gets set.
199: if [ "${OBJECT_FMT}" = "ELF" ]; then
1.9 lukem 200: shlib=elf
201: else
202: shlib=aout
203: fi
204: stlib=$shlib
1.31 jmc 205: # Now check for MKPIC or specials and turn off shlib if need be.
206: if [ "${MKPIC}" = "no" ]; then
207: shlib=no
208: fi
1.29 uwe 209: if [ "${MACHINE_ARCH}" = "m68000" ]; then
1.9 lukem 210: shlib=no # Turn off shlibs for some ports.
211: fi
212:
213: #
214: # list_set_files setfile [...]
1.1 dyoung 215: #
1.9 lukem 216: # Produce a packing list for setfile(s).
217: # In each file, a record consists of a path and a System Package name,
218: # separated by whitespace. E.g.,
219: #
1.52 ! lukem 220: # # $NetBSD: sets.subr,v 1.51 2006/06/24 05:11:40 mrg Exp $
1.9 lukem 221: # . base-sys-root [keyword[,...]]
222: # ./altroot base-sys-root
223: # ./bin base-sys-root
224: # ./bin/[ base-util-root
225: # ./bin/cat base-util-root
226: # [...]
227: #
228: # A # in the first column marks a comment.
229: #
230: # If ${obsolete} != 0, only entries with an "obsolete" keyword will
1.52 ! lukem 231: # be printed. All other keywords must be present.
1.9 lukem 232: #
233: # The third field is an optional comma separated list of keywords to
234: # control if a record is printed; every keyword listed must be enabled
235: # for the record to be printed. The following keywords are available:
236: # dummy dummy entry (ignored)
1.13 lukem 237: # obsolete file is obsolete, and only printed if
238: # ${obsolete} != 0
239: #
1.22 lukem 240: # bfd ${MKBFD} != no
241: # catpages ${MKCATPAGES} != no
242: # crypto ${MKCRYPTO} != no
243: # crypto_idea ${MKCRYPTO_IDEA} != no
244: # crypto_mdc2 ${MKCRYPTO_MDC2} != no
245: # crypto_rc5 ${MKCRYPTO_RC5} != no
246: # cvs ${MKCVS} != no
1.23 lukem 247: # doc ${MKDOC} != no
1.52 ! lukem 248: # gcc ${MKGCC} != no
1.36 matt 249: # gcccmds ${MKGCCCMDS} != no
1.32 scw 250: # gdb ${MKGDB} != no
1.22 lukem 251: # hesiod ${MKHESIOD} != no
1.23 lukem 252: # info ${MKINFO} != no
1.39 peter 253: # ipfilter ${MKIPFILTER} != no
1.38 lukem 254: # inet6 ${MKINET6} != no
1.51 mrg 255: # iscsi ${MKISCSI} != no
1.22 lukem 256: # kerberos ${MKKERBEROS} != no
257: # lint ${MKLINT} != no
258: # man ${MKMAN} != no
259: # manz ${MKMANZ} != no
1.23 lukem 260: # nls ${MKNLS} != no
1.37 he 261: # pam ${MKPAM} != no
1.39 peter 262: # pf ${MKPF} != no
1.22 lukem 263: # postfix ${MKPOSTFIX} != no
264: # profile ${MKPROFILE} != no
265: # sendmail ${MKSENDMAIL} != no
1.24 lukem 266: # share ${MKSHARE} != no
1.22 lukem 267: # skey ${MKSKEY} != no
1.25 lukem 268: # uucp ${MKUUCP} != no
1.22 lukem 269: # yp ${MKYP} != no
270: #
1.52 ! lukem 271: # gcc=<n> <n> = value of ${HAVE_GCC}
! 272: # gdb=<n> <n> = value of ${HAVE_GDB}
! 273: #
1.41 lukem 274: # use_inet6 ${USE_INET6} != no
275: # use_kerberos ${USE_KERBEROS} != no
276: # use_yp ${USE_YP} != no
277: #
1.22 lukem 278: # .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
279: # automatically append ".gz" to the filename
280: #
281: # .man if ${MKMANZ} != "no" && ${MKMAN} != "no"
282: # automatically append ".gz" to the filename
1.1 dyoung 283: #
1.8 lukem 284: list_set_files()
285: {
1.1 dyoung 286: for setname; do
287: list_set_lists $setname
1.9 lukem 288: done | xargs cat | \
1.43 apb 289: ${AWK} -v obsolete=${obsolete} '
1.9 lukem 290: BEGIN {
1.52 ! lukem 291: if (obsolete)
! 292: wanted["obsolete"] = 1
! 293:
! 294: split("'"${MKVARS}"'", needvars)
! 295: for (vi in needvars) {
! 296: nv = needvars[vi]
! 297: kw = tolower(nv)
! 298: sub(/^mk/, "", kw)
! 299: if (ENVIRON[nv] != "no")
! 300: wanted[kw] = 1
! 301: }
! 302:
! 303: if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
! 304: wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
! 305: wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
1.9 lukem 306: }
1.52 ! lukem 307: if (("man" in wanted) && ("catpages" in wanted))
! 308: wanted[".cat"] = 1
! 309: if (("man" in wanted) && ("manpages" in wanted))
! 310: wanted[".man"] = 1
1.9 lukem 311: }
312:
313: /^#/ {
314: next;
315: }
316:
317: NF > 2 && $3 != "-" {
318: split($3, keywords, ",")
319: show = 1
1.52 ! lukem 320: haveobs = 0
1.9 lukem 321: for (ki in keywords) {
322: kw = keywords[ki]
1.22 lukem 323: if (("manz" in wanted) &&
324: (kw == ".cat" || kw == ".man"))
325: $1 = $1 ".gz"
1.9 lukem 326: if (! (kw in wanted))
327: show = 0
1.52 ! lukem 328: if (kw == "obsolete")
! 329: haveobs = 1
1.9 lukem 330: }
1.52 ! lukem 331: if (obsolete && ! haveobs)
! 332: next
1.9 lukem 333: if (show)
334: print
335: next
336: }
337:
338: {
339: if (! obsolete)
340: print
341: }'
342:
1.1 dyoung 343: }
344:
345: #
346: # list_set_lists setname
347: #
348: # Print to stdout a list of files, one filename per line, which
349: # concatenate to create the packing list for setname. E.g.,
350: #
351: # .../lists/base/mi
352: # .../lists/base/rescue.mi
353: # .../lists/base/md.i386
1.9 lukem 354: # [...]
1.1 dyoung 355: #
1.9 lukem 356: # For a given setname $set, the following files may be selected from
357: # .../list/$set:
358: # mi
1.11 lukem 359: # ad.${MACHINE_ARCH}
360: # (or) ad.${MACHINE_CPU}
361: # ad.${MACHINE_CPU}.shl
362: # md.${MACHINE}.${MACHINE_ARCH}
363: # (or) md.${MACHINE}
1.9 lukem 364: # stl.mi
365: # stl.stlib
366: # shl.mi
367: # shl.shlib
368: # lkm.mi if ${lkm} != no
369: # rescue.shl
1.11 lukem 370: # rescue.${MACHINE}
371: # rescue.ad.${MACHINE_ARCH}
372: # (or) rescue.ad.${MACHINE_CPU}
373: # rescue.ad.${MACHINE_CPU}.shl
1.1 dyoung 374: #
1.9 lukem 375: # Environment:
1.1 dyoung 376: # shlib
377: # stlib
378: #
1.8 lukem 379: list_set_lists()
380: {
1.1 dyoung 381: setname=$1
382:
1.9 lukem 383: setdir=$setsdir/lists/$setname
384: echo $setdir/mi
1.11 lukem 385: if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
386: # Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
1.1 dyoung 387: # since the arch-specific one will be more specific than
388: # the cpu-specific one.
1.11 lukem 389: if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
390: echo $setdir/ad.${MACHINE_ARCH}
391: elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
392: echo $setdir/ad.${MACHINE_CPU}
1.1 dyoung 393: fi
394: if [ "$shlib" != "no" -a \
1.11 lukem 395: -f $setdir/ad.${MACHINE_CPU}.shl ]; then
396: echo $setdir/ad.${MACHINE_CPU}.shl
1.1 dyoung 397: fi
398: fi
1.11 lukem 399: if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
400: echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
401: elif [ -f $setdir/md.${MACHINE} ]; then
402: echo $setdir/md.${MACHINE}
1.1 dyoung 403: fi
1.9 lukem 404: if [ -f $setdir/stl.mi ]; then
405: echo $setdir/stl.mi
1.1 dyoung 406: fi
1.9 lukem 407: if [ -f $setdir/stl.${stlib} ]; then
408: echo $setdir/stl.${stlib}
1.1 dyoung 409: fi
410: if [ "$shlib" != "no" ]; then
1.9 lukem 411: if [ -f $setdir/shl.mi ]; then
412: echo $setdir/shl.mi
1.7 dyoung 413: fi
1.9 lukem 414: if [ -f $setdir/shl.${shlib} ]; then
415: echo $setdir/shl.${shlib}
1.7 dyoung 416: fi
1.1 dyoung 417: fi
418: if [ "$lkm" != "no" ]; then
1.9 lukem 419: if [ -f $setdir/lkm.mi ]; then
420: echo $setdir/lkm.mi
1.1 dyoung 421: fi
422: fi
423:
1.9 lukem 424: if [ -f $setdir/rescue.mi ]; then
425: echo $setdir/rescue.mi
1.1 dyoung 426: fi
1.11 lukem 427: if [ -f $setdir/rescue.${MACHINE} ]; then
428: echo $setdir/rescue.${MACHINE}
1.1 dyoung 429: fi
1.11 lukem 430: if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
431: # Prefer a rescue.ad.${MACHINE_ARCH} over a
432: # rescue.ad.${MACHINE_CPU}, since the arch-
1.1 dyoung 433: # specific one will be more specific than the
434: # cpu-specific one.
1.11 lukem 435: if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
436: echo $setdir/rescue.ad.${MACHINE_ARCH}
437: elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
438: echo $setdir/rescue.ad.${MACHINE_CPU}
1.1 dyoung 439: fi
1.10 jmc 440: if [ "$shlib" != "no" -a \
1.11 lukem 441: -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
442: echo $setdir/rescue.ad.${MACHINE_CPU}.shl
1.10 jmc 443: fi
1.1 dyoung 444: fi
1.5 dyoung 445: }
446:
1.9 lukem 447: # arch_to_cpu mach
448: #
1.11 lukem 449: # Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
1.9 lukem 450: # as determined by <bsd.own.mk>.
451: #
1.8 lukem 452: arch_to_cpu()
453: {
1.43 apb 454: MACHINE_ARCH=${1} ${MAKE} -f- all <<EOMAKE
1.5 dyoung 455: .include <bsd.own.mk>
456: all:
457: @echo \${MACHINE_CPU}
1.12 lukem 458: EOMAKE
1.1 dyoung 459: }
1.46 apb 460:
461: # arch_to_endian mach
462: #
463: # Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
464: # as determined by <bsd.endian.mk>.
465: #
466: arch_to_endian()
467: {
468: MACHINE_ARCH=${1} ${MAKE} -f- all <<EOMAKE
469: .include <bsd.endian.mk>
470: all:
471: @echo \${TARGET_ENDIANNESS}
472: EOMAKE
473: }
CVSweb <webmaster@jp.NetBSD.org>