diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-10-23 22:38:03 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-10-23 22:38:03 +0000 |
commit | bf3c020c3dffc6b56743d8a908fab5929d89c782 (patch) | |
tree | f2a1b5669121fb541ec33ff5377b9673d74ec11e | |
parent | 35f9904da1a9de4d5dc99741e0a245cf6ca6c820 (diff) |
Merge of NetBSD 961020. Includes flexible build/source dir specs
-rw-r--r-- | usr.sbin/config/config.8 | 91 | ||||
-rw-r--r-- | usr.sbin/config/config.h | 20 | ||||
-rw-r--r-- | usr.sbin/config/gram.y | 105 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 83 | ||||
-rw-r--r-- | usr.sbin/config/mkheaders.c | 9 | ||||
-rw-r--r-- | usr.sbin/config/mkioconf.c | 101 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 51 | ||||
-rw-r--r-- | usr.sbin/config/mkswap.c | 12 | ||||
-rw-r--r-- | usr.sbin/config/pack.c | 5 | ||||
-rw-r--r-- | usr.sbin/config/scan.l | 24 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 18 | ||||
-rw-r--r-- | usr.sbin/config/sem.h | 6 | ||||
-rw-r--r-- | usr.sbin/config/util.c | 19 |
13 files changed, 264 insertions, 280 deletions
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index e8c8bac7e0b..f9a69debf39 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -1,5 +1,5 @@ -.\" $OpenBSD: config.8,v 1.3 1996/04/21 23:40:05 deraadt Exp $ -.\" $NetBSD: config.8,v 1.9 1996/03/17 06:29:19 cgd Exp $ +.\" $OpenBSD: config.8,v 1.4 1996/10/23 22:37:50 niklas Exp $ +.\" $NetBSD: config.8,v 1.10 1996/08/31 20:58:16 mycroft Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -42,33 +42,25 @@ .Nd build kernel compilation directories .Sh SYNOPSIS .Nm config +.Op Fl b Ar builddir +.Op Fl s Ar srcdir .Op Fl p -.Ar system-name +.Op Ar config-file .Sh DESCRIPTION .Pp -This is the new version of the -.Nm config -program. -.\"It understands the more modern autoconfiguration scheme -.\"used on the SPARC and i386 platforms. -.\"The old version of config is still used with the -.\"HP300, DECstation, and derivative platforms. -.\"Only the version of -.\".Nm config -.\"applicable to the architecture that you are running -.\"will be installed on your machine. -.Pp .Nm Config -builds a set of configuration files from the file -.Ar system-name , -which describes -the system to configure. +creates a kernel build directory from the file +.Ar config-file , +which describes the system to configure. .Pp -.Nm Config -should run from the +There are several different ways to run the +.Nm config +program. The traditional way is to run +.Nm config +from the .Pa conf -subdirectory of the top-level machine-specific directory -of the system source (usually +subdirectory of the machine-specific directory of the system source +(usually .Pa /sys/arch/MACHINE/conf , where .Pa MACHINE @@ -76,24 +68,53 @@ is one of .Pa vax , .Pa tahoe , .Pa hp300 , -and so forth). +and so forth), and to specify as the +.Ar config-file +the name of a file located in that directory. +.Nm config +will by default create files in the directory +.Pa ../compile/SYSTEMNAME , +where +.Pa SYSTEMNAME +is the last path component of +.Ar config-file . .Nm Config -assumes the directory -.Pa ../compile -exists; it places all output files in a subdirectory there, -creating the subdirectory if necessary. -The subdirectory name is taken from the -.Ar system-name ; -thus, configuring with -.Dq Li config PICKLE -will use the directory -.Pa ../compile/PICKLE . +will assume that the top-level kernel source directory is located four +directories above the build directory. +.Pp +Another way is to create the build directory yourself, place the +configuration file in the build directory with the name +.Pa CONFIG , +and run +.Nm config +from within the build directory without specifying a +.Ar config-file . +.Nm Config +will then by default create files in the current directory. If you +run +.Nm config +this way, you must specify the location of the top-level kernel source +directory using the +.Fl s +option or by using the +.Dq Li source +directive at the beginning of the system configuration file. +.Pp +Finally, you can specify the build directory for +.Nm config +and run it from anywhere. You can specify a build directory with the +.Fl b +option or by using the +.Dq Li build +directive at the beginning of the system configuration file. You must +specify the location of the top-level kernel source directory if you +specify a build directory. .Pp If the .Fl p option is supplied, .Pa .PROF -is appended to the compilation directory name, and +is appended to the default compilation directory name, and .Nm config acts as if the lines .Dq Li makeoptions PROF="-pg" diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 760dea8139d..e6ae2f8dff7 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,5 +1,5 @@ -/* $OpenBSD: config.h,v 1.5 1996/07/07 22:02:19 maja Exp $ */ -/* $NetBSD: config.h,v 1.23 1996/03/17 13:18:15 cgd Exp $ */ +/* $OpenBSD: config.h,v 1.6 1996/10/23 22:37:51 niklas Exp $ */ +/* $NetBSD: config.h,v 1.26 1996/08/31 21:15:05 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -137,7 +137,6 @@ struct deva { int d_isdef; /* set once properly defined */ struct devbase *d_devbase; /* the base device */ struct nvlist *d_atlist; /* e.g., "at tg" (attr list) */ - struct nvlist *d_vectors; /* interrupt vectors, if any */ struct nvlist *d_attrs; /* attributes, if any */ struct devi *d_ihead; /* first instance, if any */ struct devi **d_ipp; /* used for tacking on more instances */ @@ -179,7 +178,6 @@ struct devi { short i_pvlen; /* number of parents */ short i_pvoff; /* offset in parents.vec */ short i_locoff; /* offset in locators.vec */ - short i_ivoff; /* offset in interrupt vectors, if any */ struct devi **i_parents;/* the parents themselves */ int i_locnami; /* my index into locnami[] */ int i_plocnami; /* parent's locnami[] index */ @@ -221,11 +219,9 @@ struct files { /* flags */ #define FI_SEL 0x01 /* selected */ -#define FI_CONFIGDEP 0x02 /* config-dependent */ -#define FI_DRIVER 0x04 /* device-driver */ -#define FI_NEEDSCOUNT 0x08 /* needs-count */ -#define FI_NEEDSFLAG 0x10 /* needs-flag */ -#define FI_HIDDEN 0x20 /* obscured by other(s), base names overlap */ +#define FI_NEEDSCOUNT 0x02 /* needs-count */ +#define FI_NEEDSFLAG 0x04 /* needs-flag */ +#define FI_HIDDEN 0x08 /* obscured by other(s), base names overlap */ /* * Hash tables look up name=value pairs. The pointer value of the name @@ -237,9 +233,11 @@ struct files { struct hashtab; const char *conffile; /* source file, e.g., "GENERIC.sparc" */ -const char *confdirbase; /* basename of compile directory, usu. same */ const char *machine; /* machine type, e.g., "sparc" or "sun3" */ const char *machinearch; /* machine arch, e.g., "sparc" or "m68k" */ +const char *srcdir; /* path to source directory (rel. to build) */ +const char *builddir; /* path to build directory */ +const char *defbuilddir; /* default build directory */ int errors; /* counts calls to error() */ int minmaxusers; /* minimum "maxusers" parameter */ int defmaxusers; /* default "maxusers" parameter */ @@ -320,7 +318,7 @@ void initsem __P((void)); /* util.c */ void *emalloc __P((size_t)); void *erealloc __P((void *, size_t)); -char *path __P((const char *)); +char *sourcepath __P((const char *)); void error __P((const char *, ...)); /* immediate errs */ void xerror __P((const char *, int, const char *, ...)); /* delayed errs */ __dead void panic __P((const char *, ...)); diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index 2d98f236f0b..c78de928e56 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,6 +1,6 @@ %{ -/* $OpenBSD: gram.y,v 1.5 1996/09/12 07:51:17 mickey Exp $ */ -/* $NetBSD: gram.y,v 1.7 1996/03/17 13:18:18 cgd Exp $ */ +/* $OpenBSD: gram.y,v 1.6 1996/10/23 22:37:52 niklas Exp $ */ +/* $NetBSD: gram.y,v 1.9 1996/08/31 21:15:07 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -47,11 +47,14 @@ */ #include <sys/param.h> +#include <sys/types.h> +#include <sys/stat.h> #include <ctype.h> #include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #include "config.h" #include "sem.h" @@ -85,6 +88,7 @@ static int adepth; #define fx_and(e1, e2) new0(NULL, NULL, e1, FX_AND, e2) #define fx_or(e1, e2) new0(NULL, NULL, e1, FX_OR, e2) +static void setupdirs __P((void)); static void cleanup __P((void)); static void setmachine __P((const char *, const char *)); static void setmaxpartitions __P((int)); @@ -100,9 +104,9 @@ static void setmaxpartitions __P((int)); int val; } -%token AND AT ATTACH COMPILE_WITH CONFIG DEFINE DEVICE DISABLE DUMPS ENDFILE -%token XFILE FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS -%token MINOR ON OPTIONS PSEUDO_DEVICE ROOT SWAP VECTOR WITH +%token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFINE DEVICE DISABLE DUMPS +%token ENDFILE XFILE FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS MAXUSERS +%token MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE SWAP WITH %token <val> FFLAG NUMBER %token <str> PATHNAME WORD @@ -117,7 +121,6 @@ static void setmaxpartitions __P((int)); %type <str> atname %type <list> loclist_opt loclist locdef %type <str> locdefault -%type <list> veclist_opt veclist %type <list> attrs_opt attrs %type <list> locators locator %type <list> swapdev_list dev_spec @@ -139,12 +142,24 @@ static void setmaxpartitions __P((int)); * separate grammars, with some shared terminals and nonterminals. */ Configuration: - hdrs machine_spec /* "machine foo" from machine descr. */ + dirs hdrs machine_spec /* "machine foo" from machine descr. */ dev_defs dev_eof /* ../../conf/devices */ dev_defs dev_eof /* devices.foo */ maxpart_spec dev_defs dev_eof /* ../../conf/devices */ specs; /* rest of machine description */ +dirs: + dirspecs = { setupdirs(); }; + +dirspecs: + dirspecs dir | + /* empty */; + +dir: + SOURCE PATHNAME = { if (!srcdir) srcdir = $2; } | + BUILD PATHNAME = { if (!builddir) builddir = $2; } | + '\n'; + hdrs: hdrs hdr | /* empty */; @@ -199,7 +214,7 @@ rule: /* empty */ = { $$ = NULL; }; include: - INCLUDE WORD = { (void)include($2, '\n'); }; + INCLUDE WORD = { include($2, '\n'); }; /* * The machine definitions grammar. @@ -219,9 +234,8 @@ one_def: DEFINE WORD interface_opt = { (void)defattr($2, $3); } | DEVICE devbase interface_opt attrs_opt = { defdev($2, 0, $3, $4); } | - ATTACH devbase AT atlist veclist_opt devattach_opt attrs_opt - = { defdevattach($6, $2, $4, $5 , - $7); } | + ATTACH devbase AT atlist devattach_opt attrs_opt + = { defdevattach($5, $2, $4, $6); } | MAXUSERS NUMBER NUMBER NUMBER = { setdefmaxusers($2, $3, $4); } | PSEUDO_DEVICE devbase attrs_opt = { defdev($2,1,NULL,$3); } | MAJOR '{' majorlist '}'; @@ -238,15 +252,6 @@ atname: WORD = { $$ = $1; } | ROOT = { $$ = NULL; }; -veclist_opt: - VECTOR veclist = { $$ = $2; } | - /* empty */ = { $$ = NULL; }; - -/* veclist order matters, must use right recursion */ -veclist: - WORD veclist = { $$ = new_nx($1, $2); } | - WORD = { $$ = new_n($1); }; - devbase: WORD = { $$ = getdevbase($1); }; @@ -410,6 +415,48 @@ yyerror(s) } /* + * Verify/create builddir if necessary, change to it, and verify srcdir. + */ +static void +setupdirs() +{ + struct stat st; + char *prof; + + /* srcdir must be specified if builddir is not specified or if + * no configuration filename was specified. */ + if ((builddir || strcmp(defbuilddir, ".") == 0) && !srcdir) + stop("source directory must be specified"); + + if (srcdir == NULL) + srcdir = "../../../.."; + if (builddir == NULL) + builddir = defbuilddir; + + if (stat(builddir, &st) != 0) { + if (mkdir(builddir, 0777)) { + (void)fprintf(stderr, "config: cannot create %s: %s\n", + builddir, strerror(errno)); + exit(2); + } + } else if (!S_ISDIR(st.st_mode)) { + (void)fprintf(stderr, "config: %s is not a directory\n", + builddir); + exit(2); + } + if (chdir(builddir) != 0) { + (void)fprintf(stderr, "config: cannot change to %s\n", + builddir); + exit(2); + } + if (stat(srcdir, &st) != 0 || !S_ISDIR(st.st_mode)) { + (void)fprintf(stderr, "config: %s is not a directory\n", + srcdir); + exit(2); + } +} + +/* * Cleanup procedure after syntax error: release any nvlists * allocated during parsing the current line. */ @@ -429,20 +476,24 @@ setmachine(mch, mcharch) const char *mch; const char *mcharch; { - char buf[MAXPATHLEN], archbuf[MAXPATHLEN]; + char buf[MAXPATHLEN]; machine = mch; machinearch = mcharch; + + (void)sprintf(buf, "arch/%s/conf/files.%s", machine, machine); + if (include(buf, ENDFILE) != 0) + exit(1); + if (machinearch != NULL) - (void)sprintf(archbuf, "../../%s/conf/files.%s", + (void)sprintf(buf, "arch/%s/conf/files.%s", machinearch, machinearch); else - strncpy(archbuf, _PATH_DEVNULL, MAXPATHLEN); - (void)sprintf(buf, "files.%s", machine); + strcpy(buf, _PATH_DEVNULL); + if (include(buf, ENDFILE) != 0) + exit(1); - if (include(buf, ENDFILE) || - include(archbuf, ENDFILE) || - include("../../../conf/files", ENDFILE)) + if (include("conf/files", ENDFILE) != 0) exit(1); } diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index e7db69b3d73..9b1aade9a45 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,5 +1,5 @@ -/* $OpenBSD: main.c,v 1.7 1996/09/13 04:25:41 mickey Exp $ */ -/* $NetBSD: main.c,v 1.17 1996/03/17 11:50:13 cgd Exp $ */ +/* $OpenBSD: main.c,v 1.8 1996/10/23 22:37:53 niklas Exp $ */ +/* $NetBSD: main.c,v 1.18 1996/08/31 20:58:20 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -53,6 +53,7 @@ static char copyright[] = #include <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> #include <ctype.h> #include <errno.h> #include <stdio.h> @@ -87,11 +88,11 @@ main(argc, argv) char **argv; { register char *p; + const char *last_component; int pflag, ch; - struct stat st; pflag = 0; - while ((ch = getopt(argc, argv, "gp")) != EOF) { + while ((ch = getopt(argc, argv, "gpb:s:")) != EOF) { switch (ch) { case 'g': @@ -120,6 +121,14 @@ main(argc, argv) pflag = 1; break; + case 'b': + builddir = optarg; + break; + + case 's': + srcdir = optarg; + break; + case '?': default: goto usage; @@ -128,12 +137,12 @@ main(argc, argv) argc -= optind; argv += optind; - if (argc != 1) { + if (argc > 1) { usage: - (void)fputs("usage: config [-p] sysname\n", stderr); + (void)fputs("usage: config [-p] [-s srcdir] [-b builddir] sysname\n", stderr); exit(1); } - conffile = argv[0]; + conffile = (argc == 1) ? argv[0] : "CONFIG"; if (firstfile(conffile)) { (void)fprintf(stderr, "config: cannot read %s: %s\n", conffile, strerror(errno)); @@ -161,31 +170,18 @@ usage: * Handle profiling (must do this before we try to create any * files). */ + last_component = strrchr(conffile, '/'); + last_component = (last_component) ? last_component + 1 : conffile; if (pflag) { - char *s; - - s = emalloc(strlen(conffile) + sizeof(".PROF")); - (void)sprintf(s, "%s.PROF", conffile); - confdirbase = s; + p = emalloc(strlen(last_component) + 17); + (void)sprintf(p, "../compile/%s.PROF", last_component); (void)addmkoption(intern("PROF"), "-pg"); (void)addoption(intern("GPROF"), NULL); - } else - confdirbase = conffile; - - /* - * Verify, creating if necessary, the compilation directory. - */ - p = path(NULL); - if (stat(p, &st)) { - if (mkdir(p, 0777)) { - (void)fprintf(stderr, "config: cannot create %s: %s\n", - p, strerror(errno)); - exit(2); - } - } else if (!S_ISDIR(st.st_mode)) { - (void)fprintf(stderr, "config: %s is not a directory\n", p); - exit(2); + } else { + p = emalloc(strlen(last_component) + 13); + (void)sprintf(p, "../compile/%s", last_component); } + defbuilddir = (argc == 0) ? "." : p; /* * Parse config file (including machine definitions). @@ -242,29 +238,30 @@ static int mksymlinks() { int ret; - char *p, buf[200]; + char *p, buf[MAXPATHLEN]; + const char *q; - p = path("machine"); - (void)sprintf(buf, "../../include"); - (void)unlink(p); - ret = symlink(buf, p); + sprintf(buf, "arch/%s/include", machine); + p = sourcepath(buf); + (void)unlink("machine"); + ret = symlink(p, "machine"); if (ret) - (void)fprintf(stderr, "config: symlink(%s -> %s): %s\n", - p, buf, strerror(errno)); - free(p); + (void)fprintf(stderr, "config: symlink(machine -> %s): %s\n", + p, strerror(errno)); if (machinearch != NULL) { - p = path(machinearch); - (void)sprintf(buf, "../../../%s/include", machinearch); + sprintf(buf, "arch/%s/include", machinearch); + p = sourcepath(buf); + q = machinearch; } else { - p = path(machine); - (void)sprintf(buf, "machine"); + p = strdup("machine"); + q = machine; } - (void)unlink(p); - ret = symlink(buf, p); + (void)unlink(q); + ret = symlink(p, q); if (ret) (void)fprintf(stderr, "config: symlink(%s -> %s): %s\n", - p, buf, strerror(errno)); + q, p, strerror(errno)); free(p); return (ret); diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index d158c209a22..eb327da7a17 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mkheaders.c,v 1.3 1996/04/21 23:40:15 deraadt Exp $ */ -/* $NetBSD: mkheaders.c,v 1.10 1996/03/17 13:18:21 cgd Exp $ */ +/* $OpenBSD: mkheaders.c,v 1.4 1996/10/23 22:37:54 niklas Exp $ */ +/* $NetBSD: mkheaders.c,v 1.11 1996/08/31 20:58:22 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -81,13 +81,12 @@ emitcnt(head) { register struct nvlist *nv; register FILE *fp; - register char *fname; int cnt; char nam[100]; char buf[BUFSIZ]; + char fname[BUFSIZ]; - (void)sprintf(buf, "%s.h", head->nv_name); - fname = path(buf); + (void)sprintf(fname, "%s.h", head->nv_name); if ((fp = fopen(fname, "r")) == NULL) goto writeit; nv = head; diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index 64a2ced7ba9..54f5206c8bd 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mkioconf.c,v 1.6 1996/09/06 08:53:44 maja Exp $ */ -/* $NetBSD: mkioconf.c,v 1.38 1996/03/17 06:29:27 cgd Exp $ */ +/* $OpenBSD: mkioconf.c,v 1.7 1996/10/23 22:37:55 niklas Exp $ */ +/* $NetBSD: mkioconf.c,v 1.40 1996/08/31 21:15:10 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -64,11 +64,8 @@ static int emitlocnames __P((FILE *)); static int emitpseudo __P((FILE *)); static int emitpv __P((FILE *)); static int emitroots __P((FILE *)); -static int emitvec __P((FILE *)); static char *vecname __P((char *, const char *, int)); -static const char *s_i386; - #define SEP(pos, max) (((u_int)(pos) % (max)) == 0 ? "\n\t" : " ") /* @@ -81,33 +78,27 @@ int mkioconf() { register FILE *fp; - register char *fname; int v; - s_i386 = intern("i386"); - - fname = path("ioconf.c"); qsort(packed, npacked, sizeof *packed, cforder); - if ((fp = fopen(fname, "w")) == NULL) { - (void)fprintf(stderr, "config: cannot write %s: %s\n", - fname, strerror(errno)); + if ((fp = fopen("ioconf.c", "w")) == NULL) { + (void)fprintf(stderr, "config: cannot write ioconf.c: %s\n", + strerror(errno)); return (1); } v = emithdr(fp); - if (v != 0 || emitvec(fp) || emitexterns(fp) || emitloc(fp) || + if (v != 0 || emitexterns(fp) || emitloc(fp) || emitlocnames(fp) || emitpv(fp) || emitcfdata(fp) || emitroots(fp) || emitpseudo(fp)) { if (v >= 0) (void)fprintf(stderr, - "config: error writing %s: %s\n", - fname, strerror(errno)); + "config: error writing ioconf.c: %s\n", + strerror(errno)); (void)fclose(fp); - /* (void)unlink(fname); */ - free(fname); + /* (void)unlink("ioconf.c"); */ return (1); } (void)fclose(fp); - free(fname); return (0); } @@ -405,13 +396,8 @@ struct cfdata cfdata[] = {\n\ state = "NORM"; } } - if (i->i_ivoff < 0) { - vs = ""; - v = 0; - } else { - vs = "vec+"; - v = i->i_ivoff; - } + vs = ""; + v = 0; if (i->i_locoff >= 0) { (void)sprintf(locbuf, "loc+%3d", i->i_locoff); loc = locbuf; @@ -489,68 +475,3 @@ emitpseudo(fp) } return (fputs("\t{ 0, 0 }\n};\n", fp) < 0); } - -/* - * Emit interrupt vector declarations, and calculate offsets. - */ -static int -emitvec(fp) - register FILE *fp; -{ - register struct nvlist *head, *nv; - register struct devi **p, *i; - register int j, nvec, unit; - char buf[200]; - - nvec = 0; - for (p = packed; (i = *p) != NULL; p++) { - if ((head = i->i_atdeva->d_vectors) == NULL) - continue; - if ((unit = i->i_unit) == STAR) - panic("emitvec unit==STAR"); - if (nvec == 0) - NEWLINE; - for (j = 0, nv = head; nv != NULL; j++, nv = nv->nv_next) - if (fprintf(fp, - "/* IVEC %s %d */ extern void %s();\n", - nv->nv_name, unit, - vecname(buf, nv->nv_name, unit)) < 0) - return (1); - nvec += j + 1; - } - if (nvec == 0) - return (0); - if (fprintf(fp, "\nstatic void (*vec[%d]) __P((void)) = {", nvec) < 0) - return (1); - nvec = 0; - for (p = packed; (i = *p) != NULL; p++) { - if ((head = i->i_atdeva->d_vectors) == NULL) - continue; - i->i_ivoff = nvec; - unit = i->i_unit; - for (nv = head; nv != NULL; nv = nv->nv_next) - if (fprintf(fp, "%s%s,", - SEP(nvec++, 4), - vecname(buf, nv->nv_name, unit)) < 0) - return (1); - if (fprintf(fp, "%s0,", SEP(nvec++, 4)) < 0) - return (1); - } - return (fputs("\n};\n", fp) < 0); -} - -static char * -vecname(buf, name, unit) - char *buf; - const char *name; - int unit; -{ - - /* @#%* 386 uses a different name format */ - if (machine == s_i386) { - (void)sprintf(buf, "V%s%d", name, unit); - return (buf); - } - (void)sprintf(buf, "X%s%d", name, unit); - return (buf); -} diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 9dc6ef4bc6a..c6278971a22 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mkmakefile.c,v 1.4 1996/05/10 12:10:04 mickey Exp $ */ -/* $NetBSD: mkmakefile.c,v 1.29 1996/03/17 13:18:23 cgd Exp $ */ +/* $OpenBSD: mkmakefile.c,v 1.5 1996/10/23 22:37:56 niklas Exp $ */ +/* $NetBSD: mkmakefile.c,v 1.32 1996/09/23 05:04:23 ghudson Exp $ */ /* * Copyright (c) 1992, 1993 @@ -75,20 +75,21 @@ mkmakefile() register FILE *ifp, *ofp; register int lineno; register int (*fn) __P((FILE *)); - register char *ofname; - char line[BUFSIZ], ifname[200]; + register char *ifname; + char line[BUFSIZ], buf[200]; - (void)sprintf(ifname, "Makefile.%s", machine); + (void)sprintf(buf, "arch/%s/conf/Makefile.%s", machine, machine); + ifname = sourcepath(buf); if ((ifp = fopen(ifname, "r")) == NULL) { (void)fprintf(stderr, "config: cannot read %s: %s\n", ifname, strerror(errno)); + free(ifname); return (1); } - ofname = path("Makefile"); - if ((ofp = fopen(ofname, "w")) == NULL) { - (void)fprintf(stderr, "config: cannot write %s: %s\n", - ofname, strerror(errno)); - free(ofname); + if ((ofp = fopen("Makefile", "w")) == NULL) { + (void)fprintf(stderr, "config: cannot write Makefile: %s\n", + strerror(errno)); + free(ifname); return (1); } if (emitdefs(ofp) != 0) @@ -124,8 +125,8 @@ mkmakefile() "config: error reading %s (at line %d): %s\n", ifname, lineno, strerror(errno)); goto bad; - /* (void)unlink(ofname); */ - free(ofname); + /* (void)unlink("Makefile"); */ + free(ifname); return (1); } if (fclose(ofp)) { @@ -133,16 +134,16 @@ mkmakefile() goto wrerror; } (void)fclose(ifp); - free(ofname); + free(ifname); return (0); wrerror: - (void)fprintf(stderr, "config: error writing %s: %s\n", - ofname, strerror(errno)); + (void)fprintf(stderr, "config: error writing Makefile: %s\n", + strerror(errno)); bad: if (ofp != NULL) (void)fclose(ofp); - /* (void)unlink(ofname); */ - free(ofname); + /* (void)unlink("Makefile"); */ + free(ifname); return (1); } @@ -195,6 +196,17 @@ emitdefs(fp) return (1); if (fprintf(fp, "PARAM=-DMAXUSERS=%d\n", maxusers) < 0) return (1); + if (*srcdir == '/' || *srcdir == '.') { + if (fprintf(fp, "S=\t%s\n", srcdir) < 0) + return (1); + } else { + /* + * libkern and libcompat "Makefile.inc"s want relative S + * specification to begin with '.'. + */ + if (fprintf(fp, "S=\t./%s\n", srcdir) < 0) + return (1); + } for (nv = mkoptions; nv != NULL; nv = nv->nv_next) if (fprintf(fp, "%s=%s\n", nv->nv_name, nv->nv_str) < 0) return (1); @@ -338,12 +350,11 @@ emitrules(fp) *fpath != '/' ? "$S/" : "", fpath) < 0) return (1); if ((cp = fi->fi_mkrule) == NULL) { - cp = fi->fi_flags & FI_DRIVER ? "DRIVER" : "NORMAL"; + cp = "NORMAL"; ch = fpath[strlen(fpath) - 1]; if (islower(ch)) ch = toupper(ch); - (void)sprintf(buf, "${%s_%c%s}", cp, ch, - fi->fi_flags & FI_CONFIGDEP ? "_C" : ""); + (void)sprintf(buf, "${%s_%c}", cp, ch); cp = buf; } if (fprintf(fp, "\t%s\n\n", cp) < 0) diff --git a/usr.sbin/config/mkswap.c b/usr.sbin/config/mkswap.c index 53171687799..e04bfc40a6a 100644 --- a/usr.sbin/config/mkswap.c +++ b/usr.sbin/config/mkswap.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mkswap.c,v 1.3 1996/04/21 23:40:20 deraadt Exp $ */ -/* $NetBSD: mkswap.c,v 1.4 1996/03/17 20:36:25 christos Exp $ */ +/* $OpenBSD: mkswap.c,v 1.4 1996/10/23 22:37:57 niklas Exp $ */ +/* $NetBSD: mkswap.c,v 1.5 1996/08/31 20:58:27 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -88,12 +88,10 @@ mkoneswap(cf) { register struct nvlist *nv; register FILE *fp; - register char *fname; - char buf[200]; + char fname[200]; char *mountroot; - (void)sprintf(buf, "swap%s.c", cf->cf_name); - fname = path(buf); + (void)sprintf(fname, "swap%s.c", cf->cf_name); if ((fp = fopen(fname, "w")) == NULL) { (void)fprintf(stderr, "config: cannot write %s: %s\n", fname, strerror(errno)); @@ -130,7 +128,6 @@ mkoneswap(cf) fp = NULL; goto wrerror; } - free(fname); return (0); wrerror: (void)fprintf(stderr, "config: error writing %s: %s\n", @@ -138,6 +135,5 @@ wrerror: if (fp != NULL) (void)fclose(fp); /* (void)unlink(fname); */ - free(fname); return (1); } diff --git a/usr.sbin/config/pack.c b/usr.sbin/config/pack.c index 46db9f4280b..20b57e4e102 100644 --- a/usr.sbin/config/pack.c +++ b/usr.sbin/config/pack.c @@ -1,5 +1,5 @@ -/* $OpenBSD: pack.c,v 1.4 1996/06/23 10:23:04 deraadt Exp $ */ -/* $NetBSD: pack.c,v 1.3.4.1 1996/06/17 18:22:44 cgd Exp $ */ +/* $OpenBSD: pack.c,v 1.5 1996/10/23 22:37:58 niklas Exp $ */ +/* $NetBSD: pack.c,v 1.5 1996/08/31 21:15:11 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -182,7 +182,6 @@ packdevi() l->i_pvlen = 0; l->i_pvoff = -1; l->i_locoff = -1; - l->i_ivoff = -1; /* try to find an equivalent for l */ for (j = m; j < n; j++) { p = packed[j]; diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index 04e92438879..542c5e31eff 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,6 +1,6 @@ %{ -/* $OpenBSD: scan.l,v 1.5 1996/07/07 22:02:21 maja Exp $ */ -/* $NetBSD: scan.l,v 1.4 1996/03/17 06:29:35 cgd Exp $ */ +/* $OpenBSD: scan.l,v 1.6 1996/10/23 22:37:59 niklas Exp $ */ +/* $NetBSD: scan.l,v 1.7 1996/08/31 21:15:13 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -88,6 +88,7 @@ WORD [A-Za-z_][-A-Za-z_0-9]* and { return AND; } at { return AT; } attach { return ATTACH; } +build { return BUILD; } compile-with { return COMPILE_WITH; } config { return CONFIG; } define { return DEFINE; } @@ -108,13 +109,11 @@ options { return OPTIONS; } option { return OPTIONS; } "pseudo-device" { return PSEUDO_DEVICE; } root { return ROOT; } +source { return SOURCE; } swap { return SWAP; } -vector { return VECTOR; } with { return WITH; } /* keywords with values */ -config-dependent { yylval.val = FI_CONFIGDEP; return FFLAG; } -device-driver { yylval.val = FI_DRIVER; return FFLAG; } needs-count { yylval.val = FI_NEEDSCOUNT; return FFLAG; } needs-flag { yylval.val = FI_NEEDSFLAG; return FFLAG; } @@ -191,10 +190,16 @@ include(fname, ateof) { register FILE *fp; register struct incl *in; + char *s; - if ((fp = fopen(fname, "r")) == NULL) { - error("cannot open %s for reading: %s\n", - fname, strerror(errno)); + /* Kludge until files.* files are fixed. */ + if (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)); + free(s); return (-1); } in = emalloc(sizeof *in); @@ -205,9 +210,10 @@ include(fname, ateof) in->in_preveof = eoftoken; incl = in; yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); - yyfile = intern(fname); + yyfile = intern(s); yyline = 1; eoftoken = ateof; + free(s); return (0); } diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index 40da45265d3..99850be7c28 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,5 +1,5 @@ -/* $OpenBSD: sem.c,v 1.5 1996/08/29 03:33:06 deraadt Exp $ */ -/* $NetBSD: sem.c,v 1.8 1996/03/17 21:12:03 cgd Exp $ */ +/* $OpenBSD: sem.c,v 1.6 1996/10/23 22:38:00 niklas Exp $ */ +/* $NetBSD: sem.c,v 1.9 1996/08/31 21:15:15 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -351,13 +351,13 @@ badname: /* * Define some of a device's allowable parent attachments. - * There may be a list of vectors and a list of (plain) attributes. + * There may be a list of (plain) attributes. */ void -defdevattach(deva, dev, atlist, vectors, attrs) +defdevattach(deva, dev, atlist, attrs) register struct deva *deva; struct devbase *dev; - struct nvlist *atlist, *vectors, *attrs; + struct nvlist *atlist, *attrs; { register struct nvlist *nv; register struct attr *a; @@ -396,7 +396,6 @@ defdevattach(deva, dev, atlist, vectors, attrs) /* Committed! Set up fields. */ deva->d_attrs = attrs; deva->d_atlist = atlist; - deva->d_vectors = vectors; deva->d_devbase = dev; /* @@ -438,7 +437,6 @@ defdevattach(deva, dev, atlist, vectors, attrs) return; bad: nvfreel(atlist); - nvfreel(vectors); nvfreel(attrs); } @@ -474,7 +472,6 @@ badname: deva->d_isdef = 0; deva->d_devbase = NULL; deva->d_atlist = NULL; - deva->d_vectors = NULL; deva->d_attrs = NULL; deva->d_ihead = NULL; deva->d_ipp = &deva->d_ihead; @@ -858,11 +855,6 @@ findattachment: } if ((i->i_locs = fixloc(name, attr, loclist)) == NULL) goto bad; - if (i->i_unit == STAR && iba->d_vectors != NULL) { - error("%s's cannot be *'d as they have preset vectors", - ib->d_name); - goto bad; - } i->i_at = at; i->i_atattr = attr; i->i_atdev = ab; diff --git a/usr.sbin/config/sem.h b/usr.sbin/config/sem.h index 5b94ab3bacd..9e439f211d7 100644 --- a/usr.sbin/config/sem.h +++ b/usr.sbin/config/sem.h @@ -1,5 +1,5 @@ -/* $OpenBSD: sem.h,v 1.4 1996/07/07 22:02:22 maja Exp $ */ -/* $NetBSD: sem.h,v 1.4 1996/03/17 06:29:40 cgd Exp $ */ +/* $OpenBSD: sem.h,v 1.5 1996/10/23 22:38:01 niklas Exp $ */ +/* $NetBSD: sem.h,v 1.5 1996/08/31 21:15:16 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -53,7 +53,7 @@ int defattr __P((const char *, struct nvlist *)); void defdev __P((struct devbase *, int, struct nvlist *, struct nvlist *)); void defdevattach __P((struct deva *, struct devbase *, - struct nvlist *, struct nvlist *, struct nvlist *)); + struct nvlist *, struct nvlist *)); struct devbase *getdevbase __P((const char *name)); struct deva *getdevattach __P((const char *name)); struct attr *getattr __P((const char *name)); diff --git a/usr.sbin/config/util.c b/usr.sbin/config/util.c index c3b50187735..576512bed4e 100644 --- a/usr.sbin/config/util.c +++ b/usr.sbin/config/util.c @@ -1,5 +1,5 @@ -/* $OpenBSD: util.c,v 1.4 1996/09/01 18:02:02 deraadt Exp $ */ -/* $NetBSD: util.c,v 1.4 1996/03/17 11:50:16 cgd Exp $ */ +/* $OpenBSD: util.c,v 1.5 1996/10/23 22:38:02 niklas Exp $ */ +/* $NetBSD: util.c,v 1.5 1996/08/31 20:58:29 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -98,23 +98,16 @@ nomem() } /* - * Prepend the compilation directory to a file name. + * Prepend the source path to a file name. */ char * -path(file) +sourcepath(file) const char *file; { register char *cp; -#define CDIR "../compile/" - if (file == NULL) { - cp = emalloc(sizeof(CDIR) + strlen(confdirbase)); - (void)sprintf(cp, "%s%s", CDIR, confdirbase); - } else { - cp = emalloc(sizeof(CDIR) + strlen(confdirbase) + 1 + - strlen(file)); - (void)sprintf(cp, "%s%s/%s", CDIR, confdirbase, file); - } + cp = emalloc(strlen(srcdir) + 1 + strlen(file) + 1); + (void)sprintf(cp, "%s/%s", srcdir, file); return (cp); } |