From 43a903c091e9313bc99956c513bfdb5a74b5f169 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Sun, 9 May 2004 22:29:00 +0000 Subject: [PATCH] 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. --- usr.sbin/config/config.h | 7 +++++ usr.sbin/config/config.y | 19 ++++++++++++ usr.sbin/config/configvers.h | 2 +- usr.sbin/config/lang.l | 1 + usr.sbin/config/main.c | 2 ++ usr.sbin/config/mkmakefile.c | 59 +++++++++++++++++++----------------- 6 files changed, 62 insertions(+), 28 deletions(-) diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 2e93acff18b..cbeda79ea63 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 0ee7f285c1f..d16982a9617 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 ID %token 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 @@ -275,6 +280,20 @@ yyerror(const char *s) errx(1, "%s:%d: %s", yyfile, yyline + 1, 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 */ diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h index 1eef6f674c2..4e6ccb972ec 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 e5c0c986ab0..7984bf9b167 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 6e6ea70bcc3..a22d0ad11ca 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 ce83942bda7..f7f3a9c24ee 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 @@ read_files(void) 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 @@ read_files(void) 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) { -- 2.45.2