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