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