Module Name: src Committed By: uebayasi Date: Sun Aug 30 01:33:20 UTC 2015
Modified Files: src/usr.bin/config: config.5 defs.h main.c Log Message: Define `makeoptions' values as parameters with "makeoptions_" prefix too. C sources are encouraged to include relevant opt_*.h files rather than relying on -DXXX passed via makefiles. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/config/config.5 cvs rdiff -u -r1.70 -r1.71 src/usr.bin/config/defs.h cvs rdiff -u -r1.79 -r1.80 src/usr.bin/config/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/config/config.5 diff -u src/usr.bin/config/config.5:1.28 src/usr.bin/config/config.5:1.29 --- src/usr.bin/config/config.5:1.28 Sat Aug 29 02:54:07 2015 +++ src/usr.bin/config/config.5 Sun Aug 30 01:33:20 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: config.5,v 1.28 2015/08/29 02:54:07 uebayasi Exp $ +.\" $NetBSD: config.5,v 1.29 2015/08/30 01:33:20 uebayasi Exp $ .\" .\" Copyright (c) 2006, 2007 The NetBSD Foundation. .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 28, 2015 +.Dd August 31, 2015 .Dt CONFIG 5 .Os .Sh NAME @@ -551,10 +551,6 @@ indicates when the relevant line should and works just like the .Ic file statement. -.It Ic makeoptions Ar condition name Ns += Ns Ar value Op , Ar condition \ - name Ns += Ns Ar value -Appends to a definition in the generated -.Pa Makefile . .El .Ss OPTIONS SELECTION .Bl -ohang @@ -703,6 +699,17 @@ Adds or appends to a definition in the g .Pa Makefile . A definition cannot be overriden, it must be removed before it can be added again. +Optionally, if an option +.Pa makeoptions_\*[Lt]name\*[Gt] +is defined with +.Ic defparam , +the +Ns value +is defined as an option too. +.It Ic makeoptions Ar condition name Ns += Ns Ar value Op , Ar condition \ + name Ns += Ns Ar value +Appends to a definition in the generated +.Pa Makefile . .It Ic no makeoptions Ar name Op , Ar name Op , Ar ... Removes one or more definitions from the generated .Pa Makefile . Index: src/usr.bin/config/defs.h diff -u src/usr.bin/config/defs.h:1.70 src/usr.bin/config/defs.h:1.71 --- src/usr.bin/config/defs.h:1.70 Sat Aug 29 14:07:45 2015 +++ src/usr.bin/config/defs.h Sun Aug 30 01:33:20 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.70 2015/08/29 14:07:45 uebayasi Exp $ */ +/* $NetBSD: defs.h,v 1.71 2015/08/30 01:33:20 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -107,7 +107,7 @@ extern const char *progname; * The next two lines define the current version of the config(1) binary, * and the minimum version of the configuration files it supports. */ -#define CONFIG_VERSION 20150830 +#define CONFIG_VERSION 20150831 #define CONFIG_MINVERSION 0 /* @@ -610,6 +610,7 @@ int devbase_has_instances(struct devbase int is_declared_option(const char *); int deva_has_instances(struct deva *, int); void setupdirs(void); +void fixmkoption(void); const char *strtolower(const char *); /* tests on option types */ Index: src/usr.bin/config/main.c diff -u src/usr.bin/config/main.c:1.79 src/usr.bin/config/main.c:1.80 --- src/usr.bin/config/main.c:1.79 Sat Aug 29 13:34:21 2015 +++ src/usr.bin/config/main.c Sun Aug 30 01:33:20 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.79 2015/08/29 13:34:21 uebayasi Exp $ */ +/* $NetBSD: main.c,v 1.80 2015/08/30 01:33:20 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: main.c,v 1.79 2015/08/29 13:34:21 uebayasi Exp $"); +__RCSID("$NetBSD: main.c,v 1.80 2015/08/30 01:33:20 uebayasi Exp $"); #ifndef MAKE_BOOTSTRAP #include <sys/cdefs.h> @@ -429,6 +429,12 @@ main(int argc, char **argv) stop(); /* + * Copy makeoptions to params + */ + yyfile = "fixmkoption"; + fixmkoption(); + + /* * If working on an ioconf-only config, process here and exit */ if (ioconfname) { @@ -1098,6 +1104,25 @@ appendcondmkoption(struct condexpr *cond } /* + * Copy makeoptions to params with "makeoptions_" prefix. + */ +void +fixmkoption(void) +{ + struct nvlist *nv; + char buf[100]; + const char *name; + + for (nv = mkoptions; nv != NULL; nv = nv->nv_next) { + snprintf(buf, sizeof(buf), "makeoptions_%s", nv->nv_name); + name = intern(buf); + if (!DEFINED_OPTION(name) || !OPT_DEFPARAM(name)) + continue; + addoption(name, intern(nv->nv_str)); + } +} + +/* * Add a name=value pair to an option list. The value may be NULL. */ static int