sets.subr revision 1.208
11.208Sriastrad# $NetBSD: sets.subr,v 1.208 2024/07/11 17:27:04 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.207Sriastrad: ${compat64arches:=} 2261.207Sriastrad 2271.205Snia 2281.31Sjmc# Determine lib type. Do this first so stlib also gets set. 2291.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then 2301.9Slukem shlib=elf 2311.9Slukemelse 2321.9Slukem shlib=aout 2331.9Slukemfi 2341.9Slukemstlib=$shlib 2351.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be. 2361.31Sjmcif [ "${MKPIC}" = "no" ]; then 2371.31Sjmc shlib=no 2381.31Sjmcfi 2391.206Snianlists="base $base32set $base64set comp $debugset $debug32set $debug64set $dtbset etc games gpufw man $manhtmlset misc $modset rescue $testset text" 2401.142Schristosxlists="xbase xcomp $xdebugset xetc xfont xserver" 2411.9Slukem 2421.136SchristosOSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 2431.188Schristosif [ "${KERNEL_DIR}" = "yes" ]; then 2441.188Schristos MODULEDIR="netbsd/modules" 2451.188Schristoselse 2461.188Schristos MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 2471.188Schristosfi 2481.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g" 2491.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 2501.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 2511.60Sad 2521.9Slukem# 2531.9Slukem# list_set_files setfile [...] 2541.203Srillig# 2551.9Slukem# Produce a packing list for setfile(s). 2561.9Slukem# In each file, a record consists of a path and a System Package name, 2571.9Slukem# separated by whitespace. E.g., 2581.9Slukem# 2591.208Sriastrad# # $NetBSD: sets.subr,v 1.208 2024/07/11 17:27:04 riastradh Exp $ 2601.9Slukem# . base-sys-root [keyword[,...]] 2611.9Slukem# ./altroot base-sys-root 2621.9Slukem# ./bin base-sys-root 2631.9Slukem# ./bin/[ base-util-root 2641.9Slukem# ./bin/cat base-util-root 2651.9Slukem# [...] 2661.9Slukem# 2671.9Slukem# A # in the first column marks a comment. 2681.9Slukem# 2691.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will 2701.52Slukem# be printed. All other keywords must be present. 2711.9Slukem# 2721.9Slukem# The third field is an optional comma separated list of keywords to 2731.9Slukem# control if a record is printed; every keyword listed must be enabled 2741.204Srillig# for the record to be printed. The list of all available make variables 2751.179Schristos# that can be turned on or off can be found by running in this directory: 2761.179Schristos# 2771.179Schristos# make -f mkvars.mk mkvarsyesno 2781.179Schristos# 2791.179Schristos# These MK<NAME> variables can be used as selectors in the sets as <name>. 2801.203Srillig# 2811.179Schristos# The following extra keywords are also available, listed by: 2821.179Schristos# 2831.179Schristos# make -f mkvars.mk mkextravars 2841.13Slukem# 2851.179Schristos# These are: 2861.179Schristos# 1. The HAVE_<name>: 2871.179Schristos# ssp ${HAVE_SSP} != no 2881.160Sjoerg# libgcc_eh ${HAVE_LIBGCC_EH} != no 2891.192Sjmcneill# acpi ${HAVE_ACPI} != no 2901.87Sskrll# binutils=<n> <n> = value of ${HAVE_BINUTILS} 2911.52Slukem# gcc=<n> <n> = value of ${HAVE_GCC} 2921.52Slukem# gdb=<n> <n> = value of ${HAVE_GDB} 2931.192Sjmcneill# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 2941.193Sjmcneill# nvmm ${HAVE_NVMM} != no 2951.183Schristos# openssl=<n> <n> = value of ${HAVE_OPENSSL} 2961.192Sjmcneill# uefi ${HAVE_UEFI} != no 2971.177Smrg# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 2981.186Smrg# xorg_glamor ${HAVE_XORG_GLAMOR} != no 2991.52Slukem# 3001.179Schristos# 2. The USE_<name>: 3011.41Slukem# use_inet6 ${USE_INET6} != no 3021.41Slukem# use_kerberos ${USE_KERBEROS} != no 3031.179Schristos# use_ldap ${USE_LDAP} != no 3041.41Slukem# use_yp ${USE_YP} != no 3051.41Slukem# 3061.179Schristos# 3. Finally: 3071.179Schristos# dummy dummy entry (ignored) 3081.203Srillig# obsolete file is obsolete, and only printed if 3091.179Schristos# ${obsolete} != 0 3101.179Schristos# 3111.179Schristos# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 3121.179Schristos# 3131.179Schristos# 3141.179Schristos# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 3151.179Schristos# 3161.179Schristos# 3171.195Skamil# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 3181.195Skamil# automatically append ".gz" to the filename 3191.195Skamil# 3201.22Slukem# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 3211.22Slukem# automatically append ".gz" to the filename 3221.1Sdyoung# 3231.8Slukemlist_set_files() 3241.8Slukem{ 3251.83Sapb if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 3261.65She verbose=false 3271.65She else 3281.65She verbose=true 3291.65She fi 3301.198Schristos local CONFIGS="$( list_kernel_configs )" 3311.116Suebayasi print_set_lists "$@" | \ 3321.43Sapb ${AWK} -v obsolete=${obsolete} ' 3331.190Schristos function addkmod(line, fname, prefix, pat, patlen) { 3341.190Schristos if (substr(line, 1, patlen) != pat) { 3351.198Schristos return 3361.190Schristos } 3371.190Schristos for (d in kmodarchdirs) { 3381.190Schristos xd = prefix kmodarchdirs[d] 3391.198Schristos xline = xd substr(line, patlen + 1) 3401.198Schristos xfname = xd substr(fname, patlen + 1) 3411.198Schristos list[xline] = xfname 3421.207Sriastrad emit(xline) 3431.190Schristos } 3441.190Schristos } 3451.198Schristos function adddebugkernel(line, fname, pat, patlen) { 3461.199Schristos if (pat == "" || substr(line, 1, patlen) != pat) { 3471.198Schristos return 0 3481.198Schristos } 3491.198Schristos split("'"${CONFIGS}"'", configs) 3501.198Schristos for (d in configs) { 3511.198Schristos xfname = fname 3521.200Schristos sub("@CONFIG@", configs[d], xfname) 3531.198Schristos xline = line; 3541.200Schristos sub("@CONFIG@", configs[d], xline) 3551.198Schristos list[xline] = xfname 3561.207Sriastrad emit(xline) 3571.198Schristos } 3581.198Schristos return 1 3591.198Schristos } 3601.207Sriastrad function emit(fname) { 3611.207Sriastrad emitf[fname] = 1 3621.207Sriastrad } 3631.9Slukem BEGIN { 3641.52Slukem if (obsolete) 3651.52Slukem wanted["obsolete"] = 1 3661.203Srillig 3671.207Sriastrad ncpaths = 0 3681.100Suebayasi split("'"${MKVARS}"'", needvars) 3691.165Smatt doingcompat = 0 3701.165Smatt doingcompattests = 0 3711.165Smatt ignoredkeywords["compatdir"] = 1 3721.165Smatt ignoredkeywords["compatfile"] = 1 3731.165Smatt ignoredkeywords["compattestdir"] = 1 3741.165Smatt ignoredkeywords["compattestfile"] = 1 3751.170Smatt ignoredkeywords["compatx11dir"] = 1 3761.170Smatt ignoredkeywords["compatx11file"] = 1 3771.52Slukem for (vi in needvars) { 3781.52Slukem nv = needvars[vi] 3791.52Slukem kw = tolower(nv) 3801.52Slukem sub(/^mk/, "", kw) 3811.143Snakayama sub(/^have_/, "", kw) 3821.148Smatt sub(/^target_endianness/, "endian", kw) 3831.167Smatt if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 3841.203Srillig wanted[kw] = 1 3851.167Smatt } 3861.166Smatt } 3871.166Smatt 3881.167Smatt if ("compat" in wanted) { 3891.166Smatt doingcompat = 1; 3901.166Smatt split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 3911.166Smatt compatdirkeywords["compatdir"] = 1 3921.166Smatt compatfilekeywords["compatfile"] = 1 3931.166Smatt 3941.166Smatt if (wanted["compattests"]) { 3951.165Smatt doingcompattests = 1; 3961.165Smatt compatdirkeywords["compattestdir"] = 1 3971.165Smatt compatfilekeywords["compattestfile"] = 1 3981.166Smatt } 3991.170Smatt if (wanted["compatx11"]) { 4001.170Smatt doingcompatx11 = 1; 4011.170Smatt compatdirkeywords["compatx11dir"] = 1 4021.170Smatt compatfilekeywords["compatx11file"] = 1 4031.170Smatt } 4041.166Smatt } 4051.166Smatt 4061.167Smatt if (("kmod" in wanted) && ("compatmodules" in wanted)) { 4071.166Smatt split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 4081.190Schristos kmodprefix = "./stand/" 4091.190Schristos kmodpat = kmodprefix ENVIRON["MACHINE"] 4101.166Smatt l_kmodpat = length(kmodpat) 4111.203Srillig kmoddbprefix = "./usr/libdata/debug/stand/" 4121.190Schristos kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 4131.190Schristos l_kmoddbpat = length(kmoddbpat) 4141.52Slukem } 4151.198Schristos if ("debug" in wanted) { 4161.201Schristos debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 4171.198Schristos l_debugkernelname = length(debugkernelname); 4181.198Schristos } 4191.52Slukem 4201.52Slukem if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 4211.90Sdyoung if ("binutils" in wanted) 4221.90Sdyoung wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 4231.90Sdyoung if ("gcc" in wanted) 4241.90Sdyoung wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 4251.90Sdyoung if ("gdb" in wanted) 4261.90Sdyoung wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 4271.9Slukem } 4281.192Sjmcneill if ("acpi" in wanted) { 4291.192Sjmcneill wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 4301.192Sjmcneill } 4311.192Sjmcneill if ("mesa_ver" in wanted) { 4321.192Sjmcneill wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 4331.192Sjmcneill } 4341.193Sjmcneill if ("nvmm" in wanted) { 4351.193Sjmcneill wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 4361.193Sjmcneill } 4371.183Schristos if ("openssl" in wanted) { 4381.183Schristos wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 4391.183Schristos } 4401.178Smrg if ("xorg_server_ver" in wanted) { 4411.178Smrg wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 4421.177Smrg } 4431.192Sjmcneill if ("uefi" in wanted) { 4441.192Sjmcneill wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 4451.185Smrg } 4461.195Skamil if (("man" in wanted) && ("catpages" in wanted)) 4471.195Skamil wanted[".cat"] = 1 4481.52Slukem if (("man" in wanted) && ("manpages" in wanted)) 4491.52Slukem wanted[".man"] = 1 4501.148Smatt if ("endian" in wanted) 4511.148Smatt wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 4521.162Smrg if ("machine" in wanted) 4531.162Smrg wanted["machine=" "'"${MACHINE}"'"] = 1 4541.162Smrg if ("machine_arch" in wanted) 4551.162Smrg wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 4561.162Smrg if ("machine_cpu" in wanted) 4571.162Smrg wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 4581.9Slukem } 4591.9Slukem 4601.9Slukem /^#/ { 4611.9Slukem next; 4621.9Slukem } 4631.9Slukem 4641.127Smatt /^-/ { 4651.127Smatt notwanted[substr($1, 2)] = 1; 4661.127Smatt delete list [substr($1, 2)]; 4671.127Smatt next; 4681.127Smatt } 4691.203Srillig 4701.9Slukem NF > 2 && $3 != "-" { 4711.127Smatt if (notwanted[$1] != "") 4721.127Smatt next; 4731.9Slukem split($3, keywords, ",") 4741.9Slukem show = 1 4751.52Slukem haveobs = 0 4761.167Smatt iscompatfile = 0 4771.165Smatt havekmod = 0 4781.165Smatt iscompatdir = 0 4791.207Sriastrad omitcompat = 0 4801.207Sriastrad takecompat[$1] = 0 4811.9Slukem for (ki in keywords) { 4821.9Slukem kw = keywords[ki] 4831.22Slukem if (("manz" in wanted) && 4841.22Slukem (kw == ".cat" || kw == ".man")) 4851.22Slukem $1 = $1 ".gz" 4861.134Sjoerg if (substr(kw, 1, 1) == "!") { 4871.134Sjoerg kw = substr(kw, 2) 4881.59Sjmmv if (kw in wanted) 4891.59Sjmmv show = 0 4901.165Smatt } else if (kw in compatdirkeywords) { 4911.165Smatt iscompatdir = 1 4921.165Smatt } else if (kw in compatfilekeywords) { 4931.167Smatt iscompatfile = 1 4941.172Smatt } else if (kw == "nocompatmodules") { 4951.172Smatt havekmod = -1 4961.207Sriastrad } else if (kw == "omitcompat") { 4971.207Sriastrad omitcompat = 1 4981.207Sriastrad } else if (kw ~ /^takecompat=/) { 4991.207Sriastrad takecompat[$1] = 1 5001.207Sriastrad takecompatarch[substr(kw, 5011.207Sriastrad 1 + length("takecompat=")), $1] = 1 5021.165Smatt } else if (kw in ignoredkeywords) { 5031.165Smatt # ignore 5041.167Smatt } else if (! (kw in wanted)) { 5051.167Smatt show = 0 5061.172Smatt } else if (kw == "kmod" && havekmod == 0) { 5071.167Smatt havekmod = 1 5081.59Sjmmv } 5091.52Slukem if (kw == "obsolete") 5101.52Slukem haveobs = 1 5111.9Slukem } 5121.207Sriastrad 5131.207Sriastrad if (takecompat[$1] && !(iscompatdir || iscompatfile)) { 5141.207Sriastrad next 5151.207Sriastrad } 5161.207Sriastrad if (iscompatdir && !omitcompat) { 5171.184Snakayama for (d in cpaths) { 5181.207Sriastrad if (cpaths[d] == $1 "/") { 5191.207Sriastrad break 5201.207Sriastrad } 5211.184Snakayama } 5221.184Snakayama cpaths[ncpaths++] = $1 "/" 5231.184Snakayama } 5241.52Slukem if (obsolete && ! haveobs) 5251.52Slukem next 5261.165Smatt if (!show) 5271.165Smatt next 5281.198Schristos if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 5291.198Schristos next 5301.165Smatt 5311.165Smatt list[$1] = $0 5321.190Schristos if (havekmod > 0) { 5331.190Schristos addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 5341.190Schristos addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 5351.207Sriastrad emit($1) 5361.165Smatt next 5371.165Smatt } 5381.165Smatt 5391.207Sriastrad if (!doingcompat || !(iscompatfile || iscompatdir)) { 5401.207Sriastrad emit($1) 5411.165Smatt next 5421.207Sriastrad } 5431.165Smatt 5441.167Smatt if (iscompatfile) { 5451.207Sriastrad if (omitcompat) { 5461.207Sriastrad emit($1) 5471.207Sriastrad } else if (takecompat[$1]) { 5481.207Sriastrad emitcompat[$1] = 1 5491.207Sriastrad } else { 5501.207Sriastrad emit($1) 5511.207Sriastrad emitcompat[$1] = 1 5521.207Sriastrad } 5531.168Smatt next 5541.168Smatt } 5551.207Sriastrad if (iscompatdir) { 5561.207Sriastrad if (omitcompat) { 5571.207Sriastrad # /lib in base 5581.207Sriastrad emit($1) 5591.207Sriastrad } else if (takecompat[$1]) { 5601.207Sriastrad # /lib in base32 5611.207Sriastrad # nothing to do 5621.207Sriastrad } else { 5631.207Sriastrad # /usr/include in comp 5641.207Sriastrad emit($1) 5651.207Sriastrad } 5661.207Sriastrad } else { 5671.207Sriastrad emit($1) 5681.207Sriastrad } 5691.207Sriastrad if (omitcompat) 5701.207Sriastrad next 5711.165Smatt for (d in compatarchdirs) { 5721.207Sriastrad if (takecompat[$1] && 5731.207Sriastrad !takecompatarch[compatarchdirs[d], $1]) 5741.207Sriastrad continue 5751.165Smatt tmp = $0 5761.165Smatt xfile = $1 "/" compatarchdirs[d] 5771.165Smatt tmp = xfile substr(tmp, length($1) + 1) 5781.165Smatt if (xfile in notwanted) 5791.165Smatt continue; 5801.165Smatt sub("compatdir","compat",tmp); 5811.165Smatt sub("compattestdir","compat",tmp); 5821.165Smatt list[xfile] = tmp 5831.207Sriastrad emit(xfile) 5841.165Smatt } 5851.9Slukem next 5861.9Slukem } 5871.9Slukem 5881.9Slukem { 5891.165Smatt if ($1 in notwanted) 5901.127Smatt next; 5911.207Sriastrad if (! obsolete) { 5921.127Smatt list[$1] = $0 5931.207Sriastrad emit($1) 5941.207Sriastrad } 5951.127Smatt } 5961.127Smatt 5971.127Smatt END { 5981.127Smatt for (i in list) { 5991.207Sriastrad if (i in emitf) 6001.207Sriastrad print list[i] 6011.165Smatt if (! (i in emitcompat)) 6021.165Smatt continue; 6031.165Smatt l_i = length(i) 6041.165Smatt l = 0 6051.165Smatt for (j in cpaths) { 6061.165Smatt lx = length(cpaths[j]) 6071.165Smatt if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 6081.165Smatt continue; 6091.165Smatt } 6101.165Smatt if (lx > l) { 6111.165Smatt l = lx; 6121.165Smatt cpath = cpaths[j]; 6131.165Smatt } 6141.165Smatt } 6151.165Smatt for (d in compatarchdirs) { 6161.207Sriastrad if (takecompat[$1] && 6171.207Sriastrad !takecompatarch[compatarchdirs[d], 6181.207Sriastrad i]) { 6191.207Sriastrad continue 6201.207Sriastrad } 6211.165Smatt tmp = list[i] 6221.165Smatt extrapath = compatarchdirs[d] "/" 6231.165Smatt xfile = cpath extrapath substr(i, l + 1) 6241.165Smatt if (xfile in notwanted) 6251.165Smatt continue; 6261.165Smatt sub("compatfile","compat",tmp); 6271.165Smatt sub("compattestfile","compat",tmp); 6281.165Smatt tmp = xfile substr(tmp, l_i + 1) 6291.165Smatt print tmp; 6301.165Smatt } 6311.127Smatt } 6321.9Slukem }' 6331.9Slukem 6341.1Sdyoung} 6351.1Sdyoung 6361.1Sdyoung# 6371.1Sdyoung# list_set_lists setname 6381.203Srillig# 6391.1Sdyoung# Print to stdout a list of files, one filename per line, which 6401.1Sdyoung# concatenate to create the packing list for setname. E.g., 6411.1Sdyoung# 6421.1Sdyoung# .../lists/base/mi 6431.1Sdyoung# .../lists/base/rescue.mi 6441.1Sdyoung# .../lists/base/md.i386 6451.9Slukem# [...] 6461.1Sdyoung# 6471.9Slukem# For a given setname $set, the following files may be selected from 6481.9Slukem# .../list/$set: 6491.9Slukem# mi 6501.92Suebayasi# mi.ext.* 6511.11Slukem# ad.${MACHINE_ARCH} 6521.11Slukem# (or) ad.${MACHINE_CPU} 6531.11Slukem# ad.${MACHINE_CPU}.shl 6541.11Slukem# md.${MACHINE}.${MACHINE_ARCH} 6551.11Slukem# (or) md.${MACHINE} 6561.9Slukem# stl.mi 6571.92Suebayasi# stl.${stlib} 6581.9Slukem# shl.mi 6591.92Suebayasi# shl.mi.ext.* 6601.92Suebayasi# shl.${shlib} 6611.92Suebayasi# shl.${shlib}.ext.* 6621.77Stsutsui# module.mi if ${module} != no 6631.77Stsutsui# module.${MACHINE} if ${module} != no 6641.77Stsutsui# module.ad.${MACHINE_ARCH} if ${module} != no 6651.77Stsutsui# (or) module.ad.${MACHINE_CPU} if ${module} != no 6661.9Slukem# rescue.shl 6671.11Slukem# rescue.${MACHINE} 6681.11Slukem# rescue.ad.${MACHINE_ARCH} 6691.11Slukem# (or) rescue.ad.${MACHINE_CPU} 6701.11Slukem# rescue.ad.${MACHINE_CPU}.shl 6711.1Sdyoung# 6721.9Slukem# Environment: 6731.1Sdyoung# shlib 6741.1Sdyoung# stlib 6751.1Sdyoung# 6761.8Slukemlist_set_lists() 6771.8Slukem{ 6781.1Sdyoung setname=$1 6791.1Sdyoung 6801.111Suebayasi list_set_lists_mi $setname 6811.113Suebayasi list_set_lists_ad $setname 6821.111Suebayasi list_set_lists_md $setname 6831.111Suebayasi list_set_lists_stl $setname 6841.113Suebayasi list_set_lists_shl $setname 6851.113Suebayasi list_set_lists_module $setname 6861.111Suebayasi list_set_lists_rescue $setname 6871.117Suebayasi return 0 6881.111Suebayasi} 6891.110Suebayasi 6901.111Suebayasilist_set_lists_mi() 6911.111Suebayasi{ 6921.111Suebayasi setdir=$setsdir/lists/$1 6931.113Suebayasi # always exist! 6941.9Slukem echo $setdir/mi 6951.111Suebayasi} 6961.110Suebayasi 6971.111Suebayasilist_set_lists_ad() 6981.111Suebayasi{ 6991.111Suebayasi setdir=$setsdir/lists/$1 7001.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7011.113Suebayasi list_set_lists_common_ad $1 7021.111Suebayasi} 7031.110Suebayasi 7041.111Suebayasilist_set_lists_md() 7051.111Suebayasi{ 7061.111Suebayasi setdir=$setsdir/lists/$1 7071.110Suebayasi echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 7081.110Suebayasi echo_if_exist $setdir/md.${MACHINE} 7091.111Suebayasi} 7101.110Suebayasi 7111.111Suebayasilist_set_lists_stl() 7121.111Suebayasi{ 7131.111Suebayasi setdir=$setsdir/lists/$1 7141.110Suebayasi echo_if_exist $setdir/stl.mi 7151.110Suebayasi echo_if_exist $setdir/stl.${stlib} 7161.111Suebayasi} 7171.110Suebayasi 7181.111Suebayasilist_set_lists_shl() 7191.111Suebayasi{ 7201.111Suebayasi setdir=$setsdir/lists/$1 7211.113Suebayasi [ "$shlib" != "no" ] || return 7221.112Suebayasi echo_if_exist $setdir/shl.mi 7231.112Suebayasi echo_if_exist $setdir/shl.${shlib} 7241.111Suebayasi} 7251.110Suebayasi 7261.111Suebayasilist_set_lists_module() 7271.111Suebayasi{ 7281.111Suebayasi setdir=$setsdir/lists/$1 7291.113Suebayasi [ "$module" != "no" ] || return 7301.112Suebayasi echo_if_exist $setdir/module.mi 7311.112Suebayasi echo_if_exist $setdir/module.${MACHINE} 7321.189Schristos echo_if_exist $setdir/module.ad.${MACHINE} 7331.189Schristos echo_if_exist $setdir/module.md.${MACHINE} 7341.113Suebayasi # XXX module never has .shl 7351.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7361.113Suebayasi list_set_lists_common_ad $1 module 7371.111Suebayasi} 7381.1Sdyoung 7391.111Suebayasilist_set_lists_rescue() 7401.111Suebayasi{ 7411.111Suebayasi setdir=$setsdir/lists/$1 7421.110Suebayasi echo_if_exist $setdir/rescue.mi 7431.110Suebayasi echo_if_exist $setdir/rescue.${MACHINE} 7441.113Suebayasi [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 7451.113Suebayasi list_set_lists_common_ad $1 rescue 7461.111Suebayasi} 7471.111Suebayasi 7481.113Suebayasilist_set_lists_common_ad() 7491.111Suebayasi{ 7501.113Suebayasi setdir=$setsdir/lists/$1; _prefix=$2 7511.113Suebayasi 7521.113Suebayasi [ -n "$_prefix" ] && prefix="$_prefix". 7531.113Suebayasi 7541.113Suebayasi # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 7551.113Suebayasi # <prefix>.ad.${MACHINE_CPU}, since the arch- 7561.112Suebayasi # specific one will be more specific than the 7571.112Suebayasi # cpu-specific one. 7581.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 7591.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 7601.113Suebayasi [ "$shlib" != "no" ] && \ 7611.113Suebayasi echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 7621.5Sdyoung} 7631.5Sdyoung 7641.110Suebayasiecho_if_exist() 7651.110Suebayasi{ 7661.110Suebayasi [ -f $1 ] && echo $1 7671.110Suebayasi return $? 7681.110Suebayasi} 7691.110Suebayasi 7701.110Suebayasiecho_if_exist_foreach() 7711.110Suebayasi{ 7721.110Suebayasi local _list=$1; shift 7731.110Suebayasi for _suffix in $@; do 7741.110Suebayasi echo_if_exist ${_list}.${_suffix} 7751.110Suebayasi done 7761.110Suebayasi} 7771.110Suebayasi 7781.116Suebayasiprint_set_lists() 7791.116Suebayasi{ 7801.116Suebayasi for setname; do 7811.136Schristos list=$(list_set_lists $setname) 7821.116Suebayasi for l in $list; do 7831.116Suebayasi echo $l 7841.116Suebayasi if $verbose; then 7851.116Suebayasi echo >&2 "DEBUG: list_set_files: $l" 7861.116Suebayasi fi 7871.207Sriastrad done \ 7881.207Sriastrad | ${XARGS} ${SED} ${SUBST} \ 7891.207Sriastrad | case $setname in 7901.207Sriastrad base|debug) 7911.207Sriastrad awk ' 7921.207Sriastrad !/^#/ && !/^$/ { 7931.207Sriastrad print $1, $2, \ 7941.207Sriastrad ($3 ? $3"," : "")"omitcompat" 7951.207Sriastrad } 7961.207Sriastrad ' 7971.207Sriastrad ;; 7981.207Sriastrad *) cat 7991.207Sriastrad ;; 8001.207Sriastrad esac 8011.207Sriastrad 8021.207Sriastrad case $setname in 8031.207Sriastrad base32|base64) 8041.207Sriastrad ursetname=base 8051.207Sriastrad ;; 8061.207Sriastrad debug32|debug64) 8071.207Sriastrad ursetname=debug 8081.207Sriastrad ;; 8091.207Sriastrad *) continue 8101.207Sriastrad ;; 8111.207Sriastrad esac 8121.207Sriastrad case $setname in 8131.207Sriastrad *32) compatarches=$compat32arches 8141.207Sriastrad ;; 8151.207Sriastrad *64) compatarches=$compat64arches 8161.207Sriastrad ;; 8171.207Sriastrad esac 8181.207Sriastrad list=$(list_set_lists $ursetname) 8191.207Sriastrad for l in $list; do 8201.207Sriastrad echo $l 8211.207Sriastrad if $verbose; then 8221.207Sriastrad echo >&2 "DEBUG: list_set_files: $l" 8231.207Sriastrad fi 8241.207Sriastrad done \ 8251.207Sriastrad | ${XARGS} ${SED} ${SUBST} \ 8261.207Sriastrad | awk -v compatarches="$compatarches" ' 8271.207Sriastrad BEGIN { 8281.207Sriastrad split(compatarches, compatarch, " ") 8291.207Sriastrad flags = "" 8301.207Sriastrad for (i in compatarch) 8311.207Sriastrad flags = (flags ? flags"," : "") \ 8321.207Sriastrad "takecompat="compatarch[i] 8331.207Sriastrad } 8341.207Sriastrad !/^#/ && !/^$/ { 8351.207Sriastrad print $1, $2, ($3 ? $3"," : "")flags 8361.207Sriastrad } 8371.207Sriastrad ' 8381.207Sriastrad done 8391.116Suebayasi} 8401.116Suebayasi 8411.198Schristos 8421.198Schristoslist_kernel_configs() 8431.198Schristos{ 8441.198Schristos (cd ${NETBSDSRCDIR}/etc 8451.198Schristos MAKEFLAGS= \ 8461.198Schristos ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 8471.198Schristos} 8481.198Schristos 8491.9Slukem# arch_to_cpu mach 8501.9Slukem# 8511.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 8521.9Slukem# as determined by <bsd.own.mk>. 8531.9Slukem# 8541.8Slukemarch_to_cpu() 8551.8Slukem{ 8561.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 8571.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 8581.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 8591.182Suwe -V '${MACHINE_CPU}' 8601.1Sdyoung} 8611.46Sapb 8621.46Sapb# arch_to_endian mach 8631.46Sapb# 8641.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 8651.46Sapb# as determined by <bsd.endian.mk>. 8661.46Sapb# 8671.46Sapbarch_to_endian() 8681.46Sapb{ 8691.182Suwe MACHINE_ARCH=${1} MAKEFLAGS= \ 8701.182Suwe ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 8711.182Suwe -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 8721.182Suwe -V '${TARGET_ENDIANNESS}' 8731.46Sapb} 8741.117Suebayasi 8751.117Suebayasi##### 8761.117Suebayasi 8771.117Suebayasi# print_mkvars 8781.117Suebayasiprint_mkvars() 8791.117Suebayasi{ 8801.117Suebayasi for v in $MKVARS; do 8811.117Suebayasi eval echo $v=\$$v 8821.117Suebayasi done 8831.117Suebayasi} 8841.117Suebayasi 8851.117Suebayasi# print_set_lists_{base,x,ext} 8861.117Suebayasi# list_set_lists_{base,x,ext} 8871.117Suebayasi# list_set_files_{base,x,ext} 8881.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do 8891.117Suebayasi for x in base x ext; do 8901.117Suebayasi if [ $x = base ]; then 8911.117Suebayasi list=nlists 8921.117Suebayasi else 8931.117Suebayasi list=${x}lists 8941.117Suebayasi fi 8951.117Suebayasi eval ${func}_${x} \(\) \{ $func \$$list \; \} 8961.117Suebayasi done 8971.117Suebayasidone 898