1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifndef lint
8: char copyright[] =
9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
10: All rights reserved.\n";
11: #endif not lint
12:
13: #ifndef lint
14: static char sccsid[] = "@(#)main.c 5.2 (Berkeley) 1/11/86";
15: #endif not lint
16:
17: #include <stdio.h>
18: #include <ctype.h>
19: #include "y.tab.h"
20: #include "config.h"
21:
22: /*
23: * Config builds a set of files for building a UNIX
24: * system given a description of the desired system.
25: */
26: main(argc, argv)
27: int argc;
28: char **argv;
29: {
30:
31: if (argc > 1 && eq("-p", argv[1])) {
32: profiling++;
33: argc--, argv++;
34: }
35: if (argc != 2) {
36: fprintf(stderr, "usage: config [ -p ] sysname\n");
37: exit(1);
38: }
39: PREFIX = argv[1];
40: if (freopen(argv[1], "r", stdin) == NULL) {
41: perror(argv[1]);
42: exit(2);
43: }
44: dtab = NULL;
45: confp = &conf_list;
46: if (yyparse())
47: exit(3);
48: switch (machine) {
49:
50: case MACHINE_VAX:
51: vax_ioconf(); /* Print ioconf.c */
52: ubglue(); /* Create ubglue.s */
53: break;
54:
55: case MACHINE_SUN:
56: sun_ioconf();
57: break;
58:
59: default:
60: printf("Specify machine type, e.g. ``machine vax''\n");
61: exit(1);
62: }
63: symlink("../h", path("sys")); /* make genassym.c work */
64: makefile(); /* build Makefile */
65: headers(); /* make a lot of .h files */
66: swapconf(); /* swap config files */
67: printf("Don't forget to run \"make depend\"\n");
68: }
69:
70: /*
71: * get_word
72: * returns EOF on end of file
73: * NULL on end of line
74: * pointer to the word otherwise
75: */
76: char *
77: get_word(fp)
78: register FILE *fp;
79: {
80: static char line[80];
81: register int ch;
82: register char *cp;
83:
84: while ((ch = getc(fp)) != EOF)
85: if (ch != ' ' && ch != '\t')
86: break;
87: if (ch == EOF)
88: return ((char *)EOF);
89: if (ch == '\n')
90: return (NULL);
91: cp = line;
92: *cp++ = ch;
93: while ((ch = getc(fp)) != EOF) {
94: if (isspace(ch))
95: break;
96: *cp++ = ch;
97: }
98: *cp = 0;
99: if (ch == EOF)
100: return ((char *)EOF);
101: (void) ungetc(ch, fp);
102: return (line);
103: }
104:
105: /*
106: * prepend the path to a filename
107: */
108: char *
109: path(file)
110: char *file;
111: {
112: register char *cp;
113:
114: cp = malloc((unsigned)(strlen(PREFIX)+strlen(file)+5));
115: (void) strcpy(cp, "../");
116: (void) strcat(cp, PREFIX);
117: (void) strcat(cp, "/");
118: (void) strcat(cp, file);
119: return (cp);
120: }
Defined functions
main
defined in line
26;
never used
path
defined in line
108; used 16 times
Defined variables