sets.subr revision 1.211
1# $NetBSD: sets.subr,v 1.211 2025/05/13 21:36:26 nia 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.211 2025/05/13 21:36:26 nia 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# xorg_egl ${HAVE_XORG_EGL} != no 303# 304# 2. The USE_<name>: 305# use_inet6 ${USE_INET6} != no 306# use_kerberos ${USE_KERBEROS} != no 307# use_ldap ${USE_LDAP} != no 308# use_yp ${USE_YP} != no 309# 310# 3. Finally: 311# dummy dummy entry (ignored) 312# obsolete file is obsolete, and only printed if 313# ${obsolete} != 0 314# 315# solaris ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no 316# 317# 318# endian=<n> <n> = value of ${TARGET_ENDIANNESS} 319# 320# 321# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 322# automatically append ".gz" to the filename 323# 324# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 325# automatically append ".gz" to the filename 326# 327list_set_files() 328{ 329 if [ ${MAKEVERBOSE:-2} -lt 3 ]; then 330 verbose=false 331 else 332 verbose=true 333 fi 334 local CONFIGS="$( list_kernel_configs )" 335 print_set_lists "$@" | \ 336 ${AWK} -v obsolete=${obsolete} ' 337 function addkmod(line, fname, prefix, pat, patlen) { 338 if (substr(line, 1, patlen) != pat) { 339 return 340 } 341 for (d in kmodarchdirs) { 342 xd = prefix kmodarchdirs[d] 343 xline = xd substr(line, patlen + 1) 344 xfname = xd substr(fname, patlen + 1) 345 list[xline] = xfname 346 emit(xline) 347 } 348 } 349 function adddebugkernel(line, fname, pat, patlen) { 350 if (pat == "" || substr(line, 1, patlen) != pat) { 351 return 0 352 } 353 split("'"${CONFIGS}"'", configs) 354 for (d in configs) { 355 xfname = fname 356 sub("@CONFIG@", configs[d], xfname) 357 xline = line; 358 sub("@CONFIG@", configs[d], xline) 359 list[xline] = xfname 360 emit(xline) 361 } 362 return 1 363 } 364 function emit(fname) { 365 emitf[fname] = 1 366 } 367 BEGIN { 368 if (obsolete) 369 wanted["obsolete"] = 1 370 371 ncpaths = 0 372 split("'"${MKVARS}"'", needvars) 373 doingcompat = 0 374 doingcompattests = 0 375 ignoredkeywords["compatdir"] = 1 376 ignoredkeywords["compatfile"] = 1 377 ignoredkeywords["compattestdir"] = 1 378 ignoredkeywords["compattestfile"] = 1 379 ignoredkeywords["compatx11dir"] = 1 380 ignoredkeywords["compatx11file"] = 1 381 for (vi in needvars) { 382 nv = needvars[vi] 383 kw = tolower(nv) 384 sub(/^mk/, "", kw) 385 sub(/^have_/, "", kw) 386 sub(/^target_endianness/, "endian", kw) 387 if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") { 388 wanted[kw] = 1 389 } 390 } 391 392 if ("compat" in wanted) { 393 doingcompat = 1; 394 split("'"${COMPATARCHDIRS}"'", compatarchdirs, ","); 395 compatdirkeywords["compatdir"] = 1 396 compatfilekeywords["compatfile"] = 1 397 398 if (wanted["compattests"]) { 399 doingcompattests = 1; 400 compatdirkeywords["compattestdir"] = 1 401 compatfilekeywords["compattestfile"] = 1 402 } 403 if (wanted["compatx11"]) { 404 doingcompatx11 = 1; 405 compatdirkeywords["compatx11dir"] = 1 406 compatfilekeywords["compatx11file"] = 1 407 } 408 } 409 410 if (("kmod" in wanted) && ("compatmodules" in wanted)) { 411 split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); 412 kmodprefix = "./stand/" 413 kmodpat = kmodprefix ENVIRON["MACHINE"] 414 l_kmodpat = length(kmodpat) 415 kmoddbprefix = "./usr/libdata/debug/stand/" 416 kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] 417 l_kmoddbpat = length(kmoddbpat) 418 } 419 if ("debug" in wanted) { 420 debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug" 421 l_debugkernelname = length(debugkernelname); 422 } 423 424 if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { 425 if ("binutils" in wanted) 426 wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1 427 if ("gcc" in wanted) 428 wanted["gcc=" "'"${HAVE_GCC}"'"] = 1 429 if ("gdb" in wanted) 430 wanted["gdb=" "'"${HAVE_GDB}"'"] = 1 431 } 432 if ("acpi" in wanted) { 433 wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1 434 } 435 if ("mesa_ver" in wanted) { 436 wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1 437 } 438 if ("nvmm" in wanted) { 439 wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1 440 } 441 if ("openssl" in wanted) { 442 wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1 443 } 444 if ("xorg_server_ver" in wanted) { 445 wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1 446 } 447 if ("uefi" in wanted) { 448 wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1 449 } 450 if ("efi_rt" in wanted) { 451 wanted["efi_rt=" "'"${HAVE_EFI_RT}"'"] = 1 452 } 453 if (("man" in wanted) && ("catpages" in wanted)) 454 wanted[".cat"] = 1 455 if (("man" in wanted) && ("manpages" in wanted)) 456 wanted[".man"] = 1 457 if ("endian" in wanted) 458 wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1 459 if ("machine" in wanted) 460 wanted["machine=" "'"${MACHINE}"'"] = 1 461 if ("machine_arch" in wanted) 462 wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1 463 if ("machine_cpu" in wanted) 464 wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1 465 } 466 467 /^#/ { 468 next; 469 } 470 471 /^-/ { 472 notwanted[substr($1, 2)] = 1; 473 delete list [substr($1, 2)]; 474 next; 475 } 476 477 NF > 2 && $3 != "-" { 478 if (notwanted[$1] != "") 479 next; 480 split($3, keywords, ",") 481 show = 1 482 haveobs = 0 483 iscompatfile = 0 484 havekmod = 0 485 iscompatdir = 0 486 omitcompat = 0 487 takecompat[$1] = 0 488 for (ki in keywords) { 489 kw = keywords[ki] 490 if (("manz" in wanted) && 491 (kw == ".cat" || kw == ".man")) 492 $1 = $1 ".gz" 493 if (substr(kw, 1, 1) == "!") { 494 kw = substr(kw, 2) 495 if (kw in wanted) 496 show = 0 497 } else if (kw in compatdirkeywords) { 498 iscompatdir = 1 499 } else if (kw in compatfilekeywords) { 500 iscompatfile = 1 501 } else if (kw == "nocompatmodules") { 502 havekmod = -1 503 } else if (kw == "omitcompat") { 504 omitcompat = 1 505 } else if (kw ~ /^takecompat=/) { 506 takecompat[$1] = 1 507 takecompatarch[substr(kw, 508 1 + length("takecompat=")), $1] = 1 509 } else if (kw in ignoredkeywords) { 510 # ignore 511 } else if (! (kw in wanted)) { 512 show = 0 513 } else if (kw == "kmod" && havekmod == 0) { 514 havekmod = 1 515 } 516 if (kw == "obsolete") 517 haveobs = 1 518 } 519 520 if (takecompat[$1] && !(iscompatdir || iscompatfile)) { 521 next 522 } 523 if (iscompatdir && !omitcompat) { 524 for (d in cpaths) { 525 if (cpaths[d] == $1 "/") { 526 break 527 } 528 } 529 cpaths[ncpaths++] = $1 "/" 530 } 531 if (obsolete && ! haveobs) 532 next 533 if (!show) 534 next 535 if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname)) 536 next 537 538 list[$1] = $0 539 if (havekmod > 0) { 540 addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) 541 addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) 542 emit($1) 543 next 544 } 545 546 if (!doingcompat || !(iscompatfile || iscompatdir)) { 547 emit($1) 548 next 549 } 550 551 if (iscompatfile) { 552 if (omitcompat) { 553 emit($1) 554 } else if (takecompat[$1]) { 555 emitcompat[$1] = 1 556 } else { 557 emit($1) 558 emitcompat[$1] = 1 559 } 560 next 561 } 562 if (iscompatdir) { 563 if (omitcompat) { 564 # /lib in base 565 emit($1) 566 } else if (takecompat[$1]) { 567 # /lib in base32 568 # nothing to do 569 } else { 570 # /usr/include in comp 571 emit($1) 572 } 573 } else { 574 emit($1) 575 } 576 if (omitcompat) 577 next 578 for (d in compatarchdirs) { 579 if (takecompat[$1] && 580 !takecompatarch[compatarchdirs[d], $1]) 581 continue 582 tmp = $0 583 xfile = $1 "/" compatarchdirs[d] 584 tmp = xfile substr(tmp, length($1) + 1) 585 if (xfile in notwanted) 586 continue; 587 sub("compatdir","compat",tmp); 588 sub("compattestdir","compat",tmp); 589 list[xfile] = tmp 590 emit(xfile) 591 } 592 next 593 } 594 595 { 596 if ($1 in notwanted) 597 next; 598 if (! obsolete) { 599 list[$1] = $0 600 emit($1) 601 } 602 } 603 604 END { 605 for (i in list) { 606 if (i in emitf) 607 print list[i] 608 if (! (i in emitcompat)) 609 continue; 610 l_i = length(i) 611 l = 0 612 for (j in cpaths) { 613 lx = length(cpaths[j]) 614 if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) { 615 continue; 616 } 617 if (lx > l) { 618 l = lx; 619 cpath = cpaths[j]; 620 } 621 } 622 for (d in compatarchdirs) { 623 if (takecompat[$1] && 624 !takecompatarch[compatarchdirs[d], 625 i]) { 626 continue 627 } 628 tmp = list[i] 629 extrapath = compatarchdirs[d] "/" 630 xfile = cpath extrapath substr(i, l + 1) 631 if (xfile in notwanted) 632 continue; 633 sub("compatfile","compat",tmp); 634 sub("compattestfile","compat",tmp); 635 tmp = xfile substr(tmp, l_i + 1) 636 print tmp; 637 } 638 } 639 }' 640 641} 642 643# 644# list_set_lists setname 645# 646# Print to stdout a list of files, one filename per line, which 647# concatenate to create the packing list for setname. E.g., 648# 649# .../lists/base/mi 650# .../lists/base/rescue.mi 651# .../lists/base/md.i386 652# [...] 653# 654# For a given setname $set, the following files may be selected from 655# .../list/$set: 656# mi 657# mi.ext.* 658# ad.${MACHINE_ARCH} 659# (or) ad.${MACHINE_CPU} 660# ad.${MACHINE_CPU}.shl 661# md.${MACHINE}.${MACHINE_ARCH} 662# (or) md.${MACHINE} 663# stl.mi 664# stl.${stlib} 665# shl.mi 666# shl.mi.ext.* 667# shl.${shlib} 668# shl.${shlib}.ext.* 669# module.mi if ${module} != no 670# module.${MACHINE} if ${module} != no 671# module.ad.${MACHINE_ARCH} if ${module} != no 672# (or) module.ad.${MACHINE_CPU} if ${module} != no 673# rescue.shl 674# rescue.${MACHINE} 675# rescue.ad.${MACHINE_ARCH} 676# (or) rescue.ad.${MACHINE_CPU} 677# rescue.ad.${MACHINE_CPU}.shl 678# 679# Environment: 680# shlib 681# stlib 682# 683list_set_lists() 684{ 685 setname=$1 686 687 list_set_lists_mi $setname 688 list_set_lists_ad $setname 689 list_set_lists_md $setname 690 list_set_lists_stl $setname 691 list_set_lists_shl $setname 692 list_set_lists_module $setname 693 list_set_lists_rescue $setname 694 return 0 695} 696 697list_set_lists_mi() 698{ 699 setdir=$setsdir/lists/$1 700 # always exist! 701 echo $setdir/mi 702} 703 704list_set_lists_ad() 705{ 706 setdir=$setsdir/lists/$1 707 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 708 list_set_lists_common_ad $1 709} 710 711list_set_lists_md() 712{ 713 setdir=$setsdir/lists/$1 714 echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \ 715 echo_if_exist $setdir/md.${MACHINE} 716} 717 718list_set_lists_stl() 719{ 720 setdir=$setsdir/lists/$1 721 echo_if_exist $setdir/stl.mi 722 echo_if_exist $setdir/stl.${stlib} 723} 724 725list_set_lists_shl() 726{ 727 setdir=$setsdir/lists/$1 728 [ "$shlib" != "no" ] || return 729 echo_if_exist $setdir/shl.mi 730 echo_if_exist $setdir/shl.${shlib} 731} 732 733list_set_lists_module() 734{ 735 setdir=$setsdir/lists/$1 736 [ "$module" != "no" ] || return 737 echo_if_exist $setdir/module.mi 738 echo_if_exist $setdir/module.${MACHINE} 739 echo_if_exist $setdir/module.ad.${MACHINE} 740 echo_if_exist $setdir/module.md.${MACHINE} 741 # XXX module never has .shl 742 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 743 list_set_lists_common_ad $1 module 744} 745 746list_set_lists_rescue() 747{ 748 setdir=$setsdir/lists/$1 749 echo_if_exist $setdir/rescue.mi 750 echo_if_exist $setdir/rescue.${MACHINE} 751 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \ 752 list_set_lists_common_ad $1 rescue 753} 754 755list_set_lists_common_ad() 756{ 757 setdir=$setsdir/lists/$1; _prefix=$2 758 759 [ -n "$_prefix" ] && prefix="$_prefix". 760 761 # Prefer a <prefix>.ad.${MACHINE_ARCH} over a 762 # <prefix>.ad.${MACHINE_CPU}, since the arch- 763 # specific one will be more specific than the 764 # cpu-specific one. 765 echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \ 766 echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU} 767 [ "$shlib" != "no" ] && \ 768 echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl 769} 770 771echo_if_exist() 772{ 773 [ -f $1 ] && echo $1 774 return $? 775} 776 777echo_if_exist_foreach() 778{ 779 local _list=$1; shift 780 for _suffix in $@; do 781 echo_if_exist ${_list}.${_suffix} 782 done 783} 784 785print_set_lists() 786{ 787 for setname; do 788 list=$(list_set_lists $setname) 789 for l in $list; do 790 echo $l 791 if $verbose; then 792 echo >&2 "DEBUG: list_set_files: $l" 793 fi 794 done \ 795 | ${XARGS} ${SED} ${SUBST} \ 796 | case $setname in 797 base|debug) 798 awk ' 799 !/^#/ && !/^$/ { 800 print $1, $2, \ 801 ($3 ? $3"," : "")"omitcompat" 802 } 803 ' 804 ;; 805 *) cat 806 ;; 807 esac 808 809 case $setname in 810 base32|base64) 811 ursetname=base 812 ;; 813 debug32|debug64) 814 ursetname=debug 815 ;; 816 *) continue 817 ;; 818 esac 819 case $setname in 820 *32) compatarches=$compat32arches 821 ;; 822 *64) compatarches=$compat64arches 823 ;; 824 esac 825 list=$(list_set_lists $ursetname) 826 for l in $list; do 827 echo $l 828 if $verbose; then 829 echo >&2 "DEBUG: list_set_files: $l" 830 fi 831 done \ 832 | ${XARGS} ${SED} ${SUBST} \ 833 | awk -v compatarches="$compatarches" ' 834 BEGIN { 835 split(compatarches, compatarch, " ") 836 flags = "" 837 for (i in compatarch) 838 flags = (flags ? flags"," : "") \ 839 "takecompat="compatarch[i] 840 } 841 !/^#/ && !/^$/ { 842 print $1, $2, ($3 ? $3"," : "")flags 843 } 844 ' 845 done 846} 847 848 849list_kernel_configs() 850{ 851 (cd ${NETBSDSRCDIR}/etc 852 MAKEFLAGS= \ 853 ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}') 854} 855 856# arch_to_cpu mach 857# 858# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 859# as determined by <bsd.own.mk>. 860# 861arch_to_cpu() 862{ 863 MACHINE_ARCH=${1} MAKEFLAGS= \ 864 ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 865 -f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \ 866 -V '${MACHINE_CPU}' 867} 868 869# arch_to_endian mach 870# 871# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach, 872# as determined by <bsd.endian.mk>. 873# 874arch_to_endian() 875{ 876 MACHINE_ARCH=${1} MAKEFLAGS= \ 877 ${MAKE} -m ${NETBSDSRCDIR}/share/mk \ 878 -f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \ 879 -V '${TARGET_ENDIANNESS}' 880} 881 882##### 883 884# print_mkvars 885print_mkvars() 886{ 887 for v in $MKVARS; do 888 eval echo $v=\$$v 889 done 890} 891 892# print_set_lists_{base,x,ext} 893# list_set_lists_{base,x,ext} 894# list_set_files_{base,x,ext} 895for func in print_set_lists list_set_lists list_set_files; do 896 for x in base x ext; do 897 if [ $x = base ]; then 898 list=nlists 899 else 900 list=${x}lists 901 fi 902 eval ${func}_${x} \(\) \{ $func \$$list \; \} 903 done 904done 905