summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-04-27 18:09:53 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-04-27 18:09:53 +0000
commit17eb13c151eb29a4a105173e61a3c689ddc93077 (patch)
tree803c7da0d68393eac185fb8573ca5a87a0e6c5d4 /usr.sbin
parent0a36ba41132d2b40e19e6d4f385275484c9b8c85 (diff)
lint(1) support in config:
- LINTS variables to hold the list of *.ln files. - OBJS derives from it, since it can contain more files. - add set of explicit rules for each .ln file. - add a lint-with keyword that duplicates compile-with functionality to special-case linting instead of compilation. Full linting is dependent on LINT_* macros in the arch dependent template files. As is, doesn't break normal build. Just creates larger Makefiles. Review/ok miod@, cloder@, deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/config.h6
-rw-r--r--usr.sbin/config/files.c8
-rw-r--r--usr.sbin/config/gram.y12
-rw-r--r--usr.sbin/config/mkmakefile.c25
-rw-r--r--usr.sbin/config/scan.l3
5 files changed, 36 insertions, 18 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index f44da6b8b76..d3b77bef886 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.h,v 1.21 2004/01/04 18:30:05 deraadt Exp $ */
+/* $OpenBSD: config.h,v 1.22 2006/04/27 18:09:52 espie Exp $ */
/* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */
/*
@@ -230,7 +230,7 @@ struct files {
const char *fi_base; /* tail minus ".c" (or whatever) */
struct nvlist *fi_optx;/* options expression */
struct nvlist *fi_optf;/* flattened version of above, if needed */
- const char *fi_mkrule; /* special make rule, if any */
+ const char *fi_mkrule[2];/* special make rules, if any */
};
/*
@@ -320,7 +320,7 @@ void initfiles(void);
void checkfiles(void);
int fixfiles(void); /* finalize */
int fixobjects(void);
-void addfile(const char *, struct nvlist *, int, const char *);
+void addfile(const char *, struct nvlist *, int, const char *, const char *);
void addobject(const char *, struct nvlist *, int);
/* hash.c */
diff --git a/usr.sbin/config/files.c b/usr.sbin/config/files.c
index 404f30733ea..9f5c53b25c7 100644
--- a/usr.sbin/config/files.c
+++ b/usr.sbin/config/files.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: files.c,v 1.13 2003/06/28 04:55:07 deraadt Exp $ */
+/* $OpenBSD: files.c,v 1.14 2006/04/27 18:09:52 espie Exp $ */
/* $NetBSD: files.c,v 1.6 1996/03/17 13:18:17 cgd Exp $ */
/*
@@ -84,7 +84,8 @@ initfiles(void)
}
void
-addfile(const char *path, struct nvlist *optx, int flags, const char *rule)
+addfile(const char *path, struct nvlist *optx, int flags, const char *rule,
+ const char *lintrule)
{
struct files *fi;
const char *dotp, *tail;
@@ -141,7 +142,8 @@ addfile(const char *path, struct nvlist *optx, int flags, const char *rule)
fi->fi_base = intern(base);
fi->fi_optx = optx;
fi->fi_optf = NULL;
- fi->fi_mkrule = rule;
+ fi->fi_mkrule[0] = rule;
+ fi->fi_mkrule[1] = lintrule;
*nextfile = fi;
nextfile = &fi->fi_next;
return;
diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y
index 5b5578271c9..4118437bcbe 100644
--- a/usr.sbin/config/gram.y
+++ b/usr.sbin/config/gram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: gram.y,v 1.18 2004/01/04 00:47:01 deraadt Exp $ */
+/* $OpenBSD: gram.y,v 1.19 2006/04/27 18:09:52 espie Exp $ */
/* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */
/*
@@ -96,7 +96,8 @@ static void check_maxpart(void);
int val;
}
-%token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFINE DEFOPT DEVICE DISABLE
+%token AND AT ATTACH BUILD COMPILE_WITH LINT_WITH CONFIG DEFINE DEFOPT
+%token DEVICE DISABLE
%token DUMPS ENDFILE XFILE XOBJECT FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS
%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE SWAP
%token WITH NEEDS_COUNT NEEDS_FLAG RMOPTIONS ENABLE
@@ -109,6 +110,7 @@ static void check_maxpart(void);
%type <list> fopts fexpr fatom
%type <val> fflgs fflag oflgs oflag
%type <str> rule
+%type <str> lintrule
%type <attr> attr
%type <devb> devbase
%type <deva> devattach_opt
@@ -168,7 +170,7 @@ dev_eof:
* Various nonterminals shared between the grammars.
*/
file:
- XFILE PATHNAME fopts fflgs rule { addfile($2, $3, $4, $5); };
+ XFILE PATHNAME fopts fflgs rule lintrule { addfile($2, $3, $4, $5, $6); };
object:
XOBJECT PATHNAME fopts oflgs { addobject($2, $3, $4); };
@@ -207,6 +209,10 @@ rule:
COMPILE_WITH WORD { $$ = $2; } |
/* empty */ { $$ = NULL; };
+lintrule:
+ LINT_WITH WORD { $$ = $2; } |
+ /* empty */ { $$ = NULL; };
+
include:
INCLUDE WORD { include($2, 0); };
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 916d6d55843..54252515064 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkmakefile.c,v 1.18 2006/04/08 02:22:54 krw Exp $ */
+/* $OpenBSD: mkmakefile.c,v 1.19 2006/04/27 18:09:52 espie Exp $ */
/* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */
/*
@@ -221,25 +221,28 @@ emitobjs(FILE *fp)
struct objects *oi;
int lpos, len, sp;
- if (fputs("OBJS=", fp) < 0)
+ if (fputs("LINTS=", fp) < 0)
return (1);
sp = '\t';
lpos = 7;
for (fi = allfiles; fi != NULL; fi = fi->fi_next) {
if ((fi->fi_flags & FI_SEL) == 0)
continue;
- len = strlen(fi->fi_base) + 2;
+ len = strlen(fi->fi_base) + 3;
if (lpos + len > 72) {
if (fputs(" \\\n", fp) < 0)
return (1);
sp = '\t';
lpos = 7;
}
- if (fprintf(fp, "%c%s.o", sp, fi->fi_base) < 0)
+ if (fprintf(fp, "%c%s.ln", sp, fi->fi_base) < 0)
return (1);
lpos += len + 1;
sp = ' ';
}
+ if (fputs("\n\nOBJS=\t${LINTS:.ln=.o}", fp) < 0)
+ return (1);
+ lpos = 7 + strlen("${LINTS:.ln=.o}");
for (oi = allobjects; oi != NULL; oi = oi->oi_next) {
if ((oi->oi_flags & OI_SEL) == 0)
continue;
@@ -345,7 +348,7 @@ emitfiles(FILE *fp, int suffix)
* Emit the make-rules.
*/
static int
-emitrules(FILE *fp)
+emitrules1(FILE *fp, const char *suffix, const char *rule_prefix, int ruleindex)
{
struct files *fi;
const char *cp, *fpath;
@@ -357,11 +360,11 @@ emitrules(FILE *fp)
continue;
if ((fpath = srcpath(fi)) == NULL)
return (1);
- if (fprintf(fp, "%s.o: %s%s\n", fi->fi_base,
+ if (fprintf(fp, "%s%s: %s%s\n", fi->fi_base, suffix,
*fpath != '/' ? "$S/" : "", fpath) < 0)
return (1);
- if ((cp = fi->fi_mkrule) == NULL) {
- cp = "NORMAL";
+ if ((cp = fi->fi_mkrule[ruleindex]) == NULL) {
+ cp = rule_prefix;
ch = fpath[strlen(fpath) - 1];
if (islower(ch))
ch = toupper(ch);
@@ -375,6 +378,12 @@ emitrules(FILE *fp)
return (0);
}
+static int
+emitrules(FILE *fp)
+{
+ return emitrules1(fp, ".o", "NORMAL", 0) || emitrules1(fp, ".ln", "LINT", 1);
+}
+
/*
* Emit the load commands.
*
diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l
index 302a0716dd0..00e58bd186b 100644
--- a/usr.sbin/config/scan.l
+++ b/usr.sbin/config/scan.l
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: scan.l,v 1.18 2006/03/10 07:54:44 otto Exp $ */
+/* $OpenBSD: scan.l,v 1.19 2006/04/27 18:09:52 espie Exp $ */
/* $NetBSD: scan.l,v 1.13 1997/02/02 21:12:37 thorpej Exp $ */
/*
@@ -84,6 +84,7 @@ at return AT;
attach return ATTACH;
build return BUILD;
compile-with return COMPILE_WITH;
+lint-with return LINT_WITH;
config return CONFIG;
define return DEFINE;
defopt return DEFOPT;