sets.subr revision 1.191
11.191Sjmcneill# $NetBSD: sets.subr,v 1.191 2020/05/18 21:19:34 jmcneill 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.87Sskrll# HAVE_BINUTILS 201.48Smrg# HAVE_GCC 211.52Slukem# HAVE_GDB 221.143Snakayama# HAVE_SSP 231.183Schristos# HAVE_OPENSSL 241.11Slukem# TOOLCHAIN_MISSING 251.11Slukem# OBJECT_FMT 261.22Slukem# as well as: 271.22Slukem# 281.95Suebayasi 291.42Sapb# 301.42Sapb# The following variables refer to tools that are used when building sets: 311.42Sapb# 321.43Sapb: ${AWK:=awk} 331.42Sapb: ${CKSUM:=cksum} 341.43Sapb: ${COMM:=comm} 351.44Sapb: ${DATE:=date} 361.43Sapb: ${DB:=db} 371.43Sapb: ${EGREP:=egrep} 381.43Sapb: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc. 391.44Sapb: ${FGREP:=fgrep} 401.43Sapb: ${FIND:=find} 411.44Sapb: ${GREP:=grep} 421.43Sapb: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1) 431.99Sapb: ${HOSTNAME_CMD:=hostname} # ${HOSTNAME} is special to bash(1) 441.42Sapb: ${HOST_SH:=sh} 451.43Sapb: ${IDENT:=ident} 461.43Sapb: ${JOIN:=join} 471.43Sapb: ${LS:=ls} 481.43Sapb: ${MAKE:=make} 491.42Sapb: ${MKTEMP:=mktemp} 501.43Sapb: ${MTREE:=mtree} 511.43Sapb: ${PASTE:=paste} 521.42Sapb: ${PAX:=pax} 531.43Sapb: ${PRINTF:=printf} 541.43Sapb: ${SED:=sed} 551.43Sapb: ${SORT:=sort} 561.44Sapb: ${STAT:=stat} 571.44Sapb: ${TSORT:=tsort} 581.43Sapb: ${UNAME:=uname} 591.43Sapb: ${WC:=wc} 601.118Suebayasi: ${XARGS:=xargs} 611.43Sapb 621.45Sapb# 631.45Sapb# If printf is a shell builtin command, then we can 641.45Sapb# implement cheaper versions of basename and dirname 651.45Sapb# that do not involve any fork/exec overhead. 661.45Sapb# If printf is not builtin, approximate it using echo, 671.45Sapb# and hope there are no weird file names that cause 681.45Sapb# some versions of echo to do the wrong thing. 691.45Sapb# (Converting to this version of dirname speeded up the 701.45Sapb# syspkgdeps script by an order of magnitude, from 68 711.45Sapb# seconds to 6.3 seconds on one particular host.) 721.45Sapb# 731.45Sapb# Note that naive approximations for dirname 741.45Sapb# using ${foo%/*} do not do the right thing in cases 751.45Sapb# where the result should be "/" or ".". 761.45Sapb# 771.45Sapbcase "$(type printf)" in 781.45Sapb*builtin*) 791.45Sapb basename () 801.45Sapb { 811.45Sapb local bn 821.45Sapb bn="${1##*/}" 831.45Sapb bn="${bn%$2}" 841.45Sapb printf "%s\n" "$bn" 851.45Sapb } 861.45Sapb dirname () 871.45Sapb { 881.45Sapb local dn 891.45Sapb case "$1" in 901.45Sapb ?*/*) dn="${1%/*}" ;; 911.45Sapb /*) dn=/ ;; 921.45Sapb *) dn=. ;; 931.45Sapb esac 941.45Sapb printf "%s\n" "$dn" 951.45Sapb } 961.45Sapb ;; 971.45Sapb*) 981.45Sapb basename () 991.45Sapb { 1001.45Sapb local bn 1011.45Sapb bn="${1##*/}" 1021.45Sapb bn="${bn%$2}" 1031.45Sapb echo "$bn" 1041.45Sapb } 1051.45Sapb dirname () 1061.45Sapb { 1071.45Sapb local dn 1081.45Sapb case "$1" in 1091.45Sapb ?*/*) dn="${1%/*}" ;; 1101.45Sapb /*) dn=/ ;; 1111.45Sapb *) dn=. ;; 1121.45Sapb esac 1131.45Sapb echo "$dn" 1141.45Sapb } 1151.45Sapb ;; 1161.45Sapbesac 1171.45Sapb 1181.108Suebayasi##### 1191.108Suebayasi 1201.9SlukemoIFS=$IFS 1211.9SlukemIFS=" 1221.9Slukem" 1231.100Suebayasi 1241.180Schristosfor x in $( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do 1251.108Suebayasi eval export $x 1261.9Slukemdone 1271.100Suebayasi 1281.9SlukemIFS=$oIFS 1291.9Slukem 1301.180SchristosMKVARS="$( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )" 1311.100Suebayasi 1321.105Suebayasi##### 1331.105Suebayasi 1341.117Suebayasisetsdir=${rundir} 1351.9Slukemobsolete=0 1361.91Sdyoungif [ "${MKKMOD}" = "no" ]; then 1371.91Sdyoung module=no # MODULEs are off. 1381.125Snjoly modset="" 1391.125Snjolyelse 1401.125Snjoly module=yes 1411.125Snjoly modset="modules" 1421.125Snjolyfi 1431.125Snjolyif [ "${MKATF}" = "no" ]; then 1441.125Snjoly testset="" 1451.125Snjolyelse 1461.125Snjoly testset="tests" 1471.9Slukemfi 1481.171Smattif [ "${MKDEBUG}" = "no" -a "${MKDEBUGLIB}" = "no" ]; then 1491.141Schristos debugset="" 1501.142Schristos xdebugset="" 1511.141Schristoselse 1521.141Schristos debugset="debug" 1531.142Schristos xdebugset="xdebug" 1541.141Schristosfi 1551.191Sjmcneillif [ "${MKDTB}" = "no" ]; then 1561.191Sjmcneill dtbset="" 1571.191Sjmcneillelse 1581.191Sjmcneill dtbset="dtb" 1591.191Sjmcneillfi 1601.31Sjmc# Determine lib type. Do this first so stlib also gets set. 1611.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 1621.9Slukem shlib=elf 1631.9Slukemelse 1641.9Slukem shlib=aout 1651.9Slukemfi 1661.9Slukemstlib=$shlib 1671.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 1681.31Sjmcif [ "${MKPIC}" = "no" ]; then 1691.31Sjmc shlib=no 1701.31Sjmcfi 1711.191Sjmcneillnlists="base comp $debugset $dtbset etc games man misc $modset rescue $testset text" 1721.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 1731.92Suebayasiextlists="extbase extcomp extetc" 1741.9Slukem 1751.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 1761.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 1771.188Schristos MODULEDIR="netbsd/modules" 1781.188Schristoselse 1791.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 1801.188Schristosfi 1811.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 1821.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 1831.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 1841.60Sad 1851.9Slukem# 1861.9Slukem# list_set_files setfile [...] 1871.1Sdyoung# 1881.9Slukem# Produce a packing list for setfile(s). 1891.9Slukem# In each file, a record consists of a path and a System Package name, 1901.9Slukem# separated by whitespace. E.g., 1911.9Slukem# 1921.191Sjmcneill# # $NetBSD: sets.subr,v 1.191 2020/05/18 21:19:34 jmcneill Exp $ 1931.9Slukem# . base-sys-root [keyword[,...]] 1941.9Slukem# ./altroot base-sys-root 1951.9Slukem# ./bin base-sys-root 1961.9Slukem# ./bin/[ base-util-root 1971.9Slukem# ./bin/cat base-util-root 1981.9Slukem# [...] 1991.9Slukem# 2001.9Slukem# A # in the first column marks a comment. 2011.9Slukem# 2021.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2031.52Slukem# be printed. All other keywords must be present. 2041.9Slukem# 2051.9Slukem# The third field is an optional comma separated list of keywords to 2061.9Slukem# control if a record is printed; every keyword listed must be enabled 2071.179Schristos# for the record to be printed. The list of all avalaible make variables 2081.179Schristos# that can be turned on or off can be found by running in this directory: 2091.179Schristos# 2101.179Schristos# make -f mkvars.mk mkvarsyesno 2111.179Schristos# 2121.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2131.179Schristos# 2141.179Schristos# The following extra keywords are also available, listed by: 2151.179Schristos# 2161.179Schristos# make -f mkvars.mk mkextravars 2171.13Slukem# 2181.179Schristos# These are: 2191.179Schristos# 1. The HAVE_<name>: 2201.179Schristos# ssp ${HAVE_SSP} != no 2211.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2221.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2231.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2241.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2251.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2261.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 2271.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 2281.185Smrg# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2291.52Slukem# 2301.179Schristos# 2. The USE_<name>: 2311.41Slukem# use_inet6 ${USE_INET6} != no 2321.41Slukem# use_kerberos ${USE_KERBEROS} != no 2331.179Schristos# use_ldap ${USE_LDAP} != no 2341.41Slukem# use_yp ${USE_YP} != no 2351.41Slukem# 2361.179Schristos# 3. Finally: 2371.179Schristos# dummy dummy entry (ignored) 2381.179Schristos# obsolete file is obsolete, and only printed if 2391.179Schristos# ${obsolete} != 0 2401.179Schristos# 2411.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 2421.179Schristos# 2431.179Schristos# 2441.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 2451.179Schristos# 2461.179Schristos# 2471.22Slukem# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 2481.22Slukem# automatically append ".gz" to the filename 2491.22Slukem# 2501.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 2511.22Slukem# automatically append ".gz" to the filename 2521.1Sdyoung# 2531.8Slukemlist_set_files() 2541.8Slukem{ 2551.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 2561.65She verbose=false 2571.65She else 2581.65She verbose=true 2591.65She fi 2601.116Suebayasi print_set_lists "$@" | \ 2611.43Sapb ${AWK} -v obsolete=${obsolete} ' 2621.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 2631.190Schristos if (substr(line, 1, patlen) != pat) { 2641.190Schristos return; 2651.190Schristos } 2661.190Schristos for (d in kmodarchdirs) { 2671.190Schristos xd = prefix kmodarchdirs[d] 2681.190Schristos xfile = xd substr(line, patlen + 1) 2691.190Schristos tmp = xd substr(fname, patlen + 1) 2701.190Schristos list[xfile] = tmp; 2711.190Schristos } 2721.190Schristos } 2731.9Slukem BEGIN { 2741.52Slukem if (obsolete) 2751.52Slukem wanted["obsolete"] = 1 2761.52Slukem 2771.100Suebayasi split("'"${MKVARS}"'", needvars) 2781.165Smatt doingcompat = 0 2791.165Smatt doingcompattests = 0 2801.165Smatt ignoredkeywords["compatdir"] = 1 2811.165Smatt ignoredkeywords["compatfile"] = 1 2821.165Smatt ignoredkeywords["compattestdir"] = 1 2831.165Smatt ignoredkeywords["compattestfile"] = 1 2841.170Smatt ignoredkeywords["compatx11dir"] = 1 2851.170Smatt ignoredkeywords["compatx11file"] = 1 2861.52Slukem for (vi in needvars) { 2871.52Slukem nv = needvars[vi] 2881.52Slukem kw = tolower(nv) 2891.52Slukem sub(/^mk/, "", kw) 2901.143Snakayama sub(/^have_/, "", kw) 2911.148Smatt sub(/^target_endianness/, "endian", kw) 2921.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 2931.165Smatt wanted[kw] = 1 2941.167Smatt } 2951.166Smatt } 2961.166Smatt 2971.167Smatt if ("compat" in wanted) { 2981.166Smatt doingcompat = 1; 2991.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3001.166Smatt compatdirkeywords["compatdir"] = 1 3011.166Smatt compatfilekeywords["compatfile"] = 1 3021.166Smatt 3031.166Smatt if (wanted["compattests"]) { 3041.165Smatt doingcompattests = 1; 3051.165Smatt compatdirkeywords["compattestdir"] = 1 3061.165Smatt compatfilekeywords["compattestfile"] = 1 3071.166Smatt } 3081.170Smatt if (wanted["compatx11"]) { 3091.170Smatt doingcompatx11 = 1; 3101.170Smatt compatdirkeywords["compatx11dir"] = 1 3111.170Smatt compatfilekeywords["compatx11file"] = 1 3121.170Smatt } 3131.166Smatt } 3141.166Smatt 3151.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 3161.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 3171.190Schristos kmodprefix = "./stand/" 3181.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 3191.166Smatt l_kmodpat = length(kmodpat) 3201.190Schristos kmoddbprefix = "./usr/libdata/debug/stand/" 3211.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 3221.190Schristos l_kmoddbpat = length(kmoddbpat) 3231.52Slukem } 3241.52Slukem 3251.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 3261.90Sdyoung if ("binutils" in wanted) 3271.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 3281.90Sdyoung if ("gcc" in wanted) 3291.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 3301.90Sdyoung if ("gdb" in wanted) 3311.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 3321.9Slukem } 3331.183Schristos if ("openssl" in wanted) { 3341.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 3351.183Schristos } 3361.178Smrg if ("xorg_server_ver" in wanted) { 3371.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 3381.177Smrg } 3391.185Smrg if ("mesa_ver" in wanted) { 3401.185Smrg wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 3411.185Smrg } 3421.52Slukem if (("man" in wanted) && ("catpages" in wanted)) 3431.52Slukem wanted[".cat"] = 1 3441.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 3451.52Slukem wanted[".man"] = 1 3461.148Smatt if ("endian" in wanted) 3471.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 3481.162Smrg if ("machine" in wanted) 3491.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 3501.162Smrg if ("machine_arch" in wanted) 3511.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 3521.162Smrg if ("machine_cpu" in wanted) 3531.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 3541.9Slukem } 3551.9Slukem 3561.9Slukem /^#/ { 3571.9Slukem next; 3581.9Slukem } 3591.9Slukem 3601.127Smatt /^-/ { 3611.127Smatt notwanted[substr($1, 2)] = 1; 3621.127Smatt delete list [substr($1, 2)]; 3631.127Smatt next; 3641.127Smatt } 3651.127Smatt 3661.127Smatt 3671.9Slukem NF > 2 && $3 != "-" { 3681.127Smatt if (notwanted[$1] != "") 3691.127Smatt next; 3701.9Slukem split($3, keywords, ",") 3711.9Slukem show = 1 3721.52Slukem haveobs = 0 3731.167Smatt iscompatfile = 0 3741.165Smatt havekmod = 0 3751.165Smatt iscompatdir = 0 3761.9Slukem for (ki in keywords) { 3771.9Slukem kw = keywords[ki] 3781.22Slukem if (("manz" in wanted) && 3791.22Slukem (kw == ".cat" || kw == ".man")) 3801.22Slukem $1 = $1 ".gz" 3811.134Sjoerg if (substr(kw, 1, 1) == "!") { 3821.134Sjoerg kw = substr(kw, 2) 3831.59Sjmmv if (kw in wanted) 3841.59Sjmmv show = 0 3851.165Smatt } else if (kw in compatdirkeywords) { 3861.165Smatt iscompatdir = 1 3871.165Smatt } else if (kw in compatfilekeywords) { 3881.167Smatt iscompatfile = 1 3891.172Smatt } else if (kw == "nocompatmodules") { 3901.172Smatt havekmod = -1 3911.165Smatt } else if (kw in ignoredkeywords) { 3921.165Smatt # ignore 3931.167Smatt } else if (! (kw in wanted)) { 3941.167Smatt show = 0 3951.172Smatt } else if (kw == "kmod" && havekmod == 0) { 3961.167Smatt havekmod = 1 3971.59Sjmmv } 3981.52Slukem if (kw == "obsolete") 3991.52Slukem haveobs = 1 4001.9Slukem } 4011.184Snakayama if (iscompatdir) { 4021.184Snakayama for (d in cpaths) { 4031.184Snakayama if (cpaths[d] == $1 "/") 4041.184Snakayama next 4051.184Snakayama } 4061.184Snakayama cpaths[ncpaths++] = $1 "/" 4071.184Snakayama } 4081.52Slukem if (obsolete && ! haveobs) 4091.52Slukem next 4101.165Smatt if (!show) 4111.165Smatt next 4121.165Smatt 4131.165Smatt list[$1] = $0 4141.190Schristos if (havekmod > 0) { 4151.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 4161.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 4171.165Smatt next 4181.165Smatt } 4191.165Smatt 4201.167Smatt if (!doingcompat || !(iscompatfile || iscompatdir)) 4211.165Smatt next 4221.165Smatt 4231.167Smatt if (iscompatfile) { 4241.165Smatt emitcompat[$1] = 1; 4251.168Smatt next 4261.168Smatt } 4271.165Smatt for (d in compatarchdirs) { 4281.165Smatt tmp = $0 4291.165Smatt xfile = $1 "/" compatarchdirs[d] 4301.165Smatt tmp = xfile substr(tmp, length($1) + 1) 4311.165Smatt if (xfile in notwanted) 4321.165Smatt continue; 4331.165Smatt sub("compatdir","compat",tmp); 4341.165Smatt sub("compattestdir","compat",tmp); 4351.165Smatt list[xfile] = tmp 4361.165Smatt } 4371.9Slukem next 4381.9Slukem } 4391.9Slukem 4401.9Slukem { 4411.165Smatt if ($1 in notwanted) 4421.127Smatt next; 4431.9Slukem if (! obsolete) 4441.127Smatt list[$1] = $0 4451.127Smatt } 4461.127Smatt 4471.127Smatt END { 4481.127Smatt for (i in list) { 4491.127Smatt print list[i] 4501.165Smatt if (! (i in emitcompat)) 4511.165Smatt continue; 4521.165Smatt l_i = length(i) 4531.165Smatt l = 0 4541.165Smatt for (j in cpaths) { 4551.165Smatt lx = length(cpaths[j]) 4561.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 4571.165Smatt continue; 4581.165Smatt } 4591.165Smatt if (lx > l) { 4601.165Smatt l = lx; 4611.165Smatt cpath = cpaths[j]; 4621.165Smatt } 4631.165Smatt } 4641.165Smatt for (d in compatarchdirs) { 4651.165Smatt tmp = list[i] 4661.165Smatt extrapath = compatarchdirs[d] "/" 4671.165Smatt xfile = cpath extrapath substr(i, l + 1) 4681.165Smatt if (xfile in notwanted) 4691.165Smatt continue; 4701.165Smatt sub("compatfile","compat",tmp); 4711.165Smatt sub("compattestfile","compat",tmp); 4721.165Smatt tmp = xfile substr(tmp, l_i + 1) 4731.165Smatt print tmp; 4741.165Smatt } 4751.127Smatt } 4761.9Slukem }' 4771.9Slukem 4781.1Sdyoung} 4791.1Sdyoung 4801.1Sdyoung# 4811.1Sdyoung# list_set_lists setname 4821.1Sdyoung# 4831.1Sdyoung# Print to stdout a list of files, one filename per line, which 4841.1Sdyoung# concatenate to create the packing list for setname. E.g., 4851.1Sdyoung# 4861.1Sdyoung# .../lists/base/mi 4871.1Sdyoung# .../lists/base/rescue.mi 4881.1Sdyoung# .../lists/base/md.i386 4891.9Slukem# [...] 4901.1Sdyoung# 4911.9Slukem# For a given setname $set, the following files may be selected from 4921.9Slukem# .../list/$set: 4931.9Slukem# mi 4941.92Suebayasi# mi.ext.* 4951.11Slukem# ad.${MACHINE_ARCH} 4961.11Slukem# (or) ad.${MACHINE_CPU} 4971.11Slukem# ad.${MACHINE_CPU}.shl 4981.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 4991.11Slukem# (or) md.${MACHINE} 5001.9Slukem# stl.mi 5011.92Suebayasi# stl.${stlib} 5021.9Slukem# shl.mi 5031.92Suebayasi# shl.mi.ext.* 5041.92Suebayasi# shl.${shlib} 5051.92Suebayasi# shl.${shlib}.ext.* 5061.77Stsutsui# module.mi if ${module} != no 5071.77Stsutsui# module.${MACHINE} if ${module} != no 5081.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 5091.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 5101.9Slukem# rescue.shl 5111.11Slukem# rescue.${MACHINE} 5121.11Slukem# rescue.ad.${MACHINE_ARCH} 5131.11Slukem# (or) rescue.ad.${MACHINE_CPU} 5141.11Slukem# rescue.ad.${MACHINE_CPU}.shl 5151.1Sdyoung# 5161.9Slukem# Environment: 5171.1Sdyoung# shlib 5181.1Sdyoung# stlib 5191.1Sdyoung# 5201.8Slukemlist_set_lists() 5211.8Slukem{ 5221.1Sdyoung setname=$1 5231.1Sdyoung 5241.111Suebayasi list_set_lists_mi $setname 5251.113Suebayasi list_set_lists_ad $setname 5261.111Suebayasi list_set_lists_md $setname 5271.111Suebayasi list_set_lists_stl $setname 5281.113Suebayasi list_set_lists_shl $setname 5291.113Suebayasi list_set_lists_module $setname 5301.111Suebayasi list_set_lists_rescue $setname 5311.117Suebayasi return 0 5321.111Suebayasi} 5331.110Suebayasi 5341.111Suebayasilist_set_lists_mi() 5351.111Suebayasi{ 5361.111Suebayasi setdir=$setsdir/lists/$1 5371.113Suebayasi # always exist! 5381.9Slukem echo $setdir/mi 5391.111Suebayasi} 5401.110Suebayasi 5411.111Suebayasilist_set_lists_ad() 5421.111Suebayasi{ 5431.111Suebayasi setdir=$setsdir/lists/$1 5441.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5451.113Suebayasi list_set_lists_common_ad $1 5461.111Suebayasi} 5471.110Suebayasi 5481.111Suebayasilist_set_lists_md() 5491.111Suebayasi{ 5501.111Suebayasi setdir=$setsdir/lists/$1 5511.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 5521.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 5531.111Suebayasi} 5541.110Suebayasi 5551.111Suebayasilist_set_lists_stl() 5561.111Suebayasi{ 5571.111Suebayasi setdir=$setsdir/lists/$1 5581.110Suebayasi echo_if_exist $setdir/stl.mi 5591.110Suebayasi echo_if_exist $setdir/stl.${stlib} 5601.111Suebayasi} 5611.110Suebayasi 5621.111Suebayasilist_set_lists_shl() 5631.111Suebayasi{ 5641.111Suebayasi setdir=$setsdir/lists/$1 5651.113Suebayasi [ "$shlib" != "no" ] || return 5661.112Suebayasi echo_if_exist $setdir/shl.mi 5671.112Suebayasi echo_if_exist $setdir/shl.${shlib} 5681.111Suebayasi} 5691.110Suebayasi 5701.111Suebayasilist_set_lists_module() 5711.111Suebayasi{ 5721.111Suebayasi setdir=$setsdir/lists/$1 5731.113Suebayasi [ "$module" != "no" ] || return 5741.112Suebayasi echo_if_exist $setdir/module.mi 5751.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 5761.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 5771.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 5781.113Suebayasi # XXX module never has .shl 5791.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5801.113Suebayasi list_set_lists_common_ad $1 module 5811.111Suebayasi} 5821.1Sdyoung 5831.111Suebayasilist_set_lists_rescue() 5841.111Suebayasi{ 5851.111Suebayasi setdir=$setsdir/lists/$1 5861.110Suebayasi echo_if_exist $setdir/rescue.mi 5871.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 5881.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5891.113Suebayasi list_set_lists_common_ad $1 rescue 5901.111Suebayasi} 5911.111Suebayasi 5921.113Suebayasilist_set_lists_common_ad() 5931.111Suebayasi{ 5941.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 5951.113Suebayasi 5961.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 5971.113Suebayasi 5981.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 5991.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 6001.112Suebayasi # specific one will be more specific than the 6011.112Suebayasi # cpu-specific one. 6021.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 6031.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 6041.113Suebayasi [ "$shlib" != "no" ] && \ 6051.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 6061.5Sdyoung} 6071.5Sdyoung 6081.110Suebayasiecho_if_exist() 6091.110Suebayasi{ 6101.110Suebayasi [ -f $1 ] && echo $1 6111.110Suebayasi return $? 6121.110Suebayasi} 6131.110Suebayasi 6141.110Suebayasiecho_if_exist_foreach() 6151.110Suebayasi{ 6161.110Suebayasi local _list=$1; shift 6171.110Suebayasi for _suffix in $@; do 6181.110Suebayasi echo_if_exist ${_list}.${_suffix} 6191.110Suebayasi done 6201.110Suebayasi} 6211.110Suebayasi 6221.116Suebayasiprint_set_lists() 6231.116Suebayasi{ 6241.116Suebayasi for setname; do 6251.136Schristos list=$(list_set_lists $setname) 6261.116Suebayasi for l in $list; do 6271.116Suebayasi echo $l 6281.116Suebayasi if $verbose; then 6291.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 6301.116Suebayasi fi 6311.116Suebayasi done 6321.118Suebayasi done | ${XARGS} ${SED} ${SUBST} 6331.116Suebayasi} 6341.116Suebayasi 6351.9Slukem# arch_to_cpu mach 6361.9Slukem# 6371.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 6381.9Slukem# as determined by <bsd.own.mk>. 6391.9Slukem# 6401.8Slukemarch_to_cpu() 6411.8Slukem{ 6421.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6431.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6441.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 6451.182Suwe -V '${MACHINE_CPU}' 6461.1Sdyoung} 6471.46Sapb 6481.46Sapb# arch_to_endian mach 6491.46Sapb# 6501.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 6511.46Sapb# as determined by <bsd.endian.mk>. 6521.46Sapb# 6531.46Sapbarch_to_endian() 6541.46Sapb{ 6551.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6561.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6571.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 6581.182Suwe -V '${TARGET_ENDIANNESS}' 6591.46Sapb} 6601.117Suebayasi 6611.117Suebayasi##### 6621.117Suebayasi 6631.117Suebayasi# print_mkvars 6641.117Suebayasiprint_mkvars() 6651.117Suebayasi{ 6661.117Suebayasi for v in $MKVARS; do 6671.117Suebayasi eval echo $v=\$$v 6681.117Suebayasi done 6691.117Suebayasi} 6701.117Suebayasi 6711.117Suebayasi# print_set_lists_{base,x,ext} 6721.117Suebayasi# list_set_lists_{base,x,ext} 6731.117Suebayasi# list_set_files_{base,x,ext} 6741.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 6751.117Suebayasi for x in base x ext; do 6761.117Suebayasi if [ $x = base ]; then 6771.117Suebayasi list=nlists 6781.117Suebayasi else 6791.117Suebayasi list=${x}lists 6801.117Suebayasi fi 6811.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 6821.117Suebayasi done 6831.117Suebayasidone 684