diff options
author | Nathan Whitehorn <nwhitehorn@FreeBSD.org> | 2010-07-13 04:08:08 +0000 |
---|---|---|
committer | Nathan Whitehorn <nwhitehorn@FreeBSD.org> | 2010-07-13 04:08:08 +0000 |
commit | 9b047d4a9a9f986ee0ef08d3231315e42d481533 (patch) | |
tree | 209e7f9f2191555e438e8dae59aad689b0ac3a39 /usr.sbin | |
parent | 1b0f43beb121d87e6bc743bfc1cb5442340abc95 (diff) | |
download | src-9b047d4a9a9f986ee0ef08d3231315e42d481533.tar.gz src-9b047d4a9a9f986ee0ef08d3231315e42d481533.zip |
Enhance config to handle MACHINEs with multiple architectures:
- Passing -m to config will now print the MACHINE and MACHINE_ARCH
given in the passed kernel configuration file and then exit.
- If an option is defined in options.MACHINE with the same name as the
architecture of the kernel being configured, that option will be
considered set. This allows conditional compilation based on CPU
architecture.
Config version is now 600010.
Reviewed by: imp
Notes
Notes:
svn path=/head/; revision=209969
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/config/config.8 | 3 | ||||
-rw-r--r-- | usr.sbin/config/configvers.h | 2 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 29 | ||||
-rw-r--r-- | usr.sbin/config/mkoptions.c | 14 |
4 files changed, 38 insertions, 10 deletions
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index 904ef6b843e5..03cffb4a0837 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -78,6 +78,9 @@ Note that does not append .Ar SYSTEM_NAME to the directory given. +.It Fl m +Print the MACHINE and MACHINE_ARCH values for this +kernel and exit. .It Fl g Configure a system for debugging. .It Fl x Ar kernel diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h index 2d43329b37b4..c58a64b9fec4 100644 --- a/usr.sbin/config/configvers.h +++ b/usr.sbin/config/configvers.h @@ -49,5 +49,5 @@ * * $FreeBSD$ */ -#define CONFIGVERS 600009 +#define CONFIGVERS 600010 #define MAJOR_VERS(x) ((x) / 100000) diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index e63e6ab8f569..b59bba443a6c 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -110,13 +110,18 @@ main(int argc, char **argv) char *p; char xxx[MAXPATHLEN]; char *kernfile; + int printmachine; + printmachine = 0; kernfile = NULL; - while ((ch = getopt(argc, argv, "Cd:gpVx:")) != -1) + while ((ch = getopt(argc, argv, "Cd:gmpVx:")) != -1) switch (ch) { case 'C': filebased = 1; break; + case 'm': + printmachine = 1; + break; case 'd': if (*destdir == '\0') strlcpy(destdir, optarg, sizeof(destdir)); @@ -171,13 +176,6 @@ main(int argc, char **argv) strlcat(destdir, PREFIX, sizeof(destdir)); } - p = path((char *)NULL); - if (stat(p, &buf)) { - if (mkdir(p, 0777)) - err(2, "%s", p); - } else if (!S_ISDIR(buf.st_mode)) - errx(EXIT_FAILURE, "%s isn't a directory", p); - SLIST_INIT(&cputype); SLIST_INIT(&mkopt); SLIST_INIT(&opt); @@ -207,6 +205,19 @@ main(int argc, char **argv) } checkversion(); + if (printmachine) { + printf("%s\t%s\n",machinename,machinearch); + exit(0); + } + + /* Make compile directory */ + p = path((char *)NULL); + if (stat(p, &buf)) { + if (mkdir(p, 0777)) + err(2, "%s", p); + } else if (!S_ISDIR(buf.st_mode)) + errx(EXIT_FAILURE, "%s isn't a directory", p); + /* * make symbolic links in compilation directory * for "sys" (to make genassym.c work along with #include <sys/xxx>) @@ -280,7 +291,7 @@ static void usage(void) { - fprintf(stderr, "usage: config [-CgpV] [-d destdir] sysname\n"); + fprintf(stderr, "usage: config [-CgmpV] [-d destdir] sysname\n"); fprintf(stderr, " config -x kernel\n"); exit(EX_USAGE); } diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c index 044b669f3a32..2992ec35ad73 100644 --- a/usr.sbin/config/mkoptions.c +++ b/usr.sbin/config/mkoptions.c @@ -94,6 +94,20 @@ options(void) SLIST_INSERT_HEAD(&opt, op, op_next); read_options(); + + /* Fake the value of MACHINE_ARCH as an option if necessary */ + SLIST_FOREACH(ol, &otab, o_next) { + if (strcasecmp(ol->o_name, machinearch) != 0) + continue; + + op = (struct opt *)calloc(1, sizeof(*op)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); + op->op_name = ns(ol->o_name); + SLIST_INSERT_HEAD(&opt, op, op_next); + break; + } + SLIST_FOREACH(op, &opt, op_next) { SLIST_FOREACH(ol, &otab, o_next) { if (eq(op->op_name, ol->o_name) && |