mkmakefile.c revision 1566
1273929Sjmmv/*
2240116Smarcel * Copyright (c) 1993, 19801990
3240116Smarcel *	The Regents of the University of California.  All rights reserved.
4240116Smarcel *
5240116Smarcel * Redistribution and use in source and binary forms, with or without
6240116Smarcel * modification, are permitted provided that the following conditions
7240116Smarcel * are met:
8240116Smarcel * 1. Redistributions of source code must retain the above copyright
9240116Smarcel *    notice, this list of conditions and the following disclaimer.
10240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright
11240116Smarcel *    notice, this list of conditions and the following disclaimer in the
12240116Smarcel *    documentation and/or other materials provided with the distribution.
13240116Smarcel * 3. All advertising materials mentioning features or use of this software
14240116Smarcel *    must display the following acknowledgement:
15240116Smarcel *	This product includes software developed by the University of
16240116Smarcel *	California, Berkeley and its contributors.
17240116Smarcel * 4. Neither the name of the University nor the names of its contributors
18240116Smarcel *    may be used to endorse or promote products derived from this software
19240116Smarcel *    without specific prior written permission.
20240116Smarcel *
21240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22240116Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23240116Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24273929Sjmmv * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25240116Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26273929Sjmmv * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27273929Sjmmv * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28240116Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29240116Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30240116Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31240116Smarcel * SUCH DAMAGE.
32240116Smarcel */
33273929Sjmmv
34240116Smarcel#ifndef lint
35240116Smarcelstatic char sccsid[] = "@(#)mkmakefile.c	8.1 (Berkeley) 6/6/93";
36240116Smarcel#endif /* not lint */
37240116Smarcel
38240116Smarcel/*
39240116Smarcel * Build the makefile for the system, from
40240116Smarcel * the information in the files files and the
41240116Smarcel * additional files for the machine being compiled to.
42240116Smarcel */
43240116Smarcel
44240116Smarcel#include <stdio.h>
45240116Smarcel#include <ctype.h>
46240116Smarcel#include "y.tab.h"
47240116Smarcel#include "config.h"
48240116Smarcel
49240116Smarcel#define next_word(fp, wd) \
50240116Smarcel	{ register char *word = get_word(fp); \
51240116Smarcel	  if (word == (char *)EOF) \
52240116Smarcel		return; \
53240116Smarcel	  else \
54240116Smarcel		wd = word; \
55240116Smarcel	}
56240116Smarcel#define next_quoted_word(fp, wd) \
57240116Smarcel	{ register char *word = get_quoted_word(fp); \
58240116Smarcel	  if (word == (char *)EOF) \
59240116Smarcel		return; \
60240116Smarcel	  else \
61240116Smarcel		wd = word; \
62240116Smarcel	}
63240116Smarcel
64240116Smarcelstatic	struct file_list *fcur;
65240116Smarcelchar *tail();
66240116Smarcel
67240116Smarcel/*
68240116Smarcel * Lookup a file, by name.
69240116Smarcel */
70240116Smarcelstruct file_list *
71240116Smarcelfl_lookup(file)
72240116Smarcel	register char *file;
73240116Smarcel{
74240116Smarcel	register struct file_list *fp;
75240116Smarcel
76240116Smarcel	for (fp = ftab ; fp != 0; fp = fp->f_next) {
77240116Smarcel		if (eq(fp->f_fn, file))
78240116Smarcel			return (fp);
79240116Smarcel	}
80240116Smarcel	return (0);
81240116Smarcel}
82240116Smarcel
83240116Smarcel/*
84240116Smarcel * Lookup a file, by final component name.
85240116Smarcel */
86240116Smarcelstruct file_list *
87240116Smarcelfltail_lookup(file)
88240116Smarcel	register char *file;
89240116Smarcel{
90240116Smarcel	register struct file_list *fp;
91240116Smarcel
92240116Smarcel	for (fp = ftab ; fp != 0; fp = fp->f_next) {
93240116Smarcel		if (eq(tail(fp->f_fn), tail(file)))
94240116Smarcel			return (fp);
95240116Smarcel	}
96240116Smarcel	return (0);
97240116Smarcel}
98240116Smarcel
99240116Smarcel/*
100240116Smarcel * Make a new file list entry
101240116Smarcel */
102240116Smarcelstruct file_list *
103240116Smarcelnew_fent()
104240116Smarcel{
105240116Smarcel	register struct file_list *fp;
106240116Smarcel
107240116Smarcel	fp = (struct file_list *) malloc(sizeof *fp);
108240116Smarcel	bzero(fp, sizeof *fp);
109240116Smarcel	if (fcur == 0)
110240116Smarcel		fcur = ftab = fp;
111240116Smarcel	else
112240116Smarcel		fcur->f_next = fp;
113240116Smarcel	fcur = fp;
114240116Smarcel	return (fp);
115240116Smarcel}
116240116Smarcel
117240116Smarcelstatic	struct users {
118240116Smarcel	int	u_default;
119240116Smarcel	int	u_min;
120240116Smarcel	int	u_max;
121240116Smarcel} users[] = {
122240116Smarcel	{ 24, 8, 1024 },		/* MACHINE_VAX */
123240116Smarcel	{ 4, 2, 128 },			/* MACHINE_TAHOE */
124240116Smarcel	{ 8, 2, 64 },			/* MACHINE_HP300 */
125240116Smarcel	{ 8, 2, 64 },			/* MACHINE_I386 */
126240116Smarcel	{ 8, 2, 64 },			/* MACHINE_MIPS */
127240116Smarcel	{ 8, 2, 64 },			/* MACHINE_PMAX */
128240116Smarcel	{ 8, 2, 64 },			/* MACHINE_LUNA68K */
129240116Smarcel	{ 8, 2, 64 },			/* MACHINE_NEWS3400 */
130240116Smarcel};
131240116Smarcel#define	NUSERS	(sizeof (users) / sizeof (users[0]))
132240116Smarcel
133240116Smarcel/*
134240116Smarcel * Build the makefile from the skeleton
135240116Smarcel */
136240116Smarcelmakefile()
137240116Smarcel{
138240116Smarcel	FILE *ifp, *ofp;
139240116Smarcel	char line[BUFSIZ];
140240116Smarcel	struct opt *op;
141240116Smarcel	struct users *up;
142240116Smarcel
143240116Smarcel	read_files();
144240116Smarcel	strcpy(line, "Makefile.");
145240116Smarcel	(void) strcat(line, machinename);
146240116Smarcel	ifp = fopen(line, "r");
147240116Smarcel	if (ifp == 0) {
148240116Smarcel		perror(line);
149240116Smarcel		exit(1);
150240116Smarcel	}
151240116Smarcel	ofp = fopen(path("Makefile"), "w");
152240116Smarcel	if (ofp == 0) {
153240116Smarcel		perror(path("Makefile"));
154240116Smarcel		exit(1);
155240116Smarcel	}
156240116Smarcel	fprintf(ofp, "KERN_IDENT=%s\n", raise(ident));
157240116Smarcel	fprintf(ofp, "IDENT=-D%s", raise(ident));
158240116Smarcel	if (profiling)
159240116Smarcel		fprintf(ofp, " -DGPROF");
160240116Smarcel	if (cputype == 0) {
161240116Smarcel		printf("cpu type must be specified\n");
162240116Smarcel		exit(1);
163240116Smarcel	}
164240116Smarcel	{ struct cputype *cp;
165240116Smarcel	  for (cp = cputype; cp; cp = cp->cpu_next)
166240116Smarcel		fprintf(ofp, " -D%s", cp->cpu_name);
167240116Smarcel	}
168240116Smarcel	for (op = opt; op; op = op->op_next)
169240116Smarcel		if (op->op_value)
170240116Smarcel			fprintf(ofp, " -D%s=\"%s\"", op->op_name, op->op_value);
171240116Smarcel		else
172240116Smarcel			fprintf(ofp, " -D%s", op->op_name);
173240116Smarcel	fprintf(ofp, "\n");
174240116Smarcel	if (hadtz == 0)
175240116Smarcel		printf("timezone not specified; gmt assumed\n");
176240116Smarcel	if ((unsigned)machine > NUSERS) {
177240116Smarcel		printf("maxusers config info isn't present, using vax\n");
178240116Smarcel		up = &users[MACHINE_VAX-1];
179240116Smarcel	} else
180240116Smarcel		up = &users[machine-1];
181240116Smarcel	if (maxusers == 0) {
182240116Smarcel		printf("maxusers not specified; %d assumed\n", up->u_default);
183240116Smarcel		maxusers = up->u_default;
184240116Smarcel	} else if (maxusers < up->u_min) {
185240116Smarcel		printf("minimum of %d maxusers assumed\n", up->u_min);
186240116Smarcel		maxusers = up->u_min;
187240116Smarcel	} else if (maxusers > up->u_max)
188240116Smarcel		printf("warning: maxusers > %d (%d)\n", up->u_max, maxusers);
189240116Smarcel	fprintf(ofp, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d\n",
190240116Smarcel	    zone, dst, maxusers);
191240116Smarcel	if (loadaddress != -1) {
192240116Smarcel		fprintf(ofp, "LOAD_ADDRESS=%X\n", loadaddress);
193240116Smarcel	}
194240116Smarcel	for (op = mkopt; op; op = op->op_next)
195240116Smarcel		fprintf(ofp, "%s=%s\n", op->op_name, op->op_value);
196240116Smarcel	if (debugging)
197240116Smarcel		fprintf(ofp, "DEBUG=-g\n");
198240116Smarcel	if (profiling)
199240116Smarcel		fprintf(ofp, "PROF=-pg\n");
200240116Smarcel	while (fgets(line, BUFSIZ, ifp) != 0) {
201240116Smarcel		if (*line != '%') {
202240116Smarcel			fprintf(ofp, "%s", line);
203240116Smarcel			continue;
204240116Smarcel		}
205240116Smarcel		if (eq(line, "%OBJS\n"))
206240116Smarcel			do_objs(ofp);
207240116Smarcel		else if (eq(line, "%CFILES\n"))
208240116Smarcel			do_cfiles(ofp);
209240116Smarcel		else if (eq(line, "%RULES\n"))
210240116Smarcel			do_rules(ofp);
211240116Smarcel		else if (eq(line, "%LOAD\n"))
212240116Smarcel			do_load(ofp);
213240116Smarcel		else
214240116Smarcel			fprintf(stderr,
215240116Smarcel			    "Unknown %% construct in generic makefile: %s",
216240116Smarcel			    line);
217240116Smarcel	}
218240116Smarcel	(void) fclose(ifp);
219240116Smarcel	(void) fclose(ofp);
220240116Smarcel}
221240116Smarcel
222240116Smarcel/*
223240116Smarcel * Read in the information about files used in making the system.
224240116Smarcel * Store it in the ftab linked list.
225240116Smarcel */
226240116Smarcelread_files()
227240116Smarcel{
228240116Smarcel	FILE *fp;
229240116Smarcel	register struct file_list *tp, *pf;
230240116Smarcel	register struct device *dp;
231240116Smarcel	struct device *save_dp;
232240116Smarcel	register struct opt *op;
233240116Smarcel	char *wd, *this, *needs, *special;
234240116Smarcel	char fname[32];
235240116Smarcel	int nreqs, first = 1, configdep, isdup, std, filetype;
236240116Smarcel
237240116Smarcel	ftab = 0;
238240116Smarcel	(void) strcpy(fname, "../../conf/files");
239240116Smarcelopenit:
240240116Smarcel	fp = fopen(fname, "r");
241240116Smarcel	if (fp == 0) {
242240116Smarcel		perror(fname);
243240116Smarcel		exit(1);
244240116Smarcel	}
245240116Smarcel	if(ident == NULL) {
246240116Smarcel		printf("no ident line specified\n");
247240116Smarcel		exit(1);
248240116Smarcel	}
249240116Smarcelnext:
250240116Smarcel	/*
251240116Smarcel	 * filename	[ standard | optional ] [ config-dependent ]
252240116Smarcel	 *	[ dev* | profiling-routine ] [ device-driver]
253240116Smarcel	 *	[ compile-with "compile rule" ]
254240116Smarcel	 */
255240116Smarcel	wd = get_word(fp);
256240116Smarcel	if (wd == (char *)EOF) {
257240116Smarcel		(void) fclose(fp);
258240116Smarcel		if (first == 1) {
259240116Smarcel			(void) sprintf(fname, "files.%s", machinename);
260240116Smarcel			first++;
261240116Smarcel			goto openit;
262240116Smarcel		}
263240116Smarcel		if (first == 2) {
264240116Smarcel			(void) sprintf(fname, "files.%s", raise(ident));
265240116Smarcel			first++;
266240116Smarcel			fp = fopen(fname, "r");
267240116Smarcel			if (fp != 0)
268240116Smarcel				goto next;
269240116Smarcel		}
270240116Smarcel		return;
271240116Smarcel	}
272240116Smarcel	if (wd == 0)
273240116Smarcel		goto next;
274240116Smarcel	/*************************************************\
275240116Smarcel	* If it's a comment ignore to the end of the line *
276240116Smarcel	\*************************************************/
277240116Smarcel	if(wd[0] == '#')
278240116Smarcel	{
279240116Smarcel		while( ((wd = get_word(fp)) != (char *)EOF) && wd)
280240116Smarcel		;
281240116Smarcel		goto next;
282240116Smarcel	}
283240116Smarcel	this = ns(wd);
284240116Smarcel	next_word(fp, wd);
285240116Smarcel	if (wd == 0) {
286240116Smarcel		printf("%s: No type for %s.\n",
287240116Smarcel		    fname, this);
288240116Smarcel		exit(1);
289240116Smarcel	}
290240116Smarcel	if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags))
291240116Smarcel		isdup = 1;
292240116Smarcel	else
293240116Smarcel		isdup = 0;
294240116Smarcel	tp = 0;
295240116Smarcel	if (first == 3 && (tp = fltail_lookup(this)) != 0)
296240116Smarcel		printf("%s: Local file %s overrides %s.\n",
297240116Smarcel		    fname, this, tp->f_fn);
298240116Smarcel	nreqs = 0;
299240116Smarcel	special = 0;
300240116Smarcel	configdep = 0;
301240116Smarcel	needs = 0;
302240116Smarcel	std = 0;
303240116Smarcel	filetype = NORMAL;
304240116Smarcel	if (eq(wd, "standard"))
305240116Smarcel		std = 1;
306240116Smarcel	else if (!eq(wd, "optional")) {
307240116Smarcel		printf("%s: %s must be optional or standard\n", fname, this);
308240116Smarcel		exit(1);
309240116Smarcel	}
310240116Smarcelnextparam:
311240116Smarcel	next_word(fp, wd);
312240116Smarcel	if (wd == 0)
313240116Smarcel		goto doneparam;
314240116Smarcel	if (eq(wd, "config-dependent")) {
315240116Smarcel		configdep++;
316240116Smarcel		goto nextparam;
317240116Smarcel	}
318240116Smarcel	if (eq(wd, "compile-with")) {
319240116Smarcel		next_quoted_word(fp, wd);
320240116Smarcel		if (wd == 0) {
321240116Smarcel			printf("%s: %s missing compile command string.\n",
322240116Smarcel			       fname);
323240116Smarcel			exit(1);
324240116Smarcel		}
325240116Smarcel		special = ns(wd);
326240116Smarcel		goto nextparam;
327240116Smarcel	}
328240116Smarcel	nreqs++;
329240116Smarcel	if (eq(wd, "device-driver")) {
330240116Smarcel		filetype = DRIVER;
331240116Smarcel		goto nextparam;
332240116Smarcel	}
333240116Smarcel	if (eq(wd, "profiling-routine")) {
334240116Smarcel		filetype = PROFILING;
335240116Smarcel		goto nextparam;
336240116Smarcel	}
337240116Smarcel	if (needs == 0 && nreqs == 1)
338240116Smarcel		needs = ns(wd);
339240116Smarcel	if (isdup)
340240116Smarcel		goto invis;
341240116Smarcel	for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next)
342240116Smarcel		if (eq(dp->d_name, wd)) {
343240116Smarcel			if (std && dp->d_type == PSEUDO_DEVICE &&
344240116Smarcel			    dp->d_slave <= 0)
345240116Smarcel				dp->d_slave = 1;
346240116Smarcel			goto nextparam;
347240116Smarcel		}
348240116Smarcel	if (std) {
349240116Smarcel		dp = (struct device *) malloc(sizeof *dp);
350240116Smarcel		init_dev(dp);
351240116Smarcel		dp->d_name = ns(wd);
352240116Smarcel		dp->d_type = PSEUDO_DEVICE;
353240116Smarcel		dp->d_slave = 1;
354240116Smarcel		save_dp->d_next = dp;
355240116Smarcel		goto nextparam;
356240116Smarcel	}
357240116Smarcel	for (op = opt; op != 0; op = op->op_next)
358240116Smarcel		if (op->op_value == 0 && opteq(op->op_name, wd)) {
359240116Smarcel			if (nreqs == 1) {
360240116Smarcel				free(needs);
361240116Smarcel				needs = 0;
362240116Smarcel			}
363240116Smarcel			goto nextparam;
364240116Smarcel		}
365240116Smarcelinvis:
366240116Smarcel	while ((wd = get_word(fp)) != 0)
367240116Smarcel		;
368240116Smarcel	if (tp == 0)
369240116Smarcel		tp = new_fent();
370240116Smarcel	tp->f_fn = this;
371240116Smarcel	tp->f_type = INVISIBLE;
372240116Smarcel	tp->f_needs = needs;
373240116Smarcel	tp->f_flags = isdup;
374240116Smarcel	tp->f_special = special;
375240116Smarcel	goto next;
376240116Smarcel
377240116Smarceldoneparam:
378240116Smarcel	if (std == 0 && nreqs == 0) {
379240116Smarcel		printf("%s: what is %s optional on?\n",
380240116Smarcel		    fname, this);
381240116Smarcel		exit(1);
382240116Smarcel	}
383240116Smarcel
384240116Smarcelsave:
385240116Smarcel	if (wd) {
386240116Smarcel		printf("%s: syntax error describing %s\n",
387240116Smarcel		    fname, this);
388240116Smarcel		exit(1);
389240116Smarcel	}
390240116Smarcel	if (filetype == PROFILING && profiling == 0)
391240116Smarcel		goto next;
392240116Smarcel	if (tp == 0)
393240116Smarcel		tp = new_fent();
394240116Smarcel	tp->f_fn = this;
395240116Smarcel	tp->f_type = filetype;
396240116Smarcel	tp->f_flags = 0;
397240116Smarcel	if (configdep)
398240116Smarcel		tp->f_flags |= CONFIGDEP;
399240116Smarcel	tp->f_needs = needs;
400240116Smarcel	tp->f_special = special;
401240116Smarcel	if (pf && pf->f_type == INVISIBLE)
402240116Smarcel		pf->f_flags = 1;		/* mark as duplicate */
403240116Smarcel	goto next;
404240116Smarcel}
405240116Smarcel
406240116Smarcelopteq(cp, dp)
407240116Smarcel	char *cp, *dp;
408240116Smarcel{
409240116Smarcel	char c, d;
410240116Smarcel
411240116Smarcel	for (; ; cp++, dp++) {
412240116Smarcel		if (*cp != *dp) {
413240116Smarcel			c = isupper(*cp) ? tolower(*cp) : *cp;
414240116Smarcel			d = isupper(*dp) ? tolower(*dp) : *dp;
415240116Smarcel			if (c != d)
416240116Smarcel				return (0);
417240116Smarcel		}
418240116Smarcel		if (*cp == 0)
419240116Smarcel			return (1);
420240116Smarcel	}
421240116Smarcel}
422
423do_objs(fp)
424	FILE *fp;
425{
426	register struct file_list *tp, *fl;
427	register int lpos, len;
428	register char *cp, och, *sp;
429	char swapname[32];
430
431	fprintf(fp, "OBJS=");
432	lpos = 6;
433	for (tp = ftab; tp != 0; tp = tp->f_next) {
434		if (tp->f_type == INVISIBLE)
435			continue;
436		sp = tail(tp->f_fn);
437		for (fl = conf_list; fl; fl = fl->f_next) {
438			if (fl->f_type != SWAPSPEC)
439				continue;
440			(void) sprintf(swapname, "swap%s.c", fl->f_fn);
441			if (eq(sp, swapname))
442				goto cont;
443		}
444		cp = sp + (len = strlen(sp)) - 1;
445		och = *cp;
446		*cp = 'o';
447		if (len + lpos > 72) {
448			lpos = 8;
449			fprintf(fp, "\\\n\t");
450		}
451		fprintf(fp, "%s ", sp);
452		lpos += len + 1;
453		*cp = och;
454cont:
455		;
456	}
457	if (lpos != 8)
458		putc('\n', fp);
459}
460
461do_cfiles(fp)
462	FILE *fp;
463{
464	register struct file_list *tp, *fl;
465	register int lpos, len;
466	char swapname[32];
467
468	fputs("CFILES=", fp);
469	lpos = 8;
470	for (tp = ftab; tp; tp = tp->f_next)
471		if (tp->f_type != INVISIBLE) {
472			len = strlen(tp->f_fn);
473			if (tp->f_fn[len - 1] != 'c')
474				continue;
475			if ((len = 3 + len) + lpos > 72) {
476				lpos = 8;
477				fputs("\\\n\t", fp);
478			}
479			fprintf(fp, "$S/%s ", tp->f_fn);
480			lpos += len + 1;
481		}
482	for (fl = conf_list; fl; fl = fl->f_next)
483		if (fl->f_type == SYSTEMSPEC) {
484			(void) sprintf(swapname, "swap%s.c", fl->f_fn);
485			if ((len = 3 + strlen(swapname)) + lpos > 72) {
486				lpos = 8;
487				fputs("\\\n\t", fp);
488			}
489			if (eq(fl->f_fn, "generic"))
490				fprintf(fp, "$S/%s/%s/%s ",
491				    machinename, machinename, swapname);
492			else
493				fprintf(fp, "%s ", swapname);
494			lpos += len + 1;
495		}
496	if (lpos != 8)
497		putc('\n', fp);
498}
499
500char *
501tail(fn)
502	char *fn;
503{
504	register char *cp;
505
506	cp = rindex(fn, '/');
507	if (cp == 0)
508		return (fn);
509	return (cp+1);
510}
511
512/*
513 * Create the makerules for each file
514 * which is part of the system.
515 * Devices are processed with the special c2 option -i
516 * which avoids any problem areas with i/o addressing
517 * (e.g. for the VAX); assembler files are processed by as.
518 */
519do_rules(f)
520	FILE *f;
521{
522	register char *cp, *np, och, *tp;
523	register struct file_list *ftp;
524	char *special;
525
526	for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
527		if (ftp->f_type == INVISIBLE)
528			continue;
529		cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1;
530		och = *cp;
531		*cp = '\0';
532		if (och == 'o') {
533			fprintf(f, "%so:\n\t-cp $S/%so .\n\n", tail(np), np);
534			continue;
535		}
536		fprintf(f, "%so: $S/%s%c\n", tail(np), np, och);
537		tp = tail(np);
538		special = ftp->f_special;
539		if (special == 0) {
540			char *ftype;
541			static char cmd[128];
542
543			switch (ftp->f_type) {
544
545			case NORMAL:
546				ftype = "NORMAL";
547				break;
548
549			case DRIVER:
550				ftype = "DRIVER";
551				break;
552
553			case PROFILING:
554				if (!profiling)
555					continue;
556				ftype = "PROFILE";
557				break;
558
559			default:
560				printf("config: don't know rules for %s\n", np);
561				break;
562			}
563			(void)sprintf(cmd, "${%s_%c%s}", ftype, toupper(och),
564				      ftp->f_flags & CONFIGDEP? "_C" : "");
565			special = cmd;
566		}
567		*cp = och;
568		fprintf(f, "\t%s\n\n", special);
569	}
570}
571
572/*
573 * Create the load strings
574 */
575do_load(f)
576	register FILE *f;
577{
578	register struct file_list *fl;
579	register int first;
580	struct file_list *do_systemspec();
581
582	for (first = 1, fl = conf_list; fl; first = 0)
583		fl = fl->f_type == SYSTEMSPEC ?
584			do_systemspec(f, fl, first) : fl->f_next;
585	fputs("all:", f);
586	for (fl = conf_list; fl; fl = fl->f_next)
587		if (fl->f_type == SYSTEMSPEC)
588			fprintf(f, " %s", fl->f_needs);
589	putc('\n', f);
590}
591
592struct file_list *
593do_systemspec(f, fl, first)
594	FILE *f;
595	register struct file_list *fl;
596	int first;
597{
598
599	fprintf(f, "%s: ${SYSTEM_DEP} swap%s.o", fl->f_needs, fl->f_fn);
600	if (first)
601		fprintf(f, " vers.o");
602	fprintf(f, "\n\t${SYSTEM_LD_HEAD}\n");
603	fprintf(f, "\t${SYSTEM_LD} swap%s.o\n", fl->f_fn);
604	fprintf(f, "\t${SYSTEM_LD_TAIL}\n\n");
605	do_swapspec(f, fl->f_fn);
606	for (fl = fl->f_next; fl; fl = fl->f_next)
607		if (fl->f_type != SWAPSPEC)
608			break;
609	return (fl);
610}
611
612do_swapspec(f, name)
613	FILE *f;
614	register char *name;
615{
616
617	if (!eq(name, "generic"))
618		fprintf(f, "swap%s.o: swap%s.c\n", name, name);
619	else
620		fprintf(f, "swapgeneric.o: $S/%s/%s/swapgeneric.c\n",
621			machinename, machinename);
622	fprintf(f, "\t${NORMAL_C}\n\n");
623}
624
625char *
626raise(str)
627	register char *str;
628{
629	register char *cp = str;
630
631	while (*str) {
632		if (islower(*str))
633			*str = toupper(*str);
634		str++;
635	}
636	return (cp);
637}
638