sets.subr revision 1.204
11.204Srillig# $NetBSD: sets.subr,v 1.204 2022/09/10 12:31:42 rillig 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.76Stsutsui# module if != "no", enable MODULE sets 111.9Slukem# shlib shared library format (a.out, elf, or "") 121.9Slukem# stlib static library format (a.out, elf) 131.11Slukem# 141.11Slukem# The following <bsd.own.mk> variables are exported to the environment: 151.203Srillig# MACHINE 161.11Slukem# MACHINE_ARCH 171.11Slukem# MACHINE_CPU 181.192Sjmcneill# HAVE_ACPI 191.87Sskrll# HAVE_BINUTILS 201.48Smrg# HAVE_GCC 211.52Slukem# HAVE_GDB 221.193Sjmcneill# HAVE_NVMM 231.193Sjmcneill# HAVE_OPENSSL 241.143Snakayama# HAVE_SSP 251.192Sjmcneill# HAVE_UEFI 261.11Slukem# TOOLCHAIN_MISSING 271.11Slukem# OBJECT_FMT 281.22Slukem# as well as: 291.22Slukem# 301.95Suebayasi 311.42Sapb# 321.42Sapb# The following variables refer to tools that are used when building sets: 331.42Sapb# 341.43Sapb: ${AWK:=awk} 351.42Sapb: ${CKSUM:=cksum} 361.43Sapb: ${COMM:=comm} 371.44Sapb: ${DATE:=date} 381.43Sapb: ${DB:=db} 391.43Sapb: ${EGREP:=egrep} 401.43Sapb: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc. 411.44Sapb: ${FGREP:=fgrep} 421.43Sapb: ${FIND:=find} 431.44Sapb: ${GREP:=grep} 441.43Sapb: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1) 451.99Sapb: ${HOSTNAME_CMD:=hostname} # ${HOSTNAME} is special to bash(1) 461.42Sapb: ${HOST_SH:=sh} 471.43Sapb: ${IDENT:=ident} 481.43Sapb: ${JOIN:=join} 491.43Sapb: ${LS:=ls} 501.43Sapb: ${MAKE:=make} 511.42Sapb: ${MKTEMP:=mktemp} 521.43Sapb: ${MTREE:=mtree} 531.43Sapb: ${PASTE:=paste} 541.42Sapb: ${PAX:=pax} 551.43Sapb: ${PRINTF:=printf} 561.43Sapb: ${SED:=sed} 571.43Sapb: ${SORT:=sort} 581.44Sapb: ${STAT:=stat} 591.44Sapb: ${TSORT:=tsort} 601.43Sapb: ${UNAME:=uname} 611.43Sapb: ${WC:=wc} 621.118Suebayasi: ${XARGS:=xargs} 631.43Sapb 641.45Sapb# 651.45Sapb# If printf is a shell builtin command, then we can 661.45Sapb# implement cheaper versions of basename and dirname 671.45Sapb# that do not involve any fork/exec overhead. 681.45Sapb# If printf is not builtin, approximate it using echo, 691.45Sapb# and hope there are no weird file names that cause 701.45Sapb# some versions of echo to do the wrong thing. 711.45Sapb# (Converting to this version of dirname speeded up the 721.45Sapb# syspkgdeps script by an order of magnitude, from 68 731.45Sapb# seconds to 6.3 seconds on one particular host.) 741.45Sapb# 751.45Sapb# Note that naive approximations for dirname 761.45Sapb# using ${foo%/*} do not do the right thing in cases 771.45Sapb# where the result should be "/" or ".". 781.45Sapb# 791.45Sapbcase "$(type printf)" in 801.45Sapb*builtin*) 811.45Sapb basename () 821.45Sapb { 831.45Sapb local bn 841.45Sapb bn="${1##*/}" 851.45Sapb bn="${bn%$2}" 861.45Sapb printf "%s\n" "$bn" 871.45Sapb } 881.45Sapb dirname () 891.45Sapb { 901.45Sapb local dn 911.45Sapb case "$1" in 921.45Sapb ?*/*) dn="${1%/*}" ;; 931.45Sapb /*) dn=/ ;; 941.45Sapb *) dn=. ;; 951.45Sapb esac 961.45Sapb printf "%s\n" "$dn" 971.45Sapb } 981.45Sapb ;; 991.45Sapb*) 1001.45Sapb basename () 1011.45Sapb { 1021.45Sapb local bn 1031.45Sapb bn="${1##*/}" 1041.45Sapb bn="${bn%$2}" 1051.45Sapb echo "$bn" 1061.45Sapb } 1071.45Sapb dirname () 1081.45Sapb { 1091.45Sapb local dn 1101.45Sapb case "$1" in 1111.45Sapb ?*/*) dn="${1%/*}" ;; 1121.45Sapb /*) dn=/ ;; 1131.45Sapb *) dn=. ;; 1141.45Sapb esac 1151.45Sapb echo "$dn" 1161.45Sapb } 1171.45Sapb ;; 1181.45Sapbesac 1191.45Sapb 1201.108Suebayasi##### 1211.108Suebayasi 1221.9SlukemoIFS=$IFS 1231.9SlukemIFS=" 1241.9Slukem" 1251.100Suebayasi 1261.180Schristosfor x in $( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do 1271.108Suebayasi eval export $x 1281.9Slukemdone 1291.100Suebayasi 1301.9SlukemIFS=$oIFS 1311.9Slukem 1321.180SchristosMKVARS="$( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )" 1331.100Suebayasi 1341.105Suebayasi##### 1351.105Suebayasi 1361.117Suebayasisetsdir=${rundir} 1371.9Slukemobsolete=0 1381.91Sdyoungif [ "${MKKMOD}" = "no" ]; then 1391.91Sdyoung module=no # MODULEs are off. 1401.125Snjoly modset="" 1411.125Snjolyelse 1421.125Snjoly module=yes 1431.125Snjoly modset="modules" 1441.125Snjolyfi 1451.125Snjolyif [ "${MKATF}" = "no" ]; then 1461.125Snjoly testset="" 1471.125Snjolyelse 1481.125Snjoly testset="tests" 1491.9Slukemfi 1501.171Smattif [ "${MKDEBUG}" = "no" -a "${MKDEBUGLIB}" = "no" ]; then 1511.141Schristos debugset="" 1521.142Schristos xdebugset="" 1531.141Schristoselse 1541.141Schristos debugset="debug" 1551.142Schristos xdebugset="xdebug" 1561.141Schristosfi 1571.191Sjmcneillif [ "${MKDTB}" = "no" ]; then 1581.191Sjmcneill dtbset="" 1591.191Sjmcneillelse 1601.191Sjmcneill dtbset="dtb" 1611.191Sjmcneillfi 1621.31Sjmc# Determine lib type. Do this first so stlib also gets set. 1631.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 1641.9Slukem shlib=elf 1651.9Slukemelse 1661.9Slukem shlib=aout 1671.9Slukemfi 1681.9Slukemstlib=$shlib 1691.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 1701.31Sjmcif [ "${MKPIC}" = "no" ]; then 1711.31Sjmc shlib=no 1721.31Sjmcfi 1731.197Smayanlists="base comp $debugset $dtbset etc games gpufw man misc $modset rescue $testset text" 1741.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 1751.9Slukem 1761.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 1771.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 1781.188Schristos MODULEDIR="netbsd/modules" 1791.188Schristoselse 1801.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 1811.188Schristosfi 1821.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 1831.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 1841.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 1851.60Sad 1861.9Slukem# 1871.9Slukem# list_set_files setfile [...] 1881.203Srillig# 1891.9Slukem# Produce a packing list for setfile(s). 1901.9Slukem# In each file, a record consists of a path and a System Package name, 1911.9Slukem# separated by whitespace. E.g., 1921.9Slukem# 1931.204Srillig# # $NetBSD: sets.subr,v 1.204 2022/09/10 12:31:42 rillig Exp $ 1941.9Slukem# . base-sys-root [keyword[,...]] 1951.9Slukem# ./altroot base-sys-root 1961.9Slukem# ./bin base-sys-root 1971.9Slukem# ./bin/[ base-util-root 1981.9Slukem# ./bin/cat base-util-root 1991.9Slukem# [...] 2001.9Slukem# 2011.9Slukem# A # in the first column marks a comment. 2021.9Slukem# 2031.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2041.52Slukem# be printed. All other keywords must be present. 2051.9Slukem# 2061.9Slukem# The third field is an optional comma separated list of keywords to 2071.9Slukem# control if a record is printed; every keyword listed must be enabled 2081.204Srillig# for the record to be printed. The list of all available make variables 2091.179Schristos# that can be turned on or off can be found by running in this directory: 2101.179Schristos# 2111.179Schristos# make -f mkvars.mk mkvarsyesno 2121.179Schristos# 2131.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2141.203Srillig# 2151.179Schristos# The following extra keywords are also available, listed by: 2161.179Schristos# 2171.179Schristos# make -f mkvars.mk mkextravars 2181.13Slukem# 2191.179Schristos# These are: 2201.179Schristos# 1. The HAVE_<name>: 2211.179Schristos# ssp ${HAVE_SSP} != no 2221.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2231.192Sjmcneill# acpi ${HAVE_ACPI} != no 2241.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2251.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2261.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2271.192Sjmcneill# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2281.193Sjmcneill# nvmm ${HAVE_NVMM} != no 2291.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2301.192Sjmcneill# uefi ${HAVE_UEFI} != no 2311.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 2321.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 2331.52Slukem# 2341.179Schristos# 2. The USE_<name>: 2351.41Slukem# use_inet6 ${USE_INET6} != no 2361.41Slukem# use_kerberos ${USE_KERBEROS} != no 2371.179Schristos# use_ldap ${USE_LDAP} != no 2381.41Slukem# use_yp ${USE_YP} != no 2391.41Slukem# 2401.179Schristos# 3. Finally: 2411.179Schristos# dummy dummy entry (ignored) 2421.203Srillig# obsolete file is obsolete, and only printed if 2431.179Schristos# ${obsolete} != 0 2441.179Schristos# 2451.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 2461.179Schristos# 2471.179Schristos# 2481.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 2491.179Schristos# 2501.179Schristos# 2511.195Skamil# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 2521.195Skamil# automatically append ".gz" to the filename 2531.195Skamil# 2541.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 2551.22Slukem# automatically append ".gz" to the filename 2561.1Sdyoung# 2571.8Slukemlist_set_files() 2581.8Slukem{ 2591.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 2601.65She verbose=false 2611.65She else 2621.65She verbose=true 2631.65She fi 2641.198Schristos local CONFIGS="$( list_kernel_configs )" 2651.116Suebayasi print_set_lists "$@" | \ 2661.43Sapb ${AWK} -v obsolete=${obsolete} ' 2671.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 2681.190Schristos if (substr(line, 1, patlen) != pat) { 2691.198Schristos return 2701.190Schristos } 2711.190Schristos for (d in kmodarchdirs) { 2721.190Schristos xd = prefix kmodarchdirs[d] 2731.198Schristos xline = xd substr(line, patlen + 1) 2741.198Schristos xfname = xd substr(fname, patlen + 1) 2751.198Schristos list[xline] = xfname 2761.190Schristos } 2771.190Schristos } 2781.198Schristos function adddebugkernel(line, fname, pat, patlen) { 2791.199Schristos if (pat == "" || substr(line, 1, patlen) != pat) { 2801.198Schristos return 0 2811.198Schristos } 2821.198Schristos split("'"${CONFIGS}"'", configs) 2831.198Schristos for (d in configs) { 2841.198Schristos xfname = fname 2851.200Schristos sub("@CONFIG@", configs[d], xfname) 2861.198Schristos xline = line; 2871.200Schristos sub("@CONFIG@", configs[d], xline) 2881.198Schristos list[xline] = xfname 2891.198Schristos } 2901.198Schristos return 1 2911.198Schristos } 2921.9Slukem BEGIN { 2931.52Slukem if (obsolete) 2941.52Slukem wanted["obsolete"] = 1 2951.203Srillig 2961.100Suebayasi split("'"${MKVARS}"'", needvars) 2971.165Smatt doingcompat = 0 2981.165Smatt doingcompattests = 0 2991.165Smatt ignoredkeywords["compatdir"] = 1 3001.165Smatt ignoredkeywords["compatfile"] = 1 3011.165Smatt ignoredkeywords["compattestdir"] = 1 3021.165Smatt ignoredkeywords["compattestfile"] = 1 3031.170Smatt ignoredkeywords["compatx11dir"] = 1 3041.170Smatt ignoredkeywords["compatx11file"] = 1 3051.52Slukem for (vi in needvars) { 3061.52Slukem nv = needvars[vi] 3071.52Slukem kw = tolower(nv) 3081.52Slukem sub(/^mk/, "", kw) 3091.143Snakayama sub(/^have_/, "", kw) 3101.148Smatt sub(/^target_endianness/, "endian", kw) 3111.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 3121.203Srillig wanted[kw] = 1 3131.167Smatt } 3141.166Smatt } 3151.166Smatt 3161.167Smatt if ("compat" in wanted) { 3171.166Smatt doingcompat = 1; 3181.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3191.166Smatt compatdirkeywords["compatdir"] = 1 3201.166Smatt compatfilekeywords["compatfile"] = 1 3211.166Smatt 3221.166Smatt if (wanted["compattests"]) { 3231.165Smatt doingcompattests = 1; 3241.165Smatt compatdirkeywords["compattestdir"] = 1 3251.165Smatt compatfilekeywords["compattestfile"] = 1 3261.166Smatt } 3271.170Smatt if (wanted["compatx11"]) { 3281.170Smatt doingcompatx11 = 1; 3291.170Smatt compatdirkeywords["compatx11dir"] = 1 3301.170Smatt compatfilekeywords["compatx11file"] = 1 3311.170Smatt } 3321.166Smatt } 3331.166Smatt 3341.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 3351.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 3361.190Schristos kmodprefix = "./stand/" 3371.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 3381.166Smatt l_kmodpat = length(kmodpat) 3391.203Srillig kmoddbprefix = "./usr/libdata/debug/stand/" 3401.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 3411.190Schristos l_kmoddbpat = length(kmoddbpat) 3421.52Slukem } 3431.198Schristos if ("debug" in wanted) { 3441.201Schristos debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 3451.198Schristos l_debugkernelname = length(debugkernelname); 3461.198Schristos } 3471.52Slukem 3481.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 3491.90Sdyoung if ("binutils" in wanted) 3501.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 3511.90Sdyoung if ("gcc" in wanted) 3521.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 3531.90Sdyoung if ("gdb" in wanted) 3541.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 3551.9Slukem } 3561.192Sjmcneill if ("acpi" in wanted) { 3571.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 3581.192Sjmcneill } 3591.192Sjmcneill if ("mesa_ver" in wanted) { 3601.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 3611.192Sjmcneill } 3621.193Sjmcneill if ("nvmm" in wanted) { 3631.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 3641.193Sjmcneill } 3651.183Schristos if ("openssl" in wanted) { 3661.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 3671.183Schristos } 3681.178Smrg if ("xorg_server_ver" in wanted) { 3691.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 3701.177Smrg } 3711.192Sjmcneill if ("uefi" in wanted) { 3721.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 3731.185Smrg } 3741.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 3751.195Skamil wanted[".cat"] = 1 3761.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 3771.52Slukem wanted[".man"] = 1 3781.148Smatt if ("endian" in wanted) 3791.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 3801.162Smrg if ("machine" in wanted) 3811.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 3821.162Smrg if ("machine_arch" in wanted) 3831.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 3841.162Smrg if ("machine_cpu" in wanted) 3851.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 3861.9Slukem } 3871.9Slukem 3881.9Slukem /^#/ { 3891.9Slukem next; 3901.9Slukem } 3911.9Slukem 3921.127Smatt /^-/ { 3931.127Smatt notwanted[substr($1, 2)] = 1; 3941.127Smatt delete list [substr($1, 2)]; 3951.127Smatt next; 3961.127Smatt } 3971.203Srillig 3981.127Smatt 3991.9Slukem NF > 2 && $3 != "-" { 4001.127Smatt if (notwanted[$1] != "") 4011.127Smatt next; 4021.9Slukem split($3, keywords, ",") 4031.9Slukem show = 1 4041.52Slukem haveobs = 0 4051.167Smatt iscompatfile = 0 4061.165Smatt havekmod = 0 4071.165Smatt iscompatdir = 0 4081.9Slukem for (ki in keywords) { 4091.9Slukem kw = keywords[ki] 4101.22Slukem if (("manz" in wanted) && 4111.22Slukem (kw == ".cat" || kw == ".man")) 4121.22Slukem $1 = $1 ".gz" 4131.134Sjoerg if (substr(kw, 1, 1) == "!") { 4141.134Sjoerg kw = substr(kw, 2) 4151.59Sjmmv if (kw in wanted) 4161.59Sjmmv show = 0 4171.165Smatt } else if (kw in compatdirkeywords) { 4181.165Smatt iscompatdir = 1 4191.165Smatt } else if (kw in compatfilekeywords) { 4201.167Smatt iscompatfile = 1 4211.172Smatt } else if (kw == "nocompatmodules") { 4221.172Smatt havekmod = -1 4231.165Smatt } else if (kw in ignoredkeywords) { 4241.165Smatt # ignore 4251.167Smatt } else if (! (kw in wanted)) { 4261.167Smatt show = 0 4271.172Smatt } else if (kw == "kmod" && havekmod == 0) { 4281.167Smatt havekmod = 1 4291.59Sjmmv } 4301.52Slukem if (kw == "obsolete") 4311.52Slukem haveobs = 1 4321.9Slukem } 4331.184Snakayama if (iscompatdir) { 4341.184Snakayama for (d in cpaths) { 4351.184Snakayama if (cpaths[d] == $1 "/") 4361.184Snakayama next 4371.184Snakayama } 4381.184Snakayama cpaths[ncpaths++] = $1 "/" 4391.184Snakayama } 4401.52Slukem if (obsolete && ! haveobs) 4411.52Slukem next 4421.165Smatt if (!show) 4431.165Smatt next 4441.198Schristos if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 4451.198Schristos next 4461.165Smatt 4471.165Smatt list[$1] = $0 4481.190Schristos if (havekmod > 0) { 4491.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 4501.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 4511.165Smatt next 4521.165Smatt } 4531.165Smatt 4541.167Smatt if (!doingcompat || !(iscompatfile || iscompatdir)) 4551.165Smatt next 4561.165Smatt 4571.167Smatt if (iscompatfile) { 4581.165Smatt emitcompat[$1] = 1; 4591.168Smatt next 4601.168Smatt } 4611.165Smatt for (d in compatarchdirs) { 4621.165Smatt tmp = $0 4631.165Smatt xfile = $1 "/" compatarchdirs[d] 4641.165Smatt tmp = xfile substr(tmp, length($1) + 1) 4651.165Smatt if (xfile in notwanted) 4661.165Smatt continue; 4671.165Smatt sub("compatdir","compat",tmp); 4681.165Smatt sub("compattestdir","compat",tmp); 4691.165Smatt list[xfile] = tmp 4701.165Smatt } 4711.9Slukem next 4721.9Slukem } 4731.9Slukem 4741.9Slukem { 4751.165Smatt if ($1 in notwanted) 4761.127Smatt next; 4771.9Slukem if (! obsolete) 4781.127Smatt list[$1] = $0 4791.127Smatt } 4801.127Smatt 4811.127Smatt END { 4821.127Smatt for (i in list) { 4831.127Smatt print list[i] 4841.165Smatt if (! (i in emitcompat)) 4851.165Smatt continue; 4861.165Smatt l_i = length(i) 4871.165Smatt l = 0 4881.165Smatt for (j in cpaths) { 4891.165Smatt lx = length(cpaths[j]) 4901.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 4911.165Smatt continue; 4921.165Smatt } 4931.165Smatt if (lx > l) { 4941.165Smatt l = lx; 4951.165Smatt cpath = cpaths[j]; 4961.165Smatt } 4971.165Smatt } 4981.165Smatt for (d in compatarchdirs) { 4991.165Smatt tmp = list[i] 5001.165Smatt extrapath = compatarchdirs[d] "/" 5011.165Smatt xfile = cpath extrapath substr(i, l + 1) 5021.165Smatt if (xfile in notwanted) 5031.165Smatt continue; 5041.165Smatt sub("compatfile","compat",tmp); 5051.165Smatt sub("compattestfile","compat",tmp); 5061.165Smatt tmp = xfile substr(tmp, l_i + 1) 5071.165Smatt print tmp; 5081.165Smatt } 5091.127Smatt } 5101.9Slukem }' 5111.9Slukem 5121.1Sdyoung} 5131.1Sdyoung 5141.1Sdyoung# 5151.1Sdyoung# list_set_lists setname 5161.203Srillig# 5171.1Sdyoung# Print to stdout a list of files, one filename per line, which 5181.1Sdyoung# concatenate to create the packing list for setname. E.g., 5191.1Sdyoung# 5201.1Sdyoung# .../lists/base/mi 5211.1Sdyoung# .../lists/base/rescue.mi 5221.1Sdyoung# .../lists/base/md.i386 5231.9Slukem# [...] 5241.1Sdyoung# 5251.9Slukem# For a given setname $set, the following files may be selected from 5261.9Slukem# .../list/$set: 5271.9Slukem# mi 5281.92Suebayasi# mi.ext.* 5291.11Slukem# ad.${MACHINE_ARCH} 5301.11Slukem# (or) ad.${MACHINE_CPU} 5311.11Slukem# ad.${MACHINE_CPU}.shl 5321.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 5331.11Slukem# (or) md.${MACHINE} 5341.9Slukem# stl.mi 5351.92Suebayasi# stl.${stlib} 5361.9Slukem# shl.mi 5371.92Suebayasi# shl.mi.ext.* 5381.92Suebayasi# shl.${shlib} 5391.92Suebayasi# shl.${shlib}.ext.* 5401.77Stsutsui# module.mi if ${module} != no 5411.77Stsutsui# module.${MACHINE} if ${module} != no 5421.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 5431.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 5441.9Slukem# rescue.shl 5451.11Slukem# rescue.${MACHINE} 5461.11Slukem# rescue.ad.${MACHINE_ARCH} 5471.11Slukem# (or) rescue.ad.${MACHINE_CPU} 5481.11Slukem# rescue.ad.${MACHINE_CPU}.shl 5491.1Sdyoung# 5501.9Slukem# Environment: 5511.1Sdyoung# shlib 5521.1Sdyoung# stlib 5531.1Sdyoung# 5541.8Slukemlist_set_lists() 5551.8Slukem{ 5561.1Sdyoung setname=$1 5571.1Sdyoung 5581.111Suebayasi list_set_lists_mi $setname 5591.113Suebayasi list_set_lists_ad $setname 5601.111Suebayasi list_set_lists_md $setname 5611.111Suebayasi list_set_lists_stl $setname 5621.113Suebayasi list_set_lists_shl $setname 5631.113Suebayasi list_set_lists_module $setname 5641.111Suebayasi list_set_lists_rescue $setname 5651.117Suebayasi return 0 5661.111Suebayasi} 5671.110Suebayasi 5681.111Suebayasilist_set_lists_mi() 5691.111Suebayasi{ 5701.111Suebayasi setdir=$setsdir/lists/$1 5711.113Suebayasi # always exist! 5721.9Slukem echo $setdir/mi 5731.111Suebayasi} 5741.110Suebayasi 5751.111Suebayasilist_set_lists_ad() 5761.111Suebayasi{ 5771.111Suebayasi setdir=$setsdir/lists/$1 5781.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5791.113Suebayasi list_set_lists_common_ad $1 5801.111Suebayasi} 5811.110Suebayasi 5821.111Suebayasilist_set_lists_md() 5831.111Suebayasi{ 5841.111Suebayasi setdir=$setsdir/lists/$1 5851.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 5861.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 5871.111Suebayasi} 5881.110Suebayasi 5891.111Suebayasilist_set_lists_stl() 5901.111Suebayasi{ 5911.111Suebayasi setdir=$setsdir/lists/$1 5921.110Suebayasi echo_if_exist $setdir/stl.mi 5931.110Suebayasi echo_if_exist $setdir/stl.${stlib} 5941.111Suebayasi} 5951.110Suebayasi 5961.111Suebayasilist_set_lists_shl() 5971.111Suebayasi{ 5981.111Suebayasi setdir=$setsdir/lists/$1 5991.113Suebayasi [ "$shlib" != "no" ] || return 6001.112Suebayasi echo_if_exist $setdir/shl.mi 6011.112Suebayasi echo_if_exist $setdir/shl.${shlib} 6021.111Suebayasi} 6031.110Suebayasi 6041.111Suebayasilist_set_lists_module() 6051.111Suebayasi{ 6061.111Suebayasi setdir=$setsdir/lists/$1 6071.113Suebayasi [ "$module" != "no" ] || return 6081.112Suebayasi echo_if_exist $setdir/module.mi 6091.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 6101.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 6111.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 6121.113Suebayasi # XXX module never has .shl 6131.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6141.113Suebayasi list_set_lists_common_ad $1 module 6151.111Suebayasi} 6161.1Sdyoung 6171.111Suebayasilist_set_lists_rescue() 6181.111Suebayasi{ 6191.111Suebayasi setdir=$setsdir/lists/$1 6201.110Suebayasi echo_if_exist $setdir/rescue.mi 6211.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 6221.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6231.113Suebayasi list_set_lists_common_ad $1 rescue 6241.111Suebayasi} 6251.111Suebayasi 6261.113Suebayasilist_set_lists_common_ad() 6271.111Suebayasi{ 6281.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 6291.113Suebayasi 6301.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 6311.113Suebayasi 6321.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 6331.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 6341.112Suebayasi # specific one will be more specific than the 6351.112Suebayasi # cpu-specific one. 6361.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 6371.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 6381.113Suebayasi [ "$shlib" != "no" ] && \ 6391.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 6401.5Sdyoung} 6411.5Sdyoung 6421.110Suebayasiecho_if_exist() 6431.110Suebayasi{ 6441.110Suebayasi [ -f $1 ] && echo $1 6451.110Suebayasi return $? 6461.110Suebayasi} 6471.110Suebayasi 6481.110Suebayasiecho_if_exist_foreach() 6491.110Suebayasi{ 6501.110Suebayasi local _list=$1; shift 6511.110Suebayasi for _suffix in $@; do 6521.110Suebayasi echo_if_exist ${_list}.${_suffix} 6531.110Suebayasi done 6541.110Suebayasi} 6551.110Suebayasi 6561.116Suebayasiprint_set_lists() 6571.116Suebayasi{ 6581.116Suebayasi for setname; do 6591.136Schristos list=$(list_set_lists $setname) 6601.116Suebayasi for l in $list; do 6611.116Suebayasi echo $l 6621.116Suebayasi if $verbose; then 6631.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 6641.116Suebayasi fi 6651.116Suebayasi done 6661.118Suebayasi done | ${XARGS} ${SED} ${SUBST} 6671.116Suebayasi} 6681.116Suebayasi 6691.198Schristos 6701.198Schristoslist_kernel_configs() 6711.198Schristos{ 6721.198Schristos (cd ${NETBSDSRCDIR}/etc 6731.198Schristos MAKEFLAGS= \ 6741.198Schristos ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 6751.198Schristos} 6761.198Schristos 6771.9Slukem# arch_to_cpu mach 6781.9Slukem# 6791.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 6801.9Slukem# as determined by <bsd.own.mk>. 6811.9Slukem# 6821.8Slukemarch_to_cpu() 6831.8Slukem{ 6841.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6851.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6861.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 6871.182Suwe -V '${MACHINE_CPU}' 6881.1Sdyoung} 6891.46Sapb 6901.46Sapb# arch_to_endian mach 6911.46Sapb# 6921.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 6931.46Sapb# as determined by <bsd.endian.mk>. 6941.46Sapb# 6951.46Sapbarch_to_endian() 6961.46Sapb{ 6971.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6981.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6991.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 7001.182Suwe -V '${TARGET_ENDIANNESS}' 7011.46Sapb} 7021.117Suebayasi 7031.117Suebayasi##### 7041.117Suebayasi 7051.117Suebayasi# print_mkvars 7061.117Suebayasiprint_mkvars() 7071.117Suebayasi{ 7081.117Suebayasi for v in $MKVARS; do 7091.117Suebayasi eval echo $v=\$$v 7101.117Suebayasi done 7111.117Suebayasi} 7121.117Suebayasi 7131.117Suebayasi# print_set_lists_{base,x,ext} 7141.117Suebayasi# list_set_lists_{base,x,ext} 7151.117Suebayasi# list_set_files_{base,x,ext} 7161.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 7171.117Suebayasi for x in base x ext; do 7181.117Suebayasi if [ $x = base ]; then 7191.117Suebayasi list=nlists 7201.117Suebayasi else 7211.117Suebayasi list=${x}lists 7221.117Suebayasi fi 7231.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 7241.117Suebayasi done 7251.117Suebayasidone 726