summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>1999-10-30 10:55:48 +0000
committermarcel <marcel@FreeBSD.org>1999-10-30 10:55:48 +0000
commit8024dcb61d2990a84407cbaf035def0f1b8cffdd (patch)
treea9d2384ac6461c3a49b2c9508ecc88304b9ac808 /usr.sbin
parent91b84ac6af4009a0ae8b9cb3e59d9a8108e5fc96 (diff)
downloadFreeBSD-src-8024dcb61d2990a84407cbaf035def0f1b8cffdd.zip
FreeBSD-src-8024dcb61d2990a84407cbaf035def0f1b8cffdd.tar.gz
Add option "-d destdir" which instructs config to use another output
directory than the default one. If the option is not given, then the output of config is exactly as before. Only when an alternate output directory has been specified will config modify its behavior. Additional changed: o Remove the now conflicting and unused NODEV define. It conflicts with NODEV in sys/param.h. o Rename the now conflicting MACHINE token to ARCH. It conflicts with MACHINE in sys/param.h. o Fix some easy style bugs. o Fix some easy grammar bugs in the manpage. Approved by: peter, archie
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/config.817
-rw-r--r--usr.sbin/config/config.h3
-rw-r--r--usr.sbin/config/config.y4
-rw-r--r--usr.sbin/config/lang.l2
-rw-r--r--usr.sbin/config/main.c70
-rw-r--r--usr.sbin/config/mkmakefile.c2
6 files changed, 79 insertions, 19 deletions
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8
index ad3af6b..85da1a6 100644
--- a/usr.sbin/config/config.8
+++ b/usr.sbin/config/config.8
@@ -41,6 +41,7 @@
.Sh SYNOPSIS
.Nm config
.Op Fl gpr
+.Op Fl d Ar destdir
.Ar SYSTEM_NAME
.Sh DESCRIPTION
This is the old version of the
@@ -73,6 +74,13 @@ section below).
Available options and operands:
.Pp
.Bl -tag -width SYSTEM_NAME
+.It Fl d Ar destdir
+Use
+.Ar destdir
+as the output directory, instead of the default one. Note
+that config does not append
+.Ar SYSTEM_NAME
+to the directory given.
.It Fl g
Configure a system for debugging.
.It Fl p
@@ -104,8 +112,11 @@ represents one of the architectures supported by FreeBSD.
.Nm Config
creates the directory
.Pa ../../compile/SYSTEM_NAME
-as necessary and place all output files there.
-If the directory already exists and the
+or the one given with the
+.Fl d
+option
+as necessary and places all output files there.
+If the output directory already exists and the
.Fl r
flag was specified, it will be removed first.
The output of
@@ -222,7 +233,7 @@ list of files specific to
.Em ERNIE
system
.It Pa /sys/compile/SYSTEM_NAME
-kernel build directory for system
+default kernel build directory for system
.Pa SYSTEM_NAME .
.El
.Sh SEE ALSO
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index d1fdb3e..5b7eef7 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -41,8 +41,6 @@
#include <stdlib.h>
#include <string.h>
-#define NODEV ((dev_t)-1)
-
struct file_list {
struct file_list *f_next;
char *f_fn; /* the name */
@@ -177,6 +175,7 @@ extern int maxusers;
extern int old_config_present; /* Old config/build directory still there */
extern char *PREFIX; /* Config file name - for error messages */
+extern char srcdir[]; /* root of the kernel source tree */
#define eq(a,b) (!strcmp(a,b))
#define ns(s) strdup(s)
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 2a3d989..5c6d1da 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -5,6 +5,7 @@
}
%token ANY
+%token ARCH
%token AT
%token BUS
%token COMMA
@@ -23,7 +24,6 @@
%token IOMEM
%token IOSIZ
%token IRQ
-%token MACHINE
%token MAXUSERS
%token MINUS
%token NEXUS
@@ -133,7 +133,7 @@ Spec:
;
Config_spec:
- MACHINE Save_id
+ ARCH Save_id
= {
if (!strcmp($2, "i386")) {
machine = MACHINE_I386;
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index fe685ec..16c27ba 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -66,7 +66,7 @@ struct kt {
{ "iomem", IOMEM },
{ "iosiz", IOSIZ },
{ "irq", IRQ },
- { "machine", MACHINE },
+ { "machine", ARCH }, /* MACHINE is defined in /sys/param.h */
{ "makeoptions", MAKEOPTIONS },
{ "maxusers", MAXUSERS },
{ "nexus", NEXUS },
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 7c74a7f..fa6fe9f 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -49,6 +49,7 @@ static const char rcsid[] =
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/mman.h>
+#include <sys/param.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
@@ -65,14 +66,20 @@ static const char rcsid[] =
#define FALSE (0)
#endif
+#define CDIR "../../compile/"
+
char * PREFIX;
+char destdir[MAXPATHLEN];
+char srcdir[MAXPATHLEN];
+
static int no_config_clobber = TRUE;
int old_config_present;
int debugging;
int profiling;
-static void usage __P((void));
static void configfile __P((void));
+static void get_srcdir __P((void));
+static void usage __P((void));
/*
* Config builds a set of files for building a UNIX
@@ -85,11 +92,17 @@ main(argc, argv)
{
struct stat buf;
- int ch;
+ int ch, len;
char *p;
- while ((ch = getopt(argc, argv, "gprn")) != -1)
+ while ((ch = getopt(argc, argv, "d:gprn")) != -1)
switch (ch) {
+ case 'd':
+ if (*destdir == '\0')
+ strcpy(destdir, optarg);
+ else
+ errx(2, "directory already set");
+ break;
case 'g':
debugging++;
break;
@@ -117,6 +130,16 @@ main(argc, argv)
if (freopen(PREFIX = *argv, "r", stdin) == NULL)
err(2, "%s", PREFIX);
+ if (*destdir != '\0') {
+ len = strlen(destdir);
+ while (len > 1 && destdir[len - 1] == '/')
+ destdir[--len] = '\0';
+ get_srcdir();
+ } else {
+ strcpy(destdir, CDIR);
+ strcat(destdir, PREFIX);
+ }
+
p = path((char *)NULL);
if (stat(p, &buf)) {
if (mkdir(p, 0777))
@@ -164,8 +187,12 @@ main(argc, argv)
*/
{
char xxx[80];
-
- (void) snprintf(xxx, sizeof(xxx), "../../%s/include", machinename);
+ if (*srcdir == '\0')
+ (void)snprintf(xxx, sizeof(xxx), "../../%s/include",
+ machinename);
+ else
+ (void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
+ srcdir, machinename);
(void) symlink(xxx, path("machine"));
}
options(); /* make options .h files */
@@ -176,10 +203,34 @@ main(argc, argv)
exit(0);
}
+/*
+ * get_srcdir
+ * determine the root of the kernel source tree
+ * and save that in srcdir.
+ */
+static void
+get_srcdir()
+{
+ int i;
+ char *p;
+
+ (void)getcwd(srcdir, sizeof(srcdir));
+ for (i = 0; i < 2; i++) {
+ p = strrchr(srcdir, '/');
+ if (p != NULL)
+ *p = '\0';
+ }
+
+ /* Sanity check */
+ p = strrchr(srcdir, '/');
+ if (p == NULL || strcmp(p + 1, "sys"))
+ errx(2, "non-standard kernel source tree");
+}
+
static void
usage()
{
- fprintf(stderr, "usage: config [-gpr] sysname\n");
+ fprintf(stderr, "usage: config [-gpr] [-d destdir] sysname\n");
exit(1);
}
@@ -302,11 +353,8 @@ path(file)
{
register char *cp;
-#define CDIR "../../compile/"
- cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) +
- (file ? strlen(file) : 0) + 2));
- (void) strcpy(cp, CDIR);
- (void) strcat(cp, PREFIX);
+ cp = malloc((size_t)(strlen(destdir) + (file ? strlen(file) : 0) + 2));
+ (void) strcpy(cp, destdir);
if (file) {
(void) strcat(cp, "/");
(void) strcat(cp, file);
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 1b80772..96f8610 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -181,6 +181,8 @@ makefile()
fprintf(ofp, "PROF=-pg\n");
fprintf(ofp, "PROFLEVEL=%d\n", profiling);
}
+ if (*srcdir != '\0')
+ fprintf(ofp,"S=%s\n", srcdir);
while (fgets(line, BUFSIZ, ifp) != 0) {
if (*line != '%') {
fprintf(ofp, "%s", line);
OpenPOWER on IntegriCloud