mkmakefile.c (218544) | mkmakefile.c (219819) |
---|---|
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 --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31#if 0 32static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93"; 33#endif 34static const char rcsid[] = | 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 --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31#if 0 32static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93"; 33#endif 34static const char rcsid[] = |
35 "$FreeBSD: head/usr.sbin/config/mkmakefile.c 218544 2011-02-11 06:35:53Z imp $"; | 35 "$FreeBSD: head/usr.sbin/config/mkmakefile.c 219819 2011-03-21 09:40:01Z jeff $"; |
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 --- 263 unchanged lines hidden (view full) --- 307read_file(char *fname) 308{ 309 char ifname[MAXPATHLEN]; 310 FILE *fp; 311 struct file_list *tp; 312 struct device *dp; 313 struct opt *op; 314 char *wd, *this, *compilewith, *depends, *clean, *warning; | 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 --- 263 unchanged lines hidden (view full) --- 307read_file(char *fname) 308{ 309 char ifname[MAXPATHLEN]; 310 FILE *fp; 311 struct file_list *tp; 312 struct device *dp; 313 struct opt *op; 314 char *wd, *this, *compilewith, *depends, *clean, *warning; |
315 const char *objprefix; |
|
315 int compile, match, nreqs, std, filetype, 316 imp_rule, no_obj, before_depend, mandatory, nowerror; 317 318 fp = fopen(fname, "r"); 319 if (fp == 0) 320 err(1, "%s", fname); 321next: 322 /* 323 * include "filename" 324 * filename [ standard | mandatory | optional ] 325 * [ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ] 326 * [ compile-with "compile rule" [no-implicit-rule] ] 327 * [ dependency "dependency-list"] [ before-depend ] 328 * [ clean "file-list"] [ warning "text warning" ] | 316 int compile, match, nreqs, std, filetype, 317 imp_rule, no_obj, before_depend, mandatory, nowerror; 318 319 fp = fopen(fname, "r"); 320 if (fp == 0) 321 err(1, "%s", fname); 322next: 323 /* 324 * include "filename" 325 * filename [ standard | mandatory | optional ] 326 * [ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ] 327 * [ compile-with "compile rule" [no-implicit-rule] ] 328 * [ dependency "dependency-list"] [ before-depend ] 329 * [ clean "file-list"] [ warning "text warning" ] |
330 * [ obj-prefix "file prefix"] |
|
329 */ 330 wd = get_word(fp); 331 if (wd == (char *)EOF) { 332 (void) fclose(fp); 333 return; 334 } 335 if (wd == 0) 336 goto next; --- 31 unchanged lines hidden (view full) --- 368 clean = 0; 369 warning = 0; 370 std = mandatory = 0; 371 imp_rule = 0; 372 no_obj = 0; 373 before_depend = 0; 374 nowerror = 0; 375 filetype = NORMAL; | 331 */ 332 wd = get_word(fp); 333 if (wd == (char *)EOF) { 334 (void) fclose(fp); 335 return; 336 } 337 if (wd == 0) 338 goto next; --- 31 unchanged lines hidden (view full) --- 370 clean = 0; 371 warning = 0; 372 std = mandatory = 0; 373 imp_rule = 0; 374 no_obj = 0; 375 before_depend = 0; 376 nowerror = 0; 377 filetype = NORMAL; |
378 objprefix = ""; |
|
376 if (eq(wd, "standard")) { 377 std = 1; 378 /* 379 * If an entry is marked "mandatory", config will abort if it's 380 * not called by a configuration line in the config file. Apart 381 * from this, the device is handled like one marked "optional". 382 */ 383 } else if (eq(wd, "mandatory")) { --- 78 unchanged lines hidden (view full) --- 462 fprintf(stderr, 463 "%s: %s missing warning text string.\n", 464 fname, this); 465 exit(1); 466 } 467 warning = ns(wd); 468 goto nextparam; 469 } | 379 if (eq(wd, "standard")) { 380 std = 1; 381 /* 382 * If an entry is marked "mandatory", config will abort if it's 383 * not called by a configuration line in the config file. Apart 384 * from this, the device is handled like one marked "optional". 385 */ 386 } else if (eq(wd, "mandatory")) { --- 78 unchanged lines hidden (view full) --- 465 fprintf(stderr, 466 "%s: %s missing warning text string.\n", 467 fname, this); 468 exit(1); 469 } 470 warning = ns(wd); 471 goto nextparam; 472 } |
473 if (eq(wd, "obj-prefix")) { 474 next_quoted_word(fp, wd); 475 if (wd == 0) { 476 printf("%s: %s missing object prefix string.\n", 477 fname, this); 478 exit(1); 479 } 480 objprefix = ns(wd); 481 goto nextparam; 482 } |
|
470 nreqs++; 471 if (eq(wd, "local")) { 472 filetype = LOCAL; 473 goto nextparam; 474 } 475 if (eq(wd, "no-depend")) { 476 filetype = NODEPEND; 477 goto nextparam; --- 52 unchanged lines hidden (view full) --- 530 if (before_depend) 531 tp->f_flags |= BEFORE_DEPEND; 532 if (nowerror) 533 tp->f_flags |= NOWERROR; 534 tp->f_compilewith = compilewith; 535 tp->f_depends = depends; 536 tp->f_clean = clean; 537 tp->f_warn = warning; | 483 nreqs++; 484 if (eq(wd, "local")) { 485 filetype = LOCAL; 486 goto nextparam; 487 } 488 if (eq(wd, "no-depend")) { 489 filetype = NODEPEND; 490 goto nextparam; --- 52 unchanged lines hidden (view full) --- 543 if (before_depend) 544 tp->f_flags |= BEFORE_DEPEND; 545 if (nowerror) 546 tp->f_flags |= NOWERROR; 547 tp->f_compilewith = compilewith; 548 tp->f_depends = depends; 549 tp->f_clean = clean; 550 tp->f_warn = warning; |
551 tp->f_objprefix = objprefix; |
|
538 goto next; 539} 540 541/* 542 * Read in the information about files used in making the system. 543 * Store it in the ftab linked list. 544 */ 545static void --- 68 unchanged lines hidden (view full) --- 614 lpos = 6; 615 STAILQ_FOREACH(tp, &ftab, f_next) { 616 if (tp->f_flags & NO_OBJ) 617 continue; 618 sp = tail(tp->f_fn); 619 cp = sp + (len = strlen(sp)) - 1; 620 och = *cp; 621 *cp = 'o'; | 552 goto next; 553} 554 555/* 556 * Read in the information about files used in making the system. 557 * Store it in the ftab linked list. 558 */ 559static void --- 68 unchanged lines hidden (view full) --- 628 lpos = 6; 629 STAILQ_FOREACH(tp, &ftab, f_next) { 630 if (tp->f_flags & NO_OBJ) 631 continue; 632 sp = tail(tp->f_fn); 633 cp = sp + (len = strlen(sp)) - 1; 634 och = *cp; 635 *cp = 'o'; |
636 len += strlen(tp->f_objprefix); |
|
622 if (len + lpos > 72) { 623 lpos = 8; 624 fprintf(fp, "\\\n\t"); 625 } | 637 if (len + lpos > 72) { 638 lpos = 8; 639 fprintf(fp, "\\\n\t"); 640 } |
626 fprintf(fp, "%s ", sp); | 641 fprintf(fp, "%s%s ", tp->f_objprefix, sp); |
627 lpos += len + 1; 628 *cp = och; 629 } 630 if (lpos != 8) 631 putc('\n', fp); 632} 633 634static void --- 59 unchanged lines hidden (view full) --- 694 695 STAILQ_FOREACH(ftp, &ftab, f_next) { 696 if (ftp->f_warn) 697 fprintf(stderr, "WARNING: %s\n", ftp->f_warn); 698 cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; 699 och = *cp; 700 if (ftp->f_flags & NO_IMPLCT_RULE) { 701 if (ftp->f_depends) | 642 lpos += len + 1; 643 *cp = och; 644 } 645 if (lpos != 8) 646 putc('\n', fp); 647} 648 649static void --- 59 unchanged lines hidden (view full) --- 709 710 STAILQ_FOREACH(ftp, &ftab, f_next) { 711 if (ftp->f_warn) 712 fprintf(stderr, "WARNING: %s\n", ftp->f_warn); 713 cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; 714 och = *cp; 715 if (ftp->f_flags & NO_IMPLCT_RULE) { 716 if (ftp->f_depends) |
702 fprintf(f, "%s: %s\n", np, ftp->f_depends); | 717 fprintf(f, "%s%s: %s\n", 718 ftp->f_objprefix, np, ftp->f_depends); |
703 else | 719 else |
704 fprintf(f, "%s: \n", np); | 720 fprintf(f, "%s%s: \n", ftp->f_objprefix, np); |
705 } 706 else { 707 *cp = '\0'; 708 if (och == 'o') { | 721 } 722 else { 723 *cp = '\0'; 724 if (och == 'o') { |
709 fprintf(f, "%so:\n\t-cp $S/%so .\n\n", 710 tail(np), np); | 725 fprintf(f, "%s%so:\n\t-cp $S/%so .\n\n", 726 ftp->f_objprefix, tail(np), np); |
711 continue; 712 } 713 if (ftp->f_depends) { | 727 continue; 728 } 729 if (ftp->f_depends) { |
714 fprintf(f, "%sln: $S/%s%c %s\n", tail(np), 715 np, och, ftp->f_depends); | 730 fprintf(f, "%s%sln: $S/%s%c %s\n", 731 ftp->f_objprefix, tail(np), np, och, 732 ftp->f_depends); |
716 fprintf(f, "\t${NORMAL_LINT}\n\n"); | 733 fprintf(f, "\t${NORMAL_LINT}\n\n"); |
717 fprintf(f, "%so: $S/%s%c %s\n", tail(np), 718 np, och, ftp->f_depends); | 734 fprintf(f, "%s%so: $S/%s%c %s\n", 735 ftp->f_objprefix, tail(np), np, och, 736 ftp->f_depends); |
719 } 720 else { | 737 } 738 else { |
721 fprintf(f, "%sln: $S/%s%c\n", tail(np), 722 np, och); | 739 fprintf(f, "%s%sln: $S/%s%c\n", 740 ftp->f_objprefix, tail(np), np, och); |
723 fprintf(f, "\t${NORMAL_LINT}\n\n"); | 741 fprintf(f, "\t${NORMAL_LINT}\n\n"); |
724 fprintf(f, "%so: $S/%s%c\n", tail(np), 725 np, och); | 742 fprintf(f, "%s%so: $S/%s%c\n", 743 ftp->f_objprefix, tail(np), np, och); |
726 } 727 } 728 compilewith = ftp->f_compilewith; 729 if (compilewith == 0) { 730 const char *ftype = NULL; 731 732 switch (ftp->f_type) { 733 case NORMAL: --- 11 unchanged lines hidden (view full) --- 745 } 746 snprintf(cmd, sizeof(cmd), 747 "${%s_%c%s}\n\t@${NORMAL_CTFCONVERT}", ftype, 748 toupper(och), 749 ftp->f_flags & NOWERROR ? "_NOWERROR" : ""); 750 compilewith = cmd; 751 } 752 *cp = och; | 744 } 745 } 746 compilewith = ftp->f_compilewith; 747 if (compilewith == 0) { 748 const char *ftype = NULL; 749 750 switch (ftp->f_type) { 751 case NORMAL: --- 11 unchanged lines hidden (view full) --- 763 } 764 snprintf(cmd, sizeof(cmd), 765 "${%s_%c%s}\n\t@${NORMAL_CTFCONVERT}", ftype, 766 toupper(och), 767 ftp->f_flags & NOWERROR ? "_NOWERROR" : ""); 768 compilewith = cmd; 769 } 770 *cp = och; |
753 fprintf(f, "\t%s\n\n", compilewith); | 771 if (strlen(ftp->f_objprefix)) 772 fprintf(f, "\t%s $S/%s\n\n", compilewith, np); 773 else 774 fprintf(f, "\t%s\n\n", compilewith); |
754 } 755} 756 757static void 758do_clean(FILE *fp) 759{ 760 struct file_list *tp; 761 int lpos, len; --- 29 unchanged lines hidden --- | 775 } 776} 777 778static void 779do_clean(FILE *fp) 780{ 781 struct file_list *tp; 782 int lpos, len; --- 29 unchanged lines hidden --- |