sets.subr revision 1.195
11.194Skamil# $NetBSD: sets.subr,v 1.195 2020/11/10 21:47:40 kamil 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.92Suebayasi# extlists list of extsrc sets 101.9Slukem# obsolete controls if obsolete files are selected instead 111.76Stsutsui# module if != "no", enable MODULE sets 121.9Slukem# shlib shared library format (a.out, elf, or "") 131.9Slukem# stlib static library format (a.out, elf) 141.11Slukem# 151.11Slukem# The following <bsd.own.mk> variables are exported to the environment: 161.11Slukem# MACHINE 171.11Slukem# MACHINE_ARCH 181.11Slukem# MACHINE_CPU 191.192Sjmcneill# HAVE_ACPI 201.87Sskrll# HAVE_BINUTILS 211.48Smrg# HAVE_GCC 221.52Slukem# HAVE_GDB 231.193Sjmcneill# HAVE_NVMM 241.193Sjmcneill# HAVE_OPENSSL 251.143Snakayama# HAVE_SSP 261.192Sjmcneill# HAVE_UEFI 271.11Slukem# TOOLCHAIN_MISSING 281.11Slukem# OBJECT_FMT 291.22Slukem# as well as: 301.22Slukem# 311.95Suebayasi 321.42Sapb# 331.42Sapb# The following variables refer to tools that are used when building sets: 341.42Sapb# 351.43Sapb: ${AWK:=awk} 361.42Sapb: ${CKSUM:=cksum} 371.43Sapb: ${COMM:=comm} 381.44Sapb: ${DATE:=date} 391.43Sapb: ${DB:=db} 401.43Sapb: ${EGREP:=egrep} 411.43Sapb: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc. 421.44Sapb: ${FGREP:=fgrep} 431.43Sapb: ${FIND:=find} 441.44Sapb: ${GREP:=grep} 451.43Sapb: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1) 461.99Sapb: ${HOSTNAME_CMD:=hostname} # ${HOSTNAME} is special to bash(1) 471.42Sapb: ${HOST_SH:=sh} 481.43Sapb: ${IDENT:=ident} 491.43Sapb: ${JOIN:=join} 501.43Sapb: ${LS:=ls} 511.43Sapb: ${MAKE:=make} 521.42Sapb: ${MKTEMP:=mktemp} 531.43Sapb: ${MTREE:=mtree} 541.43Sapb: ${PASTE:=paste} 551.42Sapb: ${PAX:=pax} 561.43Sapb: ${PRINTF:=printf} 571.43Sapb: ${SED:=sed} 581.43Sapb: ${SORT:=sort} 591.44Sapb: ${STAT:=stat} 601.44Sapb: ${TSORT:=tsort} 611.43Sapb: ${UNAME:=uname} 621.43Sapb: ${WC:=wc} 631.118Suebayasi: ${XARGS:=xargs} 641.43Sapb 651.45Sapb# 661.45Sapb# If printf is a shell builtin command, then we can 671.45Sapb# implement cheaper versions of basename and dirname 681.45Sapb# that do not involve any fork/exec overhead. 691.45Sapb# If printf is not builtin, approximate it using echo, 701.45Sapb# and hope there are no weird file names that cause 711.45Sapb# some versions of echo to do the wrong thing. 721.45Sapb# (Converting to this version of dirname speeded up the 731.45Sapb# syspkgdeps script by an order of magnitude, from 68 741.45Sapb# seconds to 6.3 seconds on one particular host.) 751.45Sapb# 761.45Sapb# Note that naive approximations for dirname 771.45Sapb# using ${foo%/*} do not do the right thing in cases 781.45Sapb# where the result should be "/" or ".". 791.45Sapb# 801.45Sapbcase "$(type printf)" in 811.45Sapb*builtin*) 821.45Sapb basename () 831.45Sapb { 841.45Sapb local bn 851.45Sapb bn="${1##*/}" 861.45Sapb bn="${bn%$2}" 871.45Sapb printf "%s\n" "$bn" 881.45Sapb } 891.45Sapb dirname () 901.45Sapb { 911.45Sapb local dn 921.45Sapb case "$1" in 931.45Sapb ?*/*) dn="${1%/*}" ;; 941.45Sapb /*) dn=/ ;; 951.45Sapb *) dn=. ;; 961.45Sapb esac 971.45Sapb printf "%s\n" "$dn" 981.45Sapb } 991.45Sapb ;; 1001.45Sapb*) 1011.45Sapb basename () 1021.45Sapb { 1031.45Sapb local bn 1041.45Sapb bn="${1##*/}" 1051.45Sapb bn="${bn%$2}" 1061.45Sapb echo "$bn" 1071.45Sapb } 1081.45Sapb dirname () 1091.45Sapb { 1101.45Sapb local dn 1111.45Sapb case "$1" in 1121.45Sapb ?*/*) dn="${1%/*}" ;; 1131.45Sapb /*) dn=/ ;; 1141.45Sapb *) dn=. ;; 1151.45Sapb esac 1161.45Sapb echo "$dn" 1171.45Sapb } 1181.45Sapb ;; 1191.45Sapbesac 1201.45Sapb 1211.108Suebayasi##### 1221.108Suebayasi 1231.9SlukemoIFS=$IFS 1241.9SlukemIFS=" 1251.9Slukem" 1261.100Suebayasi 1271.180Schristosfor x in $( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do 1281.108Suebayasi eval export $x 1291.9Slukemdone 1301.100Suebayasi 1311.9SlukemIFS=$oIFS 1321.9Slukem 1331.180SchristosMKVARS="$( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )" 1341.100Suebayasi 1351.105Suebayasi##### 1361.105Suebayasi 1371.117Suebayasisetsdir=${rundir} 1381.9Slukemobsolete=0 1391.91Sdyoungif [ "${MKKMOD}" = "no" ]; then 1401.91Sdyoung module=no # MODULEs are off. 1411.125Snjoly modset="" 1421.125Snjolyelse 1431.125Snjoly module=yes 1441.125Snjoly modset="modules" 1451.125Snjolyfi 1461.125Snjolyif [ "${MKATF}" = "no" ]; then 1471.125Snjoly testset="" 1481.125Snjolyelse 1491.125Snjoly testset="tests" 1501.9Slukemfi 1511.171Smattif [ "${MKDEBUG}" = "no" -a "${MKDEBUGLIB}" = "no" ]; then 1521.141Schristos debugset="" 1531.142Schristos xdebugset="" 1541.141Schristoselse 1551.141Schristos debugset="debug" 1561.142Schristos xdebugset="xdebug" 1571.141Schristosfi 1581.191Sjmcneillif [ "${MKDTB}" = "no" ]; then 1591.191Sjmcneill dtbset="" 1601.191Sjmcneillelse 1611.191Sjmcneill dtbset="dtb" 1621.191Sjmcneillfi 1631.31Sjmc# Determine lib type. Do this first so stlib also gets set. 1641.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 1651.9Slukem shlib=elf 1661.9Slukemelse 1671.9Slukem shlib=aout 1681.9Slukemfi 1691.9Slukemstlib=$shlib 1701.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 1711.31Sjmcif [ "${MKPIC}" = "no" ]; then 1721.31Sjmc shlib=no 1731.31Sjmcfi 1741.191Sjmcneillnlists="base comp $debugset $dtbset etc games man misc $modset rescue $testset text" 1751.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 1761.92Suebayasiextlists="extbase extcomp extetc" 1771.9Slukem 1781.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 1791.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 1801.188Schristos MODULEDIR="netbsd/modules" 1811.188Schristoselse 1821.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 1831.188Schristosfi 1841.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 1851.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 1861.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 1871.60Sad 1881.9Slukem# 1891.9Slukem# list_set_files setfile [...] 1901.1Sdyoung# 1911.9Slukem# Produce a packing list for setfile(s). 1921.9Slukem# In each file, a record consists of a path and a System Package name, 1931.9Slukem# separated by whitespace. E.g., 1941.9Slukem# 1951.194Skamil# # $NetBSD: sets.subr,v 1.195 2020/11/10 21:47:40 kamil Exp $ 1961.9Slukem# . base-sys-root [keyword[,...]] 1971.9Slukem# ./altroot base-sys-root 1981.9Slukem# ./bin base-sys-root 1991.9Slukem# ./bin/[ base-util-root 2001.9Slukem# ./bin/cat base-util-root 2011.9Slukem# [...] 2021.9Slukem# 2031.9Slukem# A # in the first column marks a comment. 2041.9Slukem# 2051.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2061.52Slukem# be printed. All other keywords must be present. 2071.9Slukem# 2081.9Slukem# The third field is an optional comma separated list of keywords to 2091.9Slukem# control if a record is printed; every keyword listed must be enabled 2101.179Schristos# for the record to be printed. The list of all avalaible make variables 2111.179Schristos# that can be turned on or off can be found by running in this directory: 2121.179Schristos# 2131.179Schristos# make -f mkvars.mk mkvarsyesno 2141.179Schristos# 2151.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2161.179Schristos# 2171.179Schristos# The following extra keywords are also available, listed by: 2181.179Schristos# 2191.179Schristos# make -f mkvars.mk mkextravars 2201.13Slukem# 2211.179Schristos# These are: 2221.179Schristos# 1. The HAVE_<name>: 2231.179Schristos# ssp ${HAVE_SSP} != no 2241.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2251.192Sjmcneill# acpi ${HAVE_ACPI} != no 2261.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2271.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2281.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2291.192Sjmcneill# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2301.193Sjmcneill# nvmm ${HAVE_NVMM} != no 2311.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2321.192Sjmcneill# uefi ${HAVE_UEFI} != no 2331.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 2341.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 2351.52Slukem# 2361.179Schristos# 2. The USE_<name>: 2371.41Slukem# use_inet6 ${USE_INET6} != no 2381.41Slukem# use_kerberos ${USE_KERBEROS} != no 2391.179Schristos# use_ldap ${USE_LDAP} != no 2401.41Slukem# use_yp ${USE_YP} != no 2411.41Slukem# 2421.179Schristos# 3. Finally: 2431.179Schristos# dummy dummy entry (ignored) 2441.179Schristos# obsolete file is obsolete, and only printed if 2451.179Schristos# ${obsolete} != 0 2461.179Schristos# 2471.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 2481.179Schristos# 2491.179Schristos# 2501.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 2511.179Schristos# 2521.179Schristos# 2531.195Skamil# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 2541.195Skamil# automatically append ".gz" to the filename 2551.195Skamil# 2561.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 2571.22Slukem# automatically append ".gz" to the filename 2581.1Sdyoung# 2591.8Slukemlist_set_files() 2601.8Slukem{ 2611.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 2621.65She verbose=false 2631.65She else 2641.65She verbose=true 2651.65She fi 2661.116Suebayasi print_set_lists "$@" | \ 2671.43Sapb ${AWK} -v obsolete=${obsolete} ' 2681.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 2691.190Schristos if (substr(line, 1, patlen) != pat) { 2701.190Schristos return; 2711.190Schristos } 2721.190Schristos for (d in kmodarchdirs) { 2731.190Schristos xd = prefix kmodarchdirs[d] 2741.190Schristos xfile = xd substr(line, patlen + 1) 2751.190Schristos tmp = xd substr(fname, patlen + 1) 2761.190Schristos list[xfile] = tmp; 2771.190Schristos } 2781.190Schristos } 2791.9Slukem BEGIN { 2801.52Slukem if (obsolete) 2811.52Slukem wanted["obsolete"] = 1 2821.52Slukem 2831.100Suebayasi split("'"${MKVARS}"'", needvars) 2841.165Smatt doingcompat = 0 2851.165Smatt doingcompattests = 0 2861.165Smatt ignoredkeywords["compatdir"] = 1 2871.165Smatt ignoredkeywords["compatfile"] = 1 2881.165Smatt ignoredkeywords["compattestdir"] = 1 2891.165Smatt ignoredkeywords["compattestfile"] = 1 2901.170Smatt ignoredkeywords["compatx11dir"] = 1 2911.170Smatt ignoredkeywords["compatx11file"] = 1 2921.52Slukem for (vi in needvars) { 2931.52Slukem nv = needvars[vi] 2941.52Slukem kw = tolower(nv) 2951.52Slukem sub(/^mk/, "", kw) 2961.143Snakayama sub(/^have_/, "", kw) 2971.148Smatt sub(/^target_endianness/, "endian", kw) 2981.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 2991.165Smatt wanted[kw] = 1 3001.167Smatt } 3011.166Smatt } 3021.166Smatt 3031.167Smatt if ("compat" in wanted) { 3041.166Smatt doingcompat = 1; 3051.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3061.166Smatt compatdirkeywords["compatdir"] = 1 3071.166Smatt compatfilekeywords["compatfile"] = 1 3081.166Smatt 3091.166Smatt if (wanted["compattests"]) { 3101.165Smatt doingcompattests = 1; 3111.165Smatt compatdirkeywords["compattestdir"] = 1 3121.165Smatt compatfilekeywords["compattestfile"] = 1 3131.166Smatt } 3141.170Smatt if (wanted["compatx11"]) { 3151.170Smatt doingcompatx11 = 1; 3161.170Smatt compatdirkeywords["compatx11dir"] = 1 3171.170Smatt compatfilekeywords["compatx11file"] = 1 3181.170Smatt } 3191.166Smatt } 3201.166Smatt 3211.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 3221.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 3231.190Schristos kmodprefix = "./stand/" 3241.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 3251.166Smatt l_kmodpat = length(kmodpat) 3261.190Schristos kmoddbprefix = "./usr/libdata/debug/stand/" 3271.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 3281.190Schristos l_kmoddbpat = length(kmoddbpat) 3291.52Slukem } 3301.52Slukem 3311.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 3321.90Sdyoung if ("binutils" in wanted) 3331.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 3341.90Sdyoung if ("gcc" in wanted) 3351.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 3361.90Sdyoung if ("gdb" in wanted) 3371.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 3381.9Slukem } 3391.192Sjmcneill if ("acpi" in wanted) { 3401.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 3411.192Sjmcneill } 3421.192Sjmcneill if ("mesa_ver" in wanted) { 3431.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 3441.192Sjmcneill } 3451.193Sjmcneill if ("nvmm" in wanted) { 3461.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 3471.193Sjmcneill } 3481.183Schristos if ("openssl" in wanted) { 3491.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 3501.183Schristos } 3511.178Smrg if ("xorg_server_ver" in wanted) { 3521.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 3531.177Smrg } 3541.192Sjmcneill if ("uefi" in wanted) { 3551.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 3561.185Smrg } 3571.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 3581.195Skamil wanted[".cat"] = 1 3591.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 3601.52Slukem wanted[".man"] = 1 3611.148Smatt if ("endian" in wanted) 3621.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 3631.162Smrg if ("machine" in wanted) 3641.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 3651.162Smrg if ("machine_arch" in wanted) 3661.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 3671.162Smrg if ("machine_cpu" in wanted) 3681.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 3691.9Slukem } 3701.9Slukem 3711.9Slukem /^#/ { 3721.9Slukem next; 3731.9Slukem } 3741.9Slukem 3751.127Smatt /^-/ { 3761.127Smatt notwanted[substr($1, 2)] = 1; 3771.127Smatt delete list [substr($1, 2)]; 3781.127Smatt next; 3791.127Smatt } 3801.127Smatt 3811.127Smatt 3821.9Slukem NF > 2 && $3 != "-" { 3831.127Smatt if (notwanted[$1] != "") 3841.127Smatt next; 3851.9Slukem split($3, keywords, ",") 3861.9Slukem show = 1 3871.52Slukem haveobs = 0 3881.167Smatt iscompatfile = 0 3891.165Smatt havekmod = 0 3901.165Smatt iscompatdir = 0 3911.9Slukem for (ki in keywords) { 3921.9Slukem kw = keywords[ki] 3931.22Slukem if (("manz" in wanted) && 3941.22Slukem (kw == ".cat" || kw == ".man")) 3951.22Slukem $1 = $1 ".gz" 3961.134Sjoerg if (substr(kw, 1, 1) == "!") { 3971.134Sjoerg kw = substr(kw, 2) 3981.59Sjmmv if (kw in wanted) 3991.59Sjmmv show = 0 4001.165Smatt } else if (kw in compatdirkeywords) { 4011.165Smatt iscompatdir = 1 4021.165Smatt } else if (kw in compatfilekeywords) { 4031.167Smatt iscompatfile = 1 4041.172Smatt } else if (kw == "nocompatmodules") { 4051.172Smatt havekmod = -1 4061.165Smatt } else if (kw in ignoredkeywords) { 4071.165Smatt # ignore 4081.167Smatt } else if (! (kw in wanted)) { 4091.167Smatt show = 0 4101.172Smatt } else if (kw == "kmod" && havekmod == 0) { 4111.167Smatt havekmod = 1 4121.59Sjmmv } 4131.52Slukem if (kw == "obsolete") 4141.52Slukem haveobs = 1 4151.9Slukem } 4161.184Snakayama if (iscompatdir) { 4171.184Snakayama for (d in cpaths) { 4181.184Snakayama if (cpaths[d] == $1 "/") 4191.184Snakayama next 4201.184Snakayama } 4211.184Snakayama cpaths[ncpaths++] = $1 "/" 4221.184Snakayama } 4231.52Slukem if (obsolete && ! haveobs) 4241.52Slukem next 4251.165Smatt if (!show) 4261.165Smatt next 4271.165Smatt 4281.165Smatt list[$1] = $0 4291.190Schristos if (havekmod > 0) { 4301.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 4311.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 4321.165Smatt next 4331.165Smatt } 4341.165Smatt 4351.167Smatt if (!doingcompat || !(iscompatfile || iscompatdir)) 4361.165Smatt next 4371.165Smatt 4381.167Smatt if (iscompatfile) { 4391.165Smatt emitcompat[$1] = 1; 4401.168Smatt next 4411.168Smatt } 4421.165Smatt for (d in compatarchdirs) { 4431.165Smatt tmp = $0 4441.165Smatt xfile = $1 "/" compatarchdirs[d] 4451.165Smatt tmp = xfile substr(tmp, length($1) + 1) 4461.165Smatt if (xfile in notwanted) 4471.165Smatt continue; 4481.165Smatt sub("compatdir","compat",tmp); 4491.165Smatt sub("compattestdir","compat",tmp); 4501.165Smatt list[xfile] = tmp 4511.165Smatt } 4521.9Slukem next 4531.9Slukem } 4541.9Slukem 4551.9Slukem { 4561.165Smatt if ($1 in notwanted) 4571.127Smatt next; 4581.9Slukem if (! obsolete) 4591.127Smatt list[$1] = $0 4601.127Smatt } 4611.127Smatt 4621.127Smatt END { 4631.127Smatt for (i in list) { 4641.127Smatt print list[i] 4651.165Smatt if (! (i in emitcompat)) 4661.165Smatt continue; 4671.165Smatt l_i = length(i) 4681.165Smatt l = 0 4691.165Smatt for (j in cpaths) { 4701.165Smatt lx = length(cpaths[j]) 4711.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 4721.165Smatt continue; 4731.165Smatt } 4741.165Smatt if (lx > l) { 4751.165Smatt l = lx; 4761.165Smatt cpath = cpaths[j]; 4771.165Smatt } 4781.165Smatt } 4791.165Smatt for (d in compatarchdirs) { 4801.165Smatt tmp = list[i] 4811.165Smatt extrapath = compatarchdirs[d] "/" 4821.165Smatt xfile = cpath extrapath substr(i, l + 1) 4831.165Smatt if (xfile in notwanted) 4841.165Smatt continue; 4851.165Smatt sub("compatfile","compat",tmp); 4861.165Smatt sub("compattestfile","compat",tmp); 4871.165Smatt tmp = xfile substr(tmp, l_i + 1) 4881.165Smatt print tmp; 4891.165Smatt } 4901.127Smatt } 4911.9Slukem }' 4921.9Slukem 4931.1Sdyoung} 4941.1Sdyoung 4951.1Sdyoung# 4961.1Sdyoung# list_set_lists setname 4971.1Sdyoung# 4981.1Sdyoung# Print to stdout a list of files, one filename per line, which 4991.1Sdyoung# concatenate to create the packing list for setname. E.g., 5001.1Sdyoung# 5011.1Sdyoung# .../lists/base/mi 5021.1Sdyoung# .../lists/base/rescue.mi 5031.1Sdyoung# .../lists/base/md.i386 5041.9Slukem# [...] 5051.1Sdyoung# 5061.9Slukem# For a given setname $set, the following files may be selected from 5071.9Slukem# .../list/$set: 5081.9Slukem# mi 5091.92Suebayasi# mi.ext.* 5101.11Slukem# ad.${MACHINE_ARCH} 5111.11Slukem# (or) ad.${MACHINE_CPU} 5121.11Slukem# ad.${MACHINE_CPU}.shl 5131.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 5141.11Slukem# (or) md.${MACHINE} 5151.9Slukem# stl.mi 5161.92Suebayasi# stl.${stlib} 5171.9Slukem# shl.mi 5181.92Suebayasi# shl.mi.ext.* 5191.92Suebayasi# shl.${shlib} 5201.92Suebayasi# shl.${shlib}.ext.* 5211.77Stsutsui# module.mi if ${module} != no 5221.77Stsutsui# module.${MACHINE} if ${module} != no 5231.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 5241.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 5251.9Slukem# rescue.shl 5261.11Slukem# rescue.${MACHINE} 5271.11Slukem# rescue.ad.${MACHINE_ARCH} 5281.11Slukem# (or) rescue.ad.${MACHINE_CPU} 5291.11Slukem# rescue.ad.${MACHINE_CPU}.shl 5301.1Sdyoung# 5311.9Slukem# Environment: 5321.1Sdyoung# shlib 5331.1Sdyoung# stlib 5341.1Sdyoung# 5351.8Slukemlist_set_lists() 5361.8Slukem{ 5371.1Sdyoung setname=$1 5381.1Sdyoung 5391.111Suebayasi list_set_lists_mi $setname 5401.113Suebayasi list_set_lists_ad $setname 5411.111Suebayasi list_set_lists_md $setname 5421.111Suebayasi list_set_lists_stl $setname 5431.113Suebayasi list_set_lists_shl $setname 5441.113Suebayasi list_set_lists_module $setname 5451.111Suebayasi list_set_lists_rescue $setname 5461.117Suebayasi return 0 5471.111Suebayasi} 5481.110Suebayasi 5491.111Suebayasilist_set_lists_mi() 5501.111Suebayasi{ 5511.111Suebayasi setdir=$setsdir/lists/$1 5521.113Suebayasi # always exist! 5531.9Slukem echo $setdir/mi 5541.111Suebayasi} 5551.110Suebayasi 5561.111Suebayasilist_set_lists_ad() 5571.111Suebayasi{ 5581.111Suebayasi setdir=$setsdir/lists/$1 5591.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5601.113Suebayasi list_set_lists_common_ad $1 5611.111Suebayasi} 5621.110Suebayasi 5631.111Suebayasilist_set_lists_md() 5641.111Suebayasi{ 5651.111Suebayasi setdir=$setsdir/lists/$1 5661.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 5671.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 5681.111Suebayasi} 5691.110Suebayasi 5701.111Suebayasilist_set_lists_stl() 5711.111Suebayasi{ 5721.111Suebayasi setdir=$setsdir/lists/$1 5731.110Suebayasi echo_if_exist $setdir/stl.mi 5741.110Suebayasi echo_if_exist $setdir/stl.${stlib} 5751.111Suebayasi} 5761.110Suebayasi 5771.111Suebayasilist_set_lists_shl() 5781.111Suebayasi{ 5791.111Suebayasi setdir=$setsdir/lists/$1 5801.113Suebayasi [ "$shlib" != "no" ] || return 5811.112Suebayasi echo_if_exist $setdir/shl.mi 5821.112Suebayasi echo_if_exist $setdir/shl.${shlib} 5831.111Suebayasi} 5841.110Suebayasi 5851.111Suebayasilist_set_lists_module() 5861.111Suebayasi{ 5871.111Suebayasi setdir=$setsdir/lists/$1 5881.113Suebayasi [ "$module" != "no" ] || return 5891.112Suebayasi echo_if_exist $setdir/module.mi 5901.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 5911.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 5921.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 5931.113Suebayasi # XXX module never has .shl 5941.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5951.113Suebayasi list_set_lists_common_ad $1 module 5961.111Suebayasi} 5971.1Sdyoung 5981.111Suebayasilist_set_lists_rescue() 5991.111Suebayasi{ 6001.111Suebayasi setdir=$setsdir/lists/$1 6011.110Suebayasi echo_if_exist $setdir/rescue.mi 6021.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 6031.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6041.113Suebayasi list_set_lists_common_ad $1 rescue 6051.111Suebayasi} 6061.111Suebayasi 6071.113Suebayasilist_set_lists_common_ad() 6081.111Suebayasi{ 6091.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 6101.113Suebayasi 6111.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 6121.113Suebayasi 6131.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 6141.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 6151.112Suebayasi # specific one will be more specific than the 6161.112Suebayasi # cpu-specific one. 6171.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 6181.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 6191.113Suebayasi [ "$shlib" != "no" ] && \ 6201.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 6211.5Sdyoung} 6221.5Sdyoung 6231.110Suebayasiecho_if_exist() 6241.110Suebayasi{ 6251.110Suebayasi [ -f $1 ] && echo $1 6261.110Suebayasi return $? 6271.110Suebayasi} 6281.110Suebayasi 6291.110Suebayasiecho_if_exist_foreach() 6301.110Suebayasi{ 6311.110Suebayasi local _list=$1; shift 6321.110Suebayasi for _suffix in $@; do 6331.110Suebayasi echo_if_exist ${_list}.${_suffix} 6341.110Suebayasi done 6351.110Suebayasi} 6361.110Suebayasi 6371.116Suebayasiprint_set_lists() 6381.116Suebayasi{ 6391.116Suebayasi for setname; do 6401.136Schristos list=$(list_set_lists $setname) 6411.116Suebayasi for l in $list; do 6421.116Suebayasi echo $l 6431.116Suebayasi if $verbose; then 6441.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 6451.116Suebayasi fi 6461.116Suebayasi done 6471.118Suebayasi done | ${XARGS} ${SED} ${SUBST} 6481.116Suebayasi} 6491.116Suebayasi 6501.9Slukem# arch_to_cpu mach 6511.9Slukem# 6521.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 6531.9Slukem# as determined by <bsd.own.mk>. 6541.9Slukem# 6551.8Slukemarch_to_cpu() 6561.8Slukem{ 6571.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6581.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6591.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 6601.182Suwe -V '${MACHINE_CPU}' 6611.1Sdyoung} 6621.46Sapb 6631.46Sapb# arch_to_endian mach 6641.46Sapb# 6651.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 6661.46Sapb# as determined by <bsd.endian.mk>. 6671.46Sapb# 6681.46Sapbarch_to_endian() 6691.46Sapb{ 6701.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6711.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6721.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 6731.182Suwe -V '${TARGET_ENDIANNESS}' 6741.46Sapb} 6751.117Suebayasi 6761.117Suebayasi##### 6771.117Suebayasi 6781.117Suebayasi# print_mkvars 6791.117Suebayasiprint_mkvars() 6801.117Suebayasi{ 6811.117Suebayasi for v in $MKVARS; do 6821.117Suebayasi eval echo $v=\$$v 6831.117Suebayasi done 6841.117Suebayasi} 6851.117Suebayasi 6861.117Suebayasi# print_set_lists_{base,x,ext} 6871.117Suebayasi# list_set_lists_{base,x,ext} 6881.117Suebayasi# list_set_files_{base,x,ext} 6891.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 6901.117Suebayasi for x in base x ext; do 6911.117Suebayasi if [ $x = base ]; then 6921.117Suebayasi list=nlists 6931.117Suebayasi else 6941.117Suebayasi list=${x}lists 6951.117Suebayasi fi 6961.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 6971.117Suebayasi done 6981.117Suebayasidone 699