Commit | Line | Data |
---|---|---|
cd68466f DF |
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 | ||
524aa063 | 13 | #ifndef lint |
a0105456 | 14 | static char sccsid[] = "@(#)main.c 5.3 (Berkeley) %G%"; |
cd68466f | 15 | #endif not lint |
ca5d0476 MT |
16 | |
17 | #include <stdio.h> | |
18 | #include <ctype.h> | |
19 | #include "y.tab.h" | |
20 | #include "config.h" | |
21 | ||
9995ca8d BJ |
22 | /* |
23 | * Config builds a set of files for building a UNIX | |
24 | * system given a description of the desired system. | |
25 | */ | |
ca5d0476 | 26 | main(argc, argv) |
9995ca8d BJ |
27 | int argc; |
28 | char **argv; | |
ca5d0476 | 29 | { |
9995ca8d | 30 | |
73845e07 SL |
31 | if (argc > 1 && eq("-p", argv[1])) { |
32 | profiling++; | |
33 | argc--, argv++; | |
34 | } | |
9995ca8d | 35 | if (argc != 2) { |
73845e07 | 36 | fprintf(stderr, "usage: config [ -p ] sysname\n"); |
9995ca8d BJ |
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; | |
36edb824 | 45 | confp = &conf_list; |
9995ca8d BJ |
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 | ||
a0105456 SL |
55 | case MACHINE_TAHOE: |
56 | tahoe_ioconf(); | |
57 | vbglue(); | |
9995ca8d BJ |
58 | break; |
59 | ||
60 | default: | |
61 | printf("Specify machine type, e.g. ``machine vax''\n"); | |
62 | exit(1); | |
63 | } | |
efa1561d | 64 | symlink("../h", path("sys")); /* make genassym.c work */ |
ca5d0476 MT |
65 | makefile(); /* build Makefile */ |
66 | headers(); /* make a lot of .h files */ | |
36edb824 | 67 | swapconf(); /* swap config files */ |
94e09492 | 68 | printf("Don't forget to run \"make depend\"\n"); |
ca5d0476 MT |
69 | } |
70 | ||
71 | /* | |
72 | * get_word | |
73 | * returns EOF on end of file | |
74 | * NULL on end of line | |
75 | * pointer to the word otherwise | |
76 | */ | |
9995ca8d BJ |
77 | char * |
78 | get_word(fp) | |
79 | register FILE *fp; | |
ca5d0476 | 80 | { |
9995ca8d BJ |
81 | static char line[80]; |
82 | register int ch; | |
83 | register char *cp; | |
ca5d0476 | 84 | |
9995ca8d BJ |
85 | while ((ch = getc(fp)) != EOF) |
86 | if (ch != ' ' && ch != '\t') | |
87 | break; | |
88 | if (ch == EOF) | |
22d68ad0 | 89 | return ((char *)EOF); |
9995ca8d BJ |
90 | if (ch == '\n') |
91 | return (NULL); | |
92 | cp = line; | |
ca5d0476 | 93 | *cp++ = ch; |
9995ca8d BJ |
94 | while ((ch = getc(fp)) != EOF) { |
95 | if (isspace(ch)) | |
96 | break; | |
97 | *cp++ = ch; | |
98 | } | |
99 | *cp = 0; | |
100 | if (ch == EOF) | |
22d68ad0 BJ |
101 | return ((char *)EOF); |
102 | (void) ungetc(ch, fp); | |
9995ca8d | 103 | return (line); |
ca5d0476 | 104 | } |
0a2de74e MT |
105 | |
106 | /* | |
9995ca8d | 107 | * prepend the path to a filename |
0a2de74e | 108 | */ |
22d68ad0 | 109 | char * |
0a2de74e | 110 | path(file) |
9995ca8d | 111 | char *file; |
0a2de74e | 112 | { |
9995ca8d | 113 | register char *cp; |
0a2de74e | 114 | |
22d68ad0 BJ |
115 | cp = malloc((unsigned)(strlen(PREFIX)+strlen(file)+5)); |
116 | (void) strcpy(cp, "../"); | |
117 | (void) strcat(cp, PREFIX); | |
118 | (void) strcat(cp, "/"); | |
119 | (void) strcat(cp, file); | |
9995ca8d | 120 | return (cp); |
0a2de74e | 121 | } |