Add a mechanism for files.* files to be included, in the kernel configuration

file, conditional on their existence.  For example:

[ in ../conf/GENERIC ]
cinclude "../crypto-intl/sys/conf/files.crypto-intl"

This required a change to the files.* grammar; pseudo-device in that
context has been changed to defpseudo, to avoid a conflicting rule
for pseudo-device in the kernel config files.

The same grammar change allows vendors to ship files.* files for
commercial drivers, rather than diffs to e.g. files.pci, i.e.:

include "arch/i386/pci/files.zap"
zap* at pci? device ? function ?

Where files.zap might contain:

device zap: ether, ifnet, arp, mii
attach zap at pci
object	arch/i386/pci/zap.o	zap
This commit is contained in:
thorpej 1999-07-07 00:02:09 +00:00
parent dd514ad75e
commit 0ee6c639c7
3 changed files with 21 additions and 20 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: config.h,v 1.42 1999/04/02 06:36:30 gwr Exp $ */
/* $NetBSD: config.h,v 1.43 1999/07/07 00:02:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@ -409,7 +409,7 @@ void pack __P((void));
/* scan.l */
int currentline __P((void));
int firstfile __P((const char *));
int include __P((const char *, int));
int include __P((const char *, int, int));
/* sem.c, other than for yacc actions */
void initsem __P((void));

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: gram.y,v 1.25 1999/01/21 13:10:09 pk Exp $ */
/* $NetBSD: gram.y,v 1.26 1999/07/07 00:02:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@ -59,8 +59,6 @@
#define stop(s) error(s), exit(1)
int include __P((const char *, int));
static struct config conf; /* at most one active at a time */
/* the following is used to recover nvlist space after errors */
@ -103,8 +101,8 @@ static struct nvlist *mk_ns __P((const char *, struct nvlist *));
int val;
}
%token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFFS DEFINE DEFOPT
%token DEFPARAM DEFFLAG DEVICE DEVCLASS DUMPS ENDFILE XFILE XOBJECT
%token AND AT ATTACH BUILD CINCLUDE COMPILE_WITH CONFIG DEFFS DEFINE DEFOPT
%token DEFPARAM DEFFLAG DEFPSEUDO DEVICE DEVCLASS DUMPS ENDFILE XFILE XOBJECT
%token FILE_SYSTEM FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS
%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE
%token TYPE WITH NEEDS_COUNT NEEDS_FLAG
@ -224,7 +222,8 @@ rule:
/* empty */ { $$ = NULL; };
include:
INCLUDE WORD { include($2, 0); };
INCLUDE WORD { (void) include($2, 0, 0); } |
CINCLUDE WORD { (void) include($2, 0, 1); };
/*
@ -258,7 +257,7 @@ one_def:
{ defdevattach($5, $2, $4, $6); } |
MAXPARTITIONS NUMBER { maxpartitions = $2; } |
MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2, $3, $4); } |
PSEUDO_DEVICE devbase attrs_opt { defdev($2, NULL, $3, 1); } |
DEFPSEUDO devbase attrs_opt { defdev($2, NULL, $3, 1); } |
MAJOR '{' majorlist '}';
atlist:
@ -378,9 +377,7 @@ spec:
error '\n' { cleanup(); };
config_spec:
file |
object |
include |
one_def |
FILE_SYSTEM fs_list |
OPTIONS opt_list |
MAKEOPTIONS mkopt_list |
@ -511,7 +508,7 @@ setmachine(mch, mcharch)
machinearch = mcharch;
(void)sprintf(buf, "arch/%s/conf/files.%s", machine, machine);
if (include(buf, ENDFILE) != 0)
if (include(buf, ENDFILE, 0) != 0)
exit(1);
if (machinearch != NULL)
@ -519,10 +516,10 @@ setmachine(mch, mcharch)
machinearch, machinearch);
else
strcpy(buf, _PATH_DEVNULL);
if (include(buf, ENDFILE) != 0)
if (include(buf, ENDFILE, 0) != 0)
exit(1);
if (include("conf/files", ENDFILE) != 0)
if (include("conf/files", ENDFILE, 0) != 0)
exit(1);
}

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.22 1998/06/24 11:20:55 jonathan Exp $ */
/* $NetBSD: scan.l,v 1.23 1999/07/07 00:02:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@ -86,6 +86,7 @@ and return AND;
at return AT;
attach return ATTACH;
build return BUILD;
cinclude return CINCLUDE;
compile-with return COMPILE_WITH;
config return CONFIG;
deffs return DEFFS;
@ -93,6 +94,7 @@ define return DEFINE;
defflag return DEFFLAG;
defopt return DEFOPT;
defparam return DEFPARAM;
defpseudo return DEFPSEUDO;
devclass return DEVCLASS;
device return DEVICE;
dumps return DUMPS;
@ -201,9 +203,9 @@ firstfile(fname)
* If ateof == 0 then nothing is inserted.
*/
int
include(fname, ateof)
include(fname, ateof, conditional)
const char *fname;
int ateof;
int ateof, conditional;
{
FILE *fp;
struct incl *in;
@ -216,12 +218,14 @@ include(fname, ateof)
}
/* Kludge until files.* files are fixed. */
if (strncmp(fname, "../../../", 9) == 0)
if (conditional == 0 && strncmp(fname, "../../../", 9) == 0)
fname += 9;
s = (*fname == '/') ? strdup(fname) : sourcepath(fname);
if ((fp = fopen(s, "r")) == NULL) {
error("cannot open %s for reading: %s\n", s, strerror(errno));
if (conditional == 0)
error("cannot open %s for reading: %s\n", s,
strerror(errno));
free(s);
return (-1);
}