Add two new options, -U and -D, that can be used to define "makeoptions"
on the config command line. While there, rename the undocumented (internal) parser debug option from -D to -d. Discussed on tech-toolchain.
This commit is contained in:
parent
ecad429601
commit
1957b5eaba
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: config.1,v 1.13 2012/08/30 12:42:41 wiz Exp $
|
||||
.\" $NetBSD: config.1,v 1.14 2014/05/05 19:08:13 martin Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -40,6 +40,8 @@
|
|||
.Op Fl Ppv
|
||||
.Op Fl b Ar builddir
|
||||
.Op Fl s Ar srcdir
|
||||
.Op Fl D Ar var=value
|
||||
.Op Fl U Ar value
|
||||
.Op Ar config-file
|
||||
.Nm
|
||||
.Fl x
|
||||
|
@ -109,6 +111,11 @@ Use
|
|||
.Ar builddir
|
||||
as the kernel build directory, instead of computing and creating one
|
||||
automatically.
|
||||
.It Fl D Ar var=value
|
||||
Define a makeoptions variable to the given value.
|
||||
This is equivalent to appending a
|
||||
.Li makeoptions var=value
|
||||
line to the config file.
|
||||
.It Fl L
|
||||
Generate a lint configuration.
|
||||
See section
|
||||
|
@ -131,6 +138,12 @@ is used to prepare a kernel build directory, but can be relative
|
|||
when it is used in combination with the
|
||||
.Fl L
|
||||
flag.
|
||||
.It Fl U Ar var
|
||||
Undefine the makeoption
|
||||
.Ar var .
|
||||
This is equivalent to appending the line
|
||||
.Li no makeoptions var
|
||||
to the config file.
|
||||
.It Fl v
|
||||
Increase verbosity by enabling some more warnings.
|
||||
.It Fl x
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: defs.h,v 1.44 2012/06/08 08:56:45 martin Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.45 2014/05/05 19:08:13 martin 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 20100430
|
||||
#define CONFIG_VERSION 20140502
|
||||
#define CONFIG_MINVERSION 0
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.51 2013/11/01 21:39:13 christos Exp $ */
|
||||
/* $NetBSD: main.c,v 1.52 2014/05/05 19:08:13 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -86,6 +86,7 @@ COPYRIGHT("@(#) Copyright (c) 1992, 1993\
|
|||
int vflag; /* verbose output */
|
||||
int Pflag; /* pack locators */
|
||||
int Lflag; /* lint config generation */
|
||||
int handling_cmdlineopts; /* currently processing -D/-U options */
|
||||
|
||||
int yyparse(void);
|
||||
|
||||
|
@ -100,6 +101,7 @@ static struct nvlist **nextmkopt;
|
|||
static struct nvlist **nextappmkopt;
|
||||
static struct nvlist **nextcndmkopt;
|
||||
static struct nvlist **nextfsopt;
|
||||
static struct nvlist *cmdlinedefs, *cmdlineundefs;
|
||||
|
||||
static void usage(void) __dead;
|
||||
static void dependopts(void);
|
||||
|
@ -119,6 +121,9 @@ static int mkident(void);
|
|||
static int devbase_has_dead_instances(const char *, void *, void *);
|
||||
static int devbase_has_any_instance(struct devbase *, int, int, int);
|
||||
static int check_dead_devi(const char *, void *, void *);
|
||||
static void add_makeopt(const char *);
|
||||
static void remove_makeopt(const char *);
|
||||
static void handle_cmdline_makeoptions(void);
|
||||
static void kill_orphans(void);
|
||||
static void do_kill_orphans(struct devbase *, struct attr *,
|
||||
struct devbase *, int);
|
||||
|
@ -155,11 +160,11 @@ main(int argc, char **argv)
|
|||
|
||||
pflag = 0;
|
||||
xflag = 0;
|
||||
while ((ch = getopt(argc, argv, "DLPgpvb:s:x")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "D:LPU:dgpvb:s:x")) != -1) {
|
||||
switch (ch) {
|
||||
|
||||
#ifndef MAKE_BOOTSTRAP
|
||||
case 'D':
|
||||
case 'd':
|
||||
yydebug = 1;
|
||||
break;
|
||||
#endif
|
||||
|
@ -179,7 +184,7 @@ main(int argc, char **argv)
|
|||
* do that for you, but you really should just
|
||||
* put them in the config file.
|
||||
*/
|
||||
warnx("-g is obsolete (use makeoptions DEBUG=\"-g\")");
|
||||
warnx("-g is obsolete (use -D DEBUG=\"-g\")");
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
|
||||
|
@ -213,6 +218,14 @@ main(int argc, char **argv)
|
|||
xflag = 1;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
add_makeopt(optarg);
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
remove_makeopt(optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
|
@ -385,6 +398,11 @@ main(int argc, char **argv)
|
|||
if (removeit)
|
||||
unlink(cname);
|
||||
|
||||
/*
|
||||
* Handle command line overrides
|
||||
*/
|
||||
handle_cmdline_makeoptions();
|
||||
|
||||
/*
|
||||
* Detect and properly ignore orphaned devices
|
||||
*/
|
||||
|
@ -469,6 +487,7 @@ static void
|
|||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "Usage: %s [-Ppv] [-s srcdir] [-b builddir] "
|
||||
"[-D var=value] [-U var] "
|
||||
"[config-file]\n\t%s -x [kernel-file]\n"
|
||||
"\t%s -L [-v] [-s srcdir] [config-file]\n",
|
||||
getprogname(), getprogname(), getprogname());
|
||||
|
@ -1071,6 +1090,11 @@ undo_option(struct hashtab *ht, struct nvlist **npp,
|
|||
struct nvlist *nv;
|
||||
|
||||
if (ht_remove(ht, name)) {
|
||||
/*
|
||||
* -U command line option removals are always silent
|
||||
*/
|
||||
if (handling_cmdlineopts)
|
||||
return 0;
|
||||
cfgerror("%s `%s' is not defined", type, name);
|
||||
return (1);
|
||||
}
|
||||
|
@ -1770,3 +1794,56 @@ kill_orphans(void)
|
|||
{
|
||||
ht_enumerate(devroottab, kill_orphans_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
add_makeopt(const char *opt)
|
||||
{
|
||||
struct nvlist *p;
|
||||
char *buf = estrdup(opt);
|
||||
char *eq = strchr(buf, '=');
|
||||
|
||||
if (!eq)
|
||||
errx(EXIT_FAILURE, "-D %s is not in var=value format", opt);
|
||||
|
||||
*eq = 0;
|
||||
p = newnv(estrdup(buf), estrdup(eq+1), NULL, 0, NULL);
|
||||
free(buf);
|
||||
p->nv_next = cmdlinedefs;
|
||||
cmdlinedefs = p;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_makeopt(const char *opt)
|
||||
{
|
||||
struct nvlist *p;
|
||||
|
||||
p = newnv(estrdup(opt), NULL, NULL, 0, NULL);
|
||||
p->nv_next = cmdlineundefs;
|
||||
cmdlineundefs = p;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_cmdline_makeoptions(void)
|
||||
{
|
||||
struct nvlist *p, *n;
|
||||
|
||||
handling_cmdlineopts = 1;
|
||||
for (p = cmdlineundefs; p; p = n) {
|
||||
n = p->nv_next;
|
||||
delmkoption(intern(p->nv_name));
|
||||
free(__UNCONST(p->nv_name));
|
||||
nvfree(p);
|
||||
}
|
||||
for (p = cmdlinedefs; p; p = n) {
|
||||
const char *name = intern(p->nv_name);
|
||||
|
||||
n = p->nv_next;
|
||||
delmkoption(name);
|
||||
addmkoption(name, intern(p->nv_str));
|
||||
free(__UNCONST(p->nv_name));
|
||||
free(__UNCONST(p->nv_str));
|
||||
|
||||
nvfree(p);
|
||||
}
|
||||
handling_cmdlineopts = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue