Module Name: src
Committed By: uebayasi
Date: Tue Sep 1 16:01:23 UTC 2015
Modified Files:
src/usr.bin/config: config.1 defs.h files.c main.c mkmakefile.c
Log Message:
Experimental ``suffix rules + subdirectories'' build support (-S).
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/config/config.1
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/config/defs.h
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/config/files.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/config/main.c
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/config/mkmakefile.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/config/config.1
diff -u src/usr.bin/config/config.1:1.18 src/usr.bin/config/config.1:1.19
--- src/usr.bin/config/config.1:1.18 Thu Jul 16 08:42:53 2015
+++ src/usr.bin/config/config.1 Tue Sep 1 16:01:23 2015
@@ -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 @@ is used to prepare a kernel build direct
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 .
Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.82 src/usr.bin/config/defs.h:1.83
--- src/usr.bin/config/defs.h:1.82 Tue Sep 1 13:45:52 2015
+++ src/usr.bin/config/defs.h Tue Sep 1 16:01:23 2015
@@ -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 @@ extern const char *progname;
* 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 @@ void emit_params(void);
/* main.c */
extern int Mflag;
+extern int Sflag;
void addoption(const char *, const char *);
void addfsoption(const char *);
void addmkoption(const char *, const char *);
Index: src/usr.bin/config/files.c
diff -u src/usr.bin/config/files.c:1.25 src/usr.bin/config/files.c:1.26
--- src/usr.bin/config/files.c:1.25 Tue Sep 1 13:42:48 2015
+++ src/usr.bin/config/files.c Tue Sep 1 16:01:23 2015
@@ -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 @@ fixfiles(void)
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) {
Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.83 src/usr.bin/config/main.c:1.84
--- src/usr.bin/config/main.c:1.83 Tue Sep 1 14:32:20 2015
+++ src/usr.bin/config/main.c Tue Sep 1 16:01:23 2015
@@ -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 vflag; /* verbose output */
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 @@ main(int argc, char **argv)
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 @@ main(int argc, char **argv)
srcdir = optarg;
break;
+ case 'S':
+ Sflag = 1;
+ break;
+
case 'x':
xflag = 1;
break;
@@ -645,8 +650,7 @@ mksubdirs(void)
const char *prefix, *sep;
char buf[MAXPATHLEN];
- // XXX notyet
- if (1)
+ if (!Sflag)
return 0;
TAILQ_FOREACH(fi, &allfiles, fi_next) {
Index: src/usr.bin/config/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.54 src/usr.bin/config/mkmakefile.c:1.55
--- src/usr.bin/config/mkmakefile.c:1.54 Tue Sep 1 12:10:56 2015
+++ src/usr.bin/config/mkmakefile.c Tue Sep 1 16:01:23 2015
@@ -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 @@ emitdefs(FILE *fp)
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 @@ emitdefs(FILE *fp)
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 @@ emitfiles(FILE *fp, struct filelist *fil
* 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 @@ emitfiles(FILE *fp, struct filelist *fil
fprintf(fp, "\t%s \\\n", swapname);
}
}
+ }
putc('\n', fp);
}
@@ -535,17 +544,26 @@ emitload(FILE *fp)
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);
}