|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted provided ! 6: * that: (1) source distributions retain this entire copyright notice and ! 7: * comment, and (2) distributions including binaries display the following ! 8: * acknowledgement: ``This product includes software developed by the ! 9: * University of California, Berkeley and its contributors'' in the ! 10: * documentation or other materials provided with the distribution and in ! 11: * all advertising materials mentioning features or use of this software. ! 12: * Neither the name of the University nor the names of its contributors may ! 13: * be used to endorse or promote products derived from this software without ! 14: * specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: char copyright[] = ! 22: "@(#) Copyright (c) 1980 Regents of the University of California.\n\ ! 23: All rights reserved.\n"; ! 24: #endif /* not lint */ ! 25: ! 26: #ifndef lint ! 27: static char sccsid[] = "@(#)main.c 5.12 (Berkeley) 6/1/90"; ! 28: #endif /* not lint */ ! 29: ! 30: #include <sys/types.h> ! 31: #include <sys/stat.h> ! 32: #include <sys/file.h> ! 33: #include <stdio.h> ! 34: #include <ctype.h> ! 35: #include "y.tab.h" ! 36: #include "config.h" ! 37: ! 38: static char *PREFIX; ! 39: ! 40: /* ! 41: * Config builds a set of files for building a UNIX ! 42: * system given a description of the desired system. ! 43: */ ! 44: main(argc, argv) ! 45: int argc; ! 46: char **argv; ! 47: { ! 48: ! 49: extern char *optarg; ! 50: extern int optind; ! 51: struct stat buf; ! 52: int ch; ! 53: char *p; ! 54: ! 55: while ((ch = getopt(argc, argv, "gp")) != EOF) ! 56: switch((char)ch) { ! 57: case 'g': ! 58: debugging++; ! 59: break; ! 60: case 'p': ! 61: profiling++; ! 62: break; ! 63: case '?': ! 64: default: ! 65: goto usage; ! 66: } ! 67: argc -= optind; ! 68: argv += optind; ! 69: ! 70: if (argc != 1) { ! 71: usage: fputs("usage: config [-gp] sysname\n", stderr); ! 72: exit(1); ! 73: } ! 74: ! 75: if (freopen(PREFIX = *argv, "r", stdin) == NULL) { ! 76: perror(PREFIX); ! 77: exit(2); ! 78: } ! 79: if (stat(p = path((char *)NULL), &buf)) { ! 80: if (mkdir(p, 0777)) { ! 81: perror(p); ! 82: exit(2); ! 83: } ! 84: } ! 85: else if ((buf.st_mode & S_IFMT) != S_IFDIR) { ! 86: fprintf(stderr, "config: %s isn't a directory.\n", p); ! 87: exit(2); ! 88: } ! 89: ! 90: dtab = NULL; ! 91: confp = &conf_list; ! 92: if (yyparse()) ! 93: exit(3); ! 94: switch (machine) { ! 95: ! 96: case MACHINE_VAX: ! 97: vax_ioconf(); /* Print ioconf.c */ ! 98: ubglue(); /* Create ubglue.s */ ! 99: break; ! 100: ! 101: case MACHINE_TAHOE: ! 102: tahoe_ioconf(); ! 103: vbglue(); ! 104: break; ! 105: ! 106: case MACHINE_HP300: ! 107: hp300_ioconf(); ! 108: hpglue(); ! 109: break; ! 110: ! 111: default: ! 112: printf("Specify machine type, e.g. ``machine vax''\n"); ! 113: exit(1); ! 114: } ! 115: /* ! 116: * make symbolic links in compilation directory ! 117: * for "sys" (to make genassym.c work along with #include <sys/xxx>) ! 118: * and similarly for "machine". ! 119: */ ! 120: { ! 121: char xxx[80]; ! 122: ! 123: (void) symlink("../sys", path("sys")); ! 124: (void) sprintf(xxx, "../%s", machinename); ! 125: (void) symlink(xxx, path("machine")); ! 126: } ! 127: makefile(); /* build Makefile */ ! 128: headers(); /* make a lot of .h files */ ! 129: swapconf(); /* swap config files */ ! 130: printf("Don't forget to run \"make depend\"\n"); ! 131: exit(0); ! 132: } ! 133: ! 134: /* ! 135: * get_word ! 136: * returns EOF on end of file ! 137: * NULL on end of line ! 138: * pointer to the word otherwise ! 139: */ ! 140: char * ! 141: get_word(fp) ! 142: register FILE *fp; ! 143: { ! 144: static char line[80]; ! 145: register int ch; ! 146: register char *cp; ! 147: ! 148: while ((ch = getc(fp)) != EOF) ! 149: if (ch != ' ' && ch != '\t') ! 150: break; ! 151: if (ch == EOF) ! 152: return ((char *)EOF); ! 153: if (ch == '\n') ! 154: return (NULL); ! 155: cp = line; ! 156: *cp++ = ch; ! 157: while ((ch = getc(fp)) != EOF) { ! 158: if (isspace(ch)) ! 159: break; ! 160: *cp++ = ch; ! 161: } ! 162: *cp = 0; ! 163: if (ch == EOF) ! 164: return ((char *)EOF); ! 165: (void) ungetc(ch, fp); ! 166: return (line); ! 167: } ! 168: ! 169: /* ! 170: * prepend the path to a filename ! 171: */ ! 172: char * ! 173: path(file) ! 174: char *file; ! 175: { ! 176: register char *cp; ! 177: ! 178: cp = malloc((unsigned)(strlen(PREFIX)+strlen(file)+5)); ! 179: (void) strcpy(cp, "../"); ! 180: (void) strcat(cp, PREFIX); ! 181: if (file) { ! 182: (void) strcat(cp, "/"); ! 183: (void) strcat(cp, file); ! 184: } ! 185: return (cp); ! 186: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.