|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)main.c 1.10 (Berkeley) 8/11/83"; ! 3: #endif ! 4: ! 5: #include <stdio.h> ! 6: #include <ctype.h> ! 7: #include "y.tab.h" ! 8: #include "config.h" ! 9: ! 10: /* ! 11: * Config builds a set of files for building a UNIX ! 12: * system given a description of the desired system. ! 13: */ ! 14: main(argc, argv) ! 15: int argc; ! 16: char **argv; ! 17: { ! 18: ! 19: if (argc > 1 && eq("-p", argv[1])) { ! 20: profiling++; ! 21: argc--, argv++; ! 22: } ! 23: if (argc != 2) { ! 24: fprintf(stderr, "usage: config [ -p ] sysname\n"); ! 25: exit(1); ! 26: } ! 27: PREFIX = argv[1]; ! 28: if (freopen(argv[1], "r", stdin) == NULL) { ! 29: perror(argv[1]); ! 30: exit(2); ! 31: } ! 32: dtab = NULL; ! 33: confp = &conf_list; ! 34: if (yyparse()) ! 35: exit(3); ! 36: switch (machine) { ! 37: ! 38: case MACHINE_VAX: ! 39: vax_ioconf(); /* Print ioconf.c */ ! 40: ubglue(); /* Create ubglue.s */ ! 41: break; ! 42: ! 43: case MACHINE_SUN: ! 44: sun_ioconf(); ! 45: break; ! 46: ! 47: default: ! 48: printf("Specify machine type, e.g. ``machine vax''\n"); ! 49: exit(1); ! 50: } ! 51: makefile(); /* build Makefile */ ! 52: headers(); /* make a lot of .h files */ ! 53: swapconf(); /* swap config files */ ! 54: printf("Don't forget to run \"make depend\"\n"); ! 55: } ! 56: ! 57: /* ! 58: * get_word ! 59: * returns EOF on end of file ! 60: * NULL on end of line ! 61: * pointer to the word otherwise ! 62: */ ! 63: char * ! 64: get_word(fp) ! 65: register FILE *fp; ! 66: { ! 67: static char line[80]; ! 68: register int ch; ! 69: register char *cp; ! 70: ! 71: while ((ch = getc(fp)) != EOF) ! 72: if (ch != ' ' && ch != '\t') ! 73: break; ! 74: if (ch == EOF) ! 75: return ((char *)EOF); ! 76: if (ch == '\n') ! 77: return (NULL); ! 78: cp = line; ! 79: *cp++ = ch; ! 80: while ((ch = getc(fp)) != EOF) { ! 81: if (isspace(ch)) ! 82: break; ! 83: *cp++ = ch; ! 84: } ! 85: *cp = 0; ! 86: if (ch == EOF) ! 87: return ((char *)EOF); ! 88: (void) ungetc(ch, fp); ! 89: return (line); ! 90: } ! 91: ! 92: /* ! 93: * prepend the path to a filename ! 94: */ ! 95: char * ! 96: path(file) ! 97: char *file; ! 98: { ! 99: register char *cp; ! 100: ! 101: cp = malloc((unsigned)(strlen(PREFIX)+strlen(file)+5)); ! 102: (void) strcpy(cp, "../"); ! 103: (void) strcat(cp, PREFIX); ! 104: (void) strcat(cp, "/"); ! 105: (void) strcat(cp, file); ! 106: return (cp); ! 107: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.