summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorcognet <cognet@FreeBSD.org>2004-05-09 22:29:00 +0000
committercognet <cognet@FreeBSD.org>2004-05-09 22:29:00 +0000
commit00e9b04664bf2e5a36da9308482569986b191cbd (patch)
tree73af9718cbffc98607a761e30d746e77607e3639 /usr.sbin/config
parent7d1143b1dd32ee8be2ba15b806cf64b01a6053ff (diff)
downloadFreeBSD-src-00e9b04664bf2e5a36da9308482569986b191cbd.zip
FreeBSD-src-00e9b04664bf2e5a36da9308482569986b191cbd.tar.gz
Add a new "files" directive, which allows to include a files.foo file directly
from a kernel config file. Bump config version to reflect this change.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/config.h7
-rw-r--r--usr.sbin/config/config.y19
-rw-r--r--usr.sbin/config/configvers.h2
-rw-r--r--usr.sbin/config/lang.l1
-rw-r--r--usr.sbin/config/main.c2
-rw-r--r--usr.sbin/config/mkmakefile.c59
6 files changed, 62 insertions, 28 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 2e93acf..cbeda79 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -54,6 +54,11 @@ struct file_list {
char *f_warn; /* warning message */
};
+struct files_name {
+ char *f_name;
+ STAILQ_ENTRY(files_name) f_next;
+};
+
/*
* Types.
*/
@@ -156,6 +161,8 @@ extern const char *yyfile;
extern STAILQ_HEAD(file_list_head, file_list) ftab;
+extern STAILQ_HEAD(files_name_head, files_name) fntab;
+
extern int profiling;
extern int debugging;
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 0ee7f28..d16982a 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -22,6 +22,7 @@
%token NOMAKEOPTION
%token SEMICOLON
%token INCLUDE
+%token FILES
%token <str> ID
%token <val> NUMBER
@@ -84,6 +85,7 @@ int hintmode;
int yyline;
const char *yyfile;
struct file_list_head ftab;
+struct files_name_head fntab;
char errbuf[80];
int maxusers;
@@ -121,6 +123,9 @@ Spec:
INCLUDE ID SEMICOLON
= { include($2, 0); };
|
+ FILES ID SEMICOLON
+ = { newfile($2); };
+ |
SEMICOLON
|
error SEMICOLON
@@ -276,6 +281,20 @@ yyerror(const char *s)
}
/*
+ * Add a new file to the list of files.
+ */
+static void
+newfile(char *name)
+{
+ struct files_name *nl;
+
+ nl = (struct files_name *) malloc(sizeof *nl);
+ bzero(nl, sizeof *nl);
+ nl->f_name = name;
+ STAILQ_INSERT_TAIL(&fntab, nl, f_next);
+}
+
+/*
* add a device to the list of devices
*/
static void
diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h
index 1eef6f6..4e6ccb9 100644
--- a/usr.sbin/config/configvers.h
+++ b/usr.sbin/config/configvers.h
@@ -8,4 +8,4 @@
*
* $FreeBSD$
*/
-#define CONFIGVERS 500012
+#define CONFIGVERS 500013
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index e5c0c98..7984bf9 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -80,6 +80,7 @@ struct kt {
{ "options", OPTIONS },
{ "nooption", NOOPTION },
{ "include", INCLUDE },
+ { "files", FILES },
{ 0, 0 },
};
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 6e6ea70..a22d0ad 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -145,7 +145,9 @@ main(int argc, char **argv)
errx(2, "%s isn't a directory", p);
STAILQ_INIT(&dtab);
+ STAILQ_INIT(&fntab);
SLIST_INIT(&cputype);
+ STAILQ_INIT(&ftab);
yyfile = *argv;
if (yyparse())
exit(3);
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index ce83942..f7f3a9c 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -293,29 +293,17 @@ makefile(void)
moveifchanged(path("env.c.new"), path("env.c"));
}
-/*
- * Read in the information about files used in making the system.
- * Store it in the ftab linked list.
- */
-static void
-read_files(void)
+void
+read_file(char *fname)
{
FILE *fp;
struct file_list *tp, *pf;
struct device *dp;
struct opt *op;
char *wd, *this, *needs, *compilewith, *depends, *clean, *warning;
- char fname[MAXPATHLEN];
- int nreqs, first = 1, isdup, std, filetype,
+ int nreqs, isdup, std, filetype,
imp_rule, no_obj, needcount, before_depend, mandatory, nowerror;
- STAILQ_INIT(&ftab);
- if (ident == NULL) {
- printf("no ident line specified\n");
- exit(1);
- }
- (void) snprintf(fname, sizeof(fname), "../../conf/files");
-openit:
fp = fopen(fname, "r");
if (fp == 0)
err(1, "%s", fname);
@@ -330,19 +318,8 @@ next:
wd = get_word(fp);
if (wd == (char *)EOF) {
(void) fclose(fp);
- if (first == 1) {
- first++;
- (void) snprintf(fname, sizeof(fname),
- "../../conf/files.%s", machinename);
- fp = fopen(fname, "r");
- if (fp != 0)
- goto next;
- (void) snprintf(fname, sizeof(fname),
- "files.%s", machinename);
- goto openit;
- }
return;
- }
+ }
if (wd == 0)
goto next;
if (wd[0] == '#')
@@ -557,6 +534,34 @@ doneparam:
goto next;
}
+/*
+ * Read in the information about files used in making the system.
+ * Store it in the ftab linked list.
+ */
+static void
+read_files(void)
+{
+ char fname[MAXPATHLEN];
+ FILE *fp;
+ struct files_name *nl, *tnl;
+
+ if (ident == NULL) {
+ printf("no ident line specified\n");
+ exit(1);
+ }
+ (void) snprintf(fname, sizeof(fname), "../../conf/files");
+ read_file(fname);
+ (void) snprintf(fname, sizeof(fname),
+ "../../conf/files.%s", machinename);
+ read_file(fname);
+ for (nl = STAILQ_FIRST(&fntab); nl != NULL; nl = tnl) {
+ read_file(nl->f_name);
+ tnl = STAILQ_NEXT(nl, f_next);
+ free(nl->f_name);
+ free(nl);
+ }
+}
+
static int
opteq(const char *cp, const char *dp)
{
OpenPOWER on IntegriCloud