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