diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-13 08:21:57 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-13 08:21:57 +0000 |
commit | 48eccfca3321f7c88e1a2107e3170d2194904baa (patch) | |
tree | 17a96bd2b69fb2909e92878bac4405df70db3be8 /usr.sbin/config | |
parent | 1844aacc1c369617474ad3fd76dc9a310d05db20 (diff) |
from mycroft;
Allow options and makeoptions to take an empty string as a value.
Add `object' and `library' keywords to pull in precompiled .o and .a files.
Syntax is like the `file' keyword; e.g.:
object arch/i386/i386/mumble.o [mumble] [needs-flag]
Largely from Michael Richardson in PR 3833, with some changes by me.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/config.h | 25 | ||||
-rw-r--r-- | usr.sbin/config/files.c | 87 | ||||
-rw-r--r-- | usr.sbin/config/gram.y | 25 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 8 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 18 | ||||
-rw-r--r-- | usr.sbin/config/scan.l | 7 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 3 |
7 files changed, 145 insertions, 28 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 5212203fc13..30e989ef97d 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.11 1997/08/07 10:36:57 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.12 1997/11/13 08:21:53 deraadt Exp $ */ /* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */ /* @@ -244,6 +244,25 @@ struct files { struct nvlist *fi_optf;/* flattened version of above, if needed */ const char *fi_mkrule; /* special make rule, if any */ }; + +/* + * Objects and libraries. This allows precompiled object and library + * files (e.g. binary-only device drivers) to be linked in. + */ +struct objects { + struct objects *oi_next;/* linked list */ + const char *oi_srcfile; /* the name of the "objects" file that got us */ + u_short oi_srcline; /* and the line number */ + u_char oi_flags; /* as below */ + char oi_lastc; /* last char from path */ + const char *oi_path; /* full object path */ + struct nvlist *oi_optx;/* options expression */ + struct nvlist *oi_optf;/* flattened version of above, if needed */ +}; + +#define OI_SEL 0x01 /* selected */ +#define OI_NEEDSFLAG 0x02 /* needs-flag */ + #define FX_ATOM 0 /* atom (in nv_name) */ #define FX_NOT 1 /* NOT expr (subexpression in nv_next) */ #define FX_AND 2 /* AND expr (lhs in nv_ptr, rhs in nv_next) */ @@ -294,6 +313,7 @@ int ndevi; /* number of devi's (before packing) */ int npseudo; /* number of pseudo's */ struct files *allfiles; /* list of all kernel source files */ +struct objects *allobjects; /* list of all kernel object and library files */ struct devi **packed; /* arrayified table for packed devi's */ int npacked; /* size of packed table, <= ndevi */ @@ -311,7 +331,9 @@ struct { /* loc[] table for config */ void initfiles __P((void)); void checkfiles __P((void)); int fixfiles __P((void)); /* finalize */ +int fixobjects __P((void)); void addfile __P((const char *, struct nvlist *, int, const char *)); +void addobject __P((const char *, struct nvlist *, int)); /* hash.c */ struct hashtab *ht_new __P((void)); @@ -347,6 +369,7 @@ void pack __P((void)); /* scan.l */ int currentline __P((void)); +int firstfile __P((const char *)); int include __P((const char *, int)); /* sem.c, other than for yacc actions */ diff --git a/usr.sbin/config/files.c b/usr.sbin/config/files.c index 8d7eda6a391..5295d2859a8 100644 --- a/usr.sbin/config/files.c +++ b/usr.sbin/config/files.c @@ -1,4 +1,4 @@ -/* $OpenBSD: files.c,v 1.6 1997/01/17 07:14:02 millert Exp $ */ +/* $OpenBSD: files.c,v 1.7 1997/11/13 08:21:53 deraadt Exp $ */ /* $NetBSD: files.c,v 1.6 1996/03/17 13:18:17 cgd Exp $ */ /* @@ -66,6 +66,8 @@ static struct hashtab *pathtab; /* full path names */ static struct files **nextfile; static struct files **unchecked; +static struct objects **nextobject; + static int checkaux __P((const char *, void *)); static int fixcount __P((const char *, void *)); static int fixfsel __P((const char *, void *)); @@ -82,21 +84,9 @@ initfiles() pathtab = ht_new(); nextfile = &allfiles; unchecked = &allfiles; + nextobject = &allobjects; } -#if 0 -static void -showprev(pref, fi) - const char *pref; - register struct files *fi; -{ - - xerror(fi->fi_srcfile, fi->fi_srcline, - "%sfile %s ...", pref, fi->fi_path); - errors--; -} -#endif - void addfile(path, optx, flags, rule) const char *path; @@ -167,6 +157,38 @@ bad: expr_free(optx); } +void +addobject(path, optx, flags) + const char *path; + struct nvlist *optx; + int flags; +{ + struct objects *oi; + + /* + * Commit this object to memory. We will decide later whether it + * will be used after all. + */ + oi = emalloc(sizeof *oi); + if (ht_insert(pathtab, path, oi)) { + free(oi); + if ((oi = ht_lookup(pathtab, path)) == NULL) + panic("addfile: ht_lookup(%s)", path); + error("duplicate file %s", path); + xerror(oi->oi_srcfile, oi->oi_srcline, + "here is the original definition"); + } + oi->oi_next = NULL; + oi->oi_srcfile = yyfile; + oi->oi_srcline = currentline(); + oi->oi_flags = flags; + oi->oi_path = path; + oi->oi_optx = optx; + oi->oi_optf = NULL; + *nextobject = oi; + nextobject = &oi->oi_next; +} + /* * We have finished reading some "files" file, either ../../conf/files * or ./files.$machine. Make sure that everything that is flagged as @@ -177,7 +199,6 @@ void checkfiles() { register struct files *fi, *last; - /*register struct nvlist *nv;*/ last = NULL; for (fi = *unchecked; fi != NULL; last = fi, fi = fi->fi_next) @@ -225,8 +246,9 @@ fixfiles() /* Skip files that generated counted-device complaints. */ if (fi->fi_flags & FI_HIDDEN) continue; + + /* Optional: see if it is to be included. */ if (fi->fi_optx != NULL) { - /* Optional: see if it is to be included. */ flathead = NULL; flatp = &flathead; sel = expr_eval(fi->fi_optx, @@ -268,6 +290,37 @@ fixfiles() return (err); } +/* + * We have finished reading everything. Tack the objects down: calculate + * selection. + */ +int +fixobjects() +{ + struct objects *oi; + struct nvlist *flathead, **flatp; + int err, sel; + + err = 0; + for (oi = allobjects; oi != NULL; oi = oi->oi_next) { + /* Optional: see if it is to be included. */ + if (oi->oi_optx != NULL) { + flathead = NULL; + flatp = &flathead; + sel = expr_eval(oi->oi_optx, + oi->oi_flags & OI_NEEDSFLAG ? fixfsel : + fixsel, + &flatp); + oi->oi_optf = flathead; + if (!sel) + continue; + } + + oi->oi_flags |= OI_SEL; + } + return (err); +} + /* * Called when evaluating a needs-count expression. Make sure the * atom is a countable device. The expression succeeds iff there @@ -363,7 +416,7 @@ expr_eval(expr, fn, context) return (lhs | rhs); } panic("expr_eval %d", expr->nv_int); - /* NOTREACHED */ + return (0); } /* diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index eeb0c8c56ba..6d91c4baa60 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: gram.y,v 1.8 1997/07/06 03:54:04 downsj Exp $ */ +/* $OpenBSD: gram.y,v 1.9 1997/11/13 08:21:54 deraadt Exp $ */ /* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */ /* @@ -101,17 +101,17 @@ static void check_maxpart __P((void)); } %token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFINE DEFOPT DEVICE DISABLE -%token DUMPS ENDFILE XFILE FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS MAXUSERS -%token MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE SWAP WITH -%token NEEDS_COUNT NEEDS_FLAG +%token DUMPS ENDFILE XFILE XOBJECT FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS +%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE SWAP +%token WITH NEEDS_COUNT NEEDS_FLAG %token <val> NUMBER -%token <str> PATHNAME WORD +%token <str> PATHNAME WORD EMPTY %left '|' %left '&' %type <list> fopts fexpr fatom -%type <val> fflgs fflag +%type <val> fflgs fflag oflgs oflag %type <str> rule %type <attr> attr %type <devb> devbase @@ -174,6 +174,9 @@ dev_eof: file: XFILE PATHNAME fopts fflgs rule { addfile($2, $3, $4, $5); }; +object: + XOBJECT PATHNAME fopts oflgs { addobject($2, $3, $4); }; + /* order of options is important, must use right recursion */ fopts: fexpr { $$ = $1; } | @@ -197,6 +200,13 @@ fflag: NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } | NEEDS_FLAG { $$ = FI_NEEDSFLAG; }; +oflgs: + oflgs oflag { $$ = $1 | $2; } | + /* empty */ { $$ = 0; }; + +oflag: + NEEDS_FLAG { $$ = OI_NEEDSFLAG; }; + rule: COMPILE_WITH WORD { $$ = $2; } | /* empty */ { $$ = NULL; }; @@ -219,6 +229,7 @@ dev_def: one_def: file | + object | include | DEFINE WORD interface_opt { (void)defattr($2, $3); } | DEFOPT WORD { defoption($2); } | @@ -274,6 +285,7 @@ locdefault: value: WORD { $$ = $1; } | + EMPTY { $$ = $1; } | signed_number { char bf[40]; (void)sprintf(bf, FORMAT($1), $1); $$ = intern(bf); }; @@ -316,6 +328,7 @@ spec: config_spec: file | + object | include | OPTIONS opt_list | MAKEOPTIONS mkopt_list | diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 4a335c0b572..f3e94a6c51e 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.15 1997/07/06 04:07:09 downsj Exp $ */ +/* $OpenBSD: main.c,v 1.16 1997/11/13 08:21:54 deraadt Exp $ */ /* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */ /* @@ -201,6 +201,12 @@ usage: stop(); /* + * Fix objects and libraries. + */ + if (fixobjects()) + stop(); + + /* * Perform cross-checking. */ if (maxusers == 0) { diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index a5b34ee6c18..d681fbbeb0f 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkmakefile.c,v 1.6 1997/07/06 03:54:06 downsj Exp $ */ +/* $OpenBSD: mkmakefile.c,v 1.7 1997/11/13 08:21:55 deraadt Exp $ */ /* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */ /* @@ -220,6 +220,7 @@ emitobjs(fp) register FILE *fp; { register struct files *fi; + register struct objects *oi; register int lpos, len, sp; if (fputs("OBJS=", fp) < 0) @@ -241,6 +242,21 @@ emitobjs(fp) lpos += len + 1; sp = ' '; } + for (oi = allobjects; oi != NULL; oi = oi->oi_next) { + if ((oi->oi_flags & OI_SEL) == 0) + continue; + len = strlen(oi->oi_path) + 3; + if (lpos + len > 72) { + if (fputs(" \\\n", fp) < 0) + return (1); + sp = '\t'; + lpos = 7; + } + if (fprintf(fp, "%c$S/%s", sp, oi->oi_path) < 0) + return (1); + lpos += len + 1; + sp = ' '; + } if (putc('\n', fp) < 0) return (1); return (0); diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index 147190e89dc..78b05bfc6fc 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.8 1997/07/06 03:54:06 downsj Exp $ */ +/* $OpenBSD: scan.l,v 1.9 1997/11/13 08:21:55 deraadt Exp $ */ /* $NetBSD: scan.l,v 1.13 1997/02/02 21:12:37 thorpej Exp $ */ /* @@ -105,6 +105,7 @@ maxusers return MAXUSERS; minor return MINOR; needs-count return NEEDS_COUNT; needs-flag return NEEDS_FLAG; +object return XOBJECT; on return ON; options return OPTIONS; option return OPTIONS; @@ -123,6 +124,10 @@ with return WITH; return WORD; } +\"\" { + yylval.str = intern(""); + return EMPTY; + } \"([^"\n]|\\\")+ { tok = input(); /* eat closing quote */ if (tok != '"') { diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index 6bd7f02df1c..1864b18ec45 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.11 1997/08/07 10:36:59 deraadt Exp $ */ +/* $OpenBSD: sem.c,v 1.12 1997/11/13 08:21:56 deraadt Exp $ */ /* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */ /* @@ -86,6 +86,7 @@ static int lresolve __P((struct nvlist **, const char *, const char *, static struct devi *newdevi __P((const char *, int, struct devbase *d)); static struct devi *getdevi __P((const char *)); static const char *concat __P((const char *, int)); +static char *extend __P((char *, const char *)); static int split __P((const char *, size_t, char *, size_t, int *)); static void selectbase __P((struct devbase *, struct deva *)); static int onlist __P((struct nvlist *, void *)); |