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 ``normal'' .c/.S rules as .for loops. ...



details:   https://anonhg.NetBSD.org/src/rev/f14119a4d283
branches:  trunk
changeset: 340268:f14119a4d283
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Sat Aug 29 17:35:23 2015 +0000

description:
Define ``normal'' .c/.S rules as .for loops.  Still explicit and ugly, but
these will be eventually replaced with suffix rules.  Tested x68k where .c/.S
rules are overriden with "compile-with".

diffstat:

 usr.bin/config/mkmakefile.c |  54 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 12 deletions(-)

diffs (110 lines):

diff -r e5b596d60b38 -r f14119a4d283 usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c       Sat Aug 29 17:18:35 2015 +0000
+++ b/usr.bin/config/mkmakefile.c       Sat Aug 29 17:35:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkmakefile.c,v 1.45 2015/08/29 14:07:45 uebayasi Exp $ */
+/*     $NetBSD: mkmakefile.c,v 1.46 2015/08/29 17:35:23 uebayasi Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkmakefile.c,v 1.45 2015/08/29 14:07:45 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.46 2015/08/29 17:35:23 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -445,13 +445,13 @@
 }
 
 static void
-emitfiles(FILE *fp, int suffix, int upper_suffix)
+emitxfiles(FILE *fp, int suffix, int upper_suffix, int normal)
 {
        struct files *fi;
        struct config *cf;
-       char swapname[100];
 
-       fprintf(fp, "%cFILES= \\\n", toupper(suffix));
+       fprintf(fp, "%cFILES.%snormal= \\\n", toupper(suffix),
+           normal ? "" : "ab");
        TAILQ_FOREACH(fi, &allfiles, fi_next) {
                const char *prefix, *sep;
 
@@ -465,9 +465,25 @@
                } else {
                        prefix = sep = "";
                }
-               fprintf(fp, "\t%s%s%s%s \\\n", "$S/", prefix, sep,
-                   fi->fi_path);
+               if (((fi->fi_mkrule == NULL) && normal) ||
+                   ((fi->fi_mkrule != NULL) && !normal))
+                       fprintf(fp, "\t%s%s%s%s \\\n", "$S/", prefix, sep,
+                           fi->fi_path);
        }
+       putc('\n', fp);
+}
+
+static void
+emitfiles(FILE *fp, int suffix, int upper_suffix)
+{
+       struct files *fi;
+       struct config *cf;
+       char swapname[100];
+
+       emitxfiles(fp, suffix, upper_suffix, 1);
+       emitxfiles(fp, suffix, upper_suffix, 0);
+       fprintf(fp, "%cFILES= ${%cFILES.normal} ${%cFILES.abnormal} \\\n",
+           toupper(suffix), toupper(suffix), toupper(suffix));
        /*
         * The allfiles list does not include the configuration-specific
         * C source files.  These files should be eliminated someday, but
@@ -487,15 +503,33 @@
  * Emit the make-rules.
  */
 static void
+emitxrules(FILE *fp, int suffix)
+{
+       char s = tolower(suffix), S = toupper(suffix);
+
+       fprintf(fp, ".for _%cfile in ${%cFILES.normal}\n", s, S);
+       fprintf(fp, "${_%cfile:T:R}.o: ${_%cfile}\n", s, s);
+       fprintf(fp, "\t${NORMAL_%c}\n", S);
+       fprintf(fp, ".endfor\n\n");
+}
+
+static void
 emitrules(FILE *fp)
 {
        struct files *fi;
 
+       /* normal */
+       emitxrules(fp, 'c');
+       emitxrules(fp, 's');
+
+       /* abnormal */
        TAILQ_FOREACH(fi, &allfiles, fi_next) {
                const char *prefix, *sep;
 
                if ((fi->fi_flags & FI_SEL) == 0)
                        continue;
+               if (fi->fi_mkrule == NULL)
+                       continue;
                if (fi->fi_prefix != NULL) {
                        prefix = fi->fi_prefix;
                        sep = "/";
@@ -504,11 +538,7 @@
                }
                fprintf(fp, "%s.o: %s%s%s%s\n", fi->fi_base, "$S/", prefix,
                    sep, fi->fi_path);
-               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));
-               }
+               fprintf(fp, "\t%s\n\n", fi->fi_mkrule);
        }
 }
 



Home | Main Index | Thread Index | Old Index