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