check point by sklower before hacking asm processing; new regime
[unix-history] / usr / src / usr.sbin / config / mkmakefile.c
index 4acf9e5..ff98990 100644 (file)
@@ -2,21 +2,11 @@
  * Copyright (c) 1980,1990 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980,1990 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mkmakefile.c       5.26 (Berkeley) %G%";
+static char sccsid[] = "@(#)mkmakefile.c       5.29 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -103,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]))
 
@@ -117,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) {
@@ -168,23 +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, _PATH_GPROF, 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);
@@ -216,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) {
@@ -272,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")) {
@@ -296,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)
@@ -318,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",
@@ -437,7 +439,7 @@ do_cfiles(fp)
                                lpos = 8;
                                fputs("\\\n\t", fp);
                        }
                                lpos = 8;
                                fputs("\\\n\t", fp);
                        }
-                       fprintf(fp, "../%s ", tp->f_fn);
+                       fprintf(fp, "$S/%s ", tp->f_fn);
                        lpos += len + 1;
                }
        for (fl = conf_list; fl; fl = fl->f_next)
                        lpos += len + 1;
                }
        for (fl = conf_list; fl; fl = fl->f_next)
@@ -448,7 +450,8 @@ do_cfiles(fp)
                                fputs("\\\n\t", fp);
                        }
                        if (eq(fl->f_fn, "generic"))
                                fputs("\\\n\t", fp);
                        }
                        if (eq(fl->f_fn, "generic"))
-                               fprintf(fp, "../%s/%s ", machinename, swapname);
+                               fprintf(fp, "$S/%s/%s/%s ",
+                                   machinename, machinename, swapname);
                        else
                                fprintf(fp, "%s ", swapname);
                        lpos += len + 1;
                        else
                                fprintf(fp, "%s ", swapname);
                        lpos += len + 1;
@@ -490,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\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);
@@ -513,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;
 
@@ -527,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;
 
@@ -547,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",
@@ -556,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;
 
@@ -600,7 +621,7 @@ do_systemspec(f, fl, first)
        int first;
 {
 
        int first;
 {
 
-       fprintf(f, "%s: Makefile machine/symbols.sort", fl->f_needs);
+       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)
        if (machine == MACHINE_VAX)
                fprintf(f, " ${INLINECMD} locore.o emulate.o");
        else if (machine == MACHINE_TAHOE)
@@ -611,27 +632,33 @@ do_systemspec(f, fl, first)
        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 machine/symbols.sort %s\n", 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);
@@ -650,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;
        }
 }
 
        }
 }