sets.subr revision 1.198
11.198Schristos# $NetBSD: sets.subr,v 1.198 2021/12/29 22:22:13 christos 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.197Smayanlists="base comp $debugset $dtbset etc games gpufw 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.198Schristos# # $NetBSD: sets.subr,v 1.198 2021/12/29 22:22:13 christos 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.198Schristos local CONFIGS="$( list_kernel_configs )" 2671.116Suebayasi print_set_lists "$@" | \ 2681.43Sapb ${AWK} -v obsolete=${obsolete} ' 2691.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 2701.190Schristos if (substr(line, 1, patlen) != pat) { 2711.198Schristos return 2721.190Schristos } 2731.190Schristos for (d in kmodarchdirs) { 2741.190Schristos xd = prefix kmodarchdirs[d] 2751.198Schristos xline = xd substr(line, patlen + 1) 2761.198Schristos xfname = xd substr(fname, patlen + 1) 2771.198Schristos list[xline] = xfname 2781.190Schristos } 2791.190Schristos } 2801.198Schristos function adddebugkernel(line, fname, pat, patlen) { 2811.198Schristos if (substr(line, 1, patlen) != pat) { 2821.198Schristos return 0 2831.198Schristos } 2841.198Schristos split("'"${CONFIGS}"'", configs) 2851.198Schristos for (d in configs) { 2861.198Schristos xfname = fname 2871.198Schristos sub("CONFIG", configs[d], xfname) 2881.198Schristos xline = line; 2891.198Schristos sub("CONFIG", configs[d], xline) 2901.198Schristos list[xline] = xfname 2911.198Schristos } 2921.198Schristos return 1 2931.198Schristos } 2941.9Slukem BEGIN { 2951.52Slukem if (obsolete) 2961.52Slukem wanted["obsolete"] = 1 2971.52Slukem 2981.100Suebayasi split("'"${MKVARS}"'", needvars) 2991.165Smatt doingcompat = 0 3001.165Smatt doingcompattests = 0 3011.165Smatt ignoredkeywords["compatdir"] = 1 3021.165Smatt ignoredkeywords["compatfile"] = 1 3031.165Smatt ignoredkeywords["compattestdir"] = 1 3041.165Smatt ignoredkeywords["compattestfile"] = 1 3051.170Smatt ignoredkeywords["compatx11dir"] = 1 3061.170Smatt ignoredkeywords["compatx11file"] = 1 3071.52Slukem for (vi in needvars) { 3081.52Slukem nv = needvars[vi] 3091.52Slukem kw = tolower(nv) 3101.52Slukem sub(/^mk/, "", kw) 3111.143Snakayama sub(/^have_/, "", kw) 3121.148Smatt sub(/^target_endianness/, "endian", kw) 3131.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 3141.165Smatt wanted[kw] = 1 3151.167Smatt } 3161.166Smatt } 3171.166Smatt 3181.167Smatt if ("compat" in wanted) { 3191.166Smatt doingcompat = 1; 3201.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3211.166Smatt compatdirkeywords["compatdir"] = 1 3221.166Smatt compatfilekeywords["compatfile"] = 1 3231.166Smatt 3241.166Smatt if (wanted["compattests"]) { 3251.165Smatt doingcompattests = 1; 3261.165Smatt compatdirkeywords["compattestdir"] = 1 3271.165Smatt compatfilekeywords["compattestfile"] = 1 3281.166Smatt } 3291.170Smatt if (wanted["compatx11"]) { 3301.170Smatt doingcompatx11 = 1; 3311.170Smatt compatdirkeywords["compatx11dir"] = 1 3321.170Smatt compatfilekeywords["compatx11file"] = 1 3331.170Smatt } 3341.166Smatt } 3351.166Smatt 3361.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 3371.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 3381.190Schristos kmodprefix = "./stand/" 3391.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 3401.166Smatt l_kmodpat = length(kmodpat) 3411.190Schristos kmoddbprefix = "./usr/libdata/debug/stand/" 3421.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 3431.190Schristos l_kmoddbpat = length(kmoddbpat) 3441.52Slukem } 3451.198Schristos if ("debug" in wanted) { 3461.198Schristos debugkernelname = "./usr/libdata/debug/netbsd-CONFIG.debug" 3471.198Schristos l_debugkernelname = length(debugkernelname); 3481.198Schristos } 3491.52Slukem 3501.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 3511.90Sdyoung if ("binutils" in wanted) 3521.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 3531.90Sdyoung if ("gcc" in wanted) 3541.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 3551.90Sdyoung if ("gdb" in wanted) 3561.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 3571.9Slukem } 3581.192Sjmcneill if ("acpi" in wanted) { 3591.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 3601.192Sjmcneill } 3611.192Sjmcneill if ("mesa_ver" in wanted) { 3621.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 3631.192Sjmcneill } 3641.193Sjmcneill if ("nvmm" in wanted) { 3651.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 3661.193Sjmcneill } 3671.183Schristos if ("openssl" in wanted) { 3681.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 3691.183Schristos } 3701.178Smrg if ("xorg_server_ver" in wanted) { 3711.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 3721.177Smrg } 3731.192Sjmcneill if ("uefi" in wanted) { 3741.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 3751.185Smrg } 3761.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 3771.195Skamil wanted[".cat"] = 1 3781.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 3791.52Slukem wanted[".man"] = 1 3801.148Smatt if ("endian" in wanted) 3811.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 3821.162Smrg if ("machine" in wanted) 3831.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 3841.162Smrg if ("machine_arch" in wanted) 3851.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 3861.162Smrg if ("machine_cpu" in wanted) 3871.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 3881.9Slukem } 3891.9Slukem 3901.9Slukem /^#/ { 3911.9Slukem next; 3921.9Slukem } 3931.9Slukem 3941.127Smatt /^-/ { 3951.127Smatt notwanted[substr($1, 2)] = 1; 3961.127Smatt delete list [substr($1, 2)]; 3971.127Smatt next; 3981.127Smatt } 3991.127Smatt 4001.127Smatt 4011.9Slukem NF > 2 && $3 != "-" { 4021.127Smatt if (notwanted[$1] != "") 4031.127Smatt next; 4041.9Slukem split($3, keywords, ",") 4051.9Slukem show = 1 4061.52Slukem haveobs = 0 4071.167Smatt iscompatfile = 0 4081.165Smatt havekmod = 0 4091.165Smatt iscompatdir = 0 4101.9Slukem for (ki in keywords) { 4111.9Slukem kw = keywords[ki] 4121.22Slukem if (("manz" in wanted) && 4131.22Slukem (kw == ".cat" || kw == ".man")) 4141.22Slukem $1 = $1 ".gz" 4151.134Sjoerg if (substr(kw, 1, 1) == "!") { 4161.134Sjoerg kw = substr(kw, 2) 4171.59Sjmmv if (kw in wanted) 4181.59Sjmmv show = 0 4191.165Smatt } else if (kw in compatdirkeywords) { 4201.165Smatt iscompatdir = 1 4211.165Smatt } else if (kw in compatfilekeywords) { 4221.167Smatt iscompatfile = 1 4231.172Smatt } else if (kw == "nocompatmodules") { 4241.172Smatt havekmod = -1 4251.165Smatt } else if (kw in ignoredkeywords) { 4261.165Smatt # ignore 4271.167Smatt } else if (! (kw in wanted)) { 4281.167Smatt show = 0 4291.172Smatt } else if (kw == "kmod" && havekmod == 0) { 4301.167Smatt havekmod = 1 4311.59Sjmmv } 4321.52Slukem if (kw == "obsolete") 4331.52Slukem haveobs = 1 4341.9Slukem } 4351.184Snakayama if (iscompatdir) { 4361.184Snakayama for (d in cpaths) { 4371.184Snakayama if (cpaths[d] == $1 "/") 4381.184Snakayama next 4391.184Snakayama } 4401.184Snakayama cpaths[ncpaths++] = $1 "/" 4411.184Snakayama } 4421.52Slukem if (obsolete && ! haveobs) 4431.52Slukem next 4441.165Smatt if (!show) 4451.165Smatt next 4461.198Schristos if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 4471.198Schristos next 4481.165Smatt 4491.165Smatt list[$1] = $0 4501.190Schristos if (havekmod > 0) { 4511.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 4521.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 4531.165Smatt next 4541.165Smatt } 4551.165Smatt 4561.167Smatt if (!doingcompat || !(iscompatfile || iscompatdir)) 4571.165Smatt next 4581.165Smatt 4591.167Smatt if (iscompatfile) { 4601.165Smatt emitcompat[$1] = 1; 4611.168Smatt next 4621.168Smatt } 4631.165Smatt for (d in compatarchdirs) { 4641.165Smatt tmp = $0 4651.165Smatt xfile = $1 "/" compatarchdirs[d] 4661.165Smatt tmp = xfile substr(tmp, length($1) + 1) 4671.165Smatt if (xfile in notwanted) 4681.165Smatt continue; 4691.165Smatt sub("compatdir","compat",tmp); 4701.165Smatt sub("compattestdir","compat",tmp); 4711.165Smatt list[xfile] = tmp 4721.165Smatt } 4731.9Slukem next 4741.9Slukem } 4751.9Slukem 4761.9Slukem { 4771.165Smatt if ($1 in notwanted) 4781.127Smatt next; 4791.9Slukem if (! obsolete) 4801.127Smatt list[$1] = $0 4811.127Smatt } 4821.127Smatt 4831.127Smatt END { 4841.127Smatt for (i in list) { 4851.127Smatt print list[i] 4861.165Smatt if (! (i in emitcompat)) 4871.165Smatt continue; 4881.165Smatt l_i = length(i) 4891.165Smatt l = 0 4901.165Smatt for (j in cpaths) { 4911.165Smatt lx = length(cpaths[j]) 4921.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 4931.165Smatt continue; 4941.165Smatt } 4951.165Smatt if (lx > l) { 4961.165Smatt l = lx; 4971.165Smatt cpath = cpaths[j]; 4981.165Smatt } 4991.165Smatt } 5001.165Smatt for (d in compatarchdirs) { 5011.165Smatt tmp = list[i] 5021.165Smatt extrapath = compatarchdirs[d] "/" 5031.165Smatt xfile = cpath extrapath substr(i, l + 1) 5041.165Smatt if (xfile in notwanted) 5051.165Smatt continue; 5061.165Smatt sub("compatfile","compat",tmp); 5071.165Smatt sub("compattestfile","compat",tmp); 5081.165Smatt tmp = xfile substr(tmp, l_i + 1) 5091.165Smatt print tmp; 5101.165Smatt } 5111.127Smatt } 5121.9Slukem }' 5131.9Slukem 5141.1Sdyoung} 5151.1Sdyoung 5161.1Sdyoung# 5171.1Sdyoung# list_set_lists setname 5181.1Sdyoung# 5191.1Sdyoung# Print to stdout a list of files, one filename per line, which 5201.1Sdyoung# concatenate to create the packing list for setname. E.g., 5211.1Sdyoung# 5221.1Sdyoung# .../lists/base/mi 5231.1Sdyoung# .../lists/base/rescue.mi 5241.1Sdyoung# .../lists/base/md.i386 5251.9Slukem# [...] 5261.1Sdyoung# 5271.9Slukem# For a given setname $set, the following files may be selected from 5281.9Slukem# .../list/$set: 5291.9Slukem# mi 5301.92Suebayasi# mi.ext.* 5311.11Slukem# ad.${MACHINE_ARCH} 5321.11Slukem# (or) ad.${MACHINE_CPU} 5331.11Slukem# ad.${MACHINE_CPU}.shl 5341.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 5351.11Slukem# (or) md.${MACHINE} 5361.9Slukem# stl.mi 5371.92Suebayasi# stl.${stlib} 5381.9Slukem# shl.mi 5391.92Suebayasi# shl.mi.ext.* 5401.92Suebayasi# shl.${shlib} 5411.92Suebayasi# shl.${shlib}.ext.* 5421.77Stsutsui# module.mi if ${module} != no 5431.77Stsutsui# module.${MACHINE} if ${module} != no 5441.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 5451.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 5461.9Slukem# rescue.shl 5471.11Slukem# rescue.${MACHINE} 5481.11Slukem# rescue.ad.${MACHINE_ARCH} 5491.11Slukem# (or) rescue.ad.${MACHINE_CPU} 5501.11Slukem# rescue.ad.${MACHINE_CPU}.shl 5511.1Sdyoung# 5521.9Slukem# Environment: 5531.1Sdyoung# shlib 5541.1Sdyoung# stlib 5551.1Sdyoung# 5561.8Slukemlist_set_lists() 5571.8Slukem{ 5581.1Sdyoung setname=$1 5591.1Sdyoung 5601.111Suebayasi list_set_lists_mi $setname 5611.113Suebayasi list_set_lists_ad $setname 5621.111Suebayasi list_set_lists_md $setname 5631.111Suebayasi list_set_lists_stl $setname 5641.113Suebayasi list_set_lists_shl $setname 5651.113Suebayasi list_set_lists_module $setname 5661.111Suebayasi list_set_lists_rescue $setname 5671.117Suebayasi return 0 5681.111Suebayasi} 5691.110Suebayasi 5701.111Suebayasilist_set_lists_mi() 5711.111Suebayasi{ 5721.111Suebayasi setdir=$setsdir/lists/$1 5731.113Suebayasi # always exist! 5741.9Slukem echo $setdir/mi 5751.111Suebayasi} 5761.110Suebayasi 5771.111Suebayasilist_set_lists_ad() 5781.111Suebayasi{ 5791.111Suebayasi setdir=$setsdir/lists/$1 5801.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 5811.113Suebayasi list_set_lists_common_ad $1 5821.111Suebayasi} 5831.110Suebayasi 5841.111Suebayasilist_set_lists_md() 5851.111Suebayasi{ 5861.111Suebayasi setdir=$setsdir/lists/$1 5871.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 5881.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 5891.111Suebayasi} 5901.110Suebayasi 5911.111Suebayasilist_set_lists_stl() 5921.111Suebayasi{ 5931.111Suebayasi setdir=$setsdir/lists/$1 5941.110Suebayasi echo_if_exist $setdir/stl.mi 5951.110Suebayasi echo_if_exist $setdir/stl.${stlib} 5961.111Suebayasi} 5971.110Suebayasi 5981.111Suebayasilist_set_lists_shl() 5991.111Suebayasi{ 6001.111Suebayasi setdir=$setsdir/lists/$1 6011.113Suebayasi [ "$shlib" != "no" ] || return 6021.112Suebayasi echo_if_exist $setdir/shl.mi 6031.112Suebayasi echo_if_exist $setdir/shl.${shlib} 6041.111Suebayasi} 6051.110Suebayasi 6061.111Suebayasilist_set_lists_module() 6071.111Suebayasi{ 6081.111Suebayasi setdir=$setsdir/lists/$1 6091.113Suebayasi [ "$module" != "no" ] || return 6101.112Suebayasi echo_if_exist $setdir/module.mi 6111.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 6121.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 6131.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 6141.113Suebayasi # XXX module never has .shl 6151.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6161.113Suebayasi list_set_lists_common_ad $1 module 6171.111Suebayasi} 6181.1Sdyoung 6191.111Suebayasilist_set_lists_rescue() 6201.111Suebayasi{ 6211.111Suebayasi setdir=$setsdir/lists/$1 6221.110Suebayasi echo_if_exist $setdir/rescue.mi 6231.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 6241.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 6251.113Suebayasi list_set_lists_common_ad $1 rescue 6261.111Suebayasi} 6271.111Suebayasi 6281.113Suebayasilist_set_lists_common_ad() 6291.111Suebayasi{ 6301.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 6311.113Suebayasi 6321.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 6331.113Suebayasi 6341.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 6351.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 6361.112Suebayasi # specific one will be more specific than the 6371.112Suebayasi # cpu-specific one. 6381.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 6391.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 6401.113Suebayasi [ "$shlib" != "no" ] && \ 6411.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 6421.5Sdyoung} 6431.5Sdyoung 6441.110Suebayasiecho_if_exist() 6451.110Suebayasi{ 6461.110Suebayasi [ -f $1 ] && echo $1 6471.110Suebayasi return $? 6481.110Suebayasi} 6491.110Suebayasi 6501.110Suebayasiecho_if_exist_foreach() 6511.110Suebayasi{ 6521.110Suebayasi local _list=$1; shift 6531.110Suebayasi for _suffix in $@; do 6541.110Suebayasi echo_if_exist ${_list}.${_suffix} 6551.110Suebayasi done 6561.110Suebayasi} 6571.110Suebayasi 6581.116Suebayasiprint_set_lists() 6591.116Suebayasi{ 6601.116Suebayasi for setname; do 6611.136Schristos list=$(list_set_lists $setname) 6621.116Suebayasi for l in $list; do 6631.116Suebayasi echo $l 6641.116Suebayasi if $verbose; then 6651.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 6661.116Suebayasi fi 6671.116Suebayasi done 6681.118Suebayasi done | ${XARGS} ${SED} ${SUBST} 6691.116Suebayasi} 6701.116Suebayasi 6711.198Schristos 6721.198Schristoslist_kernel_configs() 6731.198Schristos{ 6741.198Schristos (cd ${NETBSDSRCDIR}/etc 6751.198Schristos MAKEFLAGS= \ 6761.198Schristos ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 6771.198Schristos} 6781.198Schristos 6791.9Slukem# arch_to_cpu mach 6801.9Slukem# 6811.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 6821.9Slukem# as determined by <bsd.own.mk>. 6831.9Slukem# 6841.8Slukemarch_to_cpu() 6851.8Slukem{ 6861.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 6871.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 6881.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 6891.182Suwe -V '${MACHINE_CPU}' 6901.1Sdyoung} 6911.46Sapb 6921.46Sapb# arch_to_endian mach 6931.46Sapb# 6941.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 6951.46Sapb# as determined by <bsd.endian.mk>. 6961.46Sapb# 6971.46Sapbarch_to_endian() 6981.46Sapb{ 6991.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 7001.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 7011.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 7021.182Suwe -V '${TARGET_ENDIANNESS}' 7031.46Sapb} 7041.117Suebayasi 7051.117Suebayasi##### 7061.117Suebayasi 7071.117Suebayasi# print_mkvars 7081.117Suebayasiprint_mkvars() 7091.117Suebayasi{ 7101.117Suebayasi for v in $MKVARS; do 7111.117Suebayasi eval echo $v=\$$v 7121.117Suebayasi done 7131.117Suebayasi} 7141.117Suebayasi 7151.117Suebayasi# print_set_lists_{base,x,ext} 7161.117Suebayasi# list_set_lists_{base,x,ext} 7171.117Suebayasi# list_set_files_{base,x,ext} 7181.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 7191.117Suebayasi for x in base x ext; do 7201.117Suebayasi if [ $x = base ]; then 7211.117Suebayasi list=nlists 7221.117Suebayasi else 7231.117Suebayasi list=${x}lists 7241.117Suebayasi fi 7251.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 7261.117Suebayasi done 7271.117Suebayasidone 728