Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/config Implement code to generate Makefile to build ...



details:   https://anonhg.NetBSD.org/src/rev/3e8e1a58309b
branches:  trunk
changeset: 332792:3e8e1a58309b
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Thu Oct 09 17:00:15 2014 +0000

description:
Implement code to generate Makefile to build netbsd via intermediate relocatable
object files.  Disabled for now.  Commit this for further experiments.

Kernel (netbsd) has been built as:

        netbsd: *.o
                ld -o netbsd *.o

Change this to:

        netbsd: *.ko
                ld -o netbsd *.ko
        acpica.ko: ${OBJS.acpica}
                ld -r acpica.ko ${OBJS.acpica}
        :

You can call *.ko as a module, but this is not only beneficial for loadable
module, but also localize related text/data.  Various options/flags/params
will be able to be per-ko.  Unnecessary symbols can be hidden.  Many ideas
will follow.

diffstat:

 usr.bin/config/mkmakefile.c |  72 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 70 insertions(+), 2 deletions(-)

diffs (107 lines):

diff -r 11b1f1b8f1f0 -r 3e8e1a58309b usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c       Thu Oct 09 16:35:57 2014 +0000
+++ b/usr.bin/config/mkmakefile.c       Thu Oct 09 17:00:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkmakefile.c,v 1.17 2014/08/18 08:07:02 joerg Exp $    */
+/*     $NetBSD: mkmakefile.c,v 1.18 2014/10/09 17:00:15 uebayasi Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -68,6 +68,11 @@
 static void emitfiles(FILE *, int, int);
 
 static void emitobjs(FILE *);
+static void emitallkobjs(FILE *);
+static int emitallkobjscb(const char *, void *, void *);
+static void emitattrkobjs(FILE *);
+static int emitattrkobjscb(const char *, void *, void *);
+static void emitkobjs(FILE *);
 static void emitcfiles(FILE *);
 static void emitsfiles(FILE *);
 static void emitrules(FILE *);
@@ -77,6 +82,9 @@
 static void emitsubs(FILE *, const char *, const char *, int);
 static int  selectopt(const char *, void *);
 
+/* Generate Makefile to build things per-attribute *.ko (a.k.a modular build). */
+int usekobjs = 0;      /* XXX */
+
 int
 mkmakefile(void)
 {
@@ -120,7 +128,7 @@
                        continue;
                }
                if (strcmp(line, "%OBJS\n") == 0)
-                       fn = emitobjs;
+                       fn = usekobjs ? emitobjs : emitkobjs;
                else if (strcmp(line, "%CFILES\n") == 0)
                        fn = emitcfiles;
                else if (strcmp(line, "%SFILES\n") == 0)
@@ -372,6 +380,66 @@
 }
 
 static void
+emitkobjs(FILE *fp)
+{
+       emitallkobjs(fp);
+       emitattrkobjs(fp);
+}
+
+static void
+emitallkobjs(FILE *fp)
+{
+
+       fputs("OBJS=", fp);
+       ht_enumerate(attrtab, emitallkobjscb, fp);
+       putc('\n', fp);
+}
+
+static int
+emitallkobjscb(const char *name, void *v, void *arg)
+{
+       struct attr *a = v;
+       FILE *fp = arg;
+
+       if (ht_lookup(selecttab, name) == NULL)
+               return 0;
+       if (TAILQ_EMPTY(&a->a_files))
+               return 0;
+       fprintf(fp, " %s.ko", name);
+       return 0;
+}
+
+static void
+emitattrkobjs(FILE *fp)
+{
+       extern struct   hashtab *attrtab;
+
+       ht_enumerate(attrtab, emitattrkobjscb, fp);
+}
+
+static int
+emitattrkobjscb(const char *name, void *v, void *arg)
+{
+       struct attr *a = v;
+       struct files *fi;
+       FILE *fp = arg;
+
+       if (ht_lookup(selecttab, name) == NULL)
+               return 0;
+       if (TAILQ_EMPTY(&a->a_files))
+               return 0;
+       fputc('\n', fp);
+       fprintf(fp, "OBJS.%s=", name);
+       TAILQ_FOREACH(fi, &a->a_files, fi_anext) {
+               fprintf(fp, " %s.o", fi->fi_base);
+       }
+       fputc('\n', fp);
+       fprintf(fp, "%s.ko: ${OBJS.%s}\n", name, name);
+       fprintf(fp, "\t${LINK_O}\n");
+       return 0;
+}
+
+static void
 emitcfiles(FILE *fp)
 {
 



Home | Main Index | Thread Index | Old Index