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