sets.subr revision 1.209
11.209Sriastrad# $NetBSD: sets.subr,v 1.209 2024/07/11 17:27:25 riastradh 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.206Sniaif [ -z "${debug32set}" ]; then 1631.206Snia debug64set="" 1641.206Sniaelse 1651.206Snia if [ "${MACHINE_ARCH}" = "mips64eb" -o "${MACHINE_ARCH}" = "mips64el" ]; then 1661.206Snia debug64set="debug64" 1671.206Snia else 1681.206Snia debug64set="" 1691.206Snia fi 1701.206Sniafi 1711.191Sjmcneillif [ "${MKDTB}" = "no" ]; then 1721.191Sjmcneill dtbset="" 1731.191Sjmcneillelse 1741.191Sjmcneill dtbset="dtb" 1751.191Sjmcneillfi 1761.205Sniaif [ "${MKHTML}" = "no" ]; then 1771.205Snia manhtmlset="" 1781.205Sniaelse 1791.205Snia manhtmlset="manhtml" 1801.205Sniafi 1811.205Sniaif [ "${MKCOMPAT}" = "no" ]; then 1821.205Snia base32set="" 1831.205Sniaelse 1841.205Snia base32set="base32" 1851.205Sniafi 1861.206Sniaif [ "${MKCOMPAT}" != "no" ]; then 1871.206Snia if [ "${MACHINE_ARCH}" = "mips64eb" -o "${MACHINE_ARCH}" = "mips64el" ]; then 1881.206Snia base64set="base64" 1891.206Snia else 1901.206Snia base64set="" 1911.206Snia fi 1921.206Sniaelse 1931.206Snia base64set="" 1941.206Sniafi 1951.206Snia 1961.207Sriastrad# XXX This should not be encoded here -- this mostly duplicates 1971.207Sriastrad# information in compat/archdirs.mk, except that it also identifies 1981.207Sriastrad# which compat architectures are `32-bit' and which ones are `64-bit'. 1991.207Sriastradcase $MACHINE_ARCH in 2001.207Sriastradaarch64) 2011.207Sriastrad compat32arches='eabi eabihf' 2021.207Sriastrad ;; 2031.207Sriastradaarch64eb) 2041.207Sriastrad compat32arches=eabi 2051.207Sriastrad ;; 2061.207Sriastradmips64eb|mips64el) 2071.207Sriastrad compat32arches=o32 2081.207Sriastrad compat64arches=64 2091.207Sriastrad ;; 2101.207Sriastradmipsn64eb|mipsn64el) 2111.207Sriastrad compat32arches='n32 o32' 2121.207Sriastrad ;; 2131.207Sriastradpowerpc64) 2141.207Sriastrad compat32arches=powerpc 2151.207Sriastrad ;; 2161.207Sriastradriscv64) 2171.208Sriastrad compat32arches=rv32 2181.207Sriastrad ;; 2191.207Sriastradsparc64) 2201.207Sriastrad compat32arches=sparc 2211.207Sriastrad ;; 2221.207Sriastradx86_64) compat32arches=i386 2231.207Sriastrad ;; 2241.207Sriastradesac 2251.209Sriastrad: ${compat32arches:=} 2261.207Sriastrad: ${compat64arches:=} 2271.207Sriastrad 2281.205Snia 2291.31Sjmc# Determine lib type. Do this first so stlib also gets set. 2301.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 2311.9Slukem shlib=elf 2321.9Slukemelse 2331.9Slukem shlib=aout 2341.9Slukemfi 2351.9Slukemstlib=$shlib 2361.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 2371.31Sjmcif [ "${MKPIC}" = "no" ]; then 2381.31Sjmc shlib=no 2391.31Sjmcfi 2401.206Snianlists="base $base32set $base64set comp $debugset $debug32set $debug64set $dtbset etc games gpufw man $manhtmlset misc $modset rescue $testset text" 2411.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 2421.9Slukem 2431.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 2441.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 2451.188Schristos MODULEDIR="netbsd/modules" 2461.188Schristoselse 2471.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 2481.188Schristosfi 2491.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 2501.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 2511.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 2521.60Sad 2531.9Slukem# 2541.9Slukem# list_set_files setfile [...] 2551.203Srillig# 2561.9Slukem# Produce a packing list for setfile(s). 2571.9Slukem# In each file, a record consists of a path and a System Package name, 2581.9Slukem# separated by whitespace. E.g., 2591.9Slukem# 2601.209Sriastrad# # $NetBSD: sets.subr,v 1.209 2024/07/11 17:27:25 riastradh Exp $ 2611.9Slukem# . base-sys-root [keyword[,...]] 2621.9Slukem# ./altroot base-sys-root 2631.9Slukem# ./bin base-sys-root 2641.9Slukem# ./bin/[ base-util-root 2651.9Slukem# ./bin/cat base-util-root 2661.9Slukem# [...] 2671.9Slukem# 2681.9Slukem# A # in the first column marks a comment. 2691.9Slukem# 2701.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2711.52Slukem# be printed. All other keywords must be present. 2721.9Slukem# 2731.9Slukem# The third field is an optional comma separated list of keywords to 2741.9Slukem# control if a record is printed; every keyword listed must be enabled 2751.204Srillig# for the record to be printed. The list of all available make variables 2761.179Schristos# that can be turned on or off can be found by running in this directory: 2771.179Schristos# 2781.179Schristos# make -f mkvars.mk mkvarsyesno 2791.179Schristos# 2801.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2811.203Srillig# 2821.179Schristos# The following extra keywords are also available, listed by: 2831.179Schristos# 2841.179Schristos# make -f mkvars.mk mkextravars 2851.13Slukem# 2861.179Schristos# These are: 2871.179Schristos# 1. The HAVE_<name>: 2881.179Schristos# ssp ${HAVE_SSP} != no 2891.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2901.192Sjmcneill# acpi ${HAVE_ACPI} != no 2911.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2921.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2931.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2941.192Sjmcneill# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2951.193Sjmcneill# nvmm ${HAVE_NVMM} != no 2961.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2971.192Sjmcneill# uefi ${HAVE_UEFI} != no 2981.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 2991.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 3001.52Slukem# 3011.179Schristos# 2. The USE_<name>: 3021.41Slukem# use_inet6 ${USE_INET6} != no 3031.41Slukem# use_kerberos ${USE_KERBEROS} != no 3041.179Schristos# use_ldap ${USE_LDAP} != no 3051.41Slukem# use_yp ${USE_YP} != no 3061.41Slukem# 3071.179Schristos# 3. Finally: 3081.179Schristos# dummy dummy entry (ignored) 3091.203Srillig# obsolete file is obsolete, and only printed if 3101.179Schristos# ${obsolete} != 0 3111.179Schristos# 3121.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 3131.179Schristos# 3141.179Schristos# 3151.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 3161.179Schristos# 3171.179Schristos# 3181.195Skamil# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 3191.195Skamil# automatically append ".gz" to the filename 3201.195Skamil# 3211.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 3221.22Slukem# automatically append ".gz" to the filename 3231.1Sdyoung# 3241.8Slukemlist_set_files() 3251.8Slukem{ 3261.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 3271.65She verbose=false 3281.65She else 3291.65She verbose=true 3301.65She fi 3311.198Schristos local CONFIGS="$( list_kernel_configs )" 3321.116Suebayasi print_set_lists "$@" | \ 3331.43Sapb ${AWK} -v obsolete=${obsolete} ' 3341.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 3351.190Schristos if (substr(line, 1, patlen) != pat) { 3361.198Schristos return 3371.190Schristos } 3381.190Schristos for (d in kmodarchdirs) { 3391.190Schristos xd = prefix kmodarchdirs[d] 3401.198Schristos xline = xd substr(line, patlen + 1) 3411.198Schristos xfname = xd substr(fname, patlen + 1) 3421.198Schristos list[xline] = xfname 3431.207Sriastrad emit(xline) 3441.190Schristos } 3451.190Schristos } 3461.198Schristos function adddebugkernel(line, fname, pat, patlen) { 3471.199Schristos if (pat == "" || substr(line, 1, patlen) != pat) { 3481.198Schristos return 0 3491.198Schristos } 3501.198Schristos split("'"${CONFIGS}"'", configs) 3511.198Schristos for (d in configs) { 3521.198Schristos xfname = fname 3531.200Schristos sub("@CONFIG@", configs[d], xfname) 3541.198Schristos xline = line; 3551.200Schristos sub("@CONFIG@", configs[d], xline) 3561.198Schristos list[xline] = xfname 3571.207Sriastrad emit(xline) 3581.198Schristos } 3591.198Schristos return 1 3601.198Schristos } 3611.207Sriastrad function emit(fname) { 3621.207Sriastrad emitf[fname] = 1 3631.207Sriastrad } 3641.9Slukem BEGIN { 3651.52Slukem if (obsolete) 3661.52Slukem wanted["obsolete"] = 1 3671.203Srillig 3681.207Sriastrad ncpaths = 0 3691.100Suebayasi split("'"${MKVARS}"'", needvars) 3701.165Smatt doingcompat = 0 3711.165Smatt doingcompattests = 0 3721.165Smatt ignoredkeywords["compatdir"] = 1 3731.165Smatt ignoredkeywords["compatfile"] = 1 3741.165Smatt ignoredkeywords["compattestdir"] = 1 3751.165Smatt ignoredkeywords["compattestfile"] = 1 3761.170Smatt ignoredkeywords["compatx11dir"] = 1 3771.170Smatt ignoredkeywords["compatx11file"] = 1 3781.52Slukem for (vi in needvars) { 3791.52Slukem nv = needvars[vi] 3801.52Slukem kw = tolower(nv) 3811.52Slukem sub(/^mk/, "", kw) 3821.143Snakayama sub(/^have_/, "", kw) 3831.148Smatt sub(/^target_endianness/, "endian", kw) 3841.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 3851.203Srillig wanted[kw] = 1 3861.167Smatt } 3871.166Smatt } 3881.166Smatt 3891.167Smatt if ("compat" in wanted) { 3901.166Smatt doingcompat = 1; 3911.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3921.166Smatt compatdirkeywords["compatdir"] = 1 3931.166Smatt compatfilekeywords["compatfile"] = 1 3941.166Smatt 3951.166Smatt if (wanted["compattests"]) { 3961.165Smatt doingcompattests = 1; 3971.165Smatt compatdirkeywords["compattestdir"] = 1 3981.165Smatt compatfilekeywords["compattestfile"] = 1 3991.166Smatt } 4001.170Smatt if (wanted["compatx11"]) { 4011.170Smatt doingcompatx11 = 1; 4021.170Smatt compatdirkeywords["compatx11dir"] = 1 4031.170Smatt compatfilekeywords["compatx11file"] = 1 4041.170Smatt } 4051.166Smatt } 4061.166Smatt 4071.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 4081.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 4091.190Schristos kmodprefix = "./stand/" 4101.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 4111.166Smatt l_kmodpat = length(kmodpat) 4121.203Srillig kmoddbprefix = "./usr/libdata/debug/stand/" 4131.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 4141.190Schristos l_kmoddbpat = length(kmoddbpat) 4151.52Slukem } 4161.198Schristos if ("debug" in wanted) { 4171.201Schristos debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 4181.198Schristos l_debugkernelname = length(debugkernelname); 4191.198Schristos } 4201.52Slukem 4211.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 4221.90Sdyoung if ("binutils" in wanted) 4231.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 4241.90Sdyoung if ("gcc" in wanted) 4251.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 4261.90Sdyoung if ("gdb" in wanted) 4271.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 4281.9Slukem } 4291.192Sjmcneill if ("acpi" in wanted) { 4301.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 4311.192Sjmcneill } 4321.192Sjmcneill if ("mesa_ver" in wanted) { 4331.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 4341.192Sjmcneill } 4351.193Sjmcneill if ("nvmm" in wanted) { 4361.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 4371.193Sjmcneill } 4381.183Schristos if ("openssl" in wanted) { 4391.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 4401.183Schristos } 4411.178Smrg if ("xorg_server_ver" in wanted) { 4421.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 4431.177Smrg } 4441.192Sjmcneill if ("uefi" in wanted) { 4451.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 4461.185Smrg } 4471.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 4481.195Skamil wanted[".cat"] = 1 4491.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 4501.52Slukem wanted[".man"] = 1 4511.148Smatt if ("endian" in wanted) 4521.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 4531.162Smrg if ("machine" in wanted) 4541.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 4551.162Smrg if ("machine_arch" in wanted) 4561.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 4571.162Smrg if ("machine_cpu" in wanted) 4581.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 4591.9Slukem } 4601.9Slukem 4611.9Slukem /^#/ { 4621.9Slukem next; 4631.9Slukem } 4641.9Slukem 4651.127Smatt /^-/ { 4661.127Smatt notwanted[substr($1, 2)] = 1; 4671.127Smatt delete list [substr($1, 2)]; 4681.127Smatt next; 4691.127Smatt } 4701.203Srillig 4711.9Slukem NF > 2 && $3 != "-" { 4721.127Smatt if (notwanted[$1] != "") 4731.127Smatt next; 4741.9Slukem split($3, keywords, ",") 4751.9Slukem show = 1 4761.52Slukem haveobs = 0 4771.167Smatt iscompatfile = 0 4781.165Smatt havekmod = 0 4791.165Smatt iscompatdir = 0 4801.207Sriastrad omitcompat = 0 4811.207Sriastrad takecompat[$1] = 0 4821.9Slukem for (ki in keywords) { 4831.9Slukem kw = keywords[ki] 4841.22Slukem if (("manz" in wanted) && 4851.22Slukem (kw == ".cat" || kw == ".man")) 4861.22Slukem $1 = $1 ".gz" 4871.134Sjoerg if (substr(kw, 1, 1) == "!") { 4881.134Sjoerg kw = substr(kw, 2) 4891.59Sjmmv if (kw in wanted) 4901.59Sjmmv show = 0 4911.165Smatt } else if (kw in compatdirkeywords) { 4921.165Smatt iscompatdir = 1 4931.165Smatt } else if (kw in compatfilekeywords) { 4941.167Smatt iscompatfile = 1 4951.172Smatt } else if (kw == "nocompatmodules") { 4961.172Smatt havekmod = -1 4971.207Sriastrad } else if (kw == "omitcompat") { 4981.207Sriastrad omitcompat = 1 4991.207Sriastrad } else if (kw ~ /^takecompat=/) { 5001.207Sriastrad takecompat[$1] = 1 5011.207Sriastrad takecompatarch[substr(kw, 5021.207Sriastrad 1 + length("takecompat=")), $1] = 1 5031.165Smatt } else if (kw in ignoredkeywords) { 5041.165Smatt # ignore 5051.167Smatt } else if (! (kw in wanted)) { 5061.167Smatt show = 0 5071.172Smatt } else if (kw == "kmod" && havekmod == 0) { 5081.167Smatt havekmod = 1 5091.59Sjmmv } 5101.52Slukem if (kw == "obsolete") 5111.52Slukem haveobs = 1 5121.9Slukem } 5131.207Sriastrad 5141.207Sriastrad if (takecompat[$1] && !(iscompatdir || iscompatfile)) { 5151.207Sriastrad next 5161.207Sriastrad } 5171.207Sriastrad if (iscompatdir && !omitcompat) { 5181.184Snakayama for (d in cpaths) { 5191.207Sriastrad if (cpaths[d] == $1 "/") { 5201.207Sriastrad break 5211.207Sriastrad } 5221.184Snakayama } 5231.184Snakayama cpaths[ncpaths++] = $1 "/" 5241.184Snakayama } 5251.52Slukem if (obsolete && ! haveobs) 5261.52Slukem next 5271.165Smatt if (!show) 5281.165Smatt next 5291.198Schristos if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 5301.198Schristos next 5311.165Smatt 5321.165Smatt list[$1] = $0 5331.190Schristos if (havekmod > 0) { 5341.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 5351.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 5361.207Sriastrad emit($1) 5371.165Smatt next 5381.165Smatt } 5391.165Smatt 5401.207Sriastrad if (!doingcompat || !(iscompatfile || iscompatdir)) { 5411.207Sriastrad emit($1) 5421.165Smatt next 5431.207Sriastrad } 5441.165Smatt 5451.167Smatt if (iscompatfile) { 5461.207Sriastrad if (omitcompat) { 5471.207Sriastrad emit($1) 5481.207Sriastrad } else if (takecompat[$1]) { 5491.207Sriastrad emitcompat[$1] = 1 5501.207Sriastrad } else { 5511.207Sriastrad emit($1) 5521.207Sriastrad emitcompat[$1] = 1 5531.207Sriastrad } 5541.168Smatt next 5551.168Smatt } 5561.207Sriastrad if (iscompatdir) { 5571.207Sriastrad if (omitcompat) { 5581.207Sriastrad # /lib in base 5591.207Sriastrad emit($1) 5601.207Sriastrad } else if (takecompat[$1]) { 5611.207Sriastrad # /lib in base32 5621.207Sriastrad # nothing to do 5631.207Sriastrad } else { 5641.207Sriastrad # /usr/include in comp 5651.207Sriastrad emit($1) 5661.207Sriastrad } 5671.207Sriastrad } else { 5681.207Sriastrad emit($1) 5691.207Sriastrad } 5701.207Sriastrad if (omitcompat) 5711.207Sriastrad next 5721.165Smatt for (d in compatarchdirs) { 5731.207Sriastrad if (takecompat[$1] && 5741.207Sriastrad !takecompatarch[compatarchdirs[d], $1]) 5751.207Sriastrad continue 5761.165Smatt tmp = $0 5771.165Smatt xfile = $1 "/" compatarchdirs[d] 5781.165Smatt tmp = xfile substr(tmp, length($1) + 1) 5791.165Smatt if (xfile in notwanted) 5801.165Smatt continue; 5811.165Smatt sub("compatdir","compat",tmp); 5821.165Smatt sub("compattestdir","compat",tmp); 5831.165Smatt list[xfile] = tmp 5841.207Sriastrad emit(xfile) 5851.165Smatt } 5861.9Slukem next 5871.9Slukem } 5881.9Slukem 5891.9Slukem { 5901.165Smatt if ($1 in notwanted) 5911.127Smatt next; 5921.207Sriastrad if (! obsolete) { 5931.127Smatt list[$1] = $0 5941.207Sriastrad emit($1) 5951.207Sriastrad } 5961.127Smatt } 5971.127Smatt 5981.127Smatt END { 5991.127Smatt for (i in list) { 6001.207Sriastrad if (i in emitf) 6011.207Sriastrad print list[i] 6021.165Smatt if (! (i in emitcompat)) 6031.165Smatt continue; 6041.165Smatt l_i = length(i) 6051.165Smatt l = 0 6061.165Smatt for (j in cpaths) { 6071.165Smatt lx = length(cpaths[j]) 6081.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 6091.165Smatt continue; 6101.165Smatt } 6111.165Smatt if (lx > l) { 6121.165Smatt l = lx; 6131.165Smatt cpath = cpaths[j]; 6141.165Smatt } 6151.165Smatt } 6161.165Smatt for (d in compatarchdirs) { 6171.207Sriastrad if (takecompat[$1] && 6181.207Sriastrad !takecompatarch[compatarchdirs[d], 6191.207Sriastrad i]) { 6201.207Sriastrad continue 6211.207Sriastrad } 6221.165Smatt tmp = list[i] 6231.165Smatt extrapath = compatarchdirs[d] "/" 6241.165Smatt xfile = cpath extrapath substr(i, l + 1) 6251.165Smatt if (xfile in notwanted) 6261.165Smatt continue; 6271.165Smatt sub("compatfile","compat",tmp); 6281.165Smatt sub("compattestfile","compat",tmp); 6291.165Smatt tmp = xfile substr(tmp, l_i + 1) 6301.165Smatt print tmp; 6311.165Smatt } 6321.127Smatt } 6331.9Slukem }' 6341.9Slukem 6351.1Sdyoung} 6361.1Sdyoung 6371.1Sdyoung# 6381.1Sdyoung# list_set_lists setname 6391.203Srillig# 6401.1Sdyoung# Print to stdout a list of files, one filename per line, which 6411.1Sdyoung# concatenate to create the packing list for setname. E.g., 6421.1Sdyoung# 6431.1Sdyoung# .../lists/base/mi 6441.1Sdyoung# .../lists/base/rescue.mi 6451.1Sdyoung# .../lists/base/md.i386 6461.9Slukem# [...] 6471.1Sdyoung# 6481.9Slukem# For a given setname $set, the following files may be selected from 6491.9Slukem# .../list/$set: 6501.9Slukem# mi 6511.92Suebayasi# mi.ext.* 6521.11Slukem# ad.${MACHINE_ARCH} 6531.11Slukem# (or) ad.${MACHINE_CPU} 6541.11Slukem# ad.${MACHINE_CPU}.shl 6551.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 6561.11Slukem# (or) md.${MACHINE} 6571.9Slukem# stl.mi 6581.92Suebayasi# stl.${stlib} 6591.9Slukem# shl.mi 6601.92Suebayasi# shl.mi.ext.* 6611.92Suebayasi# shl.${shlib} 6621.92Suebayasi# shl.${shlib}.ext.* 6631.77Stsutsui# module.mi if ${module} != no 6641.77Stsutsui# module.${MACHINE} if ${module} != no 6651.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 6661.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 6671.9Slukem# rescue.shl 6681.11Slukem# rescue.${MACHINE} 6691.11Slukem# rescue.ad.${MACHINE_ARCH} 6701.11Slukem# (or) rescue.ad.${MACHINE_CPU} 6711.11Slukem# rescue.ad.${MACHINE_CPU}.shl 6721.1Sdyoung# 6731.9Slukem# Environment: 6741.1Sdyoung# shlib 6751.1Sdyoung# stlib 6761.1Sdyoung# 6771.8Slukemlist_set_lists() 6781.8Slukem{ 6791.1Sdyoung setname=$1 6801.1Sdyoung 6811.111Suebayasi list_set_lists_mi $setname 6821.113Suebayasi list_set_lists_ad $setname 6831.111Suebayasi list_set_lists_md $setname 6841.111Suebayasi list_set_lists_stl $setname 6851.113Suebayasi list_set_lists_shl $setname 6861.113Suebayasi list_set_lists_module $setname 6871.111Suebayasi list_set_lists_rescue $setname 6881.117Suebayasi return 0 6891.111Suebayasi} 6901.110Suebayasi 6911.111Suebayasilist_set_lists_mi() 6921.111Suebayasi{ 6931.111Suebayasi setdir=$setsdir/lists/$1 6941.113Suebayasi # always exist! 6951.9Slukem echo $setdir/mi 6961.111Suebayasi} 6971.110Suebayasi 6981.111Suebayasilist_set_lists_ad() 6991.111Suebayasi{ 7001.111Suebayasi setdir=$setsdir/lists/$1 7011.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7021.113Suebayasi list_set_lists_common_ad $1 7031.111Suebayasi} 7041.110Suebayasi 7051.111Suebayasilist_set_lists_md() 7061.111Suebayasi{ 7071.111Suebayasi setdir=$setsdir/lists/$1 7081.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 7091.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 7101.111Suebayasi} 7111.110Suebayasi 7121.111Suebayasilist_set_lists_stl() 7131.111Suebayasi{ 7141.111Suebayasi setdir=$setsdir/lists/$1 7151.110Suebayasi echo_if_exist $setdir/stl.mi 7161.110Suebayasi echo_if_exist $setdir/stl.${stlib} 7171.111Suebayasi} 7181.110Suebayasi 7191.111Suebayasilist_set_lists_shl() 7201.111Suebayasi{ 7211.111Suebayasi setdir=$setsdir/lists/$1 7221.113Suebayasi [ "$shlib" != "no" ] || return 7231.112Suebayasi echo_if_exist $setdir/shl.mi 7241.112Suebayasi echo_if_exist $setdir/shl.${shlib} 7251.111Suebayasi} 7261.110Suebayasi 7271.111Suebayasilist_set_lists_module() 7281.111Suebayasi{ 7291.111Suebayasi setdir=$setsdir/lists/$1 7301.113Suebayasi [ "$module" != "no" ] || return 7311.112Suebayasi echo_if_exist $setdir/module.mi 7321.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 7331.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 7341.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 7351.113Suebayasi # XXX module never has .shl 7361.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7371.113Suebayasi list_set_lists_common_ad $1 module 7381.111Suebayasi} 7391.1Sdyoung 7401.111Suebayasilist_set_lists_rescue() 7411.111Suebayasi{ 7421.111Suebayasi setdir=$setsdir/lists/$1 7431.110Suebayasi echo_if_exist $setdir/rescue.mi 7441.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 7451.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7461.113Suebayasi list_set_lists_common_ad $1 rescue 7471.111Suebayasi} 7481.111Suebayasi 7491.113Suebayasilist_set_lists_common_ad() 7501.111Suebayasi{ 7511.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 7521.113Suebayasi 7531.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 7541.113Suebayasi 7551.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 7561.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 7571.112Suebayasi # specific one will be more specific than the 7581.112Suebayasi # cpu-specific one. 7591.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 7601.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 7611.113Suebayasi [ "$shlib" != "no" ] && \ 7621.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 7631.5Sdyoung} 7641.5Sdyoung 7651.110Suebayasiecho_if_exist() 7661.110Suebayasi{ 7671.110Suebayasi [ -f $1 ] && echo $1 7681.110Suebayasi return $? 7691.110Suebayasi} 7701.110Suebayasi 7711.110Suebayasiecho_if_exist_foreach() 7721.110Suebayasi{ 7731.110Suebayasi local _list=$1; shift 7741.110Suebayasi for _suffix in $@; do 7751.110Suebayasi echo_if_exist ${_list}.${_suffix} 7761.110Suebayasi done 7771.110Suebayasi} 7781.110Suebayasi 7791.116Suebayasiprint_set_lists() 7801.116Suebayasi{ 7811.116Suebayasi for setname; do 7821.136Schristos list=$(list_set_lists $setname) 7831.116Suebayasi for l in $list; do 7841.116Suebayasi echo $l 7851.116Suebayasi if $verbose; then 7861.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 7871.116Suebayasi fi 7881.207Sriastrad done \ 7891.207Sriastrad | ${XARGS} ${SED} ${SUBST} \ 7901.207Sriastrad | case $setname in 7911.207Sriastrad base|debug) 7921.207Sriastrad awk ' 7931.207Sriastrad !/^#/ && !/^$/ { 7941.207Sriastrad print $1, $2, \ 7951.207Sriastrad ($3 ? $3"," : "")"omitcompat" 7961.207Sriastrad } 7971.207Sriastrad ' 7981.207Sriastrad ;; 7991.207Sriastrad *) cat 8001.207Sriastrad ;; 8011.207Sriastrad esac 8021.207Sriastrad 8031.207Sriastrad case $setname in 8041.207Sriastrad base32|base64) 8051.207Sriastrad ursetname=base 8061.207Sriastrad ;; 8071.207Sriastrad debug32|debug64) 8081.207Sriastrad ursetname=debug 8091.207Sriastrad ;; 8101.207Sriastrad *) continue 8111.207Sriastrad ;; 8121.207Sriastrad esac 8131.207Sriastrad case $setname in 8141.207Sriastrad *32) compatarches=$compat32arches 8151.207Sriastrad ;; 8161.207Sriastrad *64) compatarches=$compat64arches 8171.207Sriastrad ;; 8181.207Sriastrad esac 8191.207Sriastrad list=$(list_set_lists $ursetname) 8201.207Sriastrad for l in $list; do 8211.207Sriastrad echo $l 8221.207Sriastrad if $verbose; then 8231.207Sriastrad echo >&2 "DEBUG: list_set_files: $l" 8241.207Sriastrad fi 8251.207Sriastrad done \ 8261.207Sriastrad | ${XARGS} ${SED} ${SUBST} \ 8271.207Sriastrad | awk -v compatarches="$compatarches" ' 8281.207Sriastrad BEGIN { 8291.207Sriastrad split(compatarches, compatarch, " ") 8301.207Sriastrad flags = "" 8311.207Sriastrad for (i in compatarch) 8321.207Sriastrad flags = (flags ? flags"," : "") \ 8331.207Sriastrad "takecompat="compatarch[i] 8341.207Sriastrad } 8351.207Sriastrad !/^#/ && !/^$/ { 8361.207Sriastrad print $1, $2, ($3 ? $3"," : "")flags 8371.207Sriastrad } 8381.207Sriastrad ' 8391.207Sriastrad done 8401.116Suebayasi} 8411.116Suebayasi 8421.198Schristos 8431.198Schristoslist_kernel_configs() 8441.198Schristos{ 8451.198Schristos (cd ${NETBSDSRCDIR}/etc 8461.198Schristos MAKEFLAGS= \ 8471.198Schristos ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 8481.198Schristos} 8491.198Schristos 8501.9Slukem# arch_to_cpu mach 8511.9Slukem# 8521.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 8531.9Slukem# as determined by <bsd.own.mk>. 8541.9Slukem# 8551.8Slukemarch_to_cpu() 8561.8Slukem{ 8571.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 8581.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 8591.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 8601.182Suwe -V '${MACHINE_CPU}' 8611.1Sdyoung} 8621.46Sapb 8631.46Sapb# arch_to_endian mach 8641.46Sapb# 8651.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 8661.46Sapb# as determined by <bsd.endian.mk>. 8671.46Sapb# 8681.46Sapbarch_to_endian() 8691.46Sapb{ 8701.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 8711.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 8721.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 8731.182Suwe -V '${TARGET_ENDIANNESS}' 8741.46Sapb} 8751.117Suebayasi 8761.117Suebayasi##### 8771.117Suebayasi 8781.117Suebayasi# print_mkvars 8791.117Suebayasiprint_mkvars() 8801.117Suebayasi{ 8811.117Suebayasi for v in $MKVARS; do 8821.117Suebayasi eval echo $v=\$$v 8831.117Suebayasi done 8841.117Suebayasi} 8851.117Suebayasi 8861.117Suebayasi# print_set_lists_{base,x,ext} 8871.117Suebayasi# list_set_lists_{base,x,ext} 8881.117Suebayasi# list_set_files_{base,x,ext} 8891.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 8901.117Suebayasi for x in base x ext; do 8911.117Suebayasi if [ $x = base ]; then 8921.117Suebayasi list=nlists 8931.117Suebayasi else 8941.117Suebayasi list=${x}lists 8951.117Suebayasi fi 8961.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 8971.117Suebayasi done 8981.117Suebayasidone 899