tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
config: makeoptions support for conditions
config(5) says:
Conditions
Finally, source file selection is possible through the help of condition-
als, referred to as condition later in this documentation. The syntax
for those conditions uses well-known operators ( ``&'', ``|'' and ``!'')
to combine options and attributes.
and
makeoptions condition name+=value [, condition name+=value]
Appends to a definition in the generated Makefile.
However, makeoptions does not accept a general condition.
Is the attached patch acceptable?
--
Kind regards,
Yorick Hardy
Index: usr.bin/config/defs.h
===================================================================
RCS file: /cvsroot/src/usr.bin/config/defs.h,v
retrieving revision 1.28
diff -u -r1.28 defs.h
--- usr.bin/config/defs.h 15 Feb 2009 01:39:54 -0000 1.28
+++ usr.bin/config/defs.h 12 Mar 2009 11:57:19 -0000
@@ -464,6 +464,7 @@
int fixfiles(void); /* finalize */
int fixobjects(void);
int fixdevsw(void);
+int fixmkopt(void);
void addfile(const char *, struct nvlist *, int, const char *);
void addobject(const char *, struct nvlist *, int);
@@ -491,6 +492,7 @@
void addmkoption(const char *, const char *);
void appendmkoption(const char *, const char *);
void appendcondmkoption(const char *, const char *, const char *);
+void appendcondmkoptexpr(struct nvlist *, const char *, const char *);
void deffilesystem(const char *, struct nvlist *, struct nvlist *);
void defoption(const char *, struct nvlist *, struct nvlist *);
void defflag(const char *, struct nvlist *, struct nvlist *, int);
Index: usr.bin/config/files.c
===================================================================
RCS file: /cvsroot/src/usr.bin/config/files.c,v
retrieving revision 1.9
diff -u -r1.9 files.c
--- usr.bin/config/files.c 20 Jan 2009 18:20:48 -0000 1.9
+++ usr.bin/config/files.c 12 Mar 2009 11:57:21 -0000
@@ -433,6 +433,30 @@
return (error);
}
+/*
+ * We have finished reading everything. Take the make options down: calculate
+ * selection.
+ */
+int
+fixmkopt(void)
+{
+ struct nvlist *nv;
+
+ for (nv = appmkoptions; nv != NULL; nv = nv->nv_next)
+ {
+ if (nv->nv_ptr != NULL)
+ {
+ /* ignore this option */
+ if (!expr_eval(nv->nv_ptr, fixsel, NULL))
+ nv->nv_num = 1;
+ expr_free(nv->nv_ptr);
+ nv->nv_ptr = NULL;
+ }
+ }
+
+ return 0;
+}
+
/*
* Called when evaluating a needs-count expression. Make sure the
* atom is a countable device. The expression succeeds iff there
Index: usr.bin/config/gram.y
===================================================================
RCS file: /cvsroot/src/usr.bin/config/gram.y,v
retrieving revision 1.18
diff -u -r1.18 gram.y
--- usr.bin/config/gram.y 28 Dec 2008 01:23:46 -0000 1.18
+++ usr.bin/config/gram.y 12 Mar 2009 11:57:22 -0000
@@ -507,7 +507,8 @@
condmkoption;
condmkoption:
- WORD mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); };
+ WORD mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); } |
+ fexpr mkvarname PLUSEQ value { appendcondmkoptexpr($1, $2, $4); };
no_mkopt_list:
no_mkopt_list ',' no_mkoption |
Index: usr.bin/config/main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/config/main.c,v
retrieving revision 1.34
diff -u -r1.34 main.c
--- usr.bin/config/main.c 14 Feb 2009 21:28:58 -0000 1.34
+++ usr.bin/config/main.c 12 Mar 2009 11:57:25 -0000
@@ -393,6 +393,12 @@
stop();
/*
+ * Fix make options.
+ */
+ if (fixmkopt())
+ stop();
+
+ /*
* Perform cross-checking.
*/
if (maxusers == 0) {
@@ -965,6 +971,19 @@
}
/*
+ * Add a (complex) conditional appending "make" option.
+ */
+void
+appendcondmkoptexpr(struct nvlist *l, const char *name, const char *value)
+{
+ struct nvlist *nv;
+
+ nv = newnv(name, value, l, 0, NULL);
+ *nextappmkopt = nv;
+ nextappmkopt = &nv->nv_next;
+}
+
+/*
* Add a name=value pair to an option list. The value may be NULL.
*/
static int
Index: usr.bin/config/mkmakefile.c
===================================================================
RCS file: /cvsroot/src/usr.bin/config/mkmakefile.c,v
retrieving revision 1.10
diff -u -r1.10 mkmakefile.c
--- usr.bin/config/mkmakefile.c 20 Feb 2009 05:20:25 -0000 1.10
+++ usr.bin/config/mkmakefile.c 12 Mar 2009 11:57:26 -0000
@@ -567,7 +567,8 @@
struct nvlist *nv;
for (nv = appmkoptions; nv != NULL; nv = nv->nv_next)
- fprintf(fp, "%s+=%s\n", nv->nv_name, nv->nv_str);
+ if (nv->nv_num == 0)
+ fprintf(fp, "%s+=%s\n", nv->nv_name, nv->nv_str);
ht_enumerate(condmkopttab, print_condmkopts, fp);
}
Home |
Main Index |
Thread Index |
Old Index