Module Name: src Committed By: uebayasi Date: Sat Aug 29 02:54:07 UTC 2015
Modified Files: src/usr.bin/config: config.5 defs.h files.c gram.y mkmakefile.c Log Message: Revert "Retire optional `rule' argument of `file' command". It is still used in m68k ports. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/config/config.5 cvs rdiff -u -r1.66 -r1.67 src/usr.bin/config/defs.h cvs rdiff -u -r1.20 -r1.21 src/usr.bin/config/files.c cvs rdiff -u -r1.47 -r1.48 src/usr.bin/config/gram.y cvs rdiff -u -r1.41 -r1.42 src/usr.bin/config/mkmakefile.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.27 src/usr.bin/config/config.5:1.28 --- src/usr.bin/config/config.5:1.27 Fri Aug 28 09:04:02 2015 +++ src/usr.bin/config/config.5 Sat Aug 29 02:54:07 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: config.5,v 1.27 2015/08/28 09:04:02 uebayasi Exp $ +.\" $NetBSD: config.5,v 1.28 2015/08/29 02:54:07 uebayasi Exp $ .\" .\" Copyright (c) 2006, 2007 The NetBSD Foundation. .\" All rights reserved. @@ -471,7 +471,7 @@ Interface attributes can also be defined .Ar dependencies list. .It Ic file Ar path Oo Ar condition Oc Oo Ic needs-count Oc \ - Oo Ic needs-flag Oc + Oo Ic needs-flag Oc Op Ic compile with Ar rule Adds a source file to the list of files to be compiled into the kernel, if the .Ar conditions are met. @@ -509,6 +509,23 @@ instances of the device in the .Ic needs-count case, or to 1 in all the other cases. .Pp +The +.Ar rule +argument specifies the +.Xr make 1 +rule that will be used to compile the source file. +If it is not given, the default rule for the type of the file will be used. +For a given file, there can be more than one +.Ic file +statement, but not from the same configuration source file, and all later +statements can only specify a +.Ar rule +argument, and no +.Ar conditions +or flags. +This is useful when a file needs special consideration from one particular +architecture. +.Pp The path is relative to the top of the kernel source tree, or the inner-most defined .Ic prefix . Index: src/usr.bin/config/defs.h diff -u src/usr.bin/config/defs.h:1.66 src/usr.bin/config/defs.h:1.67 --- src/usr.bin/config/defs.h:1.66 Fri Aug 28 09:04:02 2015 +++ src/usr.bin/config/defs.h Sat Aug 29 02:54:07 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.66 2015/08/28 09:04:02 uebayasi Exp $ */ +/* $NetBSD: defs.h,v 1.67 2015/08/29 02:54:07 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -365,6 +365,7 @@ struct files { const char *fi_base; /* tail minus ".c" (or whatever) */ struct condexpr *fi_optx; /* options expression */ struct nvlist *fi_optf; /* flattened version of above, if needed */ + const char *fi_mkrule; /* special make rule, if any */ }; #define fi_srcfile fi_fit.fit_srcfile #define fi_srcline fi_fit.fit_srcline @@ -549,7 +550,7 @@ void checkfiles(void); int fixfiles(void); /* finalize */ int fixobjects(void); int fixdevsw(void); -void addfile(const char *, struct condexpr *, u_char); +void addfile(const char *, struct condexpr *, u_char, const char *); void addobject(const char *, struct condexpr *, u_char); int expr_eval(struct condexpr *, int (*)(const char *, void *), void *); Index: src/usr.bin/config/files.c diff -u src/usr.bin/config/files.c:1.20 src/usr.bin/config/files.c:1.21 --- src/usr.bin/config/files.c:1.20 Fri Aug 28 09:04:02 2015 +++ src/usr.bin/config/files.c Sat Aug 29 02:54:07 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: files.c,v 1.20 2015/08/28 09:04:02 uebayasi Exp $ */ +/* $NetBSD: files.c,v 1.21 2015/08/29 02:54:07 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: files.c,v 1.20 2015/08/28 09:04:02 uebayasi Exp $"); +__RCSID("$NetBSD: files.c,v 1.21 2015/08/29 02:54:07 uebayasi Exp $"); #include <sys/param.h> #include <errno.h> @@ -86,7 +86,7 @@ initfiles(void) } void -addfile(const char *path, struct condexpr *optx, u_char flags) +addfile(const char *path, struct condexpr *optx, u_char flags, const char *rule) { struct files *fi; const char *dotp, *tail; @@ -133,6 +133,20 @@ addfile(const char *path, struct condexp free(fi); if ((fi = ht_lookup(pathtab, path)) == NULL) panic("addfile: ht_lookup(%s)", path); + + /* + * If it's a duplicate entry, it is must specify a make + * rule, and only a make rule, and must come from + * a different source file than the original entry. + * If it does otherwise, it is disallowed. This allows + * machine-dependent files to override the compilation + * options for specific files. + */ + if (rule != NULL && optx == NULL && flags == 0 && + yyfile != fi->fi_srcfile) { + fi->fi_mkrule = rule; + return; + } cfgerror("duplicate file %s", path); cfgxerror(fi->fi_srcfile, fi->fi_srcline, "here is the original definition"); @@ -152,6 +166,7 @@ addfile(const char *path, struct condexp fi->fi_suffix = path[fi->fi_len - 1]; fi->fi_optx = optx; fi->fi_optf = NULL; + fi->fi_mkrule = rule; fi->fi_attr = NULL; TAILQ_INSERT_TAIL(&allfiles, fi, fi_next); return; Index: src/usr.bin/config/gram.y diff -u src/usr.bin/config/gram.y:1.47 src/usr.bin/config/gram.y:1.48 --- src/usr.bin/config/gram.y:1.47 Fri Aug 28 09:04:02 2015 +++ src/usr.bin/config/gram.y Sat Aug 29 02:54:07 2015 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: gram.y,v 1.47 2015/08/28 09:04:02 uebayasi Exp $ */ +/* $NetBSD: gram.y,v 1.48 2015/08/29 02:54:07 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: gram.y,v 1.47 2015/08/28 09:04:02 uebayasi Exp $"); +__RCSID("$NetBSD: gram.y,v 1.48 2015/08/29 02:54:07 uebayasi Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -194,6 +194,7 @@ static struct loclist *namelocvals(const %type <condexpr> cond_base_expr %type <str> fs_spec %type <flag> fflags fflag oflags oflag +%type <str> rule %type <attr> depend %type <devb> devbase %type <deva> devattach_opt @@ -337,7 +338,7 @@ definition: /* source file: file foo/bar.c bar|baz needs-flag compile-with blah */ define_file: - XFILE filename fopts fflags { addfile($2, $3, $4); } + XFILE filename fopts fflags rule { addfile($2, $3, $4, $5); } ; /* object file: object zot.o foo|zot needs-flag */ @@ -458,6 +459,12 @@ fflag: | NEEDS_FLAG { $$ = FI_NEEDSFLAG; } ; +/* extra compile directive for a source file */ +rule: + /* empty */ { $$ = NULL; } + | COMPILE_WITH stringvalue { $$ = $2; } +; + /* zero or more flags for an object file */ oflags: /* empty */ { $$ = 0; } Index: src/usr.bin/config/mkmakefile.c diff -u src/usr.bin/config/mkmakefile.c:1.41 src/usr.bin/config/mkmakefile.c:1.42 --- src/usr.bin/config/mkmakefile.c:1.41 Fri Aug 28 09:16:29 2015 +++ src/usr.bin/config/mkmakefile.c Sat Aug 29 02:54:07 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: mkmakefile.c,v 1.41 2015/08/28 09:16:29 uebayasi Exp $ */ +/* $NetBSD: mkmakefile.c,v 1.42 2015/08/29 02:54:07 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: mkmakefile.c,v 1.41 2015/08/28 09:16:29 uebayasi Exp $"); +__RCSID("$NetBSD: mkmakefile.c,v 1.42 2015/08/29 02:54:07 uebayasi Exp $"); #include <sys/param.h> #include <ctype.h> @@ -505,7 +505,11 @@ emitrules(FILE *fp) } fprintf(fp, "%s.o: %s%s%s%s\n", fi->fi_base, "$S/", prefix, sep, fi->fi_path); - fprintf(fp, "\t${NORMAL_%c}\n\n", toupper(fi->fi_suffix)); + if (fi->fi_mkrule != NULL) { + fprintf(fp, "\t%s\n\n", fi->fi_mkrule); + } else { + fprintf(fp, "\t${NORMAL_%c}\n\n", toupper(fi->fi_suffix)); + } } }