]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/config/mkmakefile.c
This commit was generated by cvs2svn to compensate for changes in r156369,
[FreeBSD/FreeBSD.git] / usr.sbin / config / mkmakefile.c
1 /*
2  * Copyright (c) 1993, 19801990
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29
30 #ifndef lint
31 #if 0
32 static char sccsid[] = "@(#)mkmakefile.c        8.1 (Berkeley) 6/6/93";
33 #endif
34 static const char rcsid[] =
35   "$FreeBSD$";
36 #endif /* not lint */
37
38 /*
39  * Build the makefile for the system, from
40  * the information in the files files and the
41  * additional files for the machine being compiled to.
42  */
43
44 #include <ctype.h>
45 #include <err.h>
46 #include <stdio.h>
47 #include <string.h>
48 #include <sys/param.h>
49 #include "y.tab.h"
50 #include "config.h"
51 #include "configvers.h"
52
53 #define next_word(fp, wd) \
54         { char *word = get_word(fp); \
55           if (word == (char *)EOF) \
56                 return; \
57           else \
58                 wd = word; \
59         }
60 #define next_quoted_word(fp, wd) \
61         { char *word = get_quoted_word(fp); \
62           if (word == (char *)EOF) \
63                 return; \
64           else \
65                 wd = word; \
66         }
67
68 static char *tail(char *);
69 static void do_clean(FILE *);
70 static void do_rules(FILE *);
71 static void do_xxfiles(char *, FILE *);
72 static void do_objs(FILE *);
73 static void do_before_depend(FILE *);
74 static int opteq(const char *, const char *);
75 static void read_files(void);
76
77 /*
78  * Lookup a file, by name.
79  */
80 static struct file_list *
81 fl_lookup(char *file)
82 {
83         struct file_list *fp;
84
85         STAILQ_FOREACH(fp, &ftab, f_next) {
86                 if (eq(fp->f_fn, file))
87                         return (fp);
88         }
89         return (0);
90 }
91
92 /*
93  * Make a new file list entry
94  */
95 static struct file_list *
96 new_fent(void)
97 {
98         struct file_list *fp;
99
100         fp = (struct file_list *) malloc(sizeof *fp);
101         bzero(fp, sizeof *fp);
102         STAILQ_INSERT_TAIL(&ftab, fp, f_next);
103         return (fp);
104 }
105
106 /*
107  * Build the makefile from the skeleton
108  */
109 void
110 makefile(void)
111 {
112         FILE *ifp, *ofp;
113         char line[BUFSIZ];
114         struct opt *op;
115         int versreq;
116
117         read_files();
118         snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
119         ifp = fopen(line, "r");
120         if (ifp == 0) {
121                 snprintf(line, sizeof(line), "Makefile.%s", machinename);
122                 ifp = fopen(line, "r");
123         }
124         if (ifp == 0)
125                 err(1, "%s", line);
126
127         ofp = fopen(path("Makefile.new"), "w");
128         if (ofp == 0)
129                 err(1, "%s", path("Makefile.new"));
130         fprintf(ofp, "KERN_IDENT=%s\n", ident);
131         SLIST_FOREACH(op, &mkopt, op_next)
132                 fprintf(ofp, "%s=%s\n", op->op_name, op->op_value);
133         if (debugging)
134                 fprintf(ofp, "DEBUG=-g\n");
135         if (profiling)
136                 fprintf(ofp, "PROFLEVEL=%d\n", profiling);
137         if (*srcdir != '\0')
138                 fprintf(ofp,"S=%s\n", srcdir);
139         while (fgets(line, BUFSIZ, ifp) != 0) {
140                 if (*line != '%') {
141                         fprintf(ofp, "%s", line);
142                         continue;
143                 }
144                 if (eq(line, "%BEFORE_DEPEND\n"))
145                         do_before_depend(ofp);
146                 else if (eq(line, "%OBJS\n"))
147                         do_objs(ofp);
148                 else if (strncmp(line, "%FILES.", 7) == 0)
149                         do_xxfiles(line, ofp);
150                 else if (eq(line, "%RULES\n"))
151                         do_rules(ofp);
152                 else if (eq(line, "%CLEAN\n"))
153                         do_clean(ofp);
154                 else if (strncmp(line, "%VERSREQ=", sizeof("%VERSREQ=") - 1) == 0) {
155                         versreq = atoi(line + sizeof("%VERSREQ=") - 1);
156                         if (MAJOR_VERS(versreq) != MAJOR_VERS(CONFIGVERS) ||
157                             versreq > CONFIGVERS) {
158                                 fprintf(stderr, "ERROR: version of config(8) does not match kernel!\n");
159                                 fprintf(stderr, "config version = %d, ", CONFIGVERS);
160                                 fprintf(stderr, "version required = %d\n\n", versreq);
161                                 fprintf(stderr, "Make sure that /usr/src/usr.sbin/config is in sync\n");
162                                 fprintf(stderr, "with your /usr/src/sys and install a new config binary\n");
163                                 fprintf(stderr, "before trying this again.\n\n");
164                                 fprintf(stderr, "If running the new config fails check your config\n");
165                                 fprintf(stderr, "file against the GENERIC or LINT config files for\n");
166                                 fprintf(stderr, "changes in config syntax, or option/device naming\n");
167                                 fprintf(stderr, "conventions\n\n");
168                                 exit(1);
169                         }
170                 } else
171                         fprintf(stderr,
172                             "Unknown %% construct in generic makefile: %s",
173                             line);
174         }
175         (void) fclose(ifp);
176         (void) fclose(ofp);
177         moveifchanged(path("Makefile.new"), path("Makefile"));
178 }
179
180 /*
181  * Build hints.c from the skeleton
182  */
183 void
184 makehints(void)
185 {
186         FILE *ifp, *ofp;
187         char line[BUFSIZ];
188         char *s;
189
190         if (hints) {
191                 ifp = fopen(hints, "r");
192                 if (ifp == NULL)
193                         err(1, "%s", hints);
194         } else {
195                 ifp = NULL;
196         }
197         ofp = fopen(path("hints.c.new"), "w");
198         if (ofp == NULL)
199                 err(1, "%s", path("hints.c.new"));
200         fprintf(ofp, "#include <sys/types.h>\n");
201         fprintf(ofp, "#include <sys/systm.h>\n");
202         fprintf(ofp, "\n");
203         fprintf(ofp, "int hintmode = %d;\n", hintmode);
204         fprintf(ofp, "char static_hints[] = {\n");
205         if (ifp) {
206                 while (fgets(line, BUFSIZ, ifp) != 0) {
207                         /* zap trailing CR and/or LF */
208                         while ((s = rindex(line, '\n')) != NULL)
209                                 *s = '\0';
210                         while ((s = rindex(line, '\r')) != NULL)
211                                 *s = '\0';
212                         /* remove # comments */
213                         s = index(line, '#');
214                         if (s)
215                                 *s = '\0';
216                         /* remove any whitespace and " characters */
217                         s = line;
218                         while (*s) {
219                                 if (*s == ' ' || *s == '\t' || *s == '"') {
220                                         while (*s) {
221                                                 s[0] = s[1];
222                                                 s++;
223                                         }
224                                         /* start over */
225                                         s = line;
226                                         continue;
227                                 }
228                                 s++;
229                         }
230                         /* anything left? */
231                         if (*line == '\0')
232                                 continue;
233                         fprintf(ofp, "\"%s\\0\"\n", line);
234                 }
235         }
236         fprintf(ofp, "\"\\0\"\n};\n");
237         if (ifp)
238                 fclose(ifp);
239         fclose(ofp);
240         moveifchanged(path("hints.c.new"), path("hints.c"));
241 }
242
243 /*
244  * Build env.c from the skeleton
245  */
246 void
247 makeenv(void)
248 {
249         FILE *ifp, *ofp;
250         char line[BUFSIZ];
251         char *s;
252
253         if (env) {
254                 ifp = fopen(env, "r");
255                 if (ifp == NULL)
256                         err(1, "%s", env);
257         } else {
258                 ifp = NULL;
259         }
260         ofp = fopen(path("env.c.new"), "w");
261         if (ofp == NULL)
262                 err(1, "%s", path("env.c.new"));
263         fprintf(ofp, "#include <sys/types.h>\n");
264         fprintf(ofp, "#include <sys/systm.h>\n");
265         fprintf(ofp, "\n");
266         fprintf(ofp, "int envmode = %d;\n", envmode);
267         fprintf(ofp, "char static_env[] = {\n");
268         if (ifp) {
269                 while (fgets(line, BUFSIZ, ifp) != 0) {
270                         /* zap trailing CR and/or LF */
271                         while ((s = rindex(line, '\n')) != NULL)
272                                 *s = '\0';
273                         while ((s = rindex(line, '\r')) != NULL)
274                                 *s = '\0';
275                         /* remove # comments */
276                         s = index(line, '#');
277                         if (s)
278                                 *s = '\0';
279                         /* remove any whitespace and " characters */
280                         s = line;
281                         while (*s) {
282                                 if (*s == ' ' || *s == '\t' || *s == '"') {
283                                         while (*s) {
284                                                 s[0] = s[1];
285                                                 s++;
286                                         }
287                                         /* start over */
288                                         s = line;
289                                         continue;
290                                 }
291                                 s++;
292                         }
293                         /* anything left? */
294                         if (*line == '\0')
295                                 continue;
296                         fprintf(ofp, "\"%s\\0\"\n", line);
297                 }
298         }
299         fprintf(ofp, "\"\\0\"\n};\n");
300         if (ifp)
301                 fclose(ifp);
302         fclose(ofp);
303         moveifchanged(path("env.c.new"), path("env.c"));
304 }
305
306 static void
307 read_file(char *fname)
308 {
309         FILE *fp;
310         struct file_list *tp;
311         struct device *dp;
312         struct opt *op;
313         char *wd, *this, *compilewith, *depends, *clean, *warning;
314         int compile, match, nreqs, std, filetype,
315             imp_rule, no_obj, before_depend, mandatory, nowerror;
316
317         fp = fopen(fname, "r");
318         if (fp == 0)
319                 err(1, "%s", fname);
320 next:
321         /*
322          * filename    [ standard | mandatory | optional ]
323          *      [ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ]
324          *      [ compile-with "compile rule" [no-implicit-rule] ]
325          *      [ dependency "dependency-list"] [ before-depend ]
326          *      [ clean "file-list"] [ warning "text warning" ]
327          */
328         wd = get_word(fp);
329         if (wd == (char *)EOF) {
330                 (void) fclose(fp);
331                 return;
332         } 
333         if (wd == 0)
334                 goto next;
335         if (wd[0] == '#')
336         {
337                 while (((wd = get_word(fp)) != (char *)EOF) && wd)
338                         ;
339                 goto next;
340         }
341         this = ns(wd);
342         next_word(fp, wd);
343         if (wd == 0) {
344                 printf("%s: No type for %s.\n",
345                     fname, this);
346                 exit(1);
347         }
348         tp = fl_lookup(this);
349         compile = 0;
350         match = 1;
351         nreqs = 0;
352         compilewith = 0;
353         depends = 0;
354         clean = 0;
355         warning = 0;
356         std = mandatory = 0;
357         imp_rule = 0;
358         no_obj = 0;
359         before_depend = 0;
360         nowerror = 0;
361         filetype = NORMAL;
362         if (eq(wd, "standard")) {
363                 std = 1;
364         /*
365          * If an entry is marked "mandatory", config will abort if it's
366          * not called by a configuration line in the config file.  Apart
367          * from this, the device is handled like one marked "optional".
368          */
369         } else if (eq(wd, "mandatory")) {
370                 mandatory = 1;
371         } else if (!eq(wd, "optional")) {
372                 printf("%s: %s must be optional, mandatory or standard\n",
373                        fname, this);
374                 exit(1);
375         }
376 nextparam:
377         next_word(fp, wd);
378         if (wd == 0) {
379                 compile += match;
380                 if (compile && tp == NULL)
381                         goto doneparam;
382                 goto next;
383         }
384         if (eq(wd, "|")) {
385                 if (nreqs == 0) {
386                         printf("%s: syntax error describing %s\n",
387                             fname, this);
388                         exit(1);
389                 }
390                 compile += match;
391                 match = 1;
392                 nreqs = 0;
393                 goto nextparam;
394         }
395         if (eq(wd, "no-obj")) {
396                 no_obj++;
397                 goto nextparam;
398         }
399         if (eq(wd, "no-implicit-rule")) {
400                 if (compilewith == 0) {
401                         printf("%s: alternate rule required when "
402                                "\"no-implicit-rule\" is specified.\n",
403                                fname);
404                 }
405                 imp_rule++;
406                 goto nextparam;
407         }
408         if (eq(wd, "before-depend")) {
409                 before_depend++;
410                 goto nextparam;
411         }
412         if (eq(wd, "dependency")) {
413                 next_quoted_word(fp, wd);
414                 if (wd == 0) {
415                         printf("%s: %s missing compile command string.\n",
416                                fname, this);
417                         exit(1);
418                 }
419                 depends = ns(wd);
420                 goto nextparam;
421         }
422         if (eq(wd, "clean")) {
423                 next_quoted_word(fp, wd);
424                 if (wd == 0) {
425                         printf("%s: %s missing clean file list.\n",
426                                fname, this);
427                         exit(1);
428                 }
429                 clean = ns(wd);
430                 goto nextparam;
431         }
432         if (eq(wd, "compile-with")) {
433                 next_quoted_word(fp, wd);
434                 if (wd == 0) {
435                         printf("%s: %s missing compile command string.\n",
436                                fname, this);
437                         exit(1);
438                 }
439                 compilewith = ns(wd);
440                 goto nextparam;
441         }
442         if (eq(wd, "warning")) {
443                 next_quoted_word(fp, wd);
444                 if (wd == 0) {
445                         printf("%s: %s missing warning text string.\n",
446                                 fname, this);
447                         exit(1);
448                 }
449                 warning = ns(wd);
450                 goto nextparam;
451         }
452         nreqs++;
453         if (eq(wd, "local")) {
454                 filetype = LOCAL;
455                 goto nextparam;
456         }
457         if (eq(wd, "no-depend")) {
458                 filetype = NODEPEND;
459                 goto nextparam;
460         }
461         if (eq(wd, "profiling-routine")) {
462                 filetype = PROFILING;
463                 goto nextparam;
464         }
465         if (eq(wd, "nowerror")) {
466                 nowerror = 1;
467                 goto nextparam;
468         }
469         STAILQ_FOREACH(dp, &dtab, d_next)
470                 if (eq(dp->d_name, wd)) {
471                         dp->d_done |= DEVDONE;
472                         goto nextparam;
473                 }
474         if (mandatory) {
475                 printf("%s: mandatory device \"%s\" not found\n",
476                        fname, wd);
477                 exit(1);
478         }
479         if (std) {
480                 printf("standard entry %s has a device keyword - %s!\n",
481                        this, wd);
482                 exit(1);
483         }
484         SLIST_FOREACH(op, &opt, op_next)
485                 if (op->op_value == 0 && opteq(op->op_name, wd))
486                         goto nextparam;
487         match = 0;
488         goto nextparam;
489
490 doneparam:
491         if (std == 0 && nreqs == 0) {
492                 printf("%s: what is %s optional on?\n",
493                     fname, this);
494                 exit(1);
495         }
496
497         if (wd) {
498                 printf("%s: syntax error describing %s\n",
499                     fname, this);
500                 exit(1);
501         }
502         if (filetype == PROFILING && profiling == 0)
503                 goto next;
504         tp = new_fent();
505         tp->f_fn = this;
506         tp->f_type = filetype;
507         if (imp_rule)
508                 tp->f_flags |= NO_IMPLCT_RULE;
509         if (no_obj)
510                 tp->f_flags |= NO_OBJ;
511         if (before_depend)
512                 tp->f_flags |= BEFORE_DEPEND;
513         if (nowerror)
514                 tp->f_flags |= NOWERROR;
515         tp->f_compilewith = compilewith;
516         tp->f_depends = depends;
517         tp->f_clean = clean;
518         tp->f_warn = warning;
519         goto next;
520 }
521
522 /*
523  * Read in the information about files used in making the system.
524  * Store it in the ftab linked list.
525  */
526 static void
527 read_files(void)
528 {
529         char fname[MAXPATHLEN];
530         struct files_name *nl, *tnl;
531         
532         (void) snprintf(fname, sizeof(fname), "../../conf/files");
533         read_file(fname);
534         (void) snprintf(fname, sizeof(fname),
535                         "../../conf/files.%s", machinename);
536         read_file(fname);
537         for (nl = STAILQ_FIRST(&fntab); nl != NULL; nl = tnl) {
538                 read_file(nl->f_name);
539                 tnl = STAILQ_NEXT(nl, f_next);
540                 free(nl->f_name);
541                 free(nl);
542         }
543 }
544
545 static int
546 opteq(const char *cp, const char *dp)
547 {
548         char c, d;
549
550         for (; ; cp++, dp++) {
551                 if (*cp != *dp) {
552                         c = isupper(*cp) ? tolower(*cp) : *cp;
553                         d = isupper(*dp) ? tolower(*dp) : *dp;
554                         if (c != d)
555                                 return (0);
556                 }
557                 if (*cp == 0)
558                         return (1);
559         }
560 }
561
562 static void
563 do_before_depend(FILE *fp)
564 {
565         struct file_list *tp;
566         int lpos, len;
567
568         fputs("BEFORE_DEPEND=", fp);
569         lpos = 15;
570         STAILQ_FOREACH(tp, &ftab, f_next)
571                 if (tp->f_flags & BEFORE_DEPEND) {
572                         len = strlen(tp->f_fn);
573                         if ((len = 3 + len) + lpos > 72) {
574                                 lpos = 8;
575                                 fputs("\\\n\t", fp);
576                         }
577                         if (tp->f_flags & NO_IMPLCT_RULE)
578                                 fprintf(fp, "%s ", tp->f_fn);
579                         else
580                                 fprintf(fp, "$S/%s ", tp->f_fn);
581                         lpos += len + 1;
582                 }
583         if (lpos != 8)
584                 putc('\n', fp);
585 }
586
587 static void
588 do_objs(FILE *fp)
589 {
590         struct file_list *tp;
591         int lpos, len;
592         char *cp, och, *sp;
593
594         fprintf(fp, "OBJS=");
595         lpos = 6;
596         STAILQ_FOREACH(tp, &ftab, f_next) {
597                 if (tp->f_flags & NO_OBJ)
598                         continue;
599                 sp = tail(tp->f_fn);
600                 cp = sp + (len = strlen(sp)) - 1;
601                 och = *cp;
602                 *cp = 'o';
603                 if (len + lpos > 72) {
604                         lpos = 8;
605                         fprintf(fp, "\\\n\t");
606                 }
607                 fprintf(fp, "%s ", sp);
608                 lpos += len + 1;
609                 *cp = och;
610         }
611         if (lpos != 8)
612                 putc('\n', fp);
613 }
614
615 static void
616 do_xxfiles(char *tag, FILE *fp)
617 {
618         struct file_list *tp;
619         int lpos, len, slen;
620         char *suff, *SUFF;
621
622         if (tag[strlen(tag) - 1] == '\n')
623                 tag[strlen(tag) - 1] = '\0';
624
625         suff = ns(tag + 7);
626         SUFF = ns(suff);
627         raisestr(SUFF);
628         slen = strlen(suff);
629
630         fprintf(fp, "%sFILES=", SUFF);
631         lpos = 8;
632         STAILQ_FOREACH(tp, &ftab, f_next)
633                 if (tp->f_type != NODEPEND) {
634                         len = strlen(tp->f_fn);
635                         if (tp->f_fn[len - slen - 1] != '.')
636                                 continue;
637                         if (strcasecmp(&tp->f_fn[len - slen], suff) != 0)
638                                 continue;
639                         if ((len = 3 + len) + lpos > 72) {
640                                 lpos = 8;
641                                 fputs("\\\n\t", fp);
642                         }
643                         if (tp->f_type != LOCAL)
644                                 fprintf(fp, "$S/%s ", tp->f_fn);
645                         else
646                                 fprintf(fp, "%s ", tp->f_fn);
647                         lpos += len + 1;
648                 }
649         if (lpos != 8)
650                 putc('\n', fp);
651 }
652
653 static char *
654 tail(char *fn)
655 {
656         char *cp;
657
658         cp = rindex(fn, '/');
659         if (cp == 0)
660                 return (fn);
661         return (cp+1);
662 }
663
664 /*
665  * Create the makerules for each file
666  * which is part of the system.
667  */
668 static void
669 do_rules(FILE *f)
670 {
671         char *cp, *np, och, *tp;
672         struct file_list *ftp;
673         char *compilewith;
674
675         STAILQ_FOREACH(ftp, &ftab, f_next) {
676                 if (ftp->f_warn)
677                         printf("WARNING: %s\n", ftp->f_warn);
678                 cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1;
679                 och = *cp;
680                 if (ftp->f_flags & NO_IMPLCT_RULE) {
681                         if (ftp->f_depends)
682                                 fprintf(f, "%s: %s\n", np, ftp->f_depends);
683                         else
684                                 fprintf(f, "%s: \n", np);
685                 }
686                 else {
687                         *cp = '\0';
688                         if (och == 'o') {
689                                 fprintf(f, "%so:\n\t-cp $S/%so .\n\n",
690                                         tail(np), np);
691                                 continue;
692                         }
693                         if (ftp->f_depends) {
694                                 fprintf(f, "%sln: $S/%s%c %s\n", tail(np),
695                                         np, och, ftp->f_depends);
696                                 fprintf(f, "\t${NORMAL_LINT}\n\n");
697                                 fprintf(f, "%so: $S/%s%c %s\n", tail(np),
698                                         np, och, ftp->f_depends);
699                         }
700                         else {
701                                 fprintf(f, "%sln: $S/%s%c\n", tail(np),
702                                         np, och);
703                                 fprintf(f, "\t${NORMAL_LINT}\n\n");
704                                 fprintf(f, "%so: $S/%s%c\n", tail(np),
705                                         np, och);
706                         }
707                 }
708                 tp = tail(np);
709                 compilewith = ftp->f_compilewith;
710                 if (compilewith == 0) {
711                         const char *ftype = NULL;
712                         static char cmd[128];
713
714                         switch (ftp->f_type) {
715
716                         case NORMAL:
717                                 ftype = "NORMAL";
718                                 break;
719
720                         case PROFILING:
721                                 if (!profiling)
722                                         continue;
723                                 ftype = "PROFILE";
724                                 break;
725
726                         default:
727                                 printf("config: don't know rules for %s\n", np);
728                                 break;
729                         }
730                         snprintf(cmd, sizeof(cmd), "${%s_%c%s}", ftype,
731                             toupper(och),
732                             ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
733                         compilewith = cmd;
734                 }
735                 *cp = och;
736                 fprintf(f, "\t%s\n\n", compilewith);
737         }
738 }
739
740 static void
741 do_clean(FILE *fp)
742 {
743         struct file_list *tp;
744         int lpos, len;
745
746         fputs("CLEAN=", fp);
747         lpos = 7;
748         STAILQ_FOREACH(tp, &ftab, f_next)
749                 if (tp->f_clean) {
750                         len = strlen(tp->f_clean);
751                         if (len + lpos > 72) {
752                                 lpos = 8;
753                                 fputs("\\\n\t", fp);
754                         }
755                         fprintf(fp, "%s ", tp->f_clean);
756                         lpos += len + 1;
757                 }
758         if (lpos != 8)
759                 putc('\n', fp);
760 }
761
762 char *
763 raisestr(char *str)
764 {
765         char *cp = str;
766
767         while (*str) {
768                 if (islower(*str))
769                         *str = toupper(*str);
770                 str++;
771         }
772         return (cp);
773 }