Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Define `makeoptions' values as parameters wit...
details: https://anonhg.NetBSD.org/src/rev/15716ca09c5e
branches: trunk
changeset: 340272:15716ca09c5e
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Sun Aug 30 01:33:20 2015 +0000
description:
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.
diffstat:
usr.bin/config/config.5 | 19 +++++++++++++------
usr.bin/config/defs.h | 5 +++--
usr.bin/config/main.c | 29 +++++++++++++++++++++++++++--
3 files changed, 43 insertions(+), 10 deletions(-)
diffs (130 lines):
diff -r da9f4027fc2a -r 15716ca09c5e usr.bin/config/config.5
--- a/usr.bin/config/config.5 Sat Aug 29 21:04:22 2015 +0000
+++ b/usr.bin/config/config.5 Sun Aug 30 01:33:20 2015 +0000
@@ -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 @@
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 @@
.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 .
diff -r da9f4027fc2a -r 15716ca09c5e usr.bin/config/defs.h
--- a/usr.bin/config/defs.h Sat Aug 29 21:04:22 2015 +0000
+++ b/usr.bin/config/defs.h Sun Aug 30 01:33:20 2015 +0000
@@ -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 @@
* 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 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 */
diff -r da9f4027fc2a -r 15716ca09c5e usr.bin/config/main.c
--- a/usr.bin/config/main.c Sat Aug 29 21:04:22 2015 +0000
+++ b/usr.bin/config/main.c Sun Aug 30 01:33:20 2015 +0000
@@ -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 @@
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 @@
}
/*
+ * 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
Home |
Main Index |
Thread Index |
Old Index