/* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; #endif not lint #ifndef lint static char sccsid[] = "@(#)main.c 5.2 (Berkeley) 1/11/86"; #endif not lint #include #include #include "y.tab.h" #include "config.h" /* * Config builds a set of files for building a UNIX * system given a description of the desired system. */ main(argc, argv) int argc; char **argv; { if (argc > 1 && eq("-p", argv[1])) { profiling++; argc--, argv++; } if (argc != 2) { fprintf(stderr, "usage: config [ -p ] sysname\n"); exit(1); } PREFIX = argv[1]; if (freopen(argv[1], "r", stdin) == NULL) { perror(argv[1]); exit(2); } dtab = NULL; confp = &conf_list; if (yyparse()) exit(3); switch (machine) { case MACHINE_VAX: vax_ioconf(); /* Print ioconf.c */ ubglue(); /* Create ubglue.s */ break; case MACHINE_SUN: sun_ioconf(); break; default: printf("Specify machine type, e.g. ``machine vax''\n"); exit(1); } symlink("../h", path("sys")); /* make genassym.c work */ makefile(); /* build Makefile */ headers(); /* make a lot of .h files */ swapconf(); /* swap config files */ printf("Don't forget to run \"make depend\"\n"); } /* * get_word * returns EOF on end of file * NULL on end of line * pointer to the word otherwise */ char * get_word(fp) register FILE *fp; { static char line[80]; register int ch; register char *cp; while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') break; if (ch == EOF) return ((char *)EOF); if (ch == '\n') return (NULL); cp = line; *cp++ = ch; while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; *cp++ = ch; } *cp = 0; if (ch == EOF) return ((char *)EOF); (void) ungetc(ch, fp); return (line); } /* * prepend the path to a filename */ char * path(file) char *file; { register char *cp; cp = malloc((unsigned)(strlen(PREFIX)+strlen(file)+5)); (void) strcpy(cp, "../"); (void) strcat(cp, PREFIX); (void) strcat(cp, "/"); (void) strcat(cp, file); return (cp); }