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.
This commit is contained in:
Olivier Houchard 2004-05-09 22:29:00 +00:00
parent 64dabe0b19
commit 43a903c091
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129073
6 changed files with 62 additions and 28 deletions

View File

@ -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;

View File

@ -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
@ -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
*/

View File

@ -8,4 +8,4 @@
*
* $FreeBSD$
*/
#define CONFIGVERS 500012
#define CONFIGVERS 500013

View File

@ -80,6 +80,7 @@ struct kt {
{ "options", OPTIONS },
{ "nooption", NOOPTION },
{ "include", INCLUDE },
{ "files", FILES },
{ 0, 0 },
};

View File

@ -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);

View File

@ -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)
{