Commit | Line | Data |
---|---|---|
cd68466f DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
86f9c1e9 KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
b8c620d6 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
cd68466f DF |
16 | */ |
17 | ||
524aa063 | 18 | #ifndef lint |
287b46cc | 19 | static char sccsid[] = "@(#)mkmakefile.c 5.22 (Berkeley) %G%"; |
86f9c1e9 | 20 | #endif /* not lint */ |
28061b3f | 21 | |
01d17851 | 22 | /* |
28061b3f BJ |
23 | * Build the makefile for the system, from |
24 | * the information in the files files and the | |
25 | * additional files for the machine being compiled to. | |
01d17851 MT |
26 | */ |
27 | ||
28 | #include <stdio.h> | |
d5429061 | 29 | #include <ctype.h> |
01d17851 MT |
30 | #include "y.tab.h" |
31 | #include "config.h" | |
287b46cc | 32 | #include "pathnames.h" |
01d17851 | 33 | |
28061b3f BJ |
34 | #define next_word(fp, wd) \ |
35 | { register char *word = get_word(fp); \ | |
22d68ad0 BJ |
36 | if (word == (char *)EOF) \ |
37 | return; \ | |
28061b3f BJ |
38 | else \ |
39 | wd = word; \ | |
40 | } | |
01d17851 | 41 | |
28061b3f | 42 | static struct file_list *fcur; |
15eb15d7 | 43 | char *tail(); |
01d17851 MT |
44 | |
45 | /* | |
e3dad45e | 46 | * Lookup a file, by name. |
01d17851 | 47 | */ |
28061b3f BJ |
48 | struct file_list * |
49 | fl_lookup(file) | |
50 | register char *file; | |
01d17851 | 51 | { |
28061b3f BJ |
52 | register struct file_list *fp; |
53 | ||
22d68ad0 | 54 | for (fp = ftab ; fp != 0; fp = fp->f_next) { |
28061b3f BJ |
55 | if (eq(fp->f_fn, file)) |
56 | return (fp); | |
57 | } | |
58 | return (0); | |
01d17851 MT |
59 | } |
60 | ||
15eb15d7 KM |
61 | /* |
62 | * Lookup a file, by final component name. | |
63 | */ | |
64 | struct file_list * | |
65 | fltail_lookup(file) | |
66 | register char *file; | |
67 | { | |
68 | register struct file_list *fp; | |
69 | ||
70 | for (fp = ftab ; fp != 0; fp = fp->f_next) { | |
71 | if (eq(tail(fp->f_fn), tail(file))) | |
72 | return (fp); | |
73 | } | |
74 | return (0); | |
75 | } | |
76 | ||
01d17851 | 77 | /* |
28061b3f | 78 | * Make a new file list entry |
01d17851 | 79 | */ |
28061b3f BJ |
80 | struct file_list * |
81 | new_fent() | |
01d17851 | 82 | { |
28061b3f BJ |
83 | register struct file_list *fp; |
84 | ||
85 | fp = (struct file_list *) malloc(sizeof *fp); | |
22d68ad0 BJ |
86 | fp->f_needs = 0; |
87 | fp->f_next = 0; | |
3c812eeb SL |
88 | fp->f_flags = 0; |
89 | fp->f_type = 0; | |
22d68ad0 | 90 | if (fcur == 0) |
28061b3f BJ |
91 | fcur = ftab = fp; |
92 | else | |
93 | fcur->f_next = fp; | |
94 | fcur = fp; | |
95 | return (fp); | |
01d17851 MT |
96 | } |
97 | ||
28061b3f | 98 | char *COPTS; |
18d7531d SL |
99 | static struct users { |
100 | int u_default; | |
101 | int u_min; | |
102 | int u_max; | |
103 | } users[] = { | |
104 | { 24, 8, 1024 }, /* MACHINE_VAX */ | |
a0105456 | 105 | { 4, 2, 128 }, /* MACHINE_TAHOE */ |
18d7531d SL |
106 | }; |
107 | #define NUSERS (sizeof (users) / sizeof (users[0])) | |
28061b3f | 108 | |
01d17851 | 109 | /* |
28061b3f | 110 | * Build the makefile from the skeleton |
01d17851 | 111 | */ |
01d17851 MT |
112 | makefile() |
113 | { | |
28061b3f BJ |
114 | FILE *ifp, *ofp; |
115 | char line[BUFSIZ]; | |
116 | struct opt *op; | |
18d7531d | 117 | struct users *up; |
28061b3f BJ |
118 | |
119 | read_files(); | |
05b83a6c | 120 | strcpy(line, "../conf/Makefile."); |
22d68ad0 | 121 | (void) strcat(line, machinename); |
28061b3f | 122 | ifp = fopen(line, "r"); |
22d68ad0 | 123 | if (ifp == 0) { |
28061b3f BJ |
124 | perror(line); |
125 | exit(1); | |
126 | } | |
05b83a6c | 127 | ofp = fopen(path("Makefile"), "w"); |
22d68ad0 | 128 | if (ofp == 0) { |
05b83a6c | 129 | perror(path("Makefile")); |
28061b3f BJ |
130 | exit(1); |
131 | } | |
132 | fprintf(ofp, "IDENT=-D%s", raise(ident)); | |
133 | if (profiling) | |
134 | fprintf(ofp, " -DGPROF"); | |
135 | if (cputype == 0) { | |
136 | printf("cpu type must be specified\n"); | |
137 | exit(1); | |
138 | } | |
139 | { struct cputype *cp; | |
140 | for (cp = cputype; cp; cp = cp->cpu_next) | |
141 | fprintf(ofp, " -D%s", cp->cpu_name); | |
142 | } | |
143 | for (op = opt; op; op = op->op_next) | |
144 | if (op->op_value) | |
145 | fprintf(ofp, " -D%s=\"%s\"", op->op_name, op->op_value); | |
146 | else | |
147 | fprintf(ofp, " -D%s", op->op_name); | |
148 | fprintf(ofp, "\n"); | |
149 | if (hadtz == 0) | |
150 | printf("timezone not specified; gmt assumed\n"); | |
18d7531d SL |
151 | if ((unsigned)machine > NUSERS) { |
152 | printf("maxusers config info isn't present, using vax\n"); | |
153 | up = &users[MACHINE_VAX-1]; | |
154 | } else | |
155 | up = &users[machine-1]; | |
28061b3f | 156 | if (maxusers == 0) { |
18d7531d SL |
157 | printf("maxusers not specified; %d assumed\n", up->u_default); |
158 | maxusers = up->u_default; | |
159 | } else if (maxusers < up->u_min) { | |
160 | printf("minimum of %d maxusers assumed\n", up->u_min); | |
161 | maxusers = up->u_min; | |
162 | } else if (maxusers > up->u_max) | |
163 | printf("warning: maxusers > %d (%d)\n", up->u_max, maxusers); | |
28061b3f BJ |
164 | fprintf(ofp, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d\n", |
165 | timezone, dst, maxusers); | |
7c1d4665 MK |
166 | for (op = mkopt; op; op = op->op_next) |
167 | fprintf(ofp, "%s=%s\n", op->op_name, op->op_value); | |
22d68ad0 | 168 | while (fgets(line, BUFSIZ, ifp) != 0) { |
28061b3f BJ |
169 | if (*line == '%') |
170 | goto percent; | |
171 | if (profiling && strncmp(line, "COPTS=", 6) == 0) { | |
172 | register char *cp; | |
173 | ||
287b46cc | 174 | fprintf(ofp, _PATH_GPROF, machinename); |
28061b3f BJ |
175 | cp = index(line, '\n'); |
176 | if (cp) | |
177 | *cp = 0; | |
178 | cp = line + 6; | |
179 | while (*cp && (*cp == ' ' || *cp == '\t')) | |
180 | cp++; | |
22d68ad0 | 181 | COPTS = malloc((unsigned)(strlen(cp) + 1)); |
28061b3f | 182 | if (COPTS == 0) { |
f2db9eb7 | 183 | printf("config: out of memory\n"); |
28061b3f BJ |
184 | exit(1); |
185 | } | |
186 | strcpy(COPTS, cp); | |
187 | fprintf(ofp, "%s -pg\n", line); | |
188 | continue; | |
8486638c | 189 | } |
28061b3f | 190 | fprintf(ofp, "%s", line); |
8486638c | 191 | continue; |
28061b3f BJ |
192 | percent: |
193 | if (eq(line, "%OBJS\n")) | |
194 | do_objs(ofp); | |
195 | else if (eq(line, "%CFILES\n")) | |
196 | do_cfiles(ofp); | |
197 | else if (eq(line, "%RULES\n")) | |
198 | do_rules(ofp); | |
199 | else if (eq(line, "%LOAD\n")) | |
200 | do_load(ofp); | |
201 | else | |
202 | fprintf(stderr, | |
203 | "Unknown %% construct in generic makefile: %s", | |
204 | line); | |
01d17851 | 205 | } |
73845e07 SL |
206 | (void) fclose(ifp); |
207 | (void) fclose(ofp); | |
01d17851 MT |
208 | } |
209 | ||
210 | /* | |
28061b3f BJ |
211 | * Read in the information about files used in making the system. |
212 | * Store it in the ftab linked list. | |
01d17851 | 213 | */ |
01d17851 MT |
214 | read_files() |
215 | { | |
28061b3f | 216 | FILE *fp; |
e3dad45e | 217 | register struct file_list *tp, *pf; |
28061b3f | 218 | register struct device *dp; |
05b83a6c | 219 | register struct opt *op; |
28061b3f BJ |
220 | char *wd, *this, *needs, *devorprof; |
221 | char fname[32]; | |
05b83a6c | 222 | int nreqs, first = 1, configdep, isdup; |
28061b3f | 223 | |
22d68ad0 BJ |
224 | ftab = 0; |
225 | (void) strcpy(fname, "files"); | |
28061b3f BJ |
226 | openit: |
227 | fp = fopen(fname, "r"); | |
22d68ad0 | 228 | if (fp == 0) { |
73845e07 | 229 | perror(fname); |
28061b3f BJ |
230 | exit(1); |
231 | } | |
232 | next: | |
3c812eeb SL |
233 | /* |
234 | * filename [ standard | optional ] [ config-dependent ] | |
235 | * [ dev* | profiling-routine ] [ device-driver] | |
236 | */ | |
28061b3f | 237 | wd = get_word(fp); |
22d68ad0 BJ |
238 | if (wd == (char *)EOF) { |
239 | (void) fclose(fp); | |
15eb15d7 | 240 | if (first == 1) { |
22d68ad0 | 241 | (void) sprintf(fname, "files.%s", machinename); |
15eb15d7 | 242 | first++; |
28061b3f BJ |
243 | goto openit; |
244 | } | |
15eb15d7 KM |
245 | if (first == 2) { |
246 | (void) sprintf(fname, "files.%s", raise(ident)); | |
247 | first++; | |
248 | fp = fopen(fname, "r"); | |
249 | if (fp != 0) | |
250 | goto next; | |
251 | } | |
28061b3f BJ |
252 | return; |
253 | } | |
22d68ad0 | 254 | if (wd == 0) |
28061b3f | 255 | goto next; |
01d17851 | 256 | this = ns(wd); |
01d17851 | 257 | next_word(fp, wd); |
22d68ad0 | 258 | if (wd == 0) { |
f2db9eb7 | 259 | printf("%s: No type for %s.\n", |
28061b3f BJ |
260 | fname, this); |
261 | exit(1); | |
01d17851 | 262 | } |
e3dad45e | 263 | if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) |
05b83a6c MK |
264 | isdup = 1; |
265 | else | |
266 | isdup = 0; | |
15eb15d7 KM |
267 | tp = 0; |
268 | if (first == 3 && (tp = fltail_lookup(this)) != 0) | |
269 | printf("%s: Local file %s overrides %s.\n", | |
270 | fname, this, tp->f_fn); | |
28061b3f BJ |
271 | nreqs = 0; |
272 | devorprof = ""; | |
3c812eeb | 273 | configdep = 0; |
28061b3f BJ |
274 | needs = 0; |
275 | if (eq(wd, "standard")) | |
276 | goto checkdev; | |
277 | if (!eq(wd, "optional")) { | |
3c812eeb | 278 | printf("%s: %s must be optional or standard\n", fname, this); |
28061b3f BJ |
279 | exit(1); |
280 | } | |
281 | nextopt: | |
282 | next_word(fp, wd); | |
22d68ad0 | 283 | if (wd == 0) |
28061b3f | 284 | goto doneopt; |
3c812eeb SL |
285 | if (eq(wd, "config-dependent")) { |
286 | configdep++; | |
287 | goto nextopt; | |
288 | } | |
28061b3f | 289 | devorprof = wd; |
73845e07 SL |
290 | if (eq(wd, "device-driver") || eq(wd, "profiling-routine")) { |
291 | next_word(fp, wd); | |
28061b3f | 292 | goto save; |
73845e07 | 293 | } |
28061b3f | 294 | nreqs++; |
05b83a6c | 295 | if (needs == 0 && nreqs == 1) |
28061b3f | 296 | needs = ns(wd); |
05b83a6c MK |
297 | if (isdup) |
298 | goto invis; | |
22d68ad0 | 299 | for (dp = dtab; dp != 0; dp = dp->d_next) |
28061b3f BJ |
300 | if (eq(dp->d_name, wd)) |
301 | goto nextopt; | |
05b83a6c MK |
302 | for (op = opt; op != 0; op = op->op_next) |
303 | if (op->op_value == 0 && opteq(op->op_name, wd)) { | |
304 | if (nreqs == 1) { | |
305 | free(needs); | |
306 | needs = 0; | |
307 | } | |
308 | goto nextopt; | |
309 | } | |
310 | invis: | |
22d68ad0 | 311 | while ((wd = get_word(fp)) != 0) |
28061b3f | 312 | ; |
92a477cd MK |
313 | if (tp == 0) |
314 | tp = new_fent(); | |
01d17851 | 315 | tp->f_fn = this; |
28061b3f BJ |
316 | tp->f_type = INVISIBLE; |
317 | tp->f_needs = needs; | |
05b83a6c | 318 | tp->f_flags = isdup; |
28061b3f | 319 | goto next; |
3c812eeb | 320 | |
28061b3f BJ |
321 | doneopt: |
322 | if (nreqs == 0) { | |
f2db9eb7 | 323 | printf("%s: what is %s optional on?\n", |
28061b3f BJ |
324 | fname, this); |
325 | exit(1); | |
326 | } | |
3c812eeb | 327 | |
28061b3f BJ |
328 | checkdev: |
329 | if (wd) { | |
2fcca161 | 330 | next_word(fp, wd); |
3c812eeb SL |
331 | if (wd) { |
332 | if (eq(wd, "config-dependent")) { | |
333 | configdep++; | |
334 | goto checkdev; | |
335 | } | |
28061b3f BJ |
336 | devorprof = wd; |
337 | next_word(fp, wd); | |
2fcca161 | 338 | } |
01d17851 | 339 | } |
3c812eeb | 340 | |
28061b3f | 341 | save: |
3c812eeb | 342 | if (wd) { |
f2db9eb7 | 343 | printf("%s: syntax error describing %s\n", |
28061b3f BJ |
344 | fname, this); |
345 | exit(1); | |
2fcca161 | 346 | } |
73845e07 SL |
347 | if (eq(devorprof, "profiling-routine") && profiling == 0) |
348 | goto next; | |
92a477cd MK |
349 | if (tp == 0) |
350 | tp = new_fent(); | |
28061b3f BJ |
351 | tp->f_fn = this; |
352 | if (eq(devorprof, "device-driver")) | |
3c812eeb | 353 | tp->f_type = DRIVER; |
28061b3f BJ |
354 | else if (eq(devorprof, "profiling-routine")) |
355 | tp->f_type = PROFILING; | |
356 | else | |
357 | tp->f_type = NORMAL; | |
3c812eeb SL |
358 | tp->f_flags = 0; |
359 | if (configdep) | |
360 | tp->f_flags |= CONFIGDEP; | |
28061b3f | 361 | tp->f_needs = needs; |
e3dad45e MK |
362 | if (pf && pf->f_type == INVISIBLE) |
363 | pf->f_flags = 1; /* mark as duplicate */ | |
28061b3f | 364 | goto next; |
01d17851 MT |
365 | } |
366 | ||
05b83a6c MK |
367 | opteq(cp, dp) |
368 | char *cp, *dp; | |
369 | { | |
370 | char c, d; | |
371 | ||
372 | for (; ; cp++, dp++) { | |
373 | if (*cp != *dp) { | |
374 | c = isupper(*cp) ? tolower(*cp) : *cp; | |
375 | d = isupper(*dp) ? tolower(*dp) : *dp; | |
376 | if (c != d) | |
377 | return (0); | |
378 | } | |
379 | if (*cp == 0) | |
380 | return (1); | |
381 | } | |
382 | } | |
383 | ||
01d17851 | 384 | do_objs(fp) |
28061b3f | 385 | FILE *fp; |
01d17851 | 386 | { |
15eb15d7 | 387 | register struct file_list *tp, *fl; |
28061b3f BJ |
388 | register int lpos, len; |
389 | register char *cp, och, *sp; | |
15eb15d7 | 390 | char swapname[32]; |
28061b3f BJ |
391 | |
392 | fprintf(fp, "OBJS="); | |
393 | lpos = 6; | |
22d68ad0 | 394 | for (tp = ftab; tp != 0; tp = tp->f_next) { |
28061b3f BJ |
395 | if (tp->f_type == INVISIBLE) |
396 | continue; | |
397 | sp = tail(tp->f_fn); | |
36edb824 SL |
398 | for (fl = conf_list; fl; fl = fl->f_next) { |
399 | if (fl->f_type != SWAPSPEC) | |
400 | continue; | |
9bd38ba8 | 401 | (void) sprintf(swapname, "swap%s.c", fl->f_fn); |
15eb15d7 KM |
402 | if (eq(sp, swapname)) |
403 | goto cont; | |
404 | } | |
28061b3f BJ |
405 | cp = sp + (len = strlen(sp)) - 1; |
406 | och = *cp; | |
407 | *cp = 'o'; | |
408 | if (len + lpos > 72) { | |
409 | lpos = 8; | |
410 | fprintf(fp, "\\\n\t"); | |
411 | } | |
412 | fprintf(fp, "%s ", sp); | |
413 | lpos += len + 1; | |
414 | *cp = och; | |
36edb824 SL |
415 | cont: |
416 | ; | |
01d17851 | 417 | } |
28061b3f BJ |
418 | if (lpos != 8) |
419 | putc('\n', fp); | |
01d17851 MT |
420 | } |
421 | ||
01d17851 | 422 | do_cfiles(fp) |
28061b3f | 423 | FILE *fp; |
01d17851 | 424 | { |
36e6aa7b | 425 | register struct file_list *tp, *fl; |
28061b3f | 426 | register int lpos, len; |
36e6aa7b | 427 | char swapname[32]; |
28061b3f | 428 | |
36e6aa7b | 429 | fputs("CFILES=", fp); |
28061b3f | 430 | lpos = 8; |
36e6aa7b KB |
431 | for (tp = ftab; tp; tp = tp->f_next) |
432 | if (tp->f_type != INVISIBLE) { | |
433 | len = strlen(tp->f_fn); | |
434 | if (tp->f_fn[len - 1] != 'c') | |
435 | continue; | |
436 | if ((len = 3 + len) + lpos > 72) { | |
437 | lpos = 8; | |
438 | fputs("\\\n\t", fp); | |
439 | } | |
440 | fprintf(fp, "../%s ", tp->f_fn); | |
441 | lpos += len + 1; | |
442 | } | |
443 | for (fl = conf_list; fl; fl = fl->f_next) | |
444 | if (fl->f_type == SYSTEMSPEC) { | |
9bd38ba8 | 445 | (void) sprintf(swapname, "swap%s.c", fl->f_fn); |
36e6aa7b KB |
446 | if ((len = 3 + strlen(swapname)) + lpos > 72) { |
447 | lpos = 8; | |
448 | fputs("\\\n\t", fp); | |
449 | } | |
f4970b85 MK |
450 | if (eq(fl->f_fn, "generic")) |
451 | fprintf(fp, "../%s/%s ", machinename, swapname); | |
452 | else | |
453 | fprintf(fp, "%s ", swapname); | |
36e6aa7b | 454 | lpos += len + 1; |
28061b3f | 455 | } |
28061b3f BJ |
456 | if (lpos != 8) |
457 | putc('\n', fp); | |
01d17851 MT |
458 | } |
459 | ||
28061b3f BJ |
460 | char * |
461 | tail(fn) | |
462 | char *fn; | |
01d17851 | 463 | { |
28061b3f | 464 | register char *cp; |
01d17851 | 465 | |
28061b3f | 466 | cp = rindex(fn, '/'); |
15eb15d7 KM |
467 | if (cp == 0) |
468 | return (fn); | |
28061b3f | 469 | return (cp+1); |
01d17851 MT |
470 | } |
471 | ||
472 | /* | |
28061b3f BJ |
473 | * Create the makerules for each file |
474 | * which is part of the system. | |
475 | * Devices are processed with the special c2 option -i | |
476 | * which avoids any problem areas with i/o addressing | |
477 | * (e.g. for the VAX); assembler files are processed by as. | |
01d17851 | 478 | */ |
01d17851 | 479 | do_rules(f) |
28061b3f | 480 | FILE *f; |
01d17851 | 481 | { |
28061b3f BJ |
482 | register char *cp, *np, och, *tp; |
483 | register struct file_list *ftp; | |
3c812eeb | 484 | char *extras; |
01d17851 | 485 | |
22d68ad0 | 486 | for (ftp = ftab; ftp != 0; ftp = ftp->f_next) { |
01d17851 | 487 | if (ftp->f_type == INVISIBLE) |
28061b3f | 488 | continue; |
01d17851 MT |
489 | cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; |
490 | och = *cp; | |
491 | *cp = '\0'; | |
fb547c4b | 492 | if (och == 'o') { |
a1c4ec7d | 493 | fprintf(f, "%so:\n\t-cp ../%so .\n\n", tail(np), np); |
fb547c4b MK |
494 | continue; |
495 | } | |
01d17851 MT |
496 | fprintf(f, "%so: ../%s%c\n", tail(np), np, och); |
497 | tp = tail(np); | |
28061b3f | 498 | if (och == 's') { |
cd42919c | 499 | fprintf(f, "\t-ln -s ../%ss %sc\n", np, tp); |
46e3cd06 | 500 | fprintf(f, "\t${CC} -E ${COPTS} %sc | ${AS} -o %so\n", |
cd42919c KM |
501 | tp, tp); |
502 | fprintf(f, "\trm -f %sc\n\n", tp); | |
28061b3f | 503 | continue; |
01d17851 | 504 | } |
3c812eeb SL |
505 | if (ftp->f_flags & CONFIGDEP) |
506 | extras = "${PARAM} "; | |
507 | else | |
508 | extras = ""; | |
28061b3f BJ |
509 | switch (ftp->f_type) { |
510 | ||
511 | case NORMAL: | |
512 | switch (machine) { | |
513 | ||
514 | case MACHINE_VAX: | |
a0105456 | 515 | case MACHINE_TAHOE: |
46e3cd06 | 516 | fprintf(f, "\t${CC} -c -S ${COPTS} %s../%sc\n", |
3c812eeb | 517 | extras, np); |
18d7531d SL |
518 | fprintf(f, "\t${C2} %ss | ${INLINE} | ${AS} -o %so\n", |
519 | tp, tp); | |
28061b3f BJ |
520 | fprintf(f, "\trm -f %ss\n\n", tp); |
521 | break; | |
28061b3f BJ |
522 | } |
523 | break; | |
524 | ||
3c812eeb | 525 | case DRIVER: |
28061b3f BJ |
526 | switch (machine) { |
527 | ||
528 | case MACHINE_VAX: | |
a0105456 | 529 | case MACHINE_TAHOE: |
46e3cd06 | 530 | fprintf(f, "\t${CC} -c -S ${COPTS} %s../%sc\n", |
3c812eeb | 531 | extras, np); |
18d7531d SL |
532 | fprintf(f,"\t${C2} -i %ss | ${INLINE} | ${AS} -o %so\n", |
533 | tp, tp); | |
28061b3f BJ |
534 | fprintf(f, "\trm -f %ss\n\n", tp); |
535 | break; | |
28061b3f BJ |
536 | } |
537 | break; | |
538 | ||
539 | case PROFILING: | |
8486638c SL |
540 | if (!profiling) |
541 | continue; | |
542 | if (COPTS == 0) { | |
543 | fprintf(stderr, | |
28061b3f | 544 | "config: COPTS undefined in generic makefile"); |
8486638c SL |
545 | COPTS = ""; |
546 | } | |
28061b3f BJ |
547 | switch (machine) { |
548 | ||
a0105456 SL |
549 | case MACHINE_TAHOE: |
550 | fprintf(f, "\t${CC} -c -S %s %s../%sc\n", | |
551 | COPTS, extras, np); | |
552 | fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp); | |
553 | fprintf(f,"\t${C2} %ss | ${INLINE} | ${AS} -o %so\n", | |
554 | tp, tp); | |
555 | fprintf(f, "\trm -f %ss\n\n", tp); | |
556 | break; | |
557 | ||
28061b3f | 558 | case MACHINE_VAX: |
46e3cd06 | 559 | fprintf(f, "\t${CC} -c -S %s %s../%sc\n", |
3c812eeb | 560 | COPTS, extras, np); |
c7456392 | 561 | fprintf(f, "\tex - %ss < ${GPROF.EX}\n", tp); |
18d7531d | 562 | fprintf(f, "\t${INLINE} %ss | ${AS} -o %so\n", tp, tp); |
28061b3f BJ |
563 | fprintf(f, "\trm -f %ss\n\n", tp); |
564 | break; | |
28061b3f | 565 | } |
73845e07 | 566 | break; |
28061b3f BJ |
567 | |
568 | default: | |
3c812eeb | 569 | printf("Don't know rules for %s\n", np); |
28061b3f BJ |
570 | break; |
571 | } | |
01d17851 | 572 | *cp = och; |
28061b3f | 573 | } |
01d17851 MT |
574 | } |
575 | ||
576 | /* | |
577 | * Create the load strings | |
578 | */ | |
01d17851 | 579 | do_load(f) |
28061b3f | 580 | register FILE *f; |
01d17851 | 581 | { |
28061b3f | 582 | register struct file_list *fl; |
36e6aa7b | 583 | register int first; |
36edb824 | 584 | struct file_list *do_systemspec(); |
28061b3f | 585 | |
36e6aa7b KB |
586 | for (first = 1, fl = conf_list; fl; first = 0) |
587 | fl = fl->f_type == SYSTEMSPEC ? | |
588 | do_systemspec(f, fl, first) : fl->f_next; | |
589 | fputs("all:", f); | |
590 | for (fl = conf_list; fl; fl = fl->f_next) | |
36edb824 SL |
591 | if (fl->f_type == SYSTEMSPEC) |
592 | fprintf(f, " %s", fl->f_needs); | |
36e6aa7b | 593 | putc('\n', f); |
36edb824 | 594 | } |
28061b3f | 595 | |
36edb824 SL |
596 | struct file_list * |
597 | do_systemspec(f, fl, first) | |
598 | FILE *f; | |
599 | register struct file_list *fl; | |
600 | int first; | |
601 | { | |
28061b3f | 602 | |
9e461fbb | 603 | fprintf(f, "%s: Makefile ../machine/symbols.sort", fl->f_needs); |
22a93bf2 | 604 | if (machine == MACHINE_VAX) |
7a1cc178 | 605 | fprintf(f, " ${INLINECMD} locore.o emulate.o"); |
22a93bf2 SL |
606 | else if (machine == MACHINE_TAHOE) |
607 | fprintf(f, " ${INLINE} locore.o"); | |
608 | else | |
609 | fprintf(f, " locore.o"); | |
610 | fprintf(f, " ${OBJS} param.o ioconf.o swap%s.o\n", fl->f_fn); | |
36edb824 SL |
611 | fprintf(f, "\t@echo loading %s\n\t@rm -f %s\n", |
612 | fl->f_needs, fl->f_needs); | |
613 | if (first) { | |
614 | fprintf(f, "\t@sh ../conf/newvers.sh\n"); | |
615 | fprintf(f, "\t@${CC} $(CFLAGS) -c vers.c\n"); | |
190b5698 | 616 | } |
36edb824 | 617 | switch (machine) { |
28061b3f | 618 | |
36edb824 SL |
619 | case MACHINE_VAX: |
620 | fprintf(f, "\t@${LD} -n -o %s -e start -x -T 80000000 ", | |
621 | fl->f_needs); | |
a0105456 SL |
622 | fprintf(f, |
623 | "locore.o emulate.o ${OBJS} vers.o ioconf.o param.o "); | |
624 | break; | |
625 | ||
626 | case MACHINE_TAHOE: | |
627 | fprintf(f, "\t@${LD} -n -o %s -e start -x -T C0000800 ", | |
628 | fl->f_needs); | |
629 | fprintf(f, "locore.o ${OBJS} vers.o ioconf.o param.o "); | |
36edb824 | 630 | break; |
36edb824 | 631 | } |
36edb824 SL |
632 | fprintf(f, "swap%s.o\n", fl->f_fn); |
633 | fprintf(f, "\t@echo rearranging symbols\n"); | |
634 | fprintf(f, "\t@-symorder ../%s/symbols.sort %s\n", | |
635 | machinename, fl->f_needs); | |
636 | fprintf(f, "\t@size %s\n", fl->f_needs); | |
637 | fprintf(f, "\t@chmod 755 %s\n\n", fl->f_needs); | |
638 | do_swapspec(f, fl->f_fn); | |
639 | for (fl = fl->f_next; fl->f_type == SWAPSPEC; fl = fl->f_next) | |
640 | ; | |
641 | return (fl); | |
642 | } | |
643 | ||
644 | do_swapspec(f, name) | |
645 | FILE *f; | |
646 | register char *name; | |
647 | { | |
648 | ||
649 | if (!eq(name, "generic")) { | |
650 | fprintf(f, "swap%s.o: swap%s.c\n", name, name); | |
46e3cd06 | 651 | fprintf(f, "\t${CC} -c -O ${COPTS} swap%s.c\n\n", name); |
36edb824 SL |
652 | return; |
653 | } | |
654 | fprintf(f, "swapgeneric.o: ../%s/swapgeneric.c\n", machinename); | |
655 | switch (machine) { | |
656 | ||
657 | case MACHINE_VAX: | |
a0105456 | 658 | case MACHINE_TAHOE: |
46e3cd06 | 659 | fprintf(f, "\t${CC} -c -S ${COPTS} "); |
36edb824 | 660 | fprintf(f, "../%s/swapgeneric.c\n", machinename); |
18d7531d | 661 | fprintf(f, "\t${C2} swapgeneric.s | ${INLINE}"); |
36edb824 SL |
662 | fprintf(f, " | ${AS} -o swapgeneric.o\n"); |
663 | fprintf(f, "\trm -f swapgeneric.s\n\n"); | |
664 | break; | |
28061b3f | 665 | } |
01d17851 | 666 | } |
d5429061 | 667 | |
22d68ad0 | 668 | char * |
d5429061 | 669 | raise(str) |
28061b3f | 670 | register char *str; |
d5429061 | 671 | { |
28061b3f BJ |
672 | register char *cp = str; |
673 | ||
674 | while (*str) { | |
675 | if (islower(*str)) | |
676 | *str = toupper(*str); | |
677 | str++; | |
678 | } | |
679 | return (cp); | |
d5429061 | 680 | } |