Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config Experimental ``suffix rules + subdirectories'...



details:   https://anonhg.NetBSD.org/src/rev/930795fbac20
branches:  trunk
changeset: 340365:930795fbac20
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Tue Sep 01 16:01:23 2015 +0000

description:
Experimental ``suffix rules + subdirectories'' build support (-S).

diffstat:

 usr.bin/config/config.1     |   8 +++++---
 usr.bin/config/defs.h       |   5 +++--
 usr.bin/config/files.c      |  17 +++++++++++++++--
 usr.bin/config/main.c       |  14 +++++++++-----
 usr.bin/config/mkmakefile.c |  32 +++++++++++++++++++++++++-------
 5 files changed, 57 insertions(+), 19 deletions(-)

diffs (248 lines):

diff -r 83bc211cba61 -r 930795fbac20 usr.bin/config/config.1
--- a/usr.bin/config/config.1   Tue Sep 01 14:32:20 2015 +0000
+++ b/usr.bin/config/config.1   Tue Sep 01 16:01:23 2015 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: config.1,v 1.18 2015/07/16 08:42:53 dholland Exp $
+.\"    $NetBSD: config.1,v 1.19 2015/09/01 16:01:23 uebayasi Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     from: @(#)config.8     8.2 (Berkeley) 4/19/94
 .\"
-.Dd July 16, 2015
+.Dd September 1, 2015
 .Dt CONFIG 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd build kernel compilation directories
 .Sh SYNOPSIS
 .Nm
-.Op Fl dMPpv
+.Op Fl dMPpSv
 .Op Fl b Ar builddir
 .Op Fl D Ar var=value
 .Op Fl s Ar srcdir
@@ -151,6 +151,8 @@
 when it is used in combination with the
 .Fl L
 flag.
+.It Fl S
+Use suffix rules and build objects under subdirectories (experimental).
 .It Fl U Ar var
 Undefine the makeoption
 .Ar var .
diff -r 83bc211cba61 -r 930795fbac20 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Tue Sep 01 14:32:20 2015 +0000
+++ b/usr.bin/config/defs.h     Tue Sep 01 16:01:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.82 2015/09/01 13:45:52 uebayasi Exp $       */
+/*     $NetBSD: defs.h,v 1.83 2015/09/01 16:01:23 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION         20150835
+#define CONFIG_VERSION         20150840
 #define CONFIG_MINVERSION      0
 
 /*
@@ -556,6 +556,7 @@
 
 /* main.c */
 extern int Mflag;
+extern int Sflag;
 void   addoption(const char *, const char *);
 void   addfsoption(const char *);
 void   addmkoption(const char *, const char *);
diff -r 83bc211cba61 -r 930795fbac20 usr.bin/config/files.c
--- a/usr.bin/config/files.c    Tue Sep 01 14:32:20 2015 +0000
+++ b/usr.bin/config/files.c    Tue Sep 01 16:01:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: files.c,v 1.25 2015/09/01 13:42:48 uebayasi Exp $      */
+/*     $NetBSD: files.c,v 1.26 2015/09/01 16:01:23 uebayasi Exp $      */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: files.c,v 1.25 2015/09/01 13:42:48 uebayasi Exp $");
+__RCSID("$NetBSD: files.c,v 1.26 2015/09/01 16:01:23 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -274,6 +274,19 @@
        struct nvlist *flathead, **flatp;
        int err, sel;
 
+       if (Sflag) {
+               struct config *cf;
+               char swapname[100];
+
+               addfile("devsw.c", NULL, 0, NULL);
+               addfile("ioconf.c", NULL, 0, NULL);
+               TAILQ_FOREACH(cf, &allcf, cf_next) {
+                       (void)snprintf(swapname, sizeof(swapname), "swap%s.c",
+                           cf->cf_name);
+                       addfile(intern(swapname), NULL, 0, NULL);
+               }
+       }
+
        err = 0;
        TAILQ_FOREACH(fi, &allfiles, fi_next) {
 
diff -r 83bc211cba61 -r 930795fbac20 usr.bin/config/main.c
--- a/usr.bin/config/main.c     Tue Sep 01 14:32:20 2015 +0000
+++ b/usr.bin/config/main.c     Tue Sep 01 16:01:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.83 2015/09/01 14:32:20 uebayasi Exp $       */
+/*     $NetBSD: main.c,v 1.84 2015/09/01 16:01:23 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.83 2015/09/01 14:32:20 uebayasi Exp $");
+__RCSID("$NetBSD: main.c,v 1.84 2015/09/01 16:01:23 uebayasi Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include <sys/cdefs.h>
@@ -90,6 +90,7 @@
 int    Pflag;                          /* pack locators */
 int    Lflag;                          /* lint config generation */
 int    Mflag;                          /* modular build */
+int    Sflag;                          /* suffix rules & subdirectory */
 int    handling_cmdlineopts;           /* currently processing -D/-U options */
 
 int    yyparse(void);
@@ -168,7 +169,7 @@
 
        pflag = 0;
        xflag = 0;
-       while ((ch = getopt(argc, argv, "D:LMPU:dgpvb:s:x")) != -1) {
+       while ((ch = getopt(argc, argv, "D:LMPSU:dgpvb:s:x")) != -1) {
                switch (ch) {
 
                case 'd':
@@ -227,6 +228,10 @@
                        srcdir = optarg;
                        break;
 
+               case 'S':
+                       Sflag = 1;
+                       break;
+
                case 'x':
                        xflag = 1;
                        break;
@@ -645,8 +650,7 @@
        const char *prefix, *sep;
        char buf[MAXPATHLEN];
 
-       // XXX notyet
-       if (1)
+       if (!Sflag)
                return 0;
 
        TAILQ_FOREACH(fi, &allfiles, fi_next) {
diff -r 83bc211cba61 -r 930795fbac20 usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c       Tue Sep 01 14:32:20 2015 +0000
+++ b/usr.bin/config/mkmakefile.c       Tue Sep 01 16:01:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkmakefile.c,v 1.54 2015/09/01 12:10:56 uebayasi Exp $ */
+/*     $NetBSD: mkmakefile.c,v 1.55 2015/09/01 16:01:23 uebayasi Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkmakefile.c,v 1.54 2015/09/01 12:10:56 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.55 2015/09/01 16:01:23 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -287,6 +287,10 @@
                subdir = "./";
        }
        fprintf(fp, "S=\t%s%s\n", subdir, srcdir);
+       if (Sflag) {
+               fprintf(fp, ".PATH: $S\n");
+               fprintf(fp, "___USE_SUFFIX_RULES___=1\n");
+       }
        for (nv = mkoptions; nv != NULL; nv = nv->nv_next)
                fprintf(fp, "%s=%s\n", nv->nv_name, nv->nv_str);
 }
@@ -294,11 +298,14 @@
 static void
 emitfile(FILE *fp, struct files *fi)
 {
+       const char *srcdir = "$S/";
        const char *prologue, *prefix, *sep;
 
+       if (Sflag)
+               srcdir = "";
        prologue = prefix = sep = "";
        if (*fi->fi_path != '/') {
-               prologue = "$S/";
+               prologue = srcdir;
                if (fi->fi_prefix != NULL) {
                        if (*fi->fi_prefix == '/')
                                prologue = "";
@@ -475,6 +482,7 @@
         * C source files.  These files should be eliminated someday, but
         * for now, we have to add them to ${CFILES} (and only ${CFILES}).
         */
+       if (!Sflag) {
        if (suffix == 'c') {
                TAILQ_FOREACH(cf, &allcf, cf_next) {
                        (void)snprintf(swapname, sizeof(swapname), "swap%s.c",
@@ -482,6 +490,7 @@
                        fprintf(fp, "\t%s \\\n", swapname);
                }
        }
+       }
        putc('\n', fp);
 }
 
@@ -535,17 +544,26 @@
        if (has_build_kernel == 0) {
                fprintf(fp, "build_kernel: .USE\n"
                    "\t${SYSTEM_LD_HEAD}\n"
-                   "\t${SYSTEM_LD} swap${.TARGET}.o\n"
+                   "\t${SYSTEM_LD}%s\n"
                    "\t${SYSTEM_LD_TAIL}\n"
-                   "\n");
+                   "\n",
+                   Sflag ? "" : " swap${.TARGET}.o");
        }
        /*
         * Generate per-kernel rules.
         */
        TAILQ_FOREACH(cf, &allcf, cf_next) {
+               char swapobj[100];
+
+               if (Sflag) {
+                       swapobj[0] = '\0';
+               } else {
+                       (void)snprintf(swapobj, sizeof(swapobj), " swap%s.o",
+                           cf->cf_name);
+               }
                fprintf(fp, "KERNELS+=%s\n", cf->cf_name);
-               fprintf(fp, "%s: ${SYSTEM_DEP} swap%s.o vers.o build_kernel\n",
-                   cf->cf_name, cf->cf_name);
+               fprintf(fp, "%s: ${SYSTEM_DEP}%s vers.o build_kernel\n",
+                   cf->cf_name, swapobj);
        }
        fputs("\n", fp);
 }



Home | Main Index | Thread Index | Old Index