fix-up for making GPROF'ed system.
[unix-history] / usr / src / usr.sbin / config / main.c
CommitLineData
73845e07 1/* main.c 1.8 82/12/09 */
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 16
73845e07
SL
17 if (argc > 1 && eq("-p", argv[1])) {
18 profiling++;
19 argc--, argv++;
20 }
9995ca8d 21 if (argc != 2) {
73845e07 22 fprintf(stderr, "usage: config [ -p ] sysname\n");
9995ca8d
BJ
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 }
ca5d0476
MT
48 makefile(); /* build Makefile */
49 headers(); /* make a lot of .h files */
94e09492 50 printf("Don't forget to run \"make depend\"\n");
ca5d0476
MT
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 */
9995ca8d
BJ
59char *
60get_word(fp)
61 register FILE *fp;
ca5d0476 62{
9995ca8d
BJ
63 static char line[80];
64 register int ch;
65 register char *cp;
ca5d0476 66
9995ca8d
BJ
67 while ((ch = getc(fp)) != EOF)
68 if (ch != ' ' && ch != '\t')
69 break;
70 if (ch == EOF)
22d68ad0 71 return ((char *)EOF);
9995ca8d
BJ
72 if (ch == '\n')
73 return (NULL);
74 cp = line;
ca5d0476 75 *cp++ = ch;
9995ca8d
BJ
76 while ((ch = getc(fp)) != EOF) {
77 if (isspace(ch))
78 break;
79 *cp++ = ch;
80 }
81 *cp = 0;
82 if (ch == EOF)
22d68ad0
BJ
83 return ((char *)EOF);
84 (void) ungetc(ch, fp);
9995ca8d 85 return (line);
ca5d0476 86}
0a2de74e
MT
87
88/*
9995ca8d 89 * prepend the path to a filename
0a2de74e 90 */
22d68ad0 91char *
0a2de74e 92path(file)
9995ca8d 93 char *file;
0a2de74e 94{
9995ca8d 95 register char *cp;
0a2de74e 96
22d68ad0
BJ
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);
9995ca8d 102 return (cp);
0a2de74e 103}