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