sets.subr revision 1.48
11.48Smrg# $NetBSD: sets.subr,v 1.48 2006/04/07 19:38:58 mrg Exp $ 21.1Sdyoung# 31.9Slukem 41.9Slukem# 51.11Slukem# The following variables contain defaults for sets.subr functions and callers: 61.9Slukem# setsdir path to src/distrib/sets 71.9Slukem# nlists list of base sets 81.9Slukem# xlists list of x11 sets 91.9Slukem# obsolete controls if obsolete files are selected instead 101.9Slukem# lkm if != "no", enable LKM sets 111.9Slukem# shlib shared library format (a.out, elf, or "") 121.9Slukem# stlib static library format (a.out, elf) 131.20Slukem# x11_version version of XFree86. one of: 141.20Slukem# "" cross built from src/x11 151.20Slukem# 3 XFree86 3.x from xsrc/xc 161.20Slukem# 4 XFree86 4.x from xsrc/xfree/xc 171.11Slukem# 181.11Slukem# The following <bsd.own.mk> variables are exported to the environment: 191.11Slukem# MACHINE 201.11Slukem# MACHINE_ARCH 211.11Slukem# MACHINE_CPU 221.48Smrg# HAVE_GCC 231.11Slukem# TOOLCHAIN_MISSING 241.11Slukem# OBJECT_FMT 251.22Slukem# as well as: 261.22Slukem# 271.22SlukemMKVARS="\ 281.22Slukem MKBFD \ 291.22Slukem MKCATPAGES \ 301.22Slukem MKCRYPTO \ 311.22Slukem MKCRYPTO_IDEA \ 321.22Slukem MKCRYPTO_MDC2 \ 331.22Slukem MKCRYPTO_RC5 \ 341.22Slukem MKCVS \ 351.36Smatt MKGCCCMDS \ 361.23Slukem MKDOC \ 371.32Sscw MKGDB \ 381.22Slukem MKHESIOD \ 391.23Slukem MKINFO \ 401.39Speter MKIPFILTER \ 411.38Slukem MKINET6 \ 421.22Slukem MKKERBEROS \ 431.22Slukem MKLINT \ 441.22Slukem MKMAN \ 451.33Sjmc MKMANPAGES \ 461.22Slukem MKMANZ \ 471.23Slukem MKNLS \ 481.37She MKPAM \ 491.39Speter MKPF \ 501.30Smatt MKPIC \ 511.22Slukem MKPOSTFIX \ 521.22Slukem MKPROFILE \ 531.22Slukem MKSENDMAIL \ 541.24Slukem MKSHARE \ 551.22Slukem MKSKEY \ 561.25Slukem MKUUCP \ 571.40Stron MKX11 \ 581.22Slukem MKYP \ 591.41Slukem USE_INET6 \ 601.41Slukem USE_KERBEROS \ 611.41Slukem USE_YP \ 621.22Slukem" 631.42Sapb# 641.42Sapb# The following variables refer to tools that are used when building sets: 651.42Sapb# 661.43Sapb: ${AWK:=awk} 671.42Sapb: ${CKSUM:=cksum} 681.43Sapb: ${COMM:=comm} 691.44Sapb: ${DATE:=date} 701.43Sapb: ${DB:=db} 711.43Sapb: ${EGREP:=egrep} 721.43Sapb: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc. 731.44Sapb: ${FGREP:=fgrep} 741.43Sapb: ${FIND:=find} 751.44Sapb: ${GREP:=grep} 761.43Sapb: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1) 771.44Sapb: ${HOSTNAME:=hostname} 781.42Sapb: ${HOST_SH:=sh} 791.43Sapb: ${IDENT:=ident} 801.43Sapb: ${JOIN:=join} 811.43Sapb: ${LS:=ls} 821.43Sapb: ${MAKE:=make} 831.42Sapb: ${MKTEMP:=mktemp} 841.43Sapb: ${MTREE:=mtree} 851.43Sapb: ${PASTE:=paste} 861.42Sapb: ${PAX:=pax} 871.43Sapb: ${PKG_CREATE:=pkg_create} 881.43Sapb: ${PRINTF:=printf} 891.43Sapb: ${SED:=sed} 901.43Sapb: ${SORT:=sort} 911.44Sapb: ${STAT:=stat} 921.44Sapb: ${TSORT:=tsort} 931.43Sapb: ${UNAME:=uname} 941.43Sapb: ${WC:=wc} 951.43Sapb 961.45Sapb# 971.45Sapb# If printf is a shell builtin command, then we can 981.45Sapb# implement cheaper versions of basename and dirname 991.45Sapb# that do not involve any fork/exec overhead. 1001.45Sapb# If printf is not builtin, approximate it using echo, 1011.45Sapb# and hope there are no weird file names that cause 1021.45Sapb# some versions of echo to do the wrong thing. 1031.45Sapb# (Converting to this version of dirname speeded up the 1041.45Sapb# syspkgdeps script by an order of magnitude, from 68 1051.45Sapb# seconds to 6.3 seconds on one particular host.) 1061.45Sapb# 1071.45Sapb# Note that naive approximations for dirname 1081.45Sapb# using ${foo%/*} do not do the right thing in cases 1091.45Sapb# where the result should be "/" or ".". 1101.45Sapb# 1111.45Sapbcase "$(type printf)" in 1121.45Sapb*builtin*) 1131.45Sapb basename () 1141.45Sapb { 1151.45Sapb local bn 1161.45Sapb bn="${1##*/}" 1171.45Sapb bn="${bn%$2}" 1181.45Sapb printf "%s\n" "$bn" 1191.45Sapb } 1201.45Sapb dirname () 1211.45Sapb { 1221.45Sapb local dn 1231.45Sapb case "$1" in 1241.45Sapb ?*/*) dn="${1%/*}" ;; 1251.45Sapb /*) dn=/ ;; 1261.45Sapb *) dn=. ;; 1271.45Sapb esac 1281.45Sapb printf "%s\n" "$dn" 1291.45Sapb } 1301.45Sapb ;; 1311.45Sapb*) 1321.45Sapb basename () 1331.45Sapb { 1341.45Sapb local bn 1351.45Sapb bn="${1##*/}" 1361.45Sapb bn="${bn%$2}" 1371.45Sapb echo "$bn" 1381.45Sapb } 1391.45Sapb dirname () 1401.45Sapb { 1411.45Sapb local dn 1421.45Sapb case "$1" in 1431.45Sapb ?*/*) dn="${1%/*}" ;; 1441.45Sapb /*) dn=/ ;; 1451.45Sapb *) dn=. ;; 1461.45Sapb esac 1471.45Sapb echo "$dn" 1481.45Sapb } 1491.45Sapb ;; 1501.45Sapbesac 1511.45Sapb 1521.9SlukemoIFS=$IFS 1531.9SlukemIFS=" 1541.9Slukem" 1551.9Slukemfor x in $( 1561.43Sapb${MAKE} -B -f- all <<EOMAKE 1571.9Slukem.include <bsd.own.mk> 1581.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall)) 1591.33SjmcMKMANPAGES=no 1601.33Sjmc.else 1611.33SjmcMKMANPAGES=yes 1621.33Sjmc.endif 1631.9Slukemall: 1641.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \ 1651.48Smrg HAVE_GCC OBJECT_FMT TOOLCHAIN_MISSING \ 1661.12Slukem ${MKVARS} 1671.12Slukem @echo "export \$i=\${\$i}" 1681.11Slukem.endfor 1691.20Slukem.if (\${MKX11:Uno} != "no") 1701.20Slukem @echo x11_version="" 1711.35Stron.else 1721.9Slukem @echo x11_version=4 1731.9Slukem.endif 1741.9Slukem 1751.12SlukemEOMAKE 1761.9Slukem); do 1771.11Slukem# echo 1>&2 "DEBUG: read $x" 1781.9Slukem eval $x 1791.9Slukemdone 1801.9SlukemIFS=$oIFS 1811.9Slukem 1821.34Serhsetsdir=${0%/*} 1831.9Slukemnlists="base comp etc games man misc text" 1841.9Slukemcase $x11_version in 1851.20Slukem3) xlists="xbase3 xcomp3 xcontrib3 xfont3 xmisc3 xserver3" ;; 1861.20Slukem4) xlists="xbase4 xcomp4 xcontrib4 xfont4 xmisc4 xserver4" ;; 1871.28Slukem"") xlists="xbase xcomp xetc xfont xserver" ;; 1881.20Slukem*) xlists="" ;; # unknown! 1891.9Slukemesac 1901.9Slukemobsolete=0 1911.9Slukemlkm=yes 1921.11Slukemif [ "${MACHINE}" = "evbppc" ]; then 1931.9Slukem lkm=no # Turn off LKMs for some ports. 1941.9Slukemfi 1951.31Sjmc# Determine lib type. Do this first so stlib also gets set. 1961.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 1971.9Slukem shlib=elf 1981.9Slukemelse 1991.9Slukem shlib=aout 2001.9Slukemfi 2011.9Slukemstlib=$shlib 2021.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 2031.31Sjmcif [ "${MKPIC}" = "no" ]; then 2041.31Sjmc shlib=no 2051.31Sjmcfi 2061.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then 2071.9Slukem shlib=no # Turn off shlibs for some ports. 2081.9Slukemfi 2091.9Slukem 2101.9Slukem# 2111.9Slukem# list_set_files setfile [...] 2121.1Sdyoung# 2131.9Slukem# Produce a packing list for setfile(s). 2141.9Slukem# In each file, a record consists of a path and a System Package name, 2151.9Slukem# separated by whitespace. E.g., 2161.9Slukem# 2171.48Smrg# # $NetBSD: sets.subr,v 1.48 2006/04/07 19:38:58 mrg Exp $ 2181.9Slukem# . base-sys-root [keyword[,...]] 2191.9Slukem# ./altroot base-sys-root 2201.9Slukem# ./bin base-sys-root 2211.9Slukem# ./bin/[ base-util-root 2221.9Slukem# ./bin/cat base-util-root 2231.9Slukem# [...] 2241.9Slukem# 2251.9Slukem# A # in the first column marks a comment. 2261.9Slukem# 2271.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2281.9Slukem# be printed. 2291.9Slukem# 2301.9Slukem# The third field is an optional comma separated list of keywords to 2311.9Slukem# control if a record is printed; every keyword listed must be enabled 2321.9Slukem# for the record to be printed. The following keywords are available: 2331.9Slukem# dummy dummy entry (ignored) 2341.13Slukem# obsolete file is obsolete, and only printed if 2351.13Slukem# ${obsolete} != 0 2361.13Slukem# 2371.22Slukem# bfd ${MKBFD} != no 2381.22Slukem# catpages ${MKCATPAGES} != no 2391.22Slukem# crypto ${MKCRYPTO} != no 2401.22Slukem# crypto_idea ${MKCRYPTO_IDEA} != no 2411.22Slukem# crypto_mdc2 ${MKCRYPTO_MDC2} != no 2421.22Slukem# crypto_rc5 ${MKCRYPTO_RC5} != no 2431.22Slukem# cvs ${MKCVS} != no 2441.23Slukem# doc ${MKDOC} != no 2451.36Smatt# gcccmds ${MKGCCCMDS} != no 2461.32Sscw# gdb ${MKGDB} != no 2471.22Slukem# hesiod ${MKHESIOD} != no 2481.23Slukem# info ${MKINFO} != no 2491.39Speter# ipfilter ${MKIPFILTER} != no 2501.38Slukem# inet6 ${MKINET6} != no 2511.22Slukem# kerberos ${MKKERBEROS} != no 2521.22Slukem# lint ${MKLINT} != no 2531.22Slukem# man ${MKMAN} != no 2541.22Slukem# manz ${MKMANZ} != no 2551.23Slukem# nls ${MKNLS} != no 2561.37She# pam ${MKPAM} != no 2571.39Speter# pf ${MKPF} != no 2581.22Slukem# postfix ${MKPOSTFIX} != no 2591.22Slukem# profile ${MKPROFILE} != no 2601.22Slukem# sendmail ${MKSENDMAIL} != no 2611.24Slukem# share ${MKSHARE} != no 2621.22Slukem# skey ${MKSKEY} != no 2631.25Slukem# uucp ${MKUUCP} != no 2641.22Slukem# yp ${MKYP} != no 2651.22Slukem# 2661.41Slukem# use_inet6 ${USE_INET6} != no 2671.41Slukem# use_kerberos ${USE_KERBEROS} != no 2681.41Slukem# use_yp ${USE_YP} != no 2691.41Slukem# 2701.22Slukem# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 2711.22Slukem# automatically append ".gz" to the filename 2721.22Slukem# 2731.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 2741.22Slukem# automatically append ".gz" to the filename 2751.1Sdyoung# 2761.8Slukemlist_set_files() 2771.8Slukem{ 2781.1Sdyoung for setname; do 2791.1Sdyoung list_set_lists $setname 2801.9Slukem done | xargs cat | \ 2811.43Sapb ${AWK} -v obsolete=${obsolete} ' 2821.9Slukem BEGIN { 2831.9Slukem if (! obsolete) { 2841.12Slukem split("'"${MKVARS}"'", needvars) 2851.9Slukem for (vi in needvars) { 2861.9Slukem nv = needvars[vi] 2871.41Slukem kw = tolower(nv) 2881.41Slukem sub(/^mk/, "", kw) 2891.12Slukem if (ENVIRON[nv] != "no") 2901.12Slukem wanted[kw] = 1 2911.9Slukem } 2921.33Sjmc if (("man" in wanted) && ("catpages" in wanted)) 2931.22Slukem wanted[".cat"] = 1 2941.33Sjmc if (("man" in wanted) && ("manpages" in wanted)) 2951.22Slukem wanted[".man"] = 1 2961.9Slukem } 2971.9Slukem } 2981.9Slukem 2991.9Slukem /^#/ { 3001.9Slukem next; 3011.9Slukem } 3021.9Slukem 3031.9Slukem NF > 2 && $3 != "-" { 3041.9Slukem split($3, keywords, ",") 3051.9Slukem show = 1 3061.9Slukem for (ki in keywords) { 3071.9Slukem kw = keywords[ki] 3081.9Slukem if (kw == "obsolete") { 3091.9Slukem if (obsolete) 3101.9Slukem print 3111.9Slukem next 3121.9Slukem } 3131.22Slukem if (("manz" in wanted) && 3141.22Slukem (kw == ".cat" || kw == ".man")) 3151.22Slukem $1 = $1 ".gz" 3161.9Slukem if (! (kw in wanted)) 3171.9Slukem show = 0 3181.9Slukem } 3191.9Slukem if (show) 3201.9Slukem print 3211.9Slukem next 3221.9Slukem } 3231.9Slukem 3241.9Slukem { 3251.9Slukem if (! obsolete) 3261.9Slukem print 3271.9Slukem }' 3281.9Slukem 3291.1Sdyoung} 3301.1Sdyoung 3311.1Sdyoung# 3321.1Sdyoung# list_set_lists setname 3331.1Sdyoung# 3341.1Sdyoung# Print to stdout a list of files, one filename per line, which 3351.1Sdyoung# concatenate to create the packing list for setname. E.g., 3361.1Sdyoung# 3371.1Sdyoung# .../lists/base/mi 3381.1Sdyoung# .../lists/base/rescue.mi 3391.1Sdyoung# .../lists/base/md.i386 3401.9Slukem# [...] 3411.1Sdyoung# 3421.9Slukem# For a given setname $set, the following files may be selected from 3431.9Slukem# .../list/$set: 3441.9Slukem# mi 3451.11Slukem# ad.${MACHINE_ARCH} 3461.11Slukem# (or) ad.${MACHINE_CPU} 3471.11Slukem# ad.${MACHINE_CPU}.shl 3481.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 3491.11Slukem# (or) md.${MACHINE} 3501.9Slukem# stl.mi 3511.9Slukem# stl.stlib 3521.9Slukem# shl.mi 3531.9Slukem# shl.shlib 3541.9Slukem# lkm.mi if ${lkm} != no 3551.9Slukem# gcc.mi 3561.9Slukem# gcc.shl 3571.9Slukem# tc.mi 3581.9Slukem# tc.shl 3591.9Slukem# rescue.shl 3601.11Slukem# rescue.${MACHINE} 3611.11Slukem# rescue.ad.${MACHINE_ARCH} 3621.11Slukem# (or) rescue.ad.${MACHINE_CPU} 3631.11Slukem# rescue.ad.${MACHINE_CPU}.shl 3641.1Sdyoung# 3651.9Slukem# Environment: 3661.1Sdyoung# shlib 3671.1Sdyoung# stlib 3681.1Sdyoung# 3691.8Slukemlist_set_lists() 3701.8Slukem{ 3711.1Sdyoung setname=$1 3721.1Sdyoung 3731.9Slukem setdir=$setsdir/lists/$setname 3741.9Slukem echo $setdir/mi 3751.11Slukem if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 3761.11Slukem # Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU}, 3771.1Sdyoung # since the arch-specific one will be more specific than 3781.1Sdyoung # the cpu-specific one. 3791.11Slukem if [ -f $setdir/ad.${MACHINE_ARCH} ]; then 3801.11Slukem echo $setdir/ad.${MACHINE_ARCH} 3811.11Slukem elif [ -f $setdir/ad.${MACHINE_CPU} ]; then 3821.11Slukem echo $setdir/ad.${MACHINE_CPU} 3831.1Sdyoung fi 3841.1Sdyoung if [ "$shlib" != "no" -a \ 3851.11Slukem -f $setdir/ad.${MACHINE_CPU}.shl ]; then 3861.11Slukem echo $setdir/ad.${MACHINE_CPU}.shl 3871.1Sdyoung fi 3881.1Sdyoung fi 3891.11Slukem if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then 3901.11Slukem echo $setdir/md.${MACHINE}.${MACHINE_ARCH} 3911.11Slukem elif [ -f $setdir/md.${MACHINE} ]; then 3921.11Slukem echo $setdir/md.${MACHINE} 3931.1Sdyoung fi 3941.9Slukem if [ -f $setdir/stl.mi ]; then 3951.9Slukem echo $setdir/stl.mi 3961.1Sdyoung fi 3971.9Slukem if [ -f $setdir/stl.${stlib} ]; then 3981.9Slukem echo $setdir/stl.${stlib} 3991.1Sdyoung fi 4001.1Sdyoung if [ "$shlib" != "no" ]; then 4011.9Slukem if [ -f $setdir/shl.mi ]; then 4021.9Slukem echo $setdir/shl.mi 4031.7Sdyoung fi 4041.9Slukem if [ -f $setdir/shl.${shlib} ]; then 4051.9Slukem echo $setdir/shl.${shlib} 4061.7Sdyoung fi 4071.1Sdyoung fi 4081.1Sdyoung if [ "$lkm" != "no" ]; then 4091.9Slukem if [ -f $setdir/lkm.mi ]; then 4101.9Slukem echo $setdir/lkm.mi 4111.1Sdyoung fi 4121.1Sdyoung fi 4131.11Slukem if [ "${TOOLCHAIN_MISSING}" != "yes" ]; then 4141.48Smrg if [ "${HAVE_GCC}" = "3" ]; then 4151.9Slukem if [ -f $setdir/gcc.mi ]; then 4161.9Slukem echo $setdir/gcc.mi 4171.2Smrg fi 4181.2Smrg if [ "$shlib" != "no" ]; then 4191.9Slukem if [ -f $setdir/gcc.shl ]; then 4201.9Slukem echo $setdir/gcc.shl 4211.2Smrg fi 4221.2Smrg fi 4231.48Smrg elif [ "${HAVE_GCC}" = "4" ]; then 4241.48Smrg if [ -f $setdir/gcc4.mi ]; then 4251.48Smrg echo $setdir/gcc4.mi 4261.48Smrg fi 4271.48Smrg if [ "$shlib" != "no" ]; then 4281.48Smrg if [ -f $setdir/gcc4.shl ]; then 4291.48Smrg echo $setdir/gcc4.shl 4301.48Smrg fi 4311.48Smrg fi 4321.2Smrg else 4331.9Slukem if [ -f $setdir/tc.mi ]; then 4341.9Slukem echo $setdir/tc.mi 4351.2Smrg fi 4361.2Smrg if [ "$shlib" != "no" ]; then 4371.9Slukem if [ -f $setdir/tc.shl ]; then 4381.9Slukem echo $setdir/tc.shl 4391.2Smrg fi 4401.1Sdyoung fi 4411.1Sdyoung fi 4421.1Sdyoung fi 4431.1Sdyoung 4441.9Slukem if [ -f $setdir/rescue.mi ]; then 4451.9Slukem echo $setdir/rescue.mi 4461.1Sdyoung fi 4471.11Slukem if [ -f $setdir/rescue.${MACHINE} ]; then 4481.11Slukem echo $setdir/rescue.${MACHINE} 4491.1Sdyoung fi 4501.11Slukem if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 4511.11Slukem # Prefer a rescue.ad.${MACHINE_ARCH} over a 4521.11Slukem # rescue.ad.${MACHINE_CPU}, since the arch- 4531.1Sdyoung # specific one will be more specific than the 4541.1Sdyoung # cpu-specific one. 4551.11Slukem if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then 4561.11Slukem echo $setdir/rescue.ad.${MACHINE_ARCH} 4571.11Slukem elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then 4581.11Slukem echo $setdir/rescue.ad.${MACHINE_CPU} 4591.1Sdyoung fi 4601.10Sjmc if [ "$shlib" != "no" -a \ 4611.11Slukem -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then 4621.11Slukem echo $setdir/rescue.ad.${MACHINE_CPU}.shl 4631.10Sjmc fi 4641.1Sdyoung fi 4651.5Sdyoung} 4661.5Sdyoung 4671.9Slukem# arch_to_cpu mach 4681.9Slukem# 4691.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 4701.9Slukem# as determined by <bsd.own.mk>. 4711.9Slukem# 4721.8Slukemarch_to_cpu() 4731.8Slukem{ 4741.43Sapb MACHINE_ARCH=${1} ${MAKE} -f- all <<EOMAKE 4751.5Sdyoung.include <bsd.own.mk> 4761.5Sdyoungall: 4771.5Sdyoung @echo \${MACHINE_CPU} 4781.12SlukemEOMAKE 4791.1Sdyoung} 4801.46Sapb 4811.46Sapb# arch_to_endian mach 4821.46Sapb# 4831.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 4841.46Sapb# as determined by <bsd.endian.mk>. 4851.46Sapb# 4861.46Sapbarch_to_endian() 4871.46Sapb{ 4881.46Sapb MACHINE_ARCH=${1} ${MAKE} -f- all <<EOMAKE 4891.46Sapb.include <bsd.endian.mk> 4901.46Sapball: 4911.46Sapb @echo \${TARGET_ENDIANNESS} 4921.46SapbEOMAKE 4931.46Sapb} 494