sets.subr revision 1.205
11.205Snia# $NetBSD: sets.subr,v 1.205 2024/04/09 15:17:22 nia 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.205Sniaif [ -z "${debugset}" -o "${MKCOMPAT}" = "no" ]; then 1581.205Snia debug32set="" 1591.205Sniaelse 1601.205Snia debug32set="debug32" 1611.205Sniafi 1621.191Sjmcneillif [ "${MKDTB}" = "no" ]; then 1631.191Sjmcneill dtbset="" 1641.191Sjmcneillelse 1651.191Sjmcneill dtbset="dtb" 1661.191Sjmcneillfi 1671.205Sniaif [ "${MKHTML}" = "no" ]; then 1681.205Snia manhtmlset="" 1691.205Sniaelse 1701.205Snia manhtmlset="manhtml" 1711.205Sniafi 1721.205Sniaif [ "${MKCOMPAT}" = "no" ]; then 1731.205Snia base32set="" 1741.205Sniaelse 1751.205Snia base32set="base32" 1761.205Sniafi 1771.205Snia 1781.31Sjmc# Determine lib type. Do this first so stlib also gets set. 1791.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 1801.9Slukem shlib=elf 1811.9Slukemelse 1821.9Slukem shlib=aout 1831.9Slukemfi 1841.9Slukemstlib=$shlib 1851.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 1861.31Sjmcif [ "${MKPIC}" = "no" ]; then 1871.31Sjmc shlib=no 1881.31Sjmcfi 1891.205Snianlists="base $base32set comp $debugset $debug32set $dtbset etc games gpufw man $manhtmlset misc $modset rescue $testset text" 1901.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 1911.9Slukem 1921.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 1931.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 1941.188Schristos MODULEDIR="netbsd/modules" 1951.188Schristoselse 1961.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 1971.188Schristosfi 1981.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 1991.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 2001.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 2011.60Sad 2021.9Slukem# 2031.9Slukem# list_set_files setfile [...] 2041.203Srillig# 2051.9Slukem# Produce a packing list for setfile(s). 2061.9Slukem# In each file, a record consists of a path and a System Package name, 2071.9Slukem# separated by whitespace. E.g., 2081.9Slukem# 2091.205Snia# # $NetBSD: sets.subr,v 1.205 2024/04/09 15:17:22 nia Exp $ 2101.9Slukem# . base-sys-root [keyword[,...]] 2111.9Slukem# ./altroot base-sys-root 2121.9Slukem# ./bin base-sys-root 2131.9Slukem# ./bin/[ base-util-root 2141.9Slukem# ./bin/cat base-util-root 2151.9Slukem# [...] 2161.9Slukem# 2171.9Slukem# A # in the first column marks a comment. 2181.9Slukem# 2191.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2201.52Slukem# be printed. All other keywords must be present. 2211.9Slukem# 2221.9Slukem# The third field is an optional comma separated list of keywords to 2231.9Slukem# control if a record is printed; every keyword listed must be enabled 2241.204Srillig# for the record to be printed. The list of all available make variables 2251.179Schristos# that can be turned on or off can be found by running in this directory: 2261.179Schristos# 2271.179Schristos# make -f mkvars.mk mkvarsyesno 2281.179Schristos# 2291.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2301.203Srillig# 2311.179Schristos# The following extra keywords are also available, listed by: 2321.179Schristos# 2331.179Schristos# make -f mkvars.mk mkextravars 2341.13Slukem# 2351.179Schristos# These are: 2361.179Schristos# 1. The HAVE_<name>: 2371.179Schristos# ssp ${HAVE_SSP} != no 2381.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2391.192Sjmcneill# acpi ${HAVE_ACPI} != no 2401.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2411.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2421.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2431.192Sjmcneill# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2441.193Sjmcneill# nvmm ${HAVE_NVMM} != no 2451.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2461.192Sjmcneill# uefi ${HAVE_UEFI} != no 2471.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 2481.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 2491.52Slukem# 2501.179Schristos# 2. The USE_<name>: 2511.41Slukem# use_inet6 ${USE_INET6} != no 2521.41Slukem# use_kerberos ${USE_KERBEROS} != no 2531.179Schristos# use_ldap ${USE_LDAP} != no 2541.41Slukem# use_yp ${USE_YP} != no 2551.41Slukem# 2561.179Schristos# 3. Finally: 2571.179Schristos# dummy dummy entry (ignored) 2581.203Srillig# obsolete file is obsolete, and only printed if 2591.179Schristos# ${obsolete} != 0 2601.179Schristos# 2611.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 2621.179Schristos# 2631.179Schristos# 2641.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 2651.179Schristos# 2661.179Schristos# 2671.195Skamil# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 2681.195Skamil# automatically append ".gz" to the filename 2691.195Skamil# 2701.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 2711.22Slukem# automatically append ".gz" to the filename 2721.1Sdyoung# 2731.8Slukemlist_set_files() 2741.8Slukem{ 2751.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 2761.65She verbose=false 2771.65She else 2781.65She verbose=true 2791.65She fi 2801.198Schristos local CONFIGS="$( list_kernel_configs )" 2811.116Suebayasi print_set_lists "$@" | \ 2821.43Sapb ${AWK} -v obsolete=${obsolete} ' 2831.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 2841.190Schristos if (substr(line, 1, patlen) != pat) { 2851.198Schristos return 2861.190Schristos } 2871.190Schristos for (d in kmodarchdirs) { 2881.190Schristos xd = prefix kmodarchdirs[d] 2891.198Schristos xline = xd substr(line, patlen + 1) 2901.198Schristos xfname = xd substr(fname, patlen + 1) 2911.198Schristos list[xline] = xfname 2921.190Schristos } 2931.190Schristos } 2941.198Schristos function adddebugkernel(line, fname, pat, patlen) { 2951.199Schristos if (pat == "" || substr(line, 1, patlen) != pat) { 2961.198Schristos return 0 2971.198Schristos } 2981.198Schristos split("'"${CONFIGS}"'", configs) 2991.198Schristos for (d in configs) { 3001.198Schristos xfname = fname 3011.200Schristos sub("@CONFIG@", configs[d], xfname) 3021.198Schristos xline = line; 3031.200Schristos sub("@CONFIG@", configs[d], xline) 3041.198Schristos list[xline] = xfname 3051.198Schristos } 3061.198Schristos return 1 3071.198Schristos } 3081.9Slukem BEGIN { 3091.52Slukem if (obsolete) 3101.52Slukem wanted["obsolete"] = 1 3111.203Srillig 3121.100Suebayasi split("'"${MKVARS}"'", needvars) 3131.165Smatt doingcompat = 0 3141.165Smatt doingcompattests = 0 3151.165Smatt ignoredkeywords["compatdir"] = 1 3161.165Smatt ignoredkeywords["compatfile"] = 1 3171.165Smatt ignoredkeywords["compattestdir"] = 1 3181.165Smatt ignoredkeywords["compattestfile"] = 1 3191.170Smatt ignoredkeywords["compatx11dir"] = 1 3201.170Smatt ignoredkeywords["compatx11file"] = 1 3211.52Slukem for (vi in needvars) { 3221.52Slukem nv = needvars[vi] 3231.52Slukem kw = tolower(nv) 3241.52Slukem sub(/^mk/, "", kw) 3251.143Snakayama sub(/^have_/, "", kw) 3261.148Smatt sub(/^target_endianness/, "endian", kw) 3271.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 3281.203Srillig wanted[kw] = 1 3291.167Smatt } 3301.166Smatt } 3311.166Smatt 3321.167Smatt if ("compat" in wanted) { 3331.166Smatt doingcompat = 1; 3341.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3351.166Smatt compatdirkeywords["compatdir"] = 1 3361.166Smatt compatfilekeywords["compatfile"] = 1 3371.166Smatt 3381.166Smatt if (wanted["compattests"]) { 3391.165Smatt doingcompattests = 1; 3401.165Smatt compatdirkeywords["compattestdir"] = 1 3411.165Smatt compatfilekeywords["compattestfile"] = 1 3421.166Smatt } 3431.170Smatt if (wanted["compatx11"]) { 3441.170Smatt doingcompatx11 = 1; 3451.170Smatt compatdirkeywords["compatx11dir"] = 1 3461.170Smatt compatfilekeywords["compatx11file"] = 1 3471.170Smatt } 3481.166Smatt } 3491.166Smatt 3501.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 3511.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 3521.190Schristos kmodprefix = "./stand/" 3531.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 3541.166Smatt l_kmodpat = length(kmodpat) 3551.203Srillig kmoddbprefix = "./usr/libdata/debug/stand/" 3561.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 3571.190Schristos l_kmoddbpat = length(kmoddbpat) 3581.52Slukem } 3591.198Schristos if ("debug" in wanted) { 3601.201Schristos debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 3611.198Schristos l_debugkernelname = length(debugkernelname); 3621.198Schristos } 3631.52Slukem 3641.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 3651.90Sdyoung if ("binutils" in wanted) 3661.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 3671.90Sdyoung if ("gcc" in wanted) 3681.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 3691.90Sdyoung if ("gdb" in wanted) 3701.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 3711.9Slukem } 3721.192Sjmcneill if ("acpi" in wanted) { 3731.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 3741.192Sjmcneill } 3751.192Sjmcneill if ("mesa_ver" in wanted) { 3761.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 3771.192Sjmcneill } 3781.193Sjmcneill if ("nvmm" in wanted) { 3791.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 3801.193Sjmcneill } 3811.183Schristos if ("openssl" in wanted) { 3821.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 3831.183Schristos } 3841.178Smrg if ("xorg_server_ver" in wanted) { 3851.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 3861.177Smrg } 3871.192Sjmcneill if ("uefi" in wanted) { 3881.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 3891.185Smrg } 3901.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 3911.195Skamil wanted[".cat"] = 1 3921.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 3931.52Slukem wanted[".man"] = 1 3941.148Smatt if ("endian" in wanted) 3951.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 3961.162Smrg if ("machine" in wanted) 3971.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 3981.162Smrg if ("machine_arch" in wanted) 3991.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 4001.162Smrg if ("machine_cpu" in wanted) 4011.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 4021.9Slukem } 4031.9Slukem 4041.9Slukem /^#/ { 4051.9Slukem next; 4061.9Slukem } 4071.9Slukem 4081.127Smatt /^-/ { 4091.127Smatt notwanted[substr($1, 2)] = 1; 4101.127Smatt delete list [substr($1, 2)]; 4111.127Smatt next; 4121.127Smatt } 4131.203Srillig 4141.127Smatt 4151.9Slukem NF > 2 && $3 != "-" { 4161.127Smatt if (notwanted[$1] != "") 4171.127Smatt next; 4181.9Slukem split($3, keywords, ",") 4191.9Slukem show = 1 4201.52Slukem haveobs = 0 4211.167Smatt iscompatfile = 0 4221.165Smatt havekmod = 0 4231.165Smatt iscompatdir = 0 4241.9Slukem for (ki in keywords) { 4251.9Slukem kw = keywords[ki] 4261.22Slukem if (("manz" in wanted) && 4271.22Slukem (kw == ".cat" || kw == ".man")) 4281.22Slukem $1 = $1 ".gz" 4291.134Sjoerg if (substr(kw, 1, 1) == "!") { 4301.134Sjoerg kw = substr(kw, 2) 4311.59Sjmmv if (kw in wanted) 4321.59Sjmmv show = 0 4331.165Smatt } else if (kw in compatdirkeywords) { 4341.165Smatt iscompatdir = 1 4351.165Smatt } else if (kw in compatfilekeywords) { 4361.167Smatt iscompatfile = 1 4371.172Smatt } else if (kw == "nocompatmodules") { 4381.172Smatt havekmod = -1 4391.165Smatt } else if (kw in ignoredkeywords) { 4401.165Smatt # ignore 4411.167Smatt } else if (! (kw in wanted)) { 4421.167Smatt show = 0 4431.172Smatt } else if (kw == "kmod" && havekmod == 0) { 4441.167Smatt havekmod = 1 4451.59Sjmmv } 4461.52Slukem if (kw == "obsolete") 4471.52Slukem haveobs = 1 4481.9Slukem } 4491.184Snakayama if (iscompatdir) { 4501.184Snakayama for (d in cpaths) { 4511.184Snakayama if (cpaths[d] == $1 "/") 4521.184Snakayama next 4531.184Snakayama } 4541.184Snakayama cpaths[ncpaths++] = $1 "/" 4551.184Snakayama } 4561.52Slukem if (obsolete && ! haveobs) 4571.52Slukem next 4581.165Smatt if (!show) 4591.165Smatt next 4601.198Schristos if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 4611.198Schristos next 4621.165Smatt 4631.165Smatt list[$1] = $0 4641.190Schristos if (havekmod > 0) { 4651.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 4661.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 4671.165Smatt next 4681.165Smatt } 4691.165Smatt 4701.167Smatt if (!doingcompat || !(iscompatfile || iscompatdir)) 4711.165Smatt next 4721.165Smatt 4731.167Smatt if (iscompatfile) { 4741.165Smatt emitcompat[$1] = 1; 4751.168Smatt next 4761.168Smatt } 4771.165Smatt for (d in compatarchdirs) { 4781.165Smatt tmp = $0 4791.165Smatt xfile = $1 "/" compatarchdirs[d] 4801.165Smatt tmp = xfile substr(tmp, length($1) + 1) 4811.165Smatt if (xfile in notwanted) 4821.165Smatt continue; 4831.165Smatt sub("compatdir","compat",tmp); 4841.165Smatt sub("compattestdir","compat",tmp); 4851.165Smatt list[xfile] = tmp 4861.165Smatt } 4871.9Slukem next 4881.9Slukem } 4891.9Slukem 4901.9Slukem { 4911.165Smatt if ($1 in notwanted) 4921.127Smatt next; 4931.9Slukem if (! obsolete) 4941.127Smatt list[$1] = $0 4951.127Smatt } 4961.127Smatt 4971.127Smatt END { 4981.127Smatt for (i in list) { 4991.127Smatt print list[i] 5001.165Smatt if (! (i in emitcompat)) 5011.165Smatt continue; 5021.165Smatt l_i = length(i) 5031.165Smatt l = 0 5041.165Smatt for (j in cpaths) { 5051.165Smatt lx = length(cpaths[j]) 5061.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 5071.165Smatt continue; 5081.165Smatt } 5091.165Smatt if (lx > l) { 5101.165Smatt l = lx; 5111.165Smatt cpath = cpaths[j]; 5121.165Smatt } 5131.165Smatt } 5141.165Smatt for (d in compatarchdirs) { 5151.165Smatt tmp = list[i] 5161.165Smatt extrapath = compatarchdirs[d] "/" 5171.165Smatt xfile = cpath extrapath substr(i, l + 1) 5181.165Smatt if (xfile in notwanted) 5191.165Smatt continue; 5201.165Smatt sub("compatfile","compat",tmp); 5211.165Smatt sub("compattestfile","compat",tmp); 5221.165Smatt tmp = xfile substr(tmp, l_i + 1) 5231.165Smatt print tmp; 5241.165Smatt } 5251.127Smatt } 5261.9Slukem }' 5271.9Slukem 5281.1Sdyoung} 5291.1Sdyoung 5301.1Sdyoung# 5311.1Sdyoung# list_set_lists setname 5321.203Srillig# 5331.1Sdyoung# Print to stdout a list of files, one filename per line, which 5341.1Sdyoung# concatenate to create the packing list for setname. E.g., 5351.1Sdyoung# 5361.1Sdyoung# .../lists/base/mi 5371.1Sdyoung# .../lists/base/rescue.mi 5381.1Sdyoung# .../lists/base/md.i386 5391.9Slukem# [...] 5401.1Sdyoung# 5411.9Slukem# For a given setname $set, the following files may be selected from 5421.9Slukem# .../list/$set: 5431.9Slukem# mi 5441.92Suebayasi# mi.ext.* 5451.11Slukem# ad.${MACHINE_ARCH} 5461.11Slukem# (or) ad.${MACHINE_CPU} 5471.11Slukem# ad.${MACHINE_CPU}.shl 5481.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 5491.11Slukem# (or) md.${MACHINE} 5501.9Slukem# stl.mi 5511.92Suebayasi# stl.${stlib} 5521.9Slukem# shl.mi 5531.92Suebayasi# shl.mi.ext.* 5541.92Suebayasi# shl.${shlib} 5551.92Suebayasi# shl.${shlib}.ext.* 5561.77Stsutsui# module.mi if ${module} != no 5571.77Stsutsui# module.${MACHINE} if ${module} != no 5581.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 5591.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 5601.9Slukem# rescue.shl 5611.11Slukem# rescue.${MACHINE} 5621.11Slukem# rescue.ad.${MACHINE_ARCH} 5631.11Slukem# (or) rescue.ad.${MACHINE_CPU} 5641.11Slukem# rescue.ad.${MACHINE_CPU}.shl 5651.1Sdyoung# 5661.9Slukem# Environment: 5671.1Sdyoung# shlib 5681.1Sdyoung# stlib 5691.1Sdyoung# 5701.8Slukemlist_set_lists() 5711.8Slukem{ 5721.1Sdyoung setname=$1 5731.1Sdyoung 5741.111Suebayasi list_set_lists_mi $setname 5751.113Suebayasi list_set_lists_ad $setname 5761.111Suebayasi list_set_lists_md $setname 5771.111Suebayasi list_set_lists_stl $setname 5781.113Suebayasi list_set_lists_shl $setname 5791.113Suebayasi list_set_lists_module $setname 5801.111Suebayasi list_set_lists_rescue $setname 5811.117Suebayasi return 0 5821.111Suebayasi} 5831.110Suebayasi 5841.111Suebayasilist_set_lists_mi() 5851.111Suebayasi{ 5861.111Suebayasi setdir=$setsdir/lists/$1 5871.113Suebayasi # always exist! 5881.9Slukem echo $setdir/mi 5891.111Suebayasi} 5901.110Suebayasi 5911.111Suebayasilist_set_lists_ad() 5921.111Suebayasi{ 5931.111Suebayasi setdir=$setsdir/lists/$1 5941.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5951.113Suebayasi list_set_lists_common_ad $1 5961.111Suebayasi} 5971.110Suebayasi 5981.111Suebayasilist_set_lists_md() 5991.111Suebayasi{ 6001.111Suebayasi setdir=$setsdir/lists/$1 6011.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 6021.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 6031.111Suebayasi} 6041.110Suebayasi 6051.111Suebayasilist_set_lists_stl() 6061.111Suebayasi{ 6071.111Suebayasi setdir=$setsdir/lists/$1 6081.110Suebayasi echo_if_exist $setdir/stl.mi 6091.110Suebayasi echo_if_exist $setdir/stl.${stlib} 6101.111Suebayasi} 6111.110Suebayasi 6121.111Suebayasilist_set_lists_shl() 6131.111Suebayasi{ 6141.111Suebayasi setdir=$setsdir/lists/$1 6151.113Suebayasi [ "$shlib" != "no" ] || return 6161.112Suebayasi echo_if_exist $setdir/shl.mi 6171.112Suebayasi echo_if_exist $setdir/shl.${shlib} 6181.111Suebayasi} 6191.110Suebayasi 6201.111Suebayasilist_set_lists_module() 6211.111Suebayasi{ 6221.111Suebayasi setdir=$setsdir/lists/$1 6231.113Suebayasi [ "$module" != "no" ] || return 6241.112Suebayasi echo_if_exist $setdir/module.mi 6251.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 6261.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 6271.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 6281.113Suebayasi # XXX module never has .shl 6291.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6301.113Suebayasi list_set_lists_common_ad $1 module 6311.111Suebayasi} 6321.1Sdyoung 6331.111Suebayasilist_set_lists_rescue() 6341.111Suebayasi{ 6351.111Suebayasi setdir=$setsdir/lists/$1 6361.110Suebayasi echo_if_exist $setdir/rescue.mi 6371.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 6381.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6391.113Suebayasi list_set_lists_common_ad $1 rescue 6401.111Suebayasi} 6411.111Suebayasi 6421.113Suebayasilist_set_lists_common_ad() 6431.111Suebayasi{ 6441.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 6451.113Suebayasi 6461.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 6471.113Suebayasi 6481.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 6491.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 6501.112Suebayasi # specific one will be more specific than the 6511.112Suebayasi # cpu-specific one. 6521.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 6531.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 6541.113Suebayasi [ "$shlib" != "no" ] && \ 6551.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 6561.5Sdyoung} 6571.5Sdyoung 6581.110Suebayasiecho_if_exist() 6591.110Suebayasi{ 6601.110Suebayasi [ -f $1 ] && echo $1 6611.110Suebayasi return $? 6621.110Suebayasi} 6631.110Suebayasi 6641.110Suebayasiecho_if_exist_foreach() 6651.110Suebayasi{ 6661.110Suebayasi local _list=$1; shift 6671.110Suebayasi for _suffix in $@; do 6681.110Suebayasi echo_if_exist ${_list}.${_suffix} 6691.110Suebayasi done 6701.110Suebayasi} 6711.110Suebayasi 6721.116Suebayasiprint_set_lists() 6731.116Suebayasi{ 6741.116Suebayasi for setname; do 6751.136Schristos list=$(list_set_lists $setname) 6761.116Suebayasi for l in $list; do 6771.116Suebayasi echo $l 6781.116Suebayasi if $verbose; then 6791.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 6801.116Suebayasi fi 6811.116Suebayasi done 6821.118Suebayasi done | ${XARGS} ${SED} ${SUBST} 6831.116Suebayasi} 6841.116Suebayasi 6851.198Schristos 6861.198Schristoslist_kernel_configs() 6871.198Schristos{ 6881.198Schristos (cd ${NETBSDSRCDIR}/etc 6891.198Schristos MAKEFLAGS= \ 6901.198Schristos ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 6911.198Schristos} 6921.198Schristos 6931.9Slukem# arch_to_cpu mach 6941.9Slukem# 6951.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 6961.9Slukem# as determined by <bsd.own.mk>. 6971.9Slukem# 6981.8Slukemarch_to_cpu() 6991.8Slukem{ 7001.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 7011.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 7021.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 7031.182Suwe -V '${MACHINE_CPU}' 7041.1Sdyoung} 7051.46Sapb 7061.46Sapb# arch_to_endian mach 7071.46Sapb# 7081.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 7091.46Sapb# as determined by <bsd.endian.mk>. 7101.46Sapb# 7111.46Sapbarch_to_endian() 7121.46Sapb{ 7131.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 7141.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 7151.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 7161.182Suwe -V '${TARGET_ENDIANNESS}' 7171.46Sapb} 7181.117Suebayasi 7191.117Suebayasi##### 7201.117Suebayasi 7211.117Suebayasi# print_mkvars 7221.117Suebayasiprint_mkvars() 7231.117Suebayasi{ 7241.117Suebayasi for v in $MKVARS; do 7251.117Suebayasi eval echo $v=\$$v 7261.117Suebayasi done 7271.117Suebayasi} 7281.117Suebayasi 7291.117Suebayasi# print_set_lists_{base,x,ext} 7301.117Suebayasi# list_set_lists_{base,x,ext} 7311.117Suebayasi# list_set_files_{base,x,ext} 7321.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 7331.117Suebayasi for x in base x ext; do 7341.117Suebayasi if [ $x = base ]; then 7351.117Suebayasi list=nlists 7361.117Suebayasi else 7371.117Suebayasi list=${x}lists 7381.117Suebayasi fi 7391.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 7401.117Suebayasi done 7411.117Suebayasidone 742