Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/config Added support for listing multiple additiona...



details:   https://anonhg.NetBSD.org/src/rev/801b1891d512
branches:  trunk
changeset: 510900:801b1891d512
user:      fredette <fredette%NetBSD.org@localhost>
date:      Fri Jun 08 12:47:06 2001 +0000

description:
Added support for listing multiple additional names on
a `machine' line.  For each of these subarches, its
arch/${SUBARCH}/conf/files.${SUBARCH} is included, and
a symlink ${SUBARCH} -> arch/${SUBARCH}/include is made.
This will for a "richer structure" and easier code
sharing under sys/arch.

diffstat:

 usr.sbin/config/config.h |   4 ++-
 usr.sbin/config/gram.y   |  50 ++++++++++++++++++++++++++++++++++++++---------
 usr.sbin/config/main.c   |  18 ++++++++++++++++-
 3 files changed, 60 insertions(+), 12 deletions(-)

diffs (183 lines):

diff -r 3827e76864ec -r 801b1891d512 usr.sbin/config/config.h
--- a/usr.sbin/config/config.h  Fri Jun 08 11:55:44 2001 +0000
+++ b/usr.sbin/config/config.h  Fri Jun 08 12:47:06 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.h,v 1.53 2001/05/18 07:48:07 minoura Exp $      */
+/*     $NetBSD: config.h,v 1.54 2001/06/08 12:47:06 fredette Exp $     */
 
 /*
  * Copyright (c) 1992, 1993
@@ -317,6 +317,8 @@
 const char *conffile;          /* source file, e.g., "GENERIC.sparc" */
 const char *machine;           /* machine type, e.g., "sparc" or "sun3" */
 const char *machinearch;       /* machine arch, e.g., "sparc" or "m68k" */
+struct nvlist *machinesubarches;
+                               /* machine subarches, e.g., "sun68k" or "hpc" */
 const char *srcdir;            /* path to source directory (rel. to build) */
 const char *builddir;          /* path to build directory */
 const char *defbuilddir;       /* default build directory */
diff -r 3827e76864ec -r 801b1891d512 usr.sbin/config/gram.y
--- a/usr.sbin/config/gram.y    Fri Jun 08 11:55:44 2001 +0000
+++ b/usr.sbin/config/gram.y    Fri Jun 08 12:47:06 2001 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.29 2000/10/02 19:48:34 cgd Exp $    */
+/*     $NetBSD: gram.y,v 1.30 2001/06/08 12:47:06 fredette Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -82,7 +82,7 @@
 #define        fx_or(e1, e2)   new0(NULL, NULL, e1, FX_OR, e2)
 
 static void    cleanup(void);
-static void    setmachine(const char *, const char *);
+static void    setmachine(const char *, const char *, struct nvlist *);
 static void    check_maxpart(void);
 
 static void    app(struct nvlist *, struct nvlist *);
@@ -108,6 +108,7 @@
 %token SOURCE TYPE WITH NEEDS_COUNT NEEDS_FLAG
 %token <val> NUMBER
 %token <str> PATHNAME WORD EMPTY
+%token ENDDEFS
 
 %left '|'
 %left '&'
@@ -139,6 +140,7 @@
 %type  <list>  defopts
 %type  <list>  defoptdeps
 %type  <str>   optfile_opt
+%type  <list>  subarches_opt subarches
 
 %%
 
@@ -154,9 +156,7 @@
 Configuration:
        topthings                       /* dirspecs, include "std.arch" */
        machine_spec                    /* "machine foo" from machine descr. */
-       dev_defs dev_eof                /* sys/conf/files */
-       dev_defs dev_eof                /* sys/arch/${MACHINE_ARCH}/... */
-       dev_defs dev_eof                /* sys/arch/${MACHINE}/... */
+       dev_defs ENDDEFS                /* all machine definition files */
                                        { check_maxpart(); }
        specs;                          /* rest of machine description */
 
@@ -171,12 +171,17 @@
        '\n';
 
 machine_spec:
-       XMACHINE WORD '\n'              { setmachine($2,NULL); } |
-       XMACHINE WORD WORD '\n'         { setmachine($2,$3); } |
+       XMACHINE WORD '\n'              { setmachine($2,NULL,NULL); } |
+       XMACHINE WORD WORD subarches_opt '\n'   { setmachine($2,$3,$4); } |
        error { stop("cannot proceed without machine specifier"); };
 
-dev_eof:
-       ENDFILE                         { enddefs(); checkfiles(); };
+subarches_opt:
+       subarches                       |
+       /* empty */                     { $$ = NULL; };
+
+subarches:
+       subarches WORD                  { $$ = new_nx($2, $1); } |
+       WORD                            { $$ = new_n($1); };
 
 /*
  * Various nonterminals shared between the grammars.
@@ -234,6 +239,7 @@
  */
 dev_defs:
        dev_defs dev_def |
+       dev_defs ENDFILE                { enddefs(); checkfiles(); } |
        /* empty */;
 
 dev_def:
@@ -502,17 +508,37 @@
 }
 
 static void
-setmachine(const char *mch, const char *mcharch)
+setmachine(const char *mch, const char *mcharch, struct nvlist *mchsubarches)
 {
        char buf[MAXPATHLEN];
+       struct nvlist *nv;
 
        machine = mch;
        machinearch = mcharch;
+       machinesubarches = mchsubarches;
 
+       /*
+        * Set up the file inclusion stack.  This empty include tells
+        * the parser there are no more device definitions coming.
+        */
+       strcpy(buf, _PATH_DEVNULL);
+       if (include(buf, ENDDEFS, 0) != 0)
+               exit(1);
+
+       /* Include arch/${MACHINE}/conf/files.${MACHINE} */
        (void)sprintf(buf, "arch/%s/conf/files.%s", machine, machine);
        if (include(buf, ENDFILE, 0) != 0)
                exit(1);
 
+       /* Include any arch/${MACHINE_SUBARCH}/conf/files.${MACHINE_SUBARCH} */
+       for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
+               (void)sprintf(buf, "arch/%s/conf/files.%s",
+                   nv->nv_name, nv->nv_name);
+               if (include(buf, ENDFILE, 0) != 0)
+                       exit(1);
+       }
+
+       /* Include any arch/${MACHINE_ARCH}/conf/files.${MACHINE_ARCH} */
        if (machinearch != NULL)
                (void)sprintf(buf, "arch/%s/conf/files.%s",
                    machinearch, machinearch);
@@ -521,6 +547,10 @@
        if (include(buf, ENDFILE, 0) != 0)
                exit(1);
 
+       /*
+        * Include the global conf/files.  As the last thing
+        * pushed on the stack, it will be processed first.
+        */
        if (include("conf/files", ENDFILE, 0) != 0)
                exit(1);
 }
diff -r 3827e76864ec -r 801b1891d512 usr.sbin/config/main.c
--- a/usr.sbin/config/main.c    Fri Jun 08 11:55:44 2001 +0000
+++ b/usr.sbin/config/main.c    Fri Jun 08 12:47:06 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.55 2001/02/21 00:03:43 cgd Exp $    */
+/*     $NetBSD: main.c,v 1.56 2001/06/08 12:47:06 fredette Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -326,6 +326,7 @@
        int ret;
        char *p, buf[MAXPATHLEN];
        const char *q;
+       struct nvlist *nv;
 
        sprintf(buf, "arch/%s/include", machine);
        p = sourcepath(buf);
@@ -357,6 +358,21 @@
                    q, p, strerror(errno));
        free(p);
 
+       for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
+               q = nv->nv_name;
+               sprintf(buf, "arch/%s/include", q);
+               p = sourcepath(buf);
+               ret = unlink(q);
+               if (ret && errno != ENOENT)
+                       (void)fprintf(stderr, "config: unlink(%s): %s\n",
+                           q, strerror(errno));
+               ret = symlink(p, q);
+               if (ret)
+                       (void)fprintf(stderr, "config: symlink(%s -> %s): %s\n",
+                       q, p, strerror(errno));
+               free(p);
+       }
+
        return (ret);
 }
 



Home | Main Index | Thread Index | Old Index