Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/sets Using archdirs.mk in compat, automagically gene...



details:   https://anonhg.NetBSD.org/src/rev/42dde9cd1e39
branches:  trunk
changeset: 809149:42dde9cd1e39
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Jun 22 05:59:59 2015 +0000

description:
Using archdirs.mk in compat, automagically generate compat entries for
files tagged with compatfile relative to directories tagged with compatdir.
This also applies to compattestsdirs and compattestsfile when
MKCOMPAT != "no" and MKCOMPATTESTS != "no".
Using archdirs.mk in sys/modules/arch, set list entries are automatically
create for all the other defined variants in ARCHDIR_SUBDIR (if any).
This should cut down on set lists getting out-of-sync a lot.

diffstat:

 distrib/sets/mkvars.mk |   23 ++++++++++-
 distrib/sets/sets.subr |  101 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 116 insertions(+), 8 deletions(-)

diffs (231 lines):

diff -r 33879d901991 -r 42dde9cd1e39 distrib/sets/mkvars.mk
--- a/distrib/sets/mkvars.mk    Mon Jun 22 03:57:01 2015 +0000
+++ b/distrib/sets/mkvars.mk    Mon Jun 22 05:59:59 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mkvars.mk,v 1.18 2015/05/28 14:36:44 rjs Exp $
+# $NetBSD: mkvars.mk,v 1.19 2015/06/22 05:59:59 matt Exp $
 
 MKEXTRAVARS= \
        MACHINE \
@@ -14,6 +14,7 @@
        MKMANZ \
        MKBFD \
        MKCOMPAT \
+       MKCOMPATTESTS \
        MKCOMPATMODULES \
        MKDYNAMICROOT \
        MKMANPAGES \
@@ -31,7 +32,9 @@
        MAKEVERBOSE \
        TARGET_ENDIANNESS \
        EABI \
-       ARCH64
+       ARCH64 \
+       COMPATARCHDIRS \
+       KMODARCHDIRS
 
 #####
 
@@ -44,6 +47,16 @@
 MKMANPAGES=yes
 .endif
 
+.if ${MKCOMPAT} != "no"
+.include "${NETBSDSRCDIR}/compat/archdirs.mk"
+COMPATARCHDIRS:=${ARCHDIR_SUBDIR:T}
+.endif
+
+.if ${MKKMOD} != "no"
+.include "${NETBSDSRCDIR}/sys/modules/arch/archdirs.mk"
+KMODARCHDIRS:=${ARCHDIR_SUBDIR:T}
+.endif
+
 .if ${MKX11} != "no"
 . if ${X11FLAVOUR} == "Xorg"
 MKXORG:=yes
@@ -81,6 +94,12 @@
 .for i in ${MKEXTRAVARS}
        @echo $i="${$i}"
 .endfor
+.if ${MKCOMPAT} != "no"
+       @echo COMPATARCHDIRS=${COMPATARCHDIRS} | ${TOOL_SED} -e's/ /,/'
+.endif
+.if ${MKKMOD} != "no"
+       @echo KMODARCHDIRS=${KMODARCHDIRS} | ${TOOL_SED} -e's/ /,/'
+.endif
 
 mksolaris: .PHONY
 .if (${MKDTRACE} != "no" || ${MKZFS} != "no")
diff -r 33879d901991 -r 42dde9cd1e39 distrib/sets/sets.subr
--- a/distrib/sets/sets.subr    Mon Jun 22 03:57:01 2015 +0000
+++ b/distrib/sets/sets.subr    Mon Jun 22 05:59:59 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: sets.subr,v 1.164 2015/05/28 14:36:44 rjs Exp $
+#      $NetBSD: sets.subr,v 1.165 2015/06/22 05:59:59 matt Exp $
 #
 
 #
@@ -179,7 +179,7 @@
 # In each file, a record consists of a path and a System Package name,
 # separated by whitespace. E.g.,
 #
-#      # $NetBSD: sets.subr,v 1.164 2015/05/28 14:36:44 rjs Exp $
+#      # $NetBSD: sets.subr,v 1.165 2015/06/22 05:59:59 matt Exp $
 #      .                       base-sys-root   [keyword[,...]]
 #      ./altroot               base-sys-root
 #      ./bin                   base-sys-root
@@ -206,6 +206,7 @@
 #      catpages                ${MKCATPAGES} != no
 #      compat                  ${MKCOMPAT} != no
 #      compatmodules           ${MKCOMPATMODULES} != no
+#      compattests             ${MKCOMPATTESTS} != no
 #      crypto                  ${MKCRYPTO} != no
 #      crypto_rc5              ${MKCRYPTO_RC5} != no
 #      cvs                     ${MKCVS} != no
@@ -291,17 +292,39 @@
        print_set_lists "$@" | \
        ${AWK} -v obsolete=${obsolete} '
                BEGIN {
+                       x="tmp.out"
                        if (obsolete)
                                wanted["obsolete"] = 1
                
                        split("'"${MKVARS}"'", needvars)
+                       doingcompat = 0
+                       doingcompattests = 0
+                       ignoredkeywords["compatdir"] = 1
+                       ignoredkeywords["compatfile"] = 1
+                       ignoredkeywords["compattestdir"] = 1
+                       ignoredkeywords["compattestfile"] = 1
                        for (vi in needvars) {
                                nv = needvars[vi]
                                kw = tolower(nv)
                                sub(/^mk/, "", kw)
                                sub(/^have_/, "", kw)
                                sub(/^target_endianness/, "endian", kw)
-                               if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no")
+                               if (kw == "compat" && ENVIRON[nv] != "no") {
+                                       doingcompat = 1;
+                                       split("'"${COMPATARCHDIRS}"'", compatarchdirs, ",");
+                                       wanted[kw] = 1 
+                                       compatdirkeywords["compatdir"] = 1
+                                       compatfilekeywords["compatfile"] = 1
+                               } else if (kw == "compattests" && ENVIRON[nv] != "no") {
+                                       doingcompattests = 1;
+                                       compatdirkeywords["compattestdir"] = 1
+                                       compatfilekeywords["compattestfile"] = 1
+                               } else if (kw == "kmod" && ENVIRON[nv] != "no") {
+                                       split("'"${KMODARCHDIRS}"'", kmodarchdirs, ",");
+                                       wanted[kw] = 1
+                                       kmodpat = "./stand/" ENVIRON["MACHINE"]
+                                       l_kmodpat = length(kmodpat)
+                               } else if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATDIRS" && nv != "MODULEARCHDIRS")
                                        wanted[kw] = 1 
                        }
 
@@ -344,6 +367,9 @@
                        split($3, keywords, ",")
                        show = 1
                        haveobs = 0
+                       havecompat = 0
+                       havekmod = 0
+                       iscompatdir = 0
                        for (ki in keywords) {
                                kw = keywords[ki]
                                if (("manz" in wanted) &&
@@ -353,22 +379,60 @@
                                        kw = substr(kw, 2)
                                        if (kw in wanted)
                                                show = 0
+                               } else if (kw in compatdirkeywords) {
+                                       iscompatdir = 1
+                               } else if (kw in compatfilekeywords) {
+                                       havecompat = 1
+                               } else if (kw in ignoredkeywords) {
+                                       # ignore
                                } else {
                                        if (! (kw in wanted))
                                                show = 0
+                                       else if (kw == "kmod")
+                                               havekmod = 1
                                }
                                if (kw == "obsolete")
                                        haveobs = 1
                        }
                        if (obsolete && ! haveobs)
                                next
-                       if (show)
-                               list[$1] = $0
+                       if (!show)
+                               next
+
+                       list[$1] = $0
+                       if (havekmod && substr($1,1,l_kmodpat) == kmodpat) {
+                               for (d in kmodarchdirs) {
+                                       xd = "./stand/" kmodarchdirs[d]
+                                       xfile = xd substr($1, l_kmodpat+1)
+                                       tmp = xd substr($0, l_kmodpat+1)
+                                       list[xfile] = tmp;
+                               }
+                               next
+                       }
+
+                       if (!doingcompat || !(havecompat || iscompatdir))
+                               next
+
+                       if (havecompat) {
+                               emitcompat[$1] = 1;
+                               next;
+                       }
+                       cpaths[ncpaths++] = $1 "/"
+                       for (d in compatarchdirs) {
+                               tmp = $0
+                               xfile = $1 "/" compatarchdirs[d]
+                               tmp = xfile substr(tmp, length($1) + 1)
+                               if (xfile in notwanted)
+                                       continue;
+                               sub("compatdir","compat",tmp);
+                               sub("compattestdir","compat",tmp);
+                               list[xfile] = tmp
+                       }
                        next
                }
 
                {
-                       if (notwanted[$1] != "")
+                       if ($1 in notwanted)
                                next;
                        if (! obsolete)
                                list[$1] = $0
@@ -377,6 +441,31 @@
                END {
                        for (i in list) {
                                print list[i]
+                               if (! (i in emitcompat))
+                                       continue;
+                               l_i = length(i)
+                               l = 0
+                               for (j in cpaths) {
+                                       lx = length(cpaths[j])
+                                       if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) {
+                                               continue;
+                                       }
+                                       if (lx > l) {
+                                               l = lx;
+                                               cpath = cpaths[j];
+                                       }
+                               }
+                               for (d in compatarchdirs) {
+                                       tmp = list[i]
+                                       extrapath = compatarchdirs[d] "/"
+                                       xfile = cpath extrapath substr(i, l + 1)
+                                       if (xfile in notwanted)
+                                               continue;
+                                       sub("compatfile","compat",tmp);
+                                       sub("compattestfile","compat",tmp);
+                                       tmp = xfile substr(tmp, l_i + 1)
+                                       print tmp;
+                               }
                        }
                }'
 



Home | Main Index | Thread Index | Old Index