check point by sklower before hacking asm processing; new regime
[unix-history] / usr / src / usr.sbin / config / mkmakefile.c
index d4009df..ff98990 100644 (file)
@@ -1,12 +1,13 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1980,1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mkmakefile.c       5.10 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)mkmakefile.c       5.29 (Berkeley) %G%";
+#endif /* not lint */
 
 /*
  * Build the makefile for the system, from
 
 /*
  * Build the makefile for the system, from
@@ -18,6 +19,7 @@ static char sccsid[] = "@(#)mkmakefile.c      5.10 (Berkeley) %G%";
 #include <ctype.h>
 #include "y.tab.h"
 #include "config.h"
 #include <ctype.h>
 #include "y.tab.h"
 #include "config.h"
+#include "pathnames.h"
 
 #define next_word(fp, wd) \
        { register char *word = get_word(fp); \
 
 #define next_word(fp, wd) \
        { register char *word = get_word(fp); \
@@ -91,6 +93,7 @@ static        struct users {
 } users[] = {
        { 24, 8, 1024 },                /* MACHINE_VAX */
        { 4, 2, 128 },                  /* MACHINE_TAHOE */
 } users[] = {
        { 24, 8, 1024 },                /* MACHINE_VAX */
        { 4, 2, 128 },                  /* MACHINE_TAHOE */
+       { 8, 2, 64 },                   /* MACHINE_HP300 */
 };
 #define        NUSERS  (sizeof (users) / sizeof (users[0]))
 
 };
 #define        NUSERS  (sizeof (users) / sizeof (users[0]))
 
@@ -105,7 +108,7 @@ makefile()
        struct users *up;
 
        read_files();
        struct users *up;
 
        read_files();
-       strcpy(line, "../conf/Makefile.");
+       strcpy(line, "Makefile.");
        (void) strcat(line, machinename);
        ifp = fopen(line, "r");
        if (ifp == 0) {
        (void) strcat(line, machinename);
        ifp = fopen(line, "r");
        if (ifp == 0) {
@@ -156,25 +159,32 @@ makefile()
        while (fgets(line, BUFSIZ, ifp) != 0) {
                if (*line == '%')
                        goto percent;
        while (fgets(line, BUFSIZ, ifp) != 0) {
                if (*line == '%')
                        goto percent;
-               if (profiling && strncmp(line, "COPTS=", 6) == 0) {
+               if ((debugging || profiling) &&
+                   strncmp(line, "COPTS=", 6) == 0) {
                        register char *cp;
 
                        register char *cp;
 
-                       fprintf(ofp, 
-                           "GPROF.EX=/usr/src/lib/libc/%s/csu/gmon.ex\n",
-                           machinename);
                        cp = index(line, '\n');
                        if (cp)
                                *cp = 0;
                        cp = index(line, '\n');
                        if (cp)
                                *cp = 0;
-                       cp = line + 6;
-                       while (*cp && (*cp == ' ' || *cp == '\t'))
-                               cp++;
-                       COPTS = malloc((unsigned)(strlen(cp) + 1));
-                       if (COPTS == 0) {
-                               printf("config: out of memory\n");
-                               exit(1);
+                       if (profiling) {
+                               cp = line + 6;
+                               while (*cp && (*cp == ' ' || *cp == '\t'))
+                                       cp++;
+                               COPTS = malloc((unsigned)(strlen(cp) + 1));
+                               if (COPTS == 0) {
+                                       printf("config: out of memory\n");
+                                       exit(1);
+                               }
+                               strcpy(COPTS, cp);
                        }
                        }
-                       strcpy(COPTS, cp);
-                       fprintf(ofp, "%s -pg\n", line);
+                       fprintf(ofp, "%s", line);
+                       if (debugging)
+                               fprintf(ofp, " -g");
+                       if (profiling) {
+                               fprintf(ofp, " -pg\n");
+                               fprintf(ofp, _PATH_GPROF, machinename);
+                       } else
+                               fprintf(ofp, "\n");
                        continue;
                }
                fprintf(ofp, "%s", line);
                        continue;
                }
                fprintf(ofp, "%s", line);
@@ -206,13 +216,14 @@ read_files()
        FILE *fp;
        register struct file_list *tp, *pf;
        register struct device *dp;
        FILE *fp;
        register struct file_list *tp, *pf;
        register struct device *dp;
+       struct device *save_dp;
        register struct opt *op;
        char *wd, *this, *needs, *devorprof;
        char fname[32];
        register struct opt *op;
        char *wd, *this, *needs, *devorprof;
        char fname[32];
-       int nreqs, first = 1, configdep, isdup;
+       int nreqs, first = 1, configdep, isdup, std;
 
        ftab = 0;
 
        ftab = 0;
-       (void) strcpy(fname, "files");
+       (void) strcpy(fname, "../../conf/files");
 openit:
        fp = fopen(fname, "r");
        if (fp == 0) {
 openit:
        fp = fopen(fname, "r");
        if (fp == 0) {
@@ -262,19 +273,20 @@ next:
        devorprof = "";
        configdep = 0;
        needs = 0;
        devorprof = "";
        configdep = 0;
        needs = 0;
+       std = 0;
        if (eq(wd, "standard"))
        if (eq(wd, "standard"))
-               goto checkdev;
-       if (!eq(wd, "optional")) {
+               std = 1;
+       else if (!eq(wd, "optional")) {
                printf("%s: %s must be optional or standard\n", fname, this);
                exit(1);
        }
                printf("%s: %s must be optional or standard\n", fname, this);
                exit(1);
        }
-nextopt:
+nextparam:
        next_word(fp, wd);
        if (wd == 0)
        next_word(fp, wd);
        if (wd == 0)
-               goto doneopt;
+               goto doneparam;
        if (eq(wd, "config-dependent")) {
                configdep++;
        if (eq(wd, "config-dependent")) {
                configdep++;
-               goto nextopt;
+               goto nextparam;
        }
        devorprof = wd;
        if (eq(wd, "device-driver") || eq(wd, "profiling-routine")) {
        }
        devorprof = wd;
        if (eq(wd, "device-driver") || eq(wd, "profiling-routine")) {
@@ -286,16 +298,29 @@ nextopt:
                needs = ns(wd);
        if (isdup)
                goto invis;
                needs = ns(wd);
        if (isdup)
                goto invis;
-       for (dp = dtab; dp != 0; dp = dp->d_next)
-               if (eq(dp->d_name, wd))
-                       goto nextopt;
+       for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next)
+               if (eq(dp->d_name, wd)) {
+                       if (std &&
+                           dp->d_type == PSEUDO_DEVICE && dp->d_slave <= 0)
+                               dp->d_slave = 1;
+                       goto nextparam;
+               }
+       if (std) {
+               dp = (struct device *) malloc(sizeof *dp);
+               init_dev(dp);
+               dp->d_name = ns(wd);
+               dp->d_type = PSEUDO_DEVICE;
+               dp->d_slave = 1;
+               save_dp->d_next = dp;
+               goto nextparam;
+       }
        for (op = opt; op != 0; op = op->op_next)
                if (op->op_value == 0 && opteq(op->op_name, wd)) {
                        if (nreqs == 1) {
                                free(needs);
                                needs = 0;
                        }
        for (op = opt; op != 0; op = op->op_next)
                if (op->op_value == 0 && opteq(op->op_name, wd)) {
                        if (nreqs == 1) {
                                free(needs);
                                needs = 0;
                        }
-                       goto nextopt;
+                       goto nextparam;
                }
 invis:
        while ((wd = get_word(fp)) != 0)
                }
 invis:
        while ((wd = get_word(fp)) != 0)
@@ -308,26 +333,13 @@ invis:
        tp->f_flags = isdup;
        goto next;
 
        tp->f_flags = isdup;
        goto next;
 
-doneopt:
-       if (nreqs == 0) {
+doneparam:
+       if (std == 0 && nreqs == 0) {
                printf("%s: what is %s optional on?\n",
                    fname, this);
                exit(1);
        }
 
                printf("%s: what is %s optional on?\n",
                    fname, this);
                exit(1);
        }
 
-checkdev:
-       if (wd) {
-               next_word(fp, wd);
-               if (wd) {
-                       if (eq(wd, "config-dependent")) {
-                               configdep++;
-                               goto checkdev;
-                       }
-                       devorprof = wd;
-                       next_word(fp, wd);
-               }
-       }
-
 save:
        if (wd) {
                printf("%s: syntax error describing %s\n",
 save:
        if (wd) {
                printf("%s: syntax error describing %s\n",
@@ -388,7 +400,7 @@ do_objs(fp)
                for (fl = conf_list; fl; fl = fl->f_next) {
                        if (fl->f_type != SWAPSPEC)
                                continue;
                for (fl = conf_list; fl; fl = fl->f_next) {
                        if (fl->f_type != SWAPSPEC)
                                continue;
-                       sprintf(swapname, "swap%s.c", fl->f_fn);
+                       (void) sprintf(swapname, "swap%s.c", fl->f_fn);
                        if (eq(sp, swapname))
                                goto cont;
                }
                        if (eq(sp, swapname))
                                goto cont;
                }
@@ -412,23 +424,38 @@ cont:
 do_cfiles(fp)
        FILE *fp;
 {
 do_cfiles(fp)
        FILE *fp;
 {
-       register struct file_list *tp;
+       register struct file_list *tp, *fl;
        register int lpos, len;
        register int lpos, len;
+       char swapname[32];
 
 
-       fprintf(fp, "CFILES=");
+       fputs("CFILES=", fp);
        lpos = 8;
        lpos = 8;
-       for (tp = ftab; tp != 0; tp = tp->f_next) {
-               if (tp->f_type == INVISIBLE)
-                       continue;
-               if (tp->f_fn[strlen(tp->f_fn)-1] != 'c')
-                       continue;
-               if ((len = 3 + strlen(tp->f_fn)) + lpos > 72) {
-                       lpos = 8;
-                       fprintf(fp, "\\\n\t");
+       for (tp = ftab; tp; tp = tp->f_next)
+               if (tp->f_type != INVISIBLE) {
+                       len = strlen(tp->f_fn);
+                       if (tp->f_fn[len - 1] != 'c')
+                               continue;
+                       if ((len = 3 + len) + lpos > 72) {
+                               lpos = 8;
+                               fputs("\\\n\t", fp);
+                       }
+                       fprintf(fp, "$S/%s ", tp->f_fn);
+                       lpos += len + 1;
+               }
+       for (fl = conf_list; fl; fl = fl->f_next)
+               if (fl->f_type == SYSTEMSPEC) {
+                       (void) sprintf(swapname, "swap%s.c", fl->f_fn);
+                       if ((len = 3 + strlen(swapname)) + lpos > 72) {
+                               lpos = 8;
+                               fputs("\\\n\t", fp);
+                       }
+                       if (eq(fl->f_fn, "generic"))
+                               fprintf(fp, "$S/%s/%s/%s ",
+                                   machinename, machinename, swapname);
+                       else
+                               fprintf(fp, "%s ", swapname);
+                       lpos += len + 1;
                }
                }
-               fprintf(fp, "../%s ", tp->f_fn);
-               lpos += len + 1;
-       }
        if (lpos != 8)
                putc('\n', fp);
 }
        if (lpos != 8)
                putc('\n', fp);
 }
@@ -466,13 +493,13 @@ for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
        och = *cp;
        *cp = '\0';
        if (och == 'o') {
        och = *cp;
        *cp = '\0';
        if (och == 'o') {
-               fprintf(f, "%so:\n\t-cp ../%so .\n", tail(np), np);
+               fprintf(f, "%so:\n\t-cp $S/%so .\n\n", tail(np), np);
                continue;
        }
                continue;
        }
-       fprintf(f, "%so: ../%s%c\n", tail(np), np, och);
+       fprintf(f, "%so: $S/%s%c\n", tail(np), np, och);
        tp = tail(np);
        if (och == 's') {
        tp = tail(np);
        if (och == 's') {
-               fprintf(f, "\t-ln -s ../%ss %sc\n", np, tp);
+               fprintf(f, "\t-ln -s $S/%ss %sc\n", np, tp);
                fprintf(f, "\t${CC} -E ${COPTS} %sc | ${AS} -o %so\n",
                        tp, tp);
                fprintf(f, "\trm -f %sc\n\n", tp);
                fprintf(f, "\t${CC} -E ${COPTS} %sc | ${AS} -o %so\n",
                        tp, tp);
                fprintf(f, "\trm -f %sc\n\n", tp);
@@ -489,12 +516,17 @@ for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
 
                case MACHINE_VAX:
                case MACHINE_TAHOE:
 
                case MACHINE_VAX:
                case MACHINE_TAHOE:
-                       fprintf(f, "\t${CC} -c -S ${COPTS} %s../%sc\n",
+                       fprintf(f, "\t${CC} -c -S ${COPTS} %s$S/%sc\n",
                                extras, np);
                        fprintf(f, "\t${C2} %ss | ${INLINE} | ${AS} -o %so\n",
                            tp, tp);
                        fprintf(f, "\trm -f %ss\n\n", tp);
                        break;
                                extras, np);
                        fprintf(f, "\t${C2} %ss | ${INLINE} | ${AS} -o %so\n",
                            tp, tp);
                        fprintf(f, "\trm -f %ss\n\n", tp);
                        break;
+
+               case MACHINE_HP300:
+                       fprintf(f, "\t${CC} -c ${CFLAGS} %s$S/%sc\n\n",
+                               extras, np);
+                       break;
                }
                break;
 
                }
                break;
 
@@ -503,12 +535,17 @@ for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
 
                case MACHINE_VAX:
                case MACHINE_TAHOE:
 
                case MACHINE_VAX:
                case MACHINE_TAHOE:
-                       fprintf(f, "\t${CC} -c -S ${COPTS} %s../%sc\n",
+                       fprintf(f, "\t${CC} -c -S ${COPTS} %s$S/%sc\n",
                                extras, np);
                        fprintf(f,"\t${C2} -i %ss | ${INLINE} | ${AS} -o %so\n",
                            tp, tp);
                        fprintf(f, "\trm -f %ss\n\n", tp);
                        break;
                                extras, np);
                        fprintf(f,"\t${C2} -i %ss | ${INLINE} | ${AS} -o %so\n",
                            tp, tp);
                        fprintf(f, "\trm -f %ss\n\n", tp);
                        break;
+
+               case MACHINE_HP300:
+                       fprintf(f, "\t${CC} -c ${CFLAGS} %s$S/%sc\n\n",
+                               extras, np);
+                       break;
                }
                break;
 
                }
                break;
 
@@ -523,7 +560,7 @@ for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
                switch (machine) {
 
                case MACHINE_TAHOE:
                switch (machine) {
 
                case MACHINE_TAHOE:
-                       fprintf(f, "\t${CC} -c -S %s %s../%sc\n",
+                       fprintf(f, "\t${CC} -c -S %s %s$S/%sc\n",
                                COPTS, extras, np);
                        fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp);
                        fprintf(f,"\t${C2} %ss | ${INLINE} | ${AS} -o %so\n",
                                COPTS, extras, np);
                        fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp);
                        fprintf(f,"\t${C2} %ss | ${INLINE} | ${AS} -o %so\n",
@@ -532,12 +569,20 @@ for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
                        break;
 
                case MACHINE_VAX:
                        break;
 
                case MACHINE_VAX:
-                       fprintf(f, "\t${CC} -c -S %s %s../%sc\n",
+                       fprintf(f, "\t${CC} -c -S %s %s$S/%sc\n",
                                COPTS, extras, np);
                        fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp);
                        fprintf(f, "\t${INLINE} %ss | ${AS} -o %so\n", tp, tp);
                        fprintf(f, "\trm -f %ss\n\n", tp);
                        break;
                                COPTS, extras, np);
                        fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp);
                        fprintf(f, "\t${INLINE} %ss | ${AS} -o %so\n", tp, tp);
                        fprintf(f, "\trm -f %ss\n\n", tp);
                        break;
+
+               case MACHINE_HP300:
+                       fprintf(f, "\t${CC} -c -S %s %s$S/%sc\n",
+                               COPTS, extras, np);
+                       fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp);
+                       fprintf(f, "\t${AS} -o %so %ss\n", tp, tp);
+                       fprintf(f, "\trm -f %ss\n\n", tp);
+                       break;
                }
                break;
 
                }
                break;
 
@@ -556,24 +601,17 @@ do_load(f)
        register FILE *f;
 {
        register struct file_list *fl;
        register FILE *f;
 {
        register struct file_list *fl;
-       int first = 1;
+       register int first;
        struct file_list *do_systemspec();
 
        struct file_list *do_systemspec();
 
-       fl = conf_list;
-       while (fl) {
-               if (fl->f_type != SYSTEMSPEC) {
-                       fl = fl->f_next;
-                       continue;
-               }
-               fl = do_systemspec(f, fl, first);
-               if (first)
-                       first = 0;
-       }
-       fprintf(f, "all:");
-       for (fl = conf_list; fl != 0; fl = fl->f_next)
+       for (first = 1, fl = conf_list; fl; first = 0)
+               fl = fl->f_type == SYSTEMSPEC ?
+                       do_systemspec(f, fl, first) : fl->f_next;
+       fputs("all:", f);
+       for (fl = conf_list; fl; fl = fl->f_next)
                if (fl->f_type == SYSTEMSPEC)
                        fprintf(f, " %s", fl->f_needs);
                if (fl->f_type == SYSTEMSPEC)
                        fprintf(f, " %s", fl->f_needs);
-       fprintf(f, "\n");
+       putc('\n', f);
 }
 
 struct file_list *
 }
 
 struct file_list *
@@ -583,35 +621,44 @@ do_systemspec(f, fl, first)
        int first;
 {
 
        int first;
 {
 
-       fprintf(f, "%s: Makefile", fl->f_needs);
-       if (machine == MACHINE_VAX || machine == MACHINE_TAHOE)
-               fprintf(f, " ${INLINE}", machinename);
-       fprintf(f, " locore.o ${OBJS} param.o ioconf.o swap%s.o\n", fl->f_fn);
+       fprintf(f, "%s: Makefile symbols.sort", fl->f_needs);
+       if (machine == MACHINE_VAX)
+               fprintf(f, " ${INLINECMD} locore.o emulate.o");
+       else if (machine == MACHINE_TAHOE)
+               fprintf(f, " ${INLINE} locore.o");
+       else
+               fprintf(f, " locore.o");
+       fprintf(f, " ${OBJS} param.o ioconf.o swap%s.o\n", fl->f_fn);
        fprintf(f, "\t@echo loading %s\n\t@rm -f %s\n",
            fl->f_needs, fl->f_needs);
        if (first) {
        fprintf(f, "\t@echo loading %s\n\t@rm -f %s\n",
            fl->f_needs, fl->f_needs);
        if (first) {
-               fprintf(f, "\t@sh ../conf/newvers.sh\n");
-               fprintf(f, "\t@${CC} $(CFLAGS) -c vers.c\n");
+               fprintf(f, "\t@sh $S/conf/newvers.sh\n");
+               fprintf(f, "\t@${CC} ${CFLAGS} -c vers.c\n");
        }
        switch (machine) {
 
        case MACHINE_VAX:
        }
        switch (machine) {
 
        case MACHINE_VAX:
-               fprintf(f, "\t@${LD} -n -o %s -e start -x -T 80000000 ",
-                       fl->f_needs);
+               fprintf(f, "\t@${LD} -n -o %s -e start -%c -T 80000000 ",
+                       fl->f_needs, debugging ? 'X' : 'x');
                fprintf(f,
                    "locore.o emulate.o ${OBJS} vers.o ioconf.o param.o ");
                break;
 
        case MACHINE_TAHOE:
                fprintf(f,
                    "locore.o emulate.o ${OBJS} vers.o ioconf.o param.o ");
                break;
 
        case MACHINE_TAHOE:
-               fprintf(f, "\t@${LD} -n -o %s -e start -x -T C0000800 ",
-                       fl->f_needs);
+               fprintf(f, "\t@${LD} -n -o %s -e start -%c -T C0000800 ",
+                       fl->f_needs, debugging ? 'X' : 'x');
+               fprintf(f, "locore.o ${OBJS} vers.o ioconf.o param.o ");
+               break;
+
+       case MACHINE_HP300:
+               fprintf(f, "\t@${LD} -n -o %s -e start -%c ",
+                       fl->f_needs, debugging ? 'X' : 'x');
                fprintf(f, "locore.o ${OBJS} vers.o ioconf.o param.o ");
                break;
        }
        fprintf(f, "swap%s.o\n", fl->f_fn);
        fprintf(f, "\t@echo rearranging symbols\n");
                fprintf(f, "locore.o ${OBJS} vers.o ioconf.o param.o ");
                break;
        }
        fprintf(f, "swap%s.o\n", fl->f_fn);
        fprintf(f, "\t@echo rearranging symbols\n");
-       fprintf(f, "\t@-symorder ../%s/symbols.sort %s\n",
-           machinename, fl->f_needs);
+       fprintf(f, "\t@-symorder symbols.sort %s\n", fl->f_needs);
        fprintf(f, "\t@size %s\n", fl->f_needs);
        fprintf(f, "\t@chmod 755 %s\n\n", fl->f_needs);
        do_swapspec(f, fl->f_fn);
        fprintf(f, "\t@size %s\n", fl->f_needs);
        fprintf(f, "\t@chmod 755 %s\n\n", fl->f_needs);
        do_swapspec(f, fl->f_fn);
@@ -630,17 +677,25 @@ do_swapspec(f, name)
                fprintf(f, "\t${CC} -c -O ${COPTS} swap%s.c\n\n", name);
                return;
        }
                fprintf(f, "\t${CC} -c -O ${COPTS} swap%s.c\n\n", name);
                return;
        }
-       fprintf(f, "swapgeneric.o: ../%s/swapgeneric.c\n", machinename);
+       fprintf(f, "swapgeneric.o: $S/%s/%s/swapgeneric.c\n", 
+           machinename, machinename);
        switch (machine) {
 
        case MACHINE_VAX:
        case MACHINE_TAHOE:
                fprintf(f, "\t${CC} -c -S ${COPTS} ");
        switch (machine) {
 
        case MACHINE_VAX:
        case MACHINE_TAHOE:
                fprintf(f, "\t${CC} -c -S ${COPTS} ");
-               fprintf(f, "../%s/swapgeneric.c\n", machinename);
+               fprintf(f, "$S/%s/%s/swapgeneric.c\n",
+                   machinename, machinename);
                fprintf(f, "\t${C2} swapgeneric.s | ${INLINE}");
                fprintf(f, " | ${AS} -o swapgeneric.o\n");
                fprintf(f, "\trm -f swapgeneric.s\n\n");
                break;
                fprintf(f, "\t${C2} swapgeneric.s | ${INLINE}");
                fprintf(f, " | ${AS} -o swapgeneric.o\n");
                fprintf(f, "\trm -f swapgeneric.s\n\n");
                break;
+
+       case MACHINE_HP300:
+               fprintf(f, "\t${CC} -c ${CFLAGS} ");
+               fprintf(f, "$S/%s/%s/swapgeneric.c\n\n",
+                   machinename, machinename);
+               break;
        }
 }
 
        }
 }