sets.subr revision 1.210
1# $NetBSD: sets.subr,v 1.210 2025/02/24 18:02:02 martin Exp $ 2# 3 4# 5# The following variables contain defaults for sets.subr functions and callers: 6# setsdir path to src/distrib/sets 7# nlists list of base sets 8# xlists list of x11 sets 9# obsolete controls if obsolete files are selected instead 10# module if != "no", enable MODULE sets 11# shlib shared library format (a.out, elf, or "") 12# stlib static library format (a.out, elf) 13# 14# The following <bsd.own.mk> variables are exported to the environment: 15# MACHINE 16# MACHINE_ARCH 17# MACHINE_CPU 18# HAVE_ACPI 19# HAVE_BINUTILS 20# HAVE_GCC 21# HAVE_GDB 22# HAVE_NVMM 23# HAVE_OPENSSL 24# HAVE_SSP 25# HAVE_UEFI 26# HAVE_EFI_RT 27# TOOLCHAIN_MISSING 28# OBJECT_FMT 29# as well as: 30# 31 32# 33# The following variables refer to tools that are used when building sets: 34# 35: ${AWK:=awk} 36: ${CKSUM:=cksum} 37: ${COMM:=comm} 38: ${DATE:=date} 39: ${DB:=db} 40: ${EGREP:=egrep} 41: ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc. 42: ${FGREP:=fgrep} 43: ${FIND:=find} 44: ${GREP:=grep} 45: ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1) 46: ${HOSTNAME_CMD:=hostname} # ${HOSTNAME} is special to bash(1) 47: ${HOST_SH:=sh} 48: ${IDENT:=ident} 49: ${JOIN:=join} 50: ${LS:=ls} 51: ${MAKE:=make} 52: ${MKTEMP:=mktemp} 53: ${MTREE:=mtree} 54: ${PASTE:=paste} 55: ${PAX:=pax} 56: ${PRINTF:=printf} 57: ${SED:=sed} 58: ${SORT:=sort} 59: ${STAT:=stat} 60: ${TSORT:=tsort} 61: ${UNAME:=uname} 62: ${WC:=wc} 63: ${XARGS:=xargs} 64 65# 66# If printf is a shell builtin command, then we can 67# implement cheaper versions of basename and dirname 68# that do not involve any fork/exec overhead. 69# If printf is not builtin, approximate it using echo, 70# and hope there are no weird file names that cause 71# some versions of echo to do the wrong thing. 72# (Converting to this version of dirname speeded up the 73# syspkgdeps script by an order of magnitude, from 68 74# seconds to 6.3 seconds on one particular host.) 75# 76# Note that naive approximations for dirname 77# using ${foo%/*} do not do the right thing in cases 78# where the result should be "/" or ".". 79# 80case "$(type printf)" in 81*builtin*) 82 basename () 83 { 84 local bn 85 bn="${1##*/}" 86 bn="${bn%$2}" 87 printf "%s\n" "$bn" 88 } 89 dirname () 90 { 91 local dn 92 case "$1" in 93 ?*/*) dn="${1%/*}" ;; 94 /*) dn=/ ;; 95 *) dn=. ;; 96 esac 97 printf "%s\n" "$dn" 98 } 99 ;; 100*) 101 basename () 102 { 103 local bn 104 bn="${1##*/}" 105 bn="${bn%$2}" 106 echo "$bn" 107 } 108 dirname () 109 { 110 local dn 111 case "$1" in 112 ?*/*) dn="${1%/*}" ;; 113 /*) dn=/ ;; 114 *) dn=. ;; 115 esac 116 echo "$dn" 117 } 118 ;; 119esac 120 121##### 122 123oIFS=$IFS 124IFS=" 125" 126 127for x in $( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do 128 eval export $x 129done 130 131IFS=$oIFS 132 133MKVARS="$( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )" 134 135##### 136 137setsdir=${rundir} 138obsolete=0 139if [ "${MKKMOD}" = "no" ]; then 140 module=no # MODULEs are off. 141 modset="" 142else 143 module=yes 144 modset="modules" 145fi 146if [ "${MKATF}" = "no" ]; then 147 testset="" 148else 149 testset="tests" 150fi 151if [ "${MKDEBUG}" = "no" -a "${MKDEBUGLIB}" = "no" ]; then 152 debugset="" 153 xdebugset="" 154else 155 debugset="debug" 156 xdebugset="xdebug" 157fi 158if [ -z "${debugset}" -o "${MKCOMPAT}" = "no" ]; then 159 debug32set="" 160else 161 debug32set="debug32" 162fi 163if [ -z "${debug32set}" ]; then 164 debug64set="" 165else 166 if [ "${MACHINE_ARCH}" = "mips64eb" -o "${MACHINE_ARCH}" = "mips64el" ]; then 167 debug64set="debug64" 168 else 169 debug64set="" 170 fi 171fi 172if [ "${MKDTB}" = "no" ]; then 173 dtbset="" 174else 175 dtbset="dtb" 176fi 177if [ "${MKHTML}" = "no" ]; then 178 manhtmlset="" 179else 180 manhtmlset="manhtml" 181fi 182if [ "${MKCOMPAT}" = "no" ]; then 183 base32set="" 184else 185 base32set="base32" 186fi 187if [ "${MKCOMPAT}" != "no" ]; then 188 if [ "${MACHINE_ARCH}" = "mips64eb" -o "${MACHINE_ARCH}" = "mips64el" ]; then 189 base64set="base64" 190 else 191 base64set="" 192 fi 193else 194 base64set="" 195fi 196 197# XXX This should not be encoded here -- this mostly duplicates 198# information in compat/archdirs.mk, except that it also identifies 199# which compat architectures are `32-bit' and which ones are `64-bit'. 200case $MACHINE_ARCH in 201aarch64) 202 compat32arches='eabi eabihf' 203 ;; 204aarch64eb) 205 compat32arches=eabi 206 ;; 207mips64eb|mips64el) 208 compat32arches=o32 209 compat64arches=64 210 ;; 211mipsn64eb|mipsn64el) 212 compat32arches='n32 o32' 213 ;; 214powerpc64) 215 compat32arches=powerpc 216 ;; 217riscv64) 218 compat32arches=rv32 219 ;; 220sparc64) 221 compat32arches=sparc 222 ;; 223x86_64) compat32arches=i386 224 ;; 225esac 226: ${compat32arches:=} 227: ${compat64arches:=} 228 229 230# Determine lib type. Do this first so stlib also gets set. 231if [ "${OBJECT_FMT}" = "ELF" ]; then 232 shlib=elf 233else 234 shlib=aout 235fi 236stlib=$shlib 237# Now check for MKPIC or specials and turn off shlib if need be. 238if [ "${MKPIC}" = "no" ]; then 239 shlib=no 240fi 241nlists="base $base32set $base64set comp $debugset $debug32set $debug64set $dtbset etc games gpufw man $manhtmlset misc $modset rescue $testset text" 242xlists="xbase xcomp $xdebugset xetc xfont xserver" 243 244OSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k) 245if [ "${KERNEL_DIR}" = "yes" ]; then 246 MODULEDIR="netbsd/modules" 247else 248 MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules" 249fi 250SUBST="s#@MODULEDIR@#${MODULEDIR}#g" 251SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g" 252SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g" 253 254# 255# list_set_files setfile [...] 256# 257# Produce a packing list for setfile(s). 258# In each file, a record consists of a path and a System Package name, 259# separated by whitespace. E.g., 260# 261# # $NetBSD: sets.subr,v 1.210 2025/02/24 18:02:02 martin Exp $ 262# . base-sys-root [keyword[,...]] 263# ./altroot base-sys-root 264# ./bin base-sys-root 265# ./bin/[ base-util-root 266# ./bin/cat base-util-root 267# [...] 268# 269# A # in the first column marks a comment. 270# 271# If ${obsolete} != 0, only entries with an "obsolete" keyword will 272# be printed. All other keywords must be present. 273# 274# The third field is an optional comma separated list of keywords to 275# control if a record is printed; every keyword listed must be enabled 276# for the record to be printed. The list of all available make variables 277# that can be turned on or off can be found by running in this directory: 278# 279# make -f mkvars.mk mkvarsyesno 280# 281# These MK<NAME> variables can be used as selectors in the sets as <name>. 282# 283# The following extra keywords are also available, listed by: 284# 285# make -f mkvars.mk mkextravars 286# 287# These are: 288# 1. The HAVE_<name>: 289# ssp ${HAVE_SSP} != no 290# libgcc_eh ${HAVE_LIBGCC_EH} != no 291# acpi ${HAVE_ACPI} != no 292# binutils=<n> <n> = value of ${HAVE_BINUTILS} 293# gcc=<n> <n> = value of ${HAVE_GCC} 294# gdb=<n> <n> = value of ${HAVE_GDB} 295# mesa_ver=<n> <n> = value of ${HAVE_MESA_VER} 296# nvmm ${HAVE_NVMM} != no 297# openssl=<n> <n> = value of ${HAVE_OPENSSL} 298# uefi ${HAVE_UEFI} != no 299# efi_rt ${HAVE_EFI_RT} != no 300# xorg_server_ver=<n> <n> = value of ${HAVE_XORG_SERVER_VER} 301# xorg_glamor ${HAVE_XORG_GLAMOR} != no 302# 303# 2. The USE_<name>: 304# use_inet6 ${USE_INET6} != no 305# use_kerberos ${USE_KERBEROS} != no 306# use_ldap ${USE_LDAP} != no 307# use_yp ${USE_YP} != no 308# 309# 3. Finally: 310# dummy dummy entry (ignored) 311# obsolete file is obsolete, and only printed if 312# ${obsolete} != 0 313# 314# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 315# 316# 317# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 318# 319# 320# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 321# automatically append ".gz" to the filename 322# 323# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 324# automatically append ".gz" to the filename 325# 326list_set_files() 327{ 328 if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 329 verbose=false 330 else 331 verbose=true 332 fi 333 local CONFIGS="$( list_kernel_configs )" 334 print_set_lists "$@" | \ 335 ${AWK} -v obsolete=${obsolete} ' 336 function addkmod(line, fname, prefix, pat, patlen) { 337 if (substr(line, 1, patlen) != pat) { 338 return 339 } 340 for (d in kmodarchdirs) { 341 xd = prefix kmodarchdirs[d] 342 xline = xd substr(line, patlen + 1) 343 xfname = xd substr(fname, patlen + 1) 344 list[xline] = xfname 345 emit(xline) 346 } 347 } 348 function adddebugkernel(line, fname, pat, patlen) { 349 if (pat == "" || substr(line, 1, patlen) != pat) { 350 return 0 351 } 352 split("'"${CONFIGS}"'", configs) 353 for (d in configs) { 354 xfname = fname 355 sub("@CONFIG@", configs[d], xfname) 356 xline = line; 357 sub("@CONFIG@", configs[d], xline) 358 list[xline] = xfname 359 emit(xline) 360 } 361 return 1 362 } 363 function emit(fname) { 364 emitf[fname] = 1 365 } 366 BEGIN { 367 if (obsolete) 368 wanted["obsolete"] = 1 369 370 ncpaths = 0 371 split("'"${MKVARS}"'", needvars) 372 doingcompat = 0 373 doingcompattests = 0 374 ignoredkeywords["compatdir"] = 1 375 ignoredkeywords["compatfile"] = 1 376 ignoredkeywords["compattestdir"] = 1 377 ignoredkeywords["compattestfile"] = 1 378 ignoredkeywords["compatx11dir"] = 1 379 ignoredkeywords["compatx11file"] = 1 380 for (vi in needvars) { 381 nv = needvars[vi] 382 kw = tolower(nv) 383 sub(/^mk/, "", kw) 384 sub(/^have_/, "", kw) 385 sub(/^target_endianness/, "endian", kw) 386 if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 387 wanted[kw] = 1 388 } 389 } 390 391 if ("compat" in wanted) { 392 doingcompat = 1; 393 split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 394 compatdirkeywords["compatdir"] = 1 395 compatfilekeywords["compatfile"] = 1 396 397 if (wanted["compattests"]) { 398 doingcompattests = 1; 399 compatdirkeywords["compattestdir"] = 1 400 compatfilekeywords["compattestfile"] = 1 401 } 402 if (wanted["compatx11"]) { 403 doingcompatx11 = 1; 404 compatdirkeywords["compatx11dir"] = 1 405 compatfilekeywords["compatx11file"] = 1 406 } 407 } 408 409 if (("kmod" in wanted) && ("compatmodules" in wanted)) { 410 split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 411 kmodprefix = "./stand/" 412 kmodpat = kmodprefix ENVIRON["MACHINE"] 413 l_kmodpat = length(kmodpat) 414 kmoddbprefix = "./usr/libdata/debug/stand/" 415 kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 416 l_kmoddbpat = length(kmoddbpat) 417 } 418 if ("debug" in wanted) { 419 debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 420 l_debugkernelname = length(debugkernelname); 421 } 422 423 if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 424 if ("binutils" in wanted) 425 wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 426 if ("gcc" in wanted) 427 wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 428 if ("gdb" in wanted) 429 wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 430 } 431 if ("acpi" in wanted) { 432 wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 433 } 434 if ("mesa_ver" in wanted) { 435 wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 436 } 437 if ("nvmm" in wanted) { 438 wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 439 } 440 if ("openssl" in wanted) { 441 wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 442 } 443 if ("xorg_server_ver" in wanted) { 444 wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 445 } 446 if ("uefi" in wanted) { 447 wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 448 } 449 if ("efi_rt" in wanted) { 450 wanted["efi_rt=" "'"${HAVE_EFI_RT}"'"] = 1 451 } 452 if (("man" in wanted) && ("catpages" in wanted)) 453 wanted[".cat"] = 1 454 if (("man" in wanted) && ("manpages" in wanted)) 455 wanted[".man"] = 1 456 if ("endian" in wanted) 457 wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 458 if ("machine" in wanted) 459 wanted["machine=" "'"${MACHINE}"'"] = 1 460 if ("machine_arch" in wanted) 461 wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 462 if ("machine_cpu" in wanted) 463 wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 464 } 465 466 /^#/ { 467 next; 468 } 469 470 /^-/ { 471 notwanted[substr($1, 2)] = 1; 472 delete list [substr($1, 2)]; 473 next; 474 } 475 476 NF > 2 && $3 != "-" { 477 if (notwanted[$1] != "") 478 next; 479 split($3, keywords, ",") 480 show = 1 481 haveobs = 0 482 iscompatfile = 0 483 havekmod = 0 484 iscompatdir = 0 485 omitcompat = 0 486 takecompat[$1] = 0 487 for (ki in keywords) { 488 kw = keywords[ki] 489 if (("manz" in wanted) && 490 (kw == ".cat" || kw == ".man")) 491 $1 = $1 ".gz" 492 if (substr(kw, 1, 1) == "!") { 493 kw = substr(kw, 2) 494 if (kw in wanted) 495 show = 0 496 } else if (kw in compatdirkeywords) { 497 iscompatdir = 1 498 } else if (kw in compatfilekeywords) { 499 iscompatfile = 1 500 } else if (kw == "nocompatmodules") { 501 havekmod = -1 502 } else if (kw == "omitcompat") { 503 omitcompat = 1 504 } else if (kw ~ /^takecompat=/) { 505 takecompat[$1] = 1 506 takecompatarch[substr(kw, 507 1 + length("takecompat=")), $1] = 1 508 } else if (kw in ignoredkeywords) { 509 # ignore 510 } else if (! (kw in wanted)) { 511 show = 0 512 } else if (kw == "kmod" && havekmod == 0) { 513 havekmod = 1 514 } 515 if (kw == "obsolete") 516 haveobs = 1 517 } 518 519 if (takecompat[$1] && !(iscompatdir || iscompatfile)) { 520 next 521 } 522 if (iscompatdir && !omitcompat) { 523 for (d in cpaths) { 524 if (cpaths[d] == $1 "/") { 525 break 526 } 527 } 528 cpaths[ncpaths++] = $1 "/" 529 } 530 if (obsolete && ! haveobs) 531 next 532 if (!show) 533 next 534 if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 535 next 536 537 list[$1] = $0 538 if (havekmod > 0) { 539 addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 540 addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 541 emit($1) 542 next 543 } 544 545 if (!doingcompat || !(iscompatfile || iscompatdir)) { 546 emit($1) 547 next 548 } 549 550 if (iscompatfile) { 551 if (omitcompat) { 552 emit($1) 553 } else if (takecompat[$1]) { 554 emitcompat[$1] = 1 555 } else { 556 emit($1) 557 emitcompat[$1] = 1 558 } 559 next 560 } 561 if (iscompatdir) { 562 if (omitcompat) { 563 # /lib in base 564 emit($1) 565 } else if (takecompat[$1]) { 566 # /lib in base32 567 # nothing to do 568 } else { 569 # /usr/include in comp 570 emit($1) 571 } 572 } else { 573 emit($1) 574 } 575 if (omitcompat) 576 next 577 for (d in compatarchdirs) { 578 if (takecompat[$1] && 579 !takecompatarch[compatarchdirs[d], $1]) 580 continue 581 tmp = $0 582 xfile = $1 "/" compatarchdirs[d] 583 tmp = xfile substr(tmp, length($1) + 1) 584 if (xfile in notwanted) 585 continue; 586 sub("compatdir","compat",tmp); 587 sub("compattestdir","compat",tmp); 588 list[xfile] = tmp 589 emit(xfile) 590 } 591 next 592 } 593 594 { 595 if ($1 in notwanted) 596 next; 597 if (! obsolete) { 598 list[$1] = $0 599 emit($1) 600 } 601 } 602 603 END { 604 for (i in list) { 605 if (i in emitf) 606 print list[i] 607 if (! (i in emitcompat)) 608 continue; 609 l_i = length(i) 610 l = 0 611 for (j in cpaths) { 612 lx = length(cpaths[j]) 613 if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 614 continue; 615 } 616 if (lx > l) { 617 l = lx; 618 cpath = cpaths[j]; 619 } 620 } 621 for (d in compatarchdirs) { 622 if (takecompat[$1] && 623 !takecompatarch[compatarchdirs[d], 624 i]) { 625 continue 626 } 627 tmp = list[i] 628 extrapath = compatarchdirs[d] "/" 629 xfile = cpath extrapath substr(i, l + 1) 630 if (xfile in notwanted) 631 continue; 632 sub("compatfile","compat",tmp); 633 sub("compattestfile","compat",tmp); 634 tmp = xfile substr(tmp, l_i + 1) 635 print tmp; 636 } 637 } 638 }' 639 640} 641 642# 643# list_set_lists setname 644# 645# Print to stdout a list of files, one filename per line, which 646# concatenate to create the packing list for setname. E.g., 647# 648# .../lists/base/mi 649# .../lists/base/rescue.mi 650# .../lists/base/md.i386 651# [...] 652# 653# For a given setname $set, the following files may be selected from 654# .../list/$set: 655# mi 656# mi.ext.* 657# ad.${MACHINE_ARCH} 658# (or) ad.${MACHINE_CPU} 659# ad.${MACHINE_CPU}.shl 660# md.${MACHINE}.${MACHINE_ARCH} 661# (or) md.${MACHINE} 662# stl.mi 663# stl.${stlib} 664# shl.mi 665# shl.mi.ext.* 666# shl.${shlib} 667# shl.${shlib}.ext.* 668# module.mi if ${module} != no 669# module.${MACHINE} if ${module} != no 670# module.ad.${MACHINE_ARCH} if ${module} != no 671# (or) module.ad.${MACHINE_CPU} if ${module} != no 672# rescue.shl 673# rescue.${MACHINE} 674# rescue.ad.${MACHINE_ARCH} 675# (or) rescue.ad.${MACHINE_CPU} 676# rescue.ad.${MACHINE_CPU}.shl 677# 678# Environment: 679# shlib 680# stlib 681# 682list_set_lists() 683{ 684 setname=$1 685 686 list_set_lists_mi $setname 687 list_set_lists_ad $setname 688 list_set_lists_md $setname 689 list_set_lists_stl $setname 690 list_set_lists_shl $setname 691 list_set_lists_module $setname 692 list_set_lists_rescue $setname 693 return 0 694} 695 696list_set_lists_mi() 697{ 698 setdir=$setsdir/lists/$1 699 # always exist! 700 echo $setdir/mi 701} 702 703list_set_lists_ad() 704{ 705 setdir=$setsdir/lists/$1 706 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 707 list_set_lists_common_ad $1 708} 709 710list_set_lists_md() 711{ 712 setdir=$setsdir/lists/$1 713 echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 714 echo_if_exist $setdir/md.${MACHINE} 715} 716 717list_set_lists_stl() 718{ 719 setdir=$setsdir/lists/$1 720 echo_if_exist $setdir/stl.mi 721 echo_if_exist $setdir/stl.${stlib} 722} 723 724list_set_lists_shl() 725{ 726 setdir=$setsdir/lists/$1 727 [ "$shlib" != "no" ] || return 728 echo_if_exist $setdir/shl.mi 729 echo_if_exist $setdir/shl.${shlib} 730} 731 732list_set_lists_module() 733{ 734 setdir=$setsdir/lists/$1 735 [ "$module" != "no" ] || return 736 echo_if_exist $setdir/module.mi 737 echo_if_exist $setdir/module.${MACHINE} 738 echo_if_exist $setdir/module.ad.${MACHINE} 739 echo_if_exist $setdir/module.md.${MACHINE} 740 # XXX module never has .shl 741 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 742 list_set_lists_common_ad $1 module 743} 744 745list_set_lists_rescue() 746{ 747 setdir=$setsdir/lists/$1 748 echo_if_exist $setdir/rescue.mi 749 echo_if_exist $setdir/rescue.${MACHINE} 750 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 751 list_set_lists_common_ad $1 rescue 752} 753 754list_set_lists_common_ad() 755{ 756 setdir=$setsdir/lists/$1; _prefix=$2 757 758 [ -n "$_prefix" ] && prefix="$_prefix". 759 760 # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 761 # <prefix>.ad.${MACHINE_CPU}, since the arch- 762 # specific one will be more specific than the 763 # cpu-specific one. 764 echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 765 echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 766 [ "$shlib" != "no" ] && \ 767 echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 768} 769 770echo_if_exist() 771{ 772 [ -f $1 ] && echo $1 773 return $? 774} 775 776echo_if_exist_foreach() 777{ 778 local _list=$1; shift 779 for _suffix in $@; do 780 echo_if_exist ${_list}.${_suffix} 781 done 782} 783 784print_set_lists() 785{ 786 for setname; do 787 list=$(list_set_lists $setname) 788 for l in $list; do 789 echo $l 790 if $verbose; then 791 echo >&2 "DEBUG: list_set_files: $l" 792 fi 793 done \ 794 | ${XARGS} ${SED} ${SUBST} \ 795 | case $setname in 796 base|debug) 797 awk ' 798 !/^#/ && !/^$/ { 799 print $1, $2, \ 800 ($3 ? $3"," : "")"omitcompat" 801 } 802 ' 803 ;; 804 *) cat 805 ;; 806 esac 807 808 case $setname in 809 base32|base64) 810 ursetname=base 811 ;; 812 debug32|debug64) 813 ursetname=debug 814 ;; 815 *) continue 816 ;; 817 esac 818 case $setname in 819 *32) compatarches=$compat32arches 820 ;; 821 *64) compatarches=$compat64arches 822 ;; 823 esac 824 list=$(list_set_lists $ursetname) 825 for l in $list; do 826 echo $l 827 if $verbose; then 828 echo >&2 "DEBUG: list_set_files: $l" 829 fi 830 done \ 831 | ${XARGS} ${SED} ${SUBST} \ 832 | awk -v compatarches="$compatarches" ' 833 BEGIN { 834 split(compatarches, compatarch, " ") 835 flags = "" 836 for (i in compatarch) 837 flags = (flags ? flags"," : "") \ 838 "takecompat="compatarch[i] 839 } 840 !/^#/ && !/^$/ { 841 print $1, $2, ($3 ? $3"," : "")flags 842 } 843 ' 844 done 845} 846 847 848list_kernel_configs() 849{ 850 (cd ${NETBSDSRCDIR}/etc 851 MAKEFLAGS= \ 852 ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 853} 854 855# arch_to_cpu mach 856# 857# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 858# as determined by <bsd.own.mk>. 859# 860arch_to_cpu() 861{ 862 MACHINE_ARCH=${1} MAKEFLAGS= \ 863 ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 864 -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 865 -V '${MACHINE_CPU}' 866} 867 868# arch_to_endian mach 869# 870# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 871# as determined by <bsd.endian.mk>. 872# 873arch_to_endian() 874{ 875 MACHINE_ARCH=${1} MAKEFLAGS= \ 876 ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 877 -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 878 -V '${TARGET_ENDIANNESS}' 879} 880 881##### 882 883# print_mkvars 884print_mkvars() 885{ 886 for v in $MKVARS; do 887 eval echo $v=\$$v 888 done 889} 890 891# print_set_lists_{base,x,ext} 892# list_set_lists_{base,x,ext} 893# list_set_files_{base,x,ext} 894for func in print_set_lists list_set_lists list_set_files; do 895 for x in base x ext; do 896 if [ $x = base ]; then 897 list=nlists 898 else 899 list=${x}lists 900 fi 901 eval ${func}_${x} \(\) \{ $func \$$list \; \} 902 done 903done 904