diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-28 07:50:45 +0000 |
commit | 3b8f08459569bf0faa21473e5cec2491e95c9349 (patch) | |
tree | 80f45dd81ca716bcd7ca9674581e1fc40b93cd34 /usr.sbin/config | |
parent | 9d2ab4a62d6733c45958627ac113bdbd818d1e2a (diff) | |
parent | b2ba55951383498f252746f618d513139da06e8e (diff) | |
download | src-3b8f08459569bf0faa21473e5cec2491e95c9349.tar.gz src-3b8f08459569bf0faa21473e5cec2491e95c9349.zip |
Merge head
Notes
Notes:
svn path=/projects/bmake/; revision=265044
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/config.8 | 7 | ||||
-rw-r--r-- | usr.sbin/config/config.h | 7 | ||||
-rw-r--r-- | usr.sbin/config/configvers.h | 2 | ||||
-rw-r--r-- | usr.sbin/config/lang.l | 13 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 12 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 345 |
6 files changed, 192 insertions, 194 deletions
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index 784b06b1ca73..79520a736b31 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -37,6 +37,7 @@ .Sh SYNOPSIS .Nm .Op Fl CVgp +.Op Fl I Ar path .Op Fl d Ar destdir .Ar SYSTEM_NAME .Nm @@ -69,6 +70,12 @@ If the INCLUDE_CONFIG_FILE is present in a configuration file, kernel image will contain full configuration files included literally (preserving comments). This flag is kept for backward compatibility. +.It Fl I Ar path +Search in +.Ar path +for any file included by the +.Ic include +directive. This option may be specified more than once. .It Fl d Ar destdir Use .Ar destdir diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index f275749c8256..93b2086f4f1d 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -144,6 +144,13 @@ struct hint { STAILQ_HEAD(hint_head, hint) hints; +struct includepath { + char *path; + SLIST_ENTRY(includepath) path_next; +}; + +SLIST_HEAD(, includepath) includepath; + /* * Tag present in the kernelconf.tmlp template file. It's mandatory for those * two strings to be the same. Otherwise you'll get into trouble. diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h index 6e044b89a737..56ca85cd692a 100644 --- a/usr.sbin/config/configvers.h +++ b/usr.sbin/config/configvers.h @@ -49,5 +49,5 @@ * * $FreeBSD$ */ -#define CONFIGVERS 600012 +#define CONFIGVERS 600013 #define MAJOR_VERS(x) ((x) / 100000) diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 3e4e11560445..14fa7dafee48 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -34,6 +34,7 @@ #include <assert.h> #include <ctype.h> #include <err.h> +#include <stdlib.h> #include <string.h> #include "y.tab.h" #include "config.h" @@ -257,6 +258,7 @@ include(const char *fname, int ateof) { FILE *fp; struct incl *in; + struct includepath* ipath; char *fnamebuf; fnamebuf = NULL; @@ -269,6 +271,17 @@ include(const char *fname, int ateof) } } if (fp == NULL) { + SLIST_FOREACH(ipath, &includepath, path_next) { + asprintf(&fnamebuf, "%s/%s", ipath->path, fname); + if (fnamebuf != NULL) { + fp = fopen(fnamebuf, "r"); + free(fnamebuf); + } + if (fp != NULL) + break; + } + } + if (fp == NULL) { yyerror("cannot open included file"); return (-1); } diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 78bb13dd3eba..86ecfa6cd4bc 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -110,15 +110,25 @@ main(int argc, char **argv) int ch, len; char *p; char *kernfile; + struct includepath* ipath; int printmachine; printmachine = 0; kernfile = NULL; - while ((ch = getopt(argc, argv, "Cd:gmpVx:")) != -1) + SLIST_INIT(&includepath); + while ((ch = getopt(argc, argv, "CI:d:gmpVx:")) != -1) switch (ch) { case 'C': filebased = 1; break; + case 'I': + ipath = (struct includepath *) \ + calloc(1, sizeof (struct includepath)); + if (ipath == NULL) + err(EXIT_FAILURE, "calloc"); + ipath->path = optarg; + SLIST_INSERT_HEAD(&includepath, ipath, path_next); + break; case 'm': printmachine = 1; break; diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 324ad3b7bfbe..cae2efc097b9 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -43,6 +43,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> +#include <stdarg.h> #include <stdio.h> #include <string.h> #include <sys/param.h> @@ -50,21 +51,6 @@ static const char rcsid[] = #include "config.h" #include "configvers.h" -#define next_word(fp, wd) \ - { char *word = get_word(fp); \ - if (word == (char *)EOF) \ - return; \ - else \ - wd = word; \ - } -#define next_quoted_word(fp, wd) \ - { char *word = get_quoted_word(fp); \ - if (word == (char *)EOF) \ - return; \ - else \ - wd = word; \ - } - static char *tail(char *); static void do_clean(FILE *); static void do_rules(FILE *); @@ -74,6 +60,16 @@ static void do_before_depend(FILE *); static int opteq(const char *, const char *); static void read_files(void); +static void errout(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(1); +} + /* * Lookup a file, by name. */ @@ -313,8 +309,8 @@ read_file(char *fname) struct opt *op; char *wd, *this, *compilewith, *depends, *clean, *warning; const char *objprefix; - int compile, match, nreqs, std, filetype, - imp_rule, no_obj, before_depend, mandatory, nowerror; + int compile, match, nreqs, std, filetype, not, + imp_rule, no_obj, before_depend, nowerror; fp = fopen(fname, "r"); if (fp == 0) @@ -322,7 +318,7 @@ read_file(char *fname) next: /* * include "filename" - * filename [ standard | mandatory | optional ] + * filename [ standard | optional ] * [ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ] * [ compile-with "compile rule" [no-implicit-rule] ] * [ dependency "dependency-list"] [ before-depend ] @@ -343,12 +339,9 @@ next: goto next; } if (eq(wd, "include")) { - next_quoted_word(fp, wd); - if (wd == 0) { - fprintf(stderr, "%s: missing include filename.\n", - fname); - exit(1); - } + wd = get_quoted_word(fp); + if (wd == (char *)EOF || wd == 0) + errout("%s: missing include filename.\n", fname); (void) snprintf(ifname, sizeof(ifname), "../../%s", wd); read_file(ifname); while (((wd = get_word(fp)) != (char *)EOF) && wd) @@ -356,11 +349,11 @@ next: goto next; } this = ns(wd); - next_word(fp, wd); - if (wd == 0) { - fprintf(stderr, "%s: No type for %s.\n", fname, this); - exit(1); - } + wd = get_word(fp); + if (wd == (char *)EOF) + return; + if (wd == 0) + errout("%s: No type for %s.\n", fname, this); tp = fl_lookup(this); compile = 0; match = 1; @@ -369,186 +362,154 @@ next: depends = 0; clean = 0; warning = 0; - std = mandatory = 0; + std = 0; imp_rule = 0; no_obj = 0; before_depend = 0; nowerror = 0; + not = 0; filetype = NORMAL; objprefix = ""; - if (eq(wd, "standard")) { + if (eq(wd, "standard")) std = 1; - /* - * If an entry is marked "mandatory", config will abort if it's - * not called by a configuration line in the config file. Apart - * from this, the device is handled like one marked "optional". - */ - } else if (eq(wd, "mandatory")) { - mandatory = 1; - } else if (!eq(wd, "optional")) { - fprintf(stderr, - "%s: \"%s\" %s must be optional, mandatory or standard\n", + else if (!eq(wd, "optional")) + errout("%s: \"%s\" %s must be optional or standard\n", fname, wd, this); - exit(1); - } -nextparam: - next_word(fp, wd); - if (wd == 0) { - compile += match; - if (compile && tp == NULL) - goto doneparam; - goto next; - } - if (eq(wd, "|")) { - if (nreqs == 0) { - fprintf(stderr, "%s: syntax error describing %s\n", - fname, this); - exit(1); + for (wd = get_word(fp); wd; wd = get_word(fp)) { + if (wd == (char *)EOF) + return; + if (eq(wd, "!")) { + not = 1; + continue; } - compile += match; - match = 1; - nreqs = 0; - goto nextparam; - } - if (eq(wd, "no-obj")) { - no_obj++; - goto nextparam; - } - if (eq(wd, "no-implicit-rule")) { - if (compilewith == 0) { - fprintf(stderr, "%s: alternate rule required when " - "\"no-implicit-rule\" is specified.\n", - fname); + if (eq(wd, "|")) { + if (nreqs == 0) + errout("%s: syntax error describing %s\n", + fname, this); + if (not) + compile += !match; + else + compile += match; + match = 1; + nreqs = 0; + not = 0; + continue; } - imp_rule++; - goto nextparam; - } - if (eq(wd, "before-depend")) { - before_depend++; - goto nextparam; - } - if (eq(wd, "dependency")) { - next_quoted_word(fp, wd); - if (wd == 0) { - fprintf(stderr, - "%s: %s missing dependency string.\n", - fname, this); - exit(1); + if (eq(wd, "no-obj")) { + no_obj++; + continue; } - depends = ns(wd); - goto nextparam; - } - if (eq(wd, "clean")) { - next_quoted_word(fp, wd); - if (wd == 0) { - fprintf(stderr, "%s: %s missing clean file list.\n", - fname, this); - exit(1); + if (eq(wd, "no-implicit-rule")) { + if (compilewith == 0) + errout("%s: alternate rule required when " + "\"no-implicit-rule\" is specified for" + " %s.\n", + fname, this); + imp_rule++; + continue; } - clean = ns(wd); - goto nextparam; - } - if (eq(wd, "compile-with")) { - next_quoted_word(fp, wd); - if (wd == 0) { - fprintf(stderr, - "%s: %s missing compile command string.\n", - fname, this); - exit(1); + if (eq(wd, "before-depend")) { + before_depend++; + continue; } - compilewith = ns(wd); - goto nextparam; - } - if (eq(wd, "warning")) { - next_quoted_word(fp, wd); - if (wd == 0) { - fprintf(stderr, - "%s: %s missing warning text string.\n", - fname, this); - exit(1); + if (eq(wd, "dependency")) { + wd = get_quoted_word(fp); + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing dependency string.\n", + fname, this); + depends = ns(wd); + continue; } - warning = ns(wd); - goto nextparam; - } - if (eq(wd, "obj-prefix")) { - next_quoted_word(fp, wd); - if (wd == 0) { - printf("%s: %s missing object prefix string.\n", - fname, this); - exit(1); + if (eq(wd, "clean")) { + wd = get_quoted_word(fp); + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing clean file list.\n", + fname, this); + clean = ns(wd); + continue; } - objprefix = ns(wd); - goto nextparam; - } - nreqs++; - if (eq(wd, "local")) { - filetype = LOCAL; - goto nextparam; - } - if (eq(wd, "no-depend")) { - filetype = NODEPEND; - goto nextparam; - } - if (eq(wd, "profiling-routine")) { - filetype = PROFILING; - goto nextparam; - } - if (eq(wd, "nowerror")) { - nowerror = 1; - goto nextparam; - } - STAILQ_FOREACH(dp, &dtab, d_next) - if (eq(dp->d_name, wd)) { - dp->d_done |= DEVDONE; - goto nextparam; + if (eq(wd, "compile-with")) { + wd = get_quoted_word(fp); + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing compile command string.\n", + fname, this); + compilewith = ns(wd); + continue; } - if (mandatory) { - fprintf(stderr, "%s: mandatory device \"%s\" not found\n", - fname, wd); - exit(1); - } - if (std) { - fprintf(stderr, - "standard entry %s has a device keyword - %s!\n", - this, wd); - exit(1); - } - SLIST_FOREACH(op, &opt, op_next) - if (op->op_value == 0 && opteq(op->op_name, wd)) - goto nextparam; - match = 0; - goto nextparam; - -doneparam: - if (std == 0 && nreqs == 0) { - fprintf(stderr, "%s: what is %s optional on?\n", - fname, this); - exit(1); - } - - if (wd) { - fprintf(stderr, "%s: syntax error describing %s\n", - fname, this); - exit(1); + if (eq(wd, "warning")) { + wd = get_quoted_word(fp); + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing warning text string.\n", + fname, this); + warning = ns(wd); + continue; + } + if (eq(wd, "obj-prefix")) { + wd = get_quoted_word(fp); + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing object prefix string.\n", + fname, this); + objprefix = ns(wd); + continue; + } + if (eq(wd, "nowerror")) { + nowerror = 1; + continue; + } + if (eq(wd, "local")) { + filetype = LOCAL; + continue; + } + if (eq(wd, "no-depend")) { + filetype = NODEPEND; + continue; + } + nreqs++; + if (eq(wd, "profiling-routine")) { + filetype = PROFILING; + continue; + } + if (std) + errout("standard entry %s has optional inclusion specifier %s!\n", + this, wd); + STAILQ_FOREACH(dp, &dtab, d_next) + if (eq(dp->d_name, wd)) { + dp->d_done |= DEVDONE; + goto nextparam; + } + SLIST_FOREACH(op, &opt, op_next) + if (op->op_value == 0 && opteq(op->op_name, wd)) + goto nextparam; + match = 0; +nextparam:; + } + if (not) + compile += !match; + else + compile += match; + if (compile && tp == NULL) { + if (std == 0 && nreqs == 0) + errout("%s: what is %s optional on?\n", + fname, this); + if (filetype == PROFILING && profiling == 0) + goto next; + tp = new_fent(); + tp->f_fn = this; + tp->f_type = filetype; + if (imp_rule) + tp->f_flags |= NO_IMPLCT_RULE; + if (no_obj) + tp->f_flags |= NO_OBJ; + if (before_depend) + tp->f_flags |= BEFORE_DEPEND; + if (nowerror) + tp->f_flags |= NOWERROR; + tp->f_compilewith = compilewith; + tp->f_depends = depends; + tp->f_clean = clean; + tp->f_warn = warning; + tp->f_objprefix = objprefix; } - if (filetype == PROFILING && profiling == 0) - goto next; - tp = new_fent(); - tp->f_fn = this; - tp->f_type = filetype; - if (imp_rule) - tp->f_flags |= NO_IMPLCT_RULE; - if (no_obj) - tp->f_flags |= NO_OBJ; - if (before_depend) - tp->f_flags |= BEFORE_DEPEND; - if (nowerror) - tp->f_flags |= NOWERROR; - tp->f_compilewith = compilewith; - tp->f_depends = depends; - tp->f_clean = clean; - tp->f_warn = warning; - tp->f_objprefix = objprefix; goto next; } |