sets.subr revision 1.212
11.212Sdholland# $NetBSD: sets.subr,v 1.212 2025/07/21 01:46:05 dholland 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.210Smartin# HAVE_EFI_RT 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.212Sdhollandfor x in $( MAKEFLAGS= MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do 1281.108Suebayasi eval export $x 1291.9Slukemdone 1301.100Suebayasi 1311.9SlukemIFS=$oIFS 1321.9Slukem 1331.212SdhollandMKVARS="$( MAKEFLAGS= 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.205Sniaif [ -z "${debugset}" -o "${MKCOMPAT}" = "no" ]; then 1591.205Snia debug32set="" 1601.205Sniaelse 1611.205Snia debug32set="debug32" 1621.205Sniafi 1631.206Sniaif [ -z "${debug32set}" ]; then 1641.206Snia debug64set="" 1651.206Sniaelse 1661.206Snia if [ "${MACHINE_ARCH}" = "mips64eb" -o "${MACHINE_ARCH}" = "mips64el" ]; then 1671.206Snia debug64set="debug64" 1681.206Snia else 1691.206Snia debug64set="" 1701.206Snia fi 1711.206Sniafi 1721.191Sjmcneillif [ "${MKDTB}" = "no" ]; then 1731.191Sjmcneill dtbset="" 1741.191Sjmcneillelse 1751.191Sjmcneill dtbset="dtb" 1761.191Sjmcneillfi 1771.205Sniaif [ "${MKHTML}" = "no" ]; then 1781.205Snia manhtmlset="" 1791.205Sniaelse 1801.205Snia manhtmlset="manhtml" 1811.205Sniafi 1821.205Sniaif [ "${MKCOMPAT}" = "no" ]; then 1831.205Snia base32set="" 1841.205Sniaelse 1851.205Snia base32set="base32" 1861.205Sniafi 1871.206Sniaif [ "${MKCOMPAT}" != "no" ]; then 1881.206Snia if [ "${MACHINE_ARCH}" = "mips64eb" -o "${MACHINE_ARCH}" = "mips64el" ]; then 1891.206Snia base64set="base64" 1901.206Snia else 1911.206Snia base64set="" 1921.206Snia fi 1931.206Sniaelse 1941.206Snia base64set="" 1951.206Sniafi 1961.206Snia 1971.207Sriastrad# XXX This should not be encoded here -- this mostly duplicates 1981.207Sriastrad# information in compat/archdirs.mk, except that it also identifies 1991.207Sriastrad# which compat architectures are `32-bit' and which ones are `64-bit'. 2001.207Sriastradcase $MACHINE_ARCH in 2011.207Sriastradaarch64) 2021.207Sriastrad compat32arches='eabi eabihf' 2031.207Sriastrad ;; 2041.207Sriastradaarch64eb) 2051.207Sriastrad compat32arches=eabi 2061.207Sriastrad ;; 2071.207Sriastradmips64eb|mips64el) 2081.207Sriastrad compat32arches=o32 2091.207Sriastrad compat64arches=64 2101.207Sriastrad ;; 2111.207Sriastradmipsn64eb|mipsn64el) 2121.207Sriastrad compat32arches='n32 o32' 2131.207Sriastrad ;; 2141.207Sriastradpowerpc64) 2151.207Sriastrad compat32arches=powerpc 2161.207Sriastrad ;; 2171.207Sriastradriscv64) 2181.208Sriastrad compat32arches=rv32 2191.207Sriastrad ;; 2201.207Sriastradsparc64) 2211.207Sriastrad compat32arches=sparc 2221.207Sriastrad ;; 2231.207Sriastradx86_64) compat32arches=i386 2241.207Sriastrad ;; 2251.207Sriastradesac 2261.209Sriastrad: ${compat32arches:=} 2271.207Sriastrad: ${compat64arches:=} 2281.207Sriastrad 2291.205Snia 2301.31Sjmc# Determine lib type. Do this first so stlib also gets set. 2311.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 2321.9Slukem shlib=elf 2331.9Slukemelse 2341.9Slukem shlib=aout 2351.9Slukemfi 2361.9Slukemstlib=$shlib 2371.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 2381.31Sjmcif [ "${MKPIC}" = "no" ]; then 2391.31Sjmc shlib=no 2401.31Sjmcfi 2411.206Snianlists="base $base32set $base64set comp $debugset $debug32set $debug64set $dtbset etc games gpufw man $manhtmlset misc $modset rescue $testset text" 2421.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 2431.9Slukem 2441.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 2451.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 2461.188Schristos MODULEDIR="netbsd/modules" 2471.188Schristoselse 2481.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 2491.188Schristosfi 2501.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 2511.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 2521.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 2531.60Sad 2541.9Slukem# 2551.9Slukem# list_set_files setfile [...] 2561.203Srillig# 2571.9Slukem# Produce a packing list for setfile(s). 2581.9Slukem# In each file, a record consists of a path and a System Package name, 2591.9Slukem# separated by whitespace. E.g., 2601.9Slukem# 2611.212Sdholland# # $NetBSD: sets.subr,v 1.212 2025/07/21 01:46:05 dholland Exp $ 2621.9Slukem# . base-sys-root [keyword[,...]] 2631.9Slukem# ./altroot base-sys-root 2641.9Slukem# ./bin base-sys-root 2651.9Slukem# ./bin/[ base-util-root 2661.9Slukem# ./bin/cat base-util-root 2671.9Slukem# [...] 2681.9Slukem# 2691.9Slukem# A # in the first column marks a comment. 2701.9Slukem# 2711.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2721.52Slukem# be printed. All other keywords must be present. 2731.9Slukem# 2741.9Slukem# The third field is an optional comma separated list of keywords to 2751.9Slukem# control if a record is printed; every keyword listed must be enabled 2761.204Srillig# for the record to be printed. The list of all available make variables 2771.179Schristos# that can be turned on or off can be found by running in this directory: 2781.179Schristos# 2791.179Schristos# make -f mkvars.mk mkvarsyesno 2801.179Schristos# 2811.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2821.203Srillig# 2831.179Schristos# The following extra keywords are also available, listed by: 2841.179Schristos# 2851.179Schristos# make -f mkvars.mk mkextravars 2861.13Slukem# 2871.179Schristos# These are: 2881.179Schristos# 1. The HAVE_<name>: 2891.179Schristos# ssp ${HAVE_SSP} != no 2901.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2911.192Sjmcneill# acpi ${HAVE_ACPI} != no 2921.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2931.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2941.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2951.192Sjmcneill# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2961.193Sjmcneill# nvmm ${HAVE_NVMM} != no 2971.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2981.192Sjmcneill# uefi ${HAVE_UEFI} != no 2991.210Smartin# efi_rt ${HAVE_EFI_RT} != no 3001.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 3011.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 3021.211Snia# xorg_egl ${HAVE_XORG_EGL} != no 3031.52Slukem# 3041.179Schristos# 2. The USE_<name>: 3051.41Slukem# use_inet6 ${USE_INET6} != no 3061.41Slukem# use_kerberos ${USE_KERBEROS} != no 3071.179Schristos# use_ldap ${USE_LDAP} != no 3081.41Slukem# use_yp ${USE_YP} != no 3091.41Slukem# 3101.179Schristos# 3. Finally: 3111.179Schristos# dummy dummy entry (ignored) 3121.203Srillig# obsolete file is obsolete, and only printed if 3131.179Schristos# ${obsolete} != 0 3141.179Schristos# 3151.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 3161.179Schristos# 3171.179Schristos# 3181.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 3191.179Schristos# 3201.179Schristos# 3211.195Skamil# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 3221.195Skamil# automatically append ".gz" to the filename 3231.195Skamil# 3241.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 3251.22Slukem# automatically append ".gz" to the filename 3261.1Sdyoung# 3271.8Slukemlist_set_files() 3281.8Slukem{ 3291.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 3301.65She verbose=false 3311.65She else 3321.65She verbose=true 3331.65She fi 3341.198Schristos local CONFIGS="$( list_kernel_configs )" 3351.116Suebayasi print_set_lists "$@" | \ 3361.43Sapb ${AWK} -v obsolete=${obsolete} ' 3371.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 3381.190Schristos if (substr(line, 1, patlen) != pat) { 3391.198Schristos return 3401.190Schristos } 3411.190Schristos for (d in kmodarchdirs) { 3421.190Schristos xd = prefix kmodarchdirs[d] 3431.198Schristos xline = xd substr(line, patlen + 1) 3441.198Schristos xfname = xd substr(fname, patlen + 1) 3451.198Schristos list[xline] = xfname 3461.207Sriastrad emit(xline) 3471.190Schristos } 3481.190Schristos } 3491.198Schristos function adddebugkernel(line, fname, pat, patlen) { 3501.199Schristos if (pat == "" || substr(line, 1, patlen) != pat) { 3511.198Schristos return 0 3521.198Schristos } 3531.198Schristos split("'"${CONFIGS}"'", configs) 3541.198Schristos for (d in configs) { 3551.198Schristos xfname = fname 3561.200Schristos sub("@CONFIG@", configs[d], xfname) 3571.198Schristos xline = line; 3581.200Schristos sub("@CONFIG@", configs[d], xline) 3591.198Schristos list[xline] = xfname 3601.207Sriastrad emit(xline) 3611.198Schristos } 3621.198Schristos return 1 3631.198Schristos } 3641.207Sriastrad function emit(fname) { 3651.207Sriastrad emitf[fname] = 1 3661.207Sriastrad } 3671.9Slukem BEGIN { 3681.52Slukem if (obsolete) 3691.52Slukem wanted["obsolete"] = 1 3701.203Srillig 3711.207Sriastrad ncpaths = 0 3721.100Suebayasi split("'"${MKVARS}"'", needvars) 3731.165Smatt doingcompat = 0 3741.165Smatt doingcompattests = 0 3751.165Smatt ignoredkeywords["compatdir"] = 1 3761.165Smatt ignoredkeywords["compatfile"] = 1 3771.165Smatt ignoredkeywords["compattestdir"] = 1 3781.165Smatt ignoredkeywords["compattestfile"] = 1 3791.170Smatt ignoredkeywords["compatx11dir"] = 1 3801.170Smatt ignoredkeywords["compatx11file"] = 1 3811.52Slukem for (vi in needvars) { 3821.52Slukem nv = needvars[vi] 3831.52Slukem kw = tolower(nv) 3841.52Slukem sub(/^mk/, "", kw) 3851.143Snakayama sub(/^have_/, "", kw) 3861.148Smatt sub(/^target_endianness/, "endian", kw) 3871.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 3881.203Srillig wanted[kw] = 1 3891.167Smatt } 3901.166Smatt } 3911.166Smatt 3921.167Smatt if ("compat" in wanted) { 3931.166Smatt doingcompat = 1; 3941.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3951.166Smatt compatdirkeywords["compatdir"] = 1 3961.166Smatt compatfilekeywords["compatfile"] = 1 3971.166Smatt 3981.166Smatt if (wanted["compattests"]) { 3991.165Smatt doingcompattests = 1; 4001.165Smatt compatdirkeywords["compattestdir"] = 1 4011.165Smatt compatfilekeywords["compattestfile"] = 1 4021.166Smatt } 4031.170Smatt if (wanted["compatx11"]) { 4041.170Smatt doingcompatx11 = 1; 4051.170Smatt compatdirkeywords["compatx11dir"] = 1 4061.170Smatt compatfilekeywords["compatx11file"] = 1 4071.170Smatt } 4081.166Smatt } 4091.166Smatt 4101.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 4111.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 4121.190Schristos kmodprefix = "./stand/" 4131.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 4141.166Smatt l_kmodpat = length(kmodpat) 4151.203Srillig kmoddbprefix = "./usr/libdata/debug/stand/" 4161.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 4171.190Schristos l_kmoddbpat = length(kmoddbpat) 4181.52Slukem } 4191.198Schristos if ("debug" in wanted) { 4201.201Schristos debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 4211.198Schristos l_debugkernelname = length(debugkernelname); 4221.198Schristos } 4231.52Slukem 4241.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 4251.90Sdyoung if ("binutils" in wanted) 4261.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 4271.90Sdyoung if ("gcc" in wanted) 4281.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 4291.90Sdyoung if ("gdb" in wanted) 4301.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 4311.9Slukem } 4321.192Sjmcneill if ("acpi" in wanted) { 4331.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 4341.192Sjmcneill } 4351.192Sjmcneill if ("mesa_ver" in wanted) { 4361.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 4371.192Sjmcneill } 4381.193Sjmcneill if ("nvmm" in wanted) { 4391.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 4401.193Sjmcneill } 4411.183Schristos if ("openssl" in wanted) { 4421.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 4431.183Schristos } 4441.178Smrg if ("xorg_server_ver" in wanted) { 4451.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 4461.177Smrg } 4471.192Sjmcneill if ("uefi" in wanted) { 4481.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 4491.185Smrg } 4501.210Smartin if ("efi_rt" in wanted) { 4511.210Smartin wanted["efi_rt=" "'"${HAVE_EFI_RT}"'"] = 1 4521.210Smartin } 4531.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 4541.195Skamil wanted[".cat"] = 1 4551.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 4561.52Slukem wanted[".man"] = 1 4571.148Smatt if ("endian" in wanted) 4581.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 4591.162Smrg if ("machine" in wanted) 4601.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 4611.162Smrg if ("machine_arch" in wanted) 4621.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 4631.162Smrg if ("machine_cpu" in wanted) 4641.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 4651.9Slukem } 4661.9Slukem 4671.9Slukem /^#/ { 4681.9Slukem next; 4691.9Slukem } 4701.9Slukem 4711.127Smatt /^-/ { 4721.127Smatt notwanted[substr($1, 2)] = 1; 4731.127Smatt delete list [substr($1, 2)]; 4741.127Smatt next; 4751.127Smatt } 4761.203Srillig 4771.9Slukem NF > 2 && $3 != "-" { 4781.127Smatt if (notwanted[$1] != "") 4791.127Smatt next; 4801.9Slukem split($3, keywords, ",") 4811.9Slukem show = 1 4821.52Slukem haveobs = 0 4831.167Smatt iscompatfile = 0 4841.165Smatt havekmod = 0 4851.165Smatt iscompatdir = 0 4861.207Sriastrad omitcompat = 0 4871.207Sriastrad takecompat[$1] = 0 4881.9Slukem for (ki in keywords) { 4891.9Slukem kw = keywords[ki] 4901.22Slukem if (("manz" in wanted) && 4911.22Slukem (kw == ".cat" || kw == ".man")) 4921.22Slukem $1 = $1 ".gz" 4931.134Sjoerg if (substr(kw, 1, 1) == "!") { 4941.134Sjoerg kw = substr(kw, 2) 4951.59Sjmmv if (kw in wanted) 4961.59Sjmmv show = 0 4971.165Smatt } else if (kw in compatdirkeywords) { 4981.165Smatt iscompatdir = 1 4991.165Smatt } else if (kw in compatfilekeywords) { 5001.167Smatt iscompatfile = 1 5011.172Smatt } else if (kw == "nocompatmodules") { 5021.172Smatt havekmod = -1 5031.207Sriastrad } else if (kw == "omitcompat") { 5041.207Sriastrad omitcompat = 1 5051.207Sriastrad } else if (kw ~ /^takecompat=/) { 5061.207Sriastrad takecompat[$1] = 1 5071.207Sriastrad takecompatarch[substr(kw, 5081.207Sriastrad 1 + length("takecompat=")), $1] = 1 5091.165Smatt } else if (kw in ignoredkeywords) { 5101.165Smatt # ignore 5111.167Smatt } else if (! (kw in wanted)) { 5121.167Smatt show = 0 5131.172Smatt } else if (kw == "kmod" && havekmod == 0) { 5141.167Smatt havekmod = 1 5151.59Sjmmv } 5161.52Slukem if (kw == "obsolete") 5171.52Slukem haveobs = 1 5181.9Slukem } 5191.207Sriastrad 5201.207Sriastrad if (takecompat[$1] && !(iscompatdir || iscompatfile)) { 5211.207Sriastrad next 5221.207Sriastrad } 5231.207Sriastrad if (iscompatdir && !omitcompat) { 5241.184Snakayama for (d in cpaths) { 5251.207Sriastrad if (cpaths[d] == $1 "/") { 5261.207Sriastrad break 5271.207Sriastrad } 5281.184Snakayama } 5291.184Snakayama cpaths[ncpaths++] = $1 "/" 5301.184Snakayama } 5311.52Slukem if (obsolete && ! haveobs) 5321.52Slukem next 5331.165Smatt if (!show) 5341.165Smatt next 5351.198Schristos if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 5361.198Schristos next 5371.165Smatt 5381.165Smatt list[$1] = $0 5391.190Schristos if (havekmod > 0) { 5401.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 5411.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 5421.207Sriastrad emit($1) 5431.165Smatt next 5441.165Smatt } 5451.165Smatt 5461.207Sriastrad if (!doingcompat || !(iscompatfile || iscompatdir)) { 5471.207Sriastrad emit($1) 5481.165Smatt next 5491.207Sriastrad } 5501.165Smatt 5511.167Smatt if (iscompatfile) { 5521.207Sriastrad if (omitcompat) { 5531.207Sriastrad emit($1) 5541.207Sriastrad } else if (takecompat[$1]) { 5551.207Sriastrad emitcompat[$1] = 1 5561.207Sriastrad } else { 5571.207Sriastrad emit($1) 5581.207Sriastrad emitcompat[$1] = 1 5591.207Sriastrad } 5601.168Smatt next 5611.168Smatt } 5621.207Sriastrad if (iscompatdir) { 5631.207Sriastrad if (omitcompat) { 5641.207Sriastrad # /lib in base 5651.207Sriastrad emit($1) 5661.207Sriastrad } else if (takecompat[$1]) { 5671.207Sriastrad # /lib in base32 5681.207Sriastrad # nothing to do 5691.207Sriastrad } else { 5701.207Sriastrad # /usr/include in comp 5711.207Sriastrad emit($1) 5721.207Sriastrad } 5731.207Sriastrad } else { 5741.207Sriastrad emit($1) 5751.207Sriastrad } 5761.207Sriastrad if (omitcompat) 5771.207Sriastrad next 5781.165Smatt for (d in compatarchdirs) { 5791.207Sriastrad if (takecompat[$1] && 5801.207Sriastrad !takecompatarch[compatarchdirs[d], $1]) 5811.207Sriastrad continue 5821.165Smatt tmp = $0 5831.165Smatt xfile = $1 "/" compatarchdirs[d] 5841.165Smatt tmp = xfile substr(tmp, length($1) + 1) 5851.165Smatt if (xfile in notwanted) 5861.165Smatt continue; 5871.165Smatt sub("compatdir","compat",tmp); 5881.165Smatt sub("compattestdir","compat",tmp); 5891.165Smatt list[xfile] = tmp 5901.207Sriastrad emit(xfile) 5911.165Smatt } 5921.9Slukem next 5931.9Slukem } 5941.9Slukem 5951.9Slukem { 5961.165Smatt if ($1 in notwanted) 5971.127Smatt next; 5981.207Sriastrad if (! obsolete) { 5991.127Smatt list[$1] = $0 6001.207Sriastrad emit($1) 6011.207Sriastrad } 6021.127Smatt } 6031.127Smatt 6041.127Smatt END { 6051.127Smatt for (i in list) { 6061.207Sriastrad if (i in emitf) 6071.207Sriastrad print list[i] 6081.165Smatt if (! (i in emitcompat)) 6091.165Smatt continue; 6101.165Smatt l_i = length(i) 6111.165Smatt l = 0 6121.165Smatt for (j in cpaths) { 6131.165Smatt lx = length(cpaths[j]) 6141.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 6151.165Smatt continue; 6161.165Smatt } 6171.165Smatt if (lx > l) { 6181.165Smatt l = lx; 6191.165Smatt cpath = cpaths[j]; 6201.165Smatt } 6211.165Smatt } 6221.165Smatt for (d in compatarchdirs) { 6231.207Sriastrad if (takecompat[$1] && 6241.207Sriastrad !takecompatarch[compatarchdirs[d], 6251.207Sriastrad i]) { 6261.207Sriastrad continue 6271.207Sriastrad } 6281.165Smatt tmp = list[i] 6291.165Smatt extrapath = compatarchdirs[d] "/" 6301.165Smatt xfile = cpath extrapath substr(i, l + 1) 6311.165Smatt if (xfile in notwanted) 6321.165Smatt continue; 6331.165Smatt sub("compatfile","compat",tmp); 6341.165Smatt sub("compattestfile","compat",tmp); 6351.165Smatt tmp = xfile substr(tmp, l_i + 1) 6361.165Smatt print tmp; 6371.165Smatt } 6381.127Smatt } 6391.9Slukem }' 6401.9Slukem 6411.1Sdyoung} 6421.1Sdyoung 6431.1Sdyoung# 6441.1Sdyoung# list_set_lists setname 6451.203Srillig# 6461.1Sdyoung# Print to stdout a list of files, one filename per line, which 6471.1Sdyoung# concatenate to create the packing list for setname. E.g., 6481.1Sdyoung# 6491.1Sdyoung# .../lists/base/mi 6501.1Sdyoung# .../lists/base/rescue.mi 6511.1Sdyoung# .../lists/base/md.i386 6521.9Slukem# [...] 6531.1Sdyoung# 6541.9Slukem# For a given setname $set, the following files may be selected from 6551.9Slukem# .../list/$set: 6561.9Slukem# mi 6571.92Suebayasi# mi.ext.* 6581.11Slukem# ad.${MACHINE_ARCH} 6591.11Slukem# (or) ad.${MACHINE_CPU} 6601.11Slukem# ad.${MACHINE_CPU}.shl 6611.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 6621.11Slukem# (or) md.${MACHINE} 6631.9Slukem# stl.mi 6641.92Suebayasi# stl.${stlib} 6651.9Slukem# shl.mi 6661.92Suebayasi# shl.mi.ext.* 6671.92Suebayasi# shl.${shlib} 6681.92Suebayasi# shl.${shlib}.ext.* 6691.77Stsutsui# module.mi if ${module} != no 6701.77Stsutsui# module.${MACHINE} if ${module} != no 6711.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 6721.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 6731.9Slukem# rescue.shl 6741.11Slukem# rescue.${MACHINE} 6751.11Slukem# rescue.ad.${MACHINE_ARCH} 6761.11Slukem# (or) rescue.ad.${MACHINE_CPU} 6771.11Slukem# rescue.ad.${MACHINE_CPU}.shl 6781.1Sdyoung# 6791.9Slukem# Environment: 6801.1Sdyoung# shlib 6811.1Sdyoung# stlib 6821.1Sdyoung# 6831.8Slukemlist_set_lists() 6841.8Slukem{ 6851.1Sdyoung setname=$1 6861.1Sdyoung 6871.111Suebayasi list_set_lists_mi $setname 6881.113Suebayasi list_set_lists_ad $setname 6891.111Suebayasi list_set_lists_md $setname 6901.111Suebayasi list_set_lists_stl $setname 6911.113Suebayasi list_set_lists_shl $setname 6921.113Suebayasi list_set_lists_module $setname 6931.111Suebayasi list_set_lists_rescue $setname 6941.117Suebayasi return 0 6951.111Suebayasi} 6961.110Suebayasi 6971.111Suebayasilist_set_lists_mi() 6981.111Suebayasi{ 6991.111Suebayasi setdir=$setsdir/lists/$1 7001.113Suebayasi # always exist! 7011.9Slukem echo $setdir/mi 7021.111Suebayasi} 7031.110Suebayasi 7041.111Suebayasilist_set_lists_ad() 7051.111Suebayasi{ 7061.111Suebayasi setdir=$setsdir/lists/$1 7071.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7081.113Suebayasi list_set_lists_common_ad $1 7091.111Suebayasi} 7101.110Suebayasi 7111.111Suebayasilist_set_lists_md() 7121.111Suebayasi{ 7131.111Suebayasi setdir=$setsdir/lists/$1 7141.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 7151.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 7161.111Suebayasi} 7171.110Suebayasi 7181.111Suebayasilist_set_lists_stl() 7191.111Suebayasi{ 7201.111Suebayasi setdir=$setsdir/lists/$1 7211.110Suebayasi echo_if_exist $setdir/stl.mi 7221.110Suebayasi echo_if_exist $setdir/stl.${stlib} 7231.111Suebayasi} 7241.110Suebayasi 7251.111Suebayasilist_set_lists_shl() 7261.111Suebayasi{ 7271.111Suebayasi setdir=$setsdir/lists/$1 7281.113Suebayasi [ "$shlib" != "no" ] || return 7291.112Suebayasi echo_if_exist $setdir/shl.mi 7301.112Suebayasi echo_if_exist $setdir/shl.${shlib} 7311.111Suebayasi} 7321.110Suebayasi 7331.111Suebayasilist_set_lists_module() 7341.111Suebayasi{ 7351.111Suebayasi setdir=$setsdir/lists/$1 7361.113Suebayasi [ "$module" != "no" ] || return 7371.112Suebayasi echo_if_exist $setdir/module.mi 7381.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 7391.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 7401.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 7411.113Suebayasi # XXX module never has .shl 7421.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7431.113Suebayasi list_set_lists_common_ad $1 module 7441.111Suebayasi} 7451.1Sdyoung 7461.111Suebayasilist_set_lists_rescue() 7471.111Suebayasi{ 7481.111Suebayasi setdir=$setsdir/lists/$1 7491.110Suebayasi echo_if_exist $setdir/rescue.mi 7501.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 7511.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7521.113Suebayasi list_set_lists_common_ad $1 rescue 7531.111Suebayasi} 7541.111Suebayasi 7551.113Suebayasilist_set_lists_common_ad() 7561.111Suebayasi{ 7571.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 7581.113Suebayasi 7591.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 7601.113Suebayasi 7611.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 7621.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 7631.112Suebayasi # specific one will be more specific than the 7641.112Suebayasi # cpu-specific one. 7651.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 7661.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 7671.113Suebayasi [ "$shlib" != "no" ] && \ 7681.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 7691.5Sdyoung} 7701.5Sdyoung 7711.110Suebayasiecho_if_exist() 7721.110Suebayasi{ 7731.110Suebayasi [ -f $1 ] && echo $1 7741.110Suebayasi return $? 7751.110Suebayasi} 7761.110Suebayasi 7771.110Suebayasiecho_if_exist_foreach() 7781.110Suebayasi{ 7791.110Suebayasi local _list=$1; shift 7801.110Suebayasi for _suffix in $@; do 7811.110Suebayasi echo_if_exist ${_list}.${_suffix} 7821.110Suebayasi done 7831.110Suebayasi} 7841.110Suebayasi 7851.116Suebayasiprint_set_lists() 7861.116Suebayasi{ 7871.116Suebayasi for setname; do 7881.136Schristos list=$(list_set_lists $setname) 7891.116Suebayasi for l in $list; do 7901.116Suebayasi echo $l 7911.116Suebayasi if $verbose; then 7921.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 7931.116Suebayasi fi 7941.207Sriastrad done \ 7951.207Sriastrad | ${XARGS} ${SED} ${SUBST} \ 7961.207Sriastrad | case $setname in 7971.207Sriastrad base|debug) 7981.207Sriastrad awk ' 7991.207Sriastrad !/^#/ && !/^$/ { 8001.207Sriastrad print $1, $2, \ 8011.207Sriastrad ($3 ? $3"," : "")"omitcompat" 8021.207Sriastrad } 8031.207Sriastrad ' 8041.207Sriastrad ;; 8051.207Sriastrad *) cat 8061.207Sriastrad ;; 8071.207Sriastrad esac 8081.207Sriastrad 8091.207Sriastrad case $setname in 8101.207Sriastrad base32|base64) 8111.207Sriastrad ursetname=base 8121.207Sriastrad ;; 8131.207Sriastrad debug32|debug64) 8141.207Sriastrad ursetname=debug 8151.207Sriastrad ;; 8161.207Sriastrad *) continue 8171.207Sriastrad ;; 8181.207Sriastrad esac 8191.207Sriastrad case $setname in 8201.207Sriastrad *32) compatarches=$compat32arches 8211.207Sriastrad ;; 8221.207Sriastrad *64) compatarches=$compat64arches 8231.207Sriastrad ;; 8241.207Sriastrad esac 8251.207Sriastrad list=$(list_set_lists $ursetname) 8261.207Sriastrad for l in $list; do 8271.207Sriastrad echo $l 8281.207Sriastrad if $verbose; then 8291.207Sriastrad echo >&2 "DEBUG: list_set_files: $l" 8301.207Sriastrad fi 8311.207Sriastrad done \ 8321.207Sriastrad | ${XARGS} ${SED} ${SUBST} \ 8331.207Sriastrad | awk -v compatarches="$compatarches" ' 8341.207Sriastrad BEGIN { 8351.207Sriastrad split(compatarches, compatarch, " ") 8361.207Sriastrad flags = "" 8371.207Sriastrad for (i in compatarch) 8381.207Sriastrad flags = (flags ? flags"," : "") \ 8391.207Sriastrad "takecompat="compatarch[i] 8401.207Sriastrad } 8411.207Sriastrad !/^#/ && !/^$/ { 8421.207Sriastrad print $1, $2, ($3 ? $3"," : "")flags 8431.207Sriastrad } 8441.207Sriastrad ' 8451.207Sriastrad done 8461.116Suebayasi} 8471.116Suebayasi 8481.198Schristos 8491.198Schristoslist_kernel_configs() 8501.198Schristos{ 8511.198Schristos (cd ${NETBSDSRCDIR}/etc 8521.198Schristos MAKEFLAGS= \ 8531.198Schristos ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 8541.198Schristos} 8551.198Schristos 8561.9Slukem# arch_to_cpu mach 8571.9Slukem# 8581.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 8591.9Slukem# as determined by <bsd.own.mk>. 8601.9Slukem# 8611.8Slukemarch_to_cpu() 8621.8Slukem{ 8631.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 8641.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 8651.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 8661.182Suwe -V '${MACHINE_CPU}' 8671.1Sdyoung} 8681.46Sapb 8691.46Sapb# arch_to_endian mach 8701.46Sapb# 8711.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 8721.46Sapb# as determined by <bsd.endian.mk>. 8731.46Sapb# 8741.46Sapbarch_to_endian() 8751.46Sapb{ 8761.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 8771.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 8781.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 8791.182Suwe -V '${TARGET_ENDIANNESS}' 8801.46Sapb} 8811.117Suebayasi 8821.117Suebayasi##### 8831.117Suebayasi 8841.117Suebayasi# print_mkvars 8851.117Suebayasiprint_mkvars() 8861.117Suebayasi{ 8871.117Suebayasi for v in $MKVARS; do 8881.117Suebayasi eval echo $v=\$$v 8891.117Suebayasi done 8901.117Suebayasi} 8911.117Suebayasi 8921.117Suebayasi# print_set_lists_{base,x,ext} 8931.117Suebayasi# list_set_lists_{base,x,ext} 8941.117Suebayasi# list_set_files_{base,x,ext} 8951.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 8961.117Suebayasi for x in base x ext; do 8971.117Suebayasi if [ $x = base ]; then 8981.117Suebayasi list=nlists 8991.117Suebayasi else 9001.117Suebayasi list=${x}lists 9011.117Suebayasi fi 9021.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 9031.117Suebayasi done 9041.117Suebayasidone 905