Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config In `-S' mode, generate *.c files under conf/ ...
details: https://anonhg.NetBSD.org/src/rev/c11f34282ef9
branches: trunk
changeset: 340373:c11f34282ef9
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Wed Sep 02 05:09:25 2015 +0000
description:
In `-S' mode, generate *.c files under conf/ subdirectory. Register generated
.c files to the `files' list internally.
diffstat:
usr.bin/config/defs.h | 4 +++-
usr.bin/config/files.c | 12 +++++++-----
usr.bin/config/main.c | 22 ++++++++++++++++------
usr.bin/config/mkdevsw.c | 17 +++++++++++------
usr.bin/config/mkheaders.c | 12 +++++++++---
usr.bin/config/mkioconf.c | 16 +++++++++++-----
usr.bin/config/mkswap.c | 12 ++++++++----
7 files changed, 65 insertions(+), 30 deletions(-)
diffs (truncated from 341 to 300 lines):
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/defs.h Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.83 2015/09/01 16:01:23 uebayasi Exp $ */
+/* $NetBSD: defs.h,v 1.84 2015/09/02 05:09:25 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -433,6 +433,8 @@
const char *ioconfname; /* ioconf name, mutually exclusive to machine */
const char *srcdir; /* path to source directory (rel. to build) */
const char *builddir; /* path to build directory */
+int builddirfd; /* dir fd of builddir */
+int buildconfdirfd; /* dir fd of builddir/conf */
const char *defbuilddir; /* default build directory */
const char *ident; /* kernel "ident"ification string */
int errors; /* counts calls to error() */
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/files.c
--- a/usr.bin/config/files.c Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/files.c Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: files.c,v 1.26 2015/09/01 16:01:23 uebayasi Exp $ */
+/* $NetBSD: files.c,v 1.27 2015/09/02 05:09:25 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: files.c,v 1.26 2015/09/01 16:01:23 uebayasi Exp $");
+__RCSID("$NetBSD: files.c,v 1.27 2015/09/02 05:09:25 uebayasi Exp $");
#include <sys/param.h>
#include <errno.h>
@@ -278,13 +278,15 @@
struct config *cf;
char swapname[100];
- addfile("devsw.c", NULL, 0, NULL);
- addfile("ioconf.c", NULL, 0, NULL);
+ buildprefix_push("conf");
+ addfile("conf/devsw.c", NULL, 0, NULL);
+ addfile("conf/ioconf.c", NULL, 0, NULL);
TAILQ_FOREACH(cf, &allcf, cf_next) {
- (void)snprintf(swapname, sizeof(swapname), "swap%s.c",
+ (void)snprintf(swapname, sizeof(swapname), "conf/swap%s.c",
cf->cf_name);
addfile(intern(swapname), NULL, 0, NULL);
}
+ buildprefix_pop();
}
err = 0;
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/main.c
--- a/usr.bin/config/main.c Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/main.c Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.84 2015/09/01 16:01:23 uebayasi Exp $ */
+/* $NetBSD: main.c,v 1.85 2015/09/02 05:09:25 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.84 2015/09/01 16:01:23 uebayasi Exp $");
+__RCSID("$NetBSD: main.c,v 1.85 2015/09/02 05:09:25 uebayasi Exp $");
#ifndef MAKE_BOOTSTRAP
#include <sys/cdefs.h>
@@ -100,6 +100,8 @@
#endif
int dflag;
+static const char *buildconfdir = ".";
+
static struct dlhash *obsopttab;
static struct hashtab *mkopttab;
static struct nvlist **nextopt;
@@ -522,11 +524,15 @@
/*
* Ready to go. Build all the various files.
*/
- if (mksubdirs() || mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
+ if ((Sflag && mksubdirs()) || mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
mkioconf() || (do_devsw ? mkdevsw() : 0) || mkident() || errors)
stop();
(void)printf("Build directory is %s\n", builddir);
(void)printf("Don't forget to run \"make depend\"\n");
+
+ close(buildconfdirfd);
+ close(builddirfd);
+
return 0;
}
@@ -650,9 +656,6 @@
const char *prefix, *sep;
char buf[MAXPATHLEN];
- if (!Sflag)
- return 0;
-
TAILQ_FOREACH(fi, &allfiles, fi_next) {
if ((fi->fi_flags & FI_SEL) == 0)
continue;
@@ -672,6 +675,8 @@
mksubdir(buf);
}
+ buildconfdir = "conf";
+
return 0;
}
@@ -689,6 +694,9 @@
p = buf;
+ if ((buildconfdirfd = open(buildconfdir, O_RDONLY)) == -1)
+ errx(EXIT_FAILURE, "cannot opens %s", buildconfdir);
+
snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, machine);
ret = recreate(p, "machine");
ret = recreate(p, machine);
@@ -1464,6 +1472,8 @@
errx(EXIT_FAILURE, "cannot create %s", builddir);
} else if (!S_ISDIR(st.st_mode))
errx(EXIT_FAILURE, "%s is not a directory", builddir);
+ if ((builddirfd = open(builddir, O_RDONLY)) == -1)
+ errx(EXIT_FAILURE, "cannot opens %s", builddir);
if (chdir(builddir) == -1)
err(EXIT_FAILURE, "cannot change to %s", builddir);
if (stat(srcdir, &st) == -1)
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/mkdevsw.c
--- a/usr.bin/config/mkdevsw.c Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/mkdevsw.c Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkdevsw.c,v 1.12 2014/11/10 21:13:04 christos Exp $ */
+/* $NetBSD: mkdevsw.c,v 1.13 2015/09/02 05:09:25 uebayasi Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkdevsw.c,v 1.12 2014/11/10 21:13:04 christos Exp $");
+__RCSID("$NetBSD: mkdevsw.c,v 1.13 2015/09/02 05:09:25 uebayasi Exp $");
#include <stdio.h>
#include <string.h>
@@ -53,9 +53,10 @@
{
FILE *fp;
+ fchdir(buildconfdirfd);
if ((fp = fopen("devsw.c.tmp", "w")) == NULL) {
warn("cannot create devsw.c");
- return (1);
+ goto err;
}
emitheader(fp);
@@ -67,17 +68,21 @@
if (ferror(fp)) {
warn("error writing devsw.c");
fclose(fp);
- return 1;
+ goto err;
}
(void)fclose(fp);
if (moveifchanged("devsw.c.tmp", "devsw.c") != 0) {
warn("error renaming devsw.c");
- return (1);
+ goto err;
}
+ fchdir(builddirfd);
+ return (0);
- return (0);
+err:
+ fchdir(builddirfd);
+ return (1);
}
static void
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/mkheaders.c
--- a/usr.bin/config/mkheaders.c Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/mkheaders.c Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkheaders.c,v 1.27 2015/08/20 09:44:24 christos Exp $ */
+/* $NetBSD: mkheaders.c,v 1.28 2015/09/02 05:09:25 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkheaders.c,v 1.27 2015/08/20 09:44:24 christos Exp $");
+__RCSID("$NetBSD: mkheaders.c,v 1.28 2015/09/02 05:09:25 uebayasi Exp $");
#include <sys/param.h>
#include <ctype.h>
@@ -392,6 +392,7 @@
struct devi *i;
tfname = "tmp_ioconf.h";
+ fchdir(buildconfdirfd);
if ((tfp = fopen(tfname, "w")) == NULL)
return (herr("open", tfname, NULL));
@@ -415,7 +416,11 @@
if (fclose(tfp) == EOF)
return (herr("clos", tfname, NULL));
- return (moveifchanged(tfname, "ioconf.h"));
+ if (moveifchanged(tfname, "ioconf.h") != 0)
+ return (herr("mvif", tfname, NULL));
+
+ fchdir(builddirfd);
+ return 0;
}
/*
@@ -528,6 +533,7 @@
warn("error %sing %s", what, fname);
if (fp)
(void)fclose(fp);
+ fchdir(builddirfd);
return (1);
}
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/mkioconf.c
--- a/usr.bin/config/mkioconf.c Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/mkioconf.c Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkioconf.c,v 1.30 2015/08/28 03:55:15 uebayasi Exp $ */
+/* $NetBSD: mkioconf.c,v 1.31 2015/09/02 05:09:25 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkioconf.c,v 1.30 2015/08/28 03:55:15 uebayasi Exp $");
+__RCSID("$NetBSD: mkioconf.c,v 1.31 2015/09/02 05:09:25 uebayasi Exp $");
#include <sys/param.h>
#include <err.h>
@@ -87,9 +87,10 @@
FILE *fp;
qsort(packed, npacked, sizeof *packed, cforder);
+ fchdir(buildconfdirfd);
if ((fp = fopen("ioconf.c.tmp", "w")) == NULL) {
warn("cannot write ioconf.c");
- return (1);
+ goto err;
}
fprintf(fp, "#include \"ioconf.h\"\n");
@@ -116,15 +117,20 @@
#if 0
(void)unlink("ioconf.c.tmp");
#endif
- return (1);
+ goto err;
}
(void)fclose(fp);
if (moveifchanged("ioconf.c.tmp", "ioconf.c") != 0) {
warn("error renaming ioconf.c");
- return (1);
+ goto err;
}
+ fchdir(builddirfd);
return (0);
+
+err:
+ fchdir(builddirfd);
+ return (1);
}
static int
diff -r 2654cefd2c7f -r c11f34282ef9 usr.bin/config/mkswap.c
--- a/usr.bin/config/mkswap.c Wed Sep 02 03:22:41 2015 +0000
+++ b/usr.bin/config/mkswap.c Wed Sep 02 05:09:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkswap.c,v 1.8 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: mkswap.c,v 1.9 2015/09/02 05:09:25 uebayasi Exp $ */
/*
Home |
Main Index |
Thread Index |
Old Index