[BACK]Return to sets.subr CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / distrib / sets

Annotation of src/distrib/sets/sets.subr, Revision 1.180

1.180   ! christos    1: #      $NetBSD: sets.subr,v 1.179 2017/02/08 18:21:23 christos Exp $
1.1       dyoung      2: #
1.9       lukem       3:
                      4: #
1.11      lukem       5: # The following variables contain defaults for sets.subr functions and callers:
1.9       lukem       6: #      setsdir                 path to src/distrib/sets
                      7: #      nlists                  list of base sets
                      8: #      xlists                  list of x11 sets
1.92      uebayasi    9: #      extlists                list of extsrc sets
1.9       lukem      10: #      obsolete                controls if obsolete files are selected instead
1.76      tsutsui    11: #      module                  if != "no", enable MODULE sets
1.9       lukem      12: #      shlib                   shared library format (a.out, elf, or "")
                     13: #      stlib                   static library format (a.out, elf)
1.11      lukem      14: #
                     15: # The following <bsd.own.mk> variables are exported to the environment:
                     16: #      MACHINE
                     17: #      MACHINE_ARCH
                     18: #      MACHINE_CPU
1.87      skrll      19: #      HAVE_BINUTILS
1.48      mrg        20: #      HAVE_GCC
1.52      lukem      21: #      HAVE_GDB
1.143     nakayama   22: #      HAVE_SSP
1.11      lukem      23: #      TOOLCHAIN_MISSING
                     24: #      OBJECT_FMT
1.22      lukem      25: # as well as:
                     26: #
1.95      uebayasi   27:
1.42      apb        28: #
                     29: # The following variables refer to tools that are used when building sets:
                     30: #
1.43      apb        31: : ${AWK:=awk}
1.42      apb        32: : ${CKSUM:=cksum}
1.43      apb        33: : ${COMM:=comm}
1.44      apb        34: : ${DATE:=date}
1.43      apb        35: : ${DB:=db}
                     36: : ${EGREP:=egrep}
                     37: : ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
1.44      apb        38: : ${FGREP:=fgrep}
1.43      apb        39: : ${FIND:=find}
1.44      apb        40: : ${GREP:=grep}
1.43      apb        41: : ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
1.99      apb        42: : ${HOSTNAME_CMD:=hostname}    # ${HOSTNAME} is special to bash(1)
1.42      apb        43: : ${HOST_SH:=sh}
1.43      apb        44: : ${IDENT:=ident}
                     45: : ${JOIN:=join}
                     46: : ${LS:=ls}
                     47: : ${MAKE:=make}
1.42      apb        48: : ${MKTEMP:=mktemp}
1.43      apb        49: : ${MTREE:=mtree}
                     50: : ${PASTE:=paste}
1.42      apb        51: : ${PAX:=pax}
1.43      apb        52: : ${PRINTF:=printf}
                     53: : ${SED:=sed}
                     54: : ${SORT:=sort}
1.44      apb        55: : ${STAT:=stat}
                     56: : ${TSORT:=tsort}
1.43      apb        57: : ${UNAME:=uname}
                     58: : ${WC:=wc}
1.118     uebayasi   59: : ${XARGS:=xargs}
1.43      apb        60:
1.45      apb        61: #
                     62: # If printf is a shell builtin command, then we can
                     63: # implement cheaper versions of basename and dirname
                     64: # that do not involve any fork/exec overhead.
                     65: # If printf is not builtin, approximate it using echo,
                     66: # and hope there are no weird file names that cause
                     67: # some versions of echo to do the wrong thing.
                     68: # (Converting to this version of dirname speeded up the
                     69: # syspkgdeps script by an order of magnitude, from 68
                     70: # seconds to 6.3 seconds on one particular host.)
                     71: #
                     72: # Note that naive approximations for dirname
                     73: # using ${foo%/*} do not do the right thing in cases
                     74: # where the result should be "/" or ".".
                     75: #
                     76: case "$(type printf)" in
                     77: *builtin*)
                     78:        basename ()
                     79:        {
                     80:                local bn
                     81:                bn="${1##*/}"
                     82:                bn="${bn%$2}"
                     83:                printf "%s\n" "$bn"
                     84:        }
                     85:        dirname ()
                     86:        {
                     87:                local dn
                     88:                case "$1" in
                     89:                ?*/*)   dn="${1%/*}" ;;
                     90:                /*)     dn=/ ;;
                     91:                *)      dn=. ;;
                     92:                esac
                     93:                printf "%s\n" "$dn"
                     94:        }
                     95:        ;;
                     96: *)
                     97:        basename ()
                     98:        {
                     99:                local bn
                    100:                bn="${1##*/}"
                    101:                bn="${bn%$2}"
                    102:                echo "$bn"
                    103:        }
                    104:        dirname ()
                    105:        {
                    106:                local dn
                    107:                case "$1" in
                    108:                ?*/*)   dn="${1%/*}" ;;
                    109:                /*)     dn=/ ;;
                    110:                *)      dn=. ;;
                    111:                esac
                    112:                echo "$dn"
                    113:        }
                    114:        ;;
                    115: esac
                    116:
1.108     uebayasi  117: #####
                    118:
1.9       lukem     119: oIFS=$IFS
                    120: IFS="
                    121: "
1.100     uebayasi  122:
1.180   ! christos  123: for x in $( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do
1.108     uebayasi  124:        eval export $x
1.9       lukem     125: done
1.100     uebayasi  126:
1.9       lukem     127: IFS=$oIFS
                    128:
1.180   ! christos  129: MKVARS="$( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )"
1.100     uebayasi  130:
1.105     uebayasi  131: #####
                    132:
1.117     uebayasi  133: setsdir=${rundir}
1.9       lukem     134: obsolete=0
1.91      dyoung    135: if [ "${MKKMOD}" = "no" ]; then
                    136:        module=no                       # MODULEs are off.
1.125     njoly     137:        modset=""
                    138: else
                    139:        module=yes
                    140:        modset="modules"
                    141: fi
                    142: if [ "${MKATF}" = "no" ]; then
                    143:        testset=""
                    144: else
                    145:        testset="tests"
1.9       lukem     146: fi
1.171     matt      147: if [ "${MKDEBUG}" = "no" -a "${MKDEBUGLIB}" = "no" ]; then
1.141     christos  148:        debugset=""
1.142     christos  149:        xdebugset=""
1.141     christos  150: else
                    151:        debugset="debug"
1.142     christos  152:        xdebugset="xdebug"
1.141     christos  153: fi
1.31      jmc       154: # Determine lib type. Do this first so stlib also gets set.
                    155: if [ "${OBJECT_FMT}" = "ELF" ]; then
1.9       lukem     156:        shlib=elf
                    157: else
                    158:        shlib=aout
                    159: fi
                    160: stlib=$shlib
1.31      jmc       161: # Now check for MKPIC or specials and turn off shlib if need be.
                    162: if [ "${MKPIC}" = "no" ]; then
                    163:        shlib=no
                    164: fi
1.141     christos  165: nlists="base comp $debugset etc games man misc $modset $testset text"
1.142     christos  166: xlists="xbase xcomp $xdebugset xetc xfont xserver"
1.92      uebayasi  167: extlists="extbase extcomp extetc"
1.9       lukem     168:
1.136     christos  169: OSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k)
1.81      rmind     170: MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
1.62      ad        171: SUBST="s#@MODULEDIR@#${MODULEDIR}#g"
                    172: SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
                    173: SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
1.60      ad        174:
1.9       lukem     175: #
                    176: # list_set_files setfile [...]
1.1       dyoung    177: #
1.9       lukem     178: # Produce a packing list for setfile(s).
                    179: # In each file, a record consists of a path and a System Package name,
                    180: # separated by whitespace. E.g.,
                    181: #
1.180   ! christos  182: #      # $NetBSD: sets.subr,v 1.179 2017/02/08 18:21:23 christos Exp $
1.9       lukem     183: #      .                       base-sys-root   [keyword[,...]]
                    184: #      ./altroot               base-sys-root
                    185: #      ./bin                   base-sys-root
                    186: #      ./bin/[                 base-util-root
                    187: #      ./bin/cat               base-util-root
                    188: #              [...]
                    189: #
                    190: # A # in the first column marks a comment.
                    191: #
                    192: # If ${obsolete} != 0, only entries with an "obsolete" keyword will
1.52      lukem     193: # be printed.  All other keywords must be present.
1.9       lukem     194: #
                    195: # The third field is an optional comma separated list of keywords to
                    196: # control if a record is printed; every keyword listed must be enabled
1.179     christos  197: # for the record to be printed. The list of all avalaible make variables
                    198: # that can be turned on or off can be found by running in this directory:
                    199: #
                    200: #      make -f mkvars.mk mkvarsyesno
                    201: #
                    202: # These MK<NAME> variables can be used as selectors in the sets as <name>.
                    203: #
                    204: # The following extra keywords are also available, listed by:
                    205: #
                    206: #      make -f mkvars.mk mkextravars
1.13      lukem     207: #
1.179     christos  208: # These are:
                    209: #    1. The HAVE_<name>:
                    210: #      ssp                     ${HAVE_SSP} != no
1.160     joerg     211: #      libgcc_eh               ${HAVE_LIBGCC_EH} != no
1.87      skrll     212: #      binutils=<n>            <n> = value of ${HAVE_BINUTILS}
1.52      lukem     213: #      gcc=<n>                 <n> = value of ${HAVE_GCC}
                    214: #      gdb=<n>                 <n> = value of ${HAVE_GDB}
1.177     mrg       215: #      xorg_server_ver=<n>     <n> = value of ${HAVE_XORG_SERVER_VER}
1.52      lukem     216: #
1.179     christos  217: #    2. The USE_<name>:
1.41      lukem     218: #      use_inet6               ${USE_INET6} != no
                    219: #      use_kerberos            ${USE_KERBEROS} != no
1.179     christos  220: #      use_ldap                ${USE_LDAP} != no
1.41      lukem     221: #      use_yp                  ${USE_YP} != no
                    222: #
1.179     christos  223: #    3. Finally:
                    224: #      dummy                   dummy entry (ignored)
                    225: #      obsolete                file is obsolete, and only printed if
                    226: #                              ${obsolete} != 0
                    227: #
                    228: #      solaris                 ${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no
                    229: #
                    230: #
                    231: #      endian=<n>              <n> = value of ${TARGET_ENDIANNESS}
                    232: #
                    233: #
1.22      lukem     234: #      .cat                    if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
                    235: #                                automatically append ".gz" to the filename
                    236: #
                    237: #      .man                    if ${MKMANZ} != "no" && ${MKMAN} != "no"
                    238: #                                automatically append ".gz" to the filename
1.1       dyoung    239: #
1.8       lukem     240: list_set_files()
                    241: {
1.83      apb       242:        if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
1.65      he        243:                verbose=false
                    244:        else
                    245:                verbose=true
                    246:        fi
1.116     uebayasi  247:        print_set_lists "$@" | \
1.43      apb       248:        ${AWK} -v obsolete=${obsolete} '
1.9       lukem     249:                BEGIN {
1.52      lukem     250:                        if (obsolete)
                    251:                                wanted["obsolete"] = 1
                    252:
1.100     uebayasi  253:                        split("'"${MKVARS}"'", needvars)
1.165     matt      254:                        doingcompat = 0
                    255:                        doingcompattests = 0
                    256:                        ignoredkeywords["compatdir"] = 1
                    257:                        ignoredkeywords["compatfile"] = 1
                    258:                        ignoredkeywords["compattestdir"] = 1
                    259:                        ignoredkeywords["compattestfile"] = 1
1.170     matt      260:                        ignoredkeywords["compatx11dir"] = 1
                    261:                        ignoredkeywords["compatx11file"] = 1
1.52      lukem     262:                        for (vi in needvars) {
                    263:                                nv = needvars[vi]
                    264:                                kw = tolower(nv)
                    265:                                sub(/^mk/, "", kw)
1.143     nakayama  266:                                sub(/^have_/, "", kw)
1.148     matt      267:                                sub(/^target_endianness/, "endian", kw)
1.167     matt      268:                                if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") {
1.165     matt      269:                                        wanted[kw] = 1
1.167     matt      270:                                }
1.166     matt      271:                        }
                    272:
1.167     matt      273:                        if ("compat" in wanted) {
1.166     matt      274:                                doingcompat = 1;
                    275:                                split("'"${COMPATARCHDIRS}"'", compatarchdirs, ",");
                    276:                                compatdirkeywords["compatdir"] = 1
                    277:                                compatfilekeywords["compatfile"] = 1
                    278:
                    279:                                if (wanted["compattests"]) {
1.165     matt      280:                                        doingcompattests = 1;
                    281:                                        compatdirkeywords["compattestdir"] = 1
                    282:                                        compatfilekeywords["compattestfile"] = 1
1.166     matt      283:                                }
1.170     matt      284:                                if (wanted["compatx11"]) {
                    285:                                        doingcompatx11 = 1;
                    286:                                        compatdirkeywords["compatx11dir"] = 1
                    287:                                        compatfilekeywords["compatx11file"] = 1
                    288:                                }
1.166     matt      289:                        }
                    290:
1.167     matt      291:                        if (("kmod" in wanted) && ("compatmodules" in wanted)) {
1.166     matt      292:                                split("'"${KMODARCHDIRS}"'", kmodarchdirs, ",");
                    293:                                kmodpat = "./stand/" ENVIRON["MACHINE"]
                    294:                                l_kmodpat = length(kmodpat)
1.52      lukem     295:                        }
                    296:
                    297:                        if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
1.90      dyoung    298:                                if ("binutils" in wanted)
                    299:                                        wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
                    300:                                if ("gcc" in wanted)
                    301:                                        wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
                    302:                                if ("gdb" in wanted)
                    303:                                        wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
1.9       lukem     304:                        }
1.178     mrg       305:                        if ("xorg_server_ver" in wanted) {
                    306:                                wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1
1.177     mrg       307:                        }
1.52      lukem     308:                        if (("man" in wanted) && ("catpages" in wanted))
                    309:                                wanted[".cat"] = 1
                    310:                        if (("man" in wanted) && ("manpages" in wanted))
                    311:                                wanted[".man"] = 1
1.148     matt      312:                        if ("endian" in wanted)
                    313:                                wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1
1.162     mrg       314:                        if ("machine" in wanted)
                    315:                                wanted["machine=" "'"${MACHINE}"'"] = 1
                    316:                        if ("machine_arch" in wanted)
                    317:                                wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1
                    318:                        if ("machine_cpu" in wanted)
                    319:                                wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1
1.9       lukem     320:                }
                    321:
                    322:                /^#/ {
                    323:                        next;
                    324:                }
                    325:
1.127     matt      326:                /^-/ {
                    327:                        notwanted[substr($1, 2)] = 1;
                    328:                        delete list [substr($1, 2)];
                    329:                        next;
                    330:                }
                    331:
                    332:
1.9       lukem     333:                NF > 2 && $3 != "-" {
1.127     matt      334:                        if (notwanted[$1] != "")
                    335:                                next;
1.9       lukem     336:                        split($3, keywords, ",")
                    337:                        show = 1
1.52      lukem     338:                        haveobs = 0
1.167     matt      339:                        iscompatfile = 0
1.165     matt      340:                        havekmod = 0
                    341:                        iscompatdir = 0
1.9       lukem     342:                        for (ki in keywords) {
                    343:                                kw = keywords[ki]
1.22      lukem     344:                                if (("manz" in wanted) &&
                    345:                                    (kw == ".cat" || kw == ".man"))
                    346:                                        $1 = $1 ".gz"
1.134     joerg     347:                                if (substr(kw, 1, 1) == "!") {
                    348:                                        kw = substr(kw, 2)
1.59      jmmv      349:                                        if (kw in wanted)
                    350:                                                show = 0
1.165     matt      351:                                } else if (kw in compatdirkeywords) {
                    352:                                        iscompatdir = 1
                    353:                                } else if (kw in compatfilekeywords) {
1.167     matt      354:                                        iscompatfile = 1
1.172     matt      355:                                } else if (kw == "nocompatmodules") {
                    356:                                        havekmod = -1
1.165     matt      357:                                } else if (kw in ignoredkeywords) {
                    358:                                        # ignore
1.167     matt      359:                                } else if (! (kw in wanted)) {
                    360:                                        show = 0
1.172     matt      361:                                } else if (kw == "kmod" && havekmod == 0) {
1.167     matt      362:                                        havekmod = 1
1.59      jmmv      363:                                }
1.52      lukem     364:                                if (kw == "obsolete")
                    365:                                        haveobs = 1
1.9       lukem     366:                        }
1.52      lukem     367:                        if (obsolete && ! haveobs)
                    368:                                next
1.165     matt      369:                        if (!show)
                    370:                                next
                    371:
                    372:                        list[$1] = $0
1.172     matt      373:                        if (havekmod > 0 && substr($1,1,l_kmodpat) == kmodpat) {
1.165     matt      374:                                for (d in kmodarchdirs) {
                    375:                                        xd = "./stand/" kmodarchdirs[d]
                    376:                                        xfile = xd substr($1, l_kmodpat+1)
                    377:                                        tmp = xd substr($0, l_kmodpat+1)
                    378:                                        list[xfile] = tmp;
                    379:                                }
                    380:                                next
                    381:                        }
                    382:
1.167     matt      383:                        if (!doingcompat || !(iscompatfile || iscompatdir))
1.165     matt      384:                                next
                    385:
1.167     matt      386:                        if (iscompatfile) {
1.165     matt      387:                                emitcompat[$1] = 1;
1.168     matt      388:                                next
                    389:                        }
                    390:                        for (d in cpaths) {
                    391:                                if (cpaths[d] == $1 "/")
                    392:                                        next
1.165     matt      393:                        }
                    394:                        cpaths[ncpaths++] = $1 "/"
                    395:                        for (d in compatarchdirs) {
                    396:                                tmp = $0
                    397:                                xfile = $1 "/" compatarchdirs[d]
                    398:                                tmp = xfile substr(tmp, length($1) + 1)
                    399:                                if (xfile in notwanted)
                    400:                                        continue;
                    401:                                sub("compatdir","compat",tmp);
                    402:                                sub("compattestdir","compat",tmp);
                    403:                                list[xfile] = tmp
                    404:                        }
1.9       lukem     405:                        next
                    406:                }
                    407:
                    408:                {
1.165     matt      409:                        if ($1 in notwanted)
1.127     matt      410:                                next;
1.9       lukem     411:                        if (! obsolete)
1.127     matt      412:                                list[$1] = $0
                    413:                }
                    414:
                    415:                END {
                    416:                        for (i in list) {
                    417:                                print list[i]
1.165     matt      418:                                if (! (i in emitcompat))
                    419:                                        continue;
                    420:                                l_i = length(i)
                    421:                                l = 0
                    422:                                for (j in cpaths) {
                    423:                                        lx = length(cpaths[j])
                    424:                                        if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) {
                    425:                                                continue;
                    426:                                        }
                    427:                                        if (lx > l) {
                    428:                                                l = lx;
                    429:                                                cpath = cpaths[j];
                    430:                                        }
                    431:                                }
                    432:                                for (d in compatarchdirs) {
                    433:                                        tmp = list[i]
                    434:                                        extrapath = compatarchdirs[d] "/"
                    435:                                        xfile = cpath extrapath substr(i, l + 1)
                    436:                                        if (xfile in notwanted)
                    437:                                                continue;
                    438:                                        sub("compatfile","compat",tmp);
                    439:                                        sub("compattestfile","compat",tmp);
                    440:                                        tmp = xfile substr(tmp, l_i + 1)
                    441:                                        print tmp;
                    442:                                }
1.127     matt      443:                        }
1.9       lukem     444:                }'
                    445:
1.1       dyoung    446: }
                    447:
                    448: #
                    449: # list_set_lists setname
                    450: #
                    451: # Print to stdout a list of files, one filename per line, which
                    452: # concatenate to create the packing list for setname. E.g.,
                    453: #
                    454: #      .../lists/base/mi
                    455: #      .../lists/base/rescue.mi
                    456: #      .../lists/base/md.i386
1.9       lukem     457: #              [...]
1.1       dyoung    458: #
1.9       lukem     459: # For a given setname $set, the following files may be selected from
                    460: # .../list/$set:
                    461: #      mi
1.92      uebayasi  462: #      mi.ext.*
1.11      lukem     463: #      ad.${MACHINE_ARCH}
                    464: # (or) ad.${MACHINE_CPU}
                    465: #      ad.${MACHINE_CPU}.shl
                    466: #      md.${MACHINE}.${MACHINE_ARCH}
                    467: # (or) md.${MACHINE}
1.9       lukem     468: #      stl.mi
1.92      uebayasi  469: #      stl.${stlib}
1.9       lukem     470: #      shl.mi
1.92      uebayasi  471: #      shl.mi.ext.*
                    472: #      shl.${shlib}
                    473: #      shl.${shlib}.ext.*
1.77      tsutsui   474: #      module.mi                       if ${module} != no
                    475: #      module.${MACHINE}               if ${module} != no
                    476: #      module.ad.${MACHINE_ARCH}       if ${module} != no
                    477: # (or) module.ad.${MACHINE_CPU}        if ${module} != no
1.9       lukem     478: #      rescue.shl
1.11      lukem     479: #      rescue.${MACHINE}
                    480: #      rescue.ad.${MACHINE_ARCH}
                    481: # (or) rescue.ad.${MACHINE_CPU}
                    482: #      rescue.ad.${MACHINE_CPU}.shl
1.1       dyoung    483: #
1.9       lukem     484: # Environment:
1.1       dyoung    485: #      shlib
                    486: #      stlib
                    487: #
1.8       lukem     488: list_set_lists()
                    489: {
1.1       dyoung    490:        setname=$1
                    491:
1.111     uebayasi  492:        list_set_lists_mi $setname
1.113     uebayasi  493:        list_set_lists_ad $setname
1.111     uebayasi  494:        list_set_lists_md $setname
                    495:        list_set_lists_stl $setname
1.113     uebayasi  496:        list_set_lists_shl $setname
                    497:        list_set_lists_module $setname
1.111     uebayasi  498:        list_set_lists_rescue $setname
1.117     uebayasi  499:        return 0
1.111     uebayasi  500: }
1.110     uebayasi  501:
1.111     uebayasi  502: list_set_lists_mi()
                    503: {
                    504:        setdir=$setsdir/lists/$1
1.113     uebayasi  505:        # always exist!
1.9       lukem     506:        echo $setdir/mi
1.111     uebayasi  507: }
1.110     uebayasi  508:
1.111     uebayasi  509: list_set_lists_ad()
                    510: {
                    511:        setdir=$setsdir/lists/$1
1.113     uebayasi  512:        [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
                    513:        list_set_lists_common_ad $1
1.111     uebayasi  514: }
1.110     uebayasi  515:
1.111     uebayasi  516: list_set_lists_md()
                    517: {
                    518:        setdir=$setsdir/lists/$1
1.110     uebayasi  519:        echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \
                    520:        echo_if_exist $setdir/md.${MACHINE}
1.111     uebayasi  521: }
1.110     uebayasi  522:
1.111     uebayasi  523: list_set_lists_stl()
                    524: {
                    525:        setdir=$setsdir/lists/$1
1.110     uebayasi  526:        echo_if_exist $setdir/stl.mi
                    527:        echo_if_exist $setdir/stl.${stlib}
1.111     uebayasi  528: }
1.110     uebayasi  529:
1.111     uebayasi  530: list_set_lists_shl()
                    531: {
                    532:        setdir=$setsdir/lists/$1
1.113     uebayasi  533:        [ "$shlib" != "no" ] || return
1.112     uebayasi  534:        echo_if_exist $setdir/shl.mi
                    535:        echo_if_exist $setdir/shl.${shlib}
1.111     uebayasi  536: }
1.110     uebayasi  537:
1.111     uebayasi  538: list_set_lists_module()
                    539: {
                    540:        setdir=$setsdir/lists/$1
1.113     uebayasi  541:        [ "$module" != "no" ] || return
1.112     uebayasi  542:        echo_if_exist $setdir/module.mi
                    543:        echo_if_exist $setdir/module.${MACHINE}
1.113     uebayasi  544:        # XXX module never has .shl
                    545:        [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
                    546:        list_set_lists_common_ad $1 module
1.111     uebayasi  547: }
1.1       dyoung    548:
1.111     uebayasi  549: list_set_lists_rescue()
                    550: {
                    551:        setdir=$setsdir/lists/$1
1.110     uebayasi  552:        echo_if_exist $setdir/rescue.mi
                    553:        echo_if_exist $setdir/rescue.${MACHINE}
1.113     uebayasi  554:        [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
                    555:        list_set_lists_common_ad $1 rescue
1.111     uebayasi  556: }
                    557:
1.113     uebayasi  558: list_set_lists_common_ad()
1.111     uebayasi  559: {
1.113     uebayasi  560:        setdir=$setsdir/lists/$1; _prefix=$2
                    561:
                    562:        [ -n "$_prefix" ] && prefix="$_prefix".
                    563:
                    564:        # Prefer a <prefix>.ad.${MACHINE_ARCH} over a
                    565:        # <prefix>.ad.${MACHINE_CPU}, since the arch-
1.112     uebayasi  566:        # specific one will be more specific than the
                    567:        # cpu-specific one.
1.113     uebayasi  568:        echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \
                    569:        echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}
                    570:        [ "$shlib" != "no" ] && \
                    571:        echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl
1.5       dyoung    572: }
                    573:
1.110     uebayasi  574: echo_if_exist()
                    575: {
                    576:        [ -f $1 ] && echo $1
                    577:        return $?
                    578: }
                    579:
                    580: echo_if_exist_foreach()
                    581: {
                    582:        local _list=$1; shift
                    583:        for _suffix in $@; do
                    584:                echo_if_exist ${_list}.${_suffix}
                    585:        done
                    586: }
                    587:
1.116     uebayasi  588: print_set_lists()
                    589: {
                    590:        for setname; do
1.136     christos  591:                list=$(list_set_lists $setname)
1.116     uebayasi  592:                for l in $list; do
                    593:                        echo $l
                    594:                        if $verbose; then
                    595:                                echo >&2 "DEBUG: list_set_files: $l"
                    596:                        fi
                    597:                done
1.118     uebayasi  598:        done | ${XARGS} ${SED} ${SUBST}
1.116     uebayasi  599: }
                    600:
1.9       lukem     601: # arch_to_cpu mach
                    602: #
1.11      lukem     603: # Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
1.9       lukem     604: # as determined by <bsd.own.mk>.
                    605: #
1.8       lukem     606: arch_to_cpu()
                    607: {
1.180   ! christos  608:        MAKEVERBOSE= MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
1.5       dyoung    609: .include <bsd.own.mk>
                    610: all:
                    611:        @echo \${MACHINE_CPU}
1.12      lukem     612: EOMAKE
1.1       dyoung    613: }
1.46      apb       614:
                    615: # arch_to_endian mach
                    616: #
                    617: # Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
                    618: # as determined by <bsd.endian.mk>.
                    619: #
                    620: arch_to_endian()
                    621: {
1.180   ! christos  622:        MAKEVERBOSE= MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
1.46      apb       623: .include <bsd.endian.mk>
                    624: all:
                    625:        @echo \${TARGET_ENDIANNESS}
                    626: EOMAKE
                    627: }
1.117     uebayasi  628:
                    629: #####
                    630:
                    631: # print_mkvars
                    632: print_mkvars()
                    633: {
                    634:        for v in $MKVARS; do
                    635:                eval echo $v=\$$v
                    636:        done
                    637: }
                    638:
                    639: # print_set_lists_{base,x,ext}
                    640: # list_set_lists_{base,x,ext}
                    641: # list_set_files_{base,x,ext}
                    642: for func in print_set_lists list_set_lists list_set_files; do
                    643:        for x in base x ext; do
                    644:                if [ $x = base ]; then
                    645:                        list=nlists
                    646:                else
                    647:                        list=${x}lists
                    648:                fi
                    649:                eval ${func}_${x} \(\) \{ $func \$$list \; \}
                    650:        done
                    651: done

CVSweb <webmaster@jp.NetBSD.org>