[4] | 1 | #! /usr/bin/perl
|
---|
| 2 | #
|
---|
| 3 | # TOPPERS/OSEK Kernel
|
---|
| 4 | # Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 5 | # OSEK Kernel
|
---|
| 6 | #
|
---|
| 7 | # Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 8 | # Toyohashi Univ. of Technology, JAPAN
|
---|
| 9 | # Copyright (C) 2004-2006 by Witz Corporation, JAPAN
|
---|
| 10 | #
|
---|
| 11 | # ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation
|
---|
| 12 | # ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
|
---|
| 13 | # q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
|
---|
| 14 | # ðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»EüÏEÄzziȺC
|
---|
| 15 | # pÆÄÔj·é±Æð³Åø·éD
|
---|
| 16 | # (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
| 17 | # \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
| 18 | # XR[hÉÜÜêÄ¢é±ÆD
|
---|
| 19 | # (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
| 20 | # pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
| 21 | gip
|
---|
| 22 | # Ò}j
|
---|
| 23 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
| 24 | # ̳ÛØKèðfÚ·é±ÆD
|
---|
| 25 | # (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
| 26 | # pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
| 27 | # ÆD
|
---|
| 28 | # (a) Äzzɺ¤hL
|
---|
| 29 | gipÒ}j
|
---|
| 30 | AÈÇjÉCãLÌ
|
---|
| 31 | # ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
| 32 | # (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
| 33 | # ñ·é±ÆD
|
---|
| 34 | # (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
| 35 | # Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
| 36 | #
|
---|
| 37 | # {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
| 38 | # æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
|
---|
| 39 | # ÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEFAÌpÉæè¼
|
---|
| 40 | # ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
|
---|
| 41 | #
|
---|
| 42 | #
|
---|
| 43 |
|
---|
| 44 | require "getopt.pl";
|
---|
| 45 |
|
---|
| 46 | # IvVÌè`
|
---|
| 47 | #
|
---|
| 48 | # -C <cc_path> CRpCÌR}h¼
|
---|
| 49 | # -O <cc_opts> CRpC/CPPÉn·IvV
|
---|
| 50 | #
|
---|
| 51 | # -X \[Xt@Cð§IÉCwb_t@CÆ©È·
|
---|
| 52 | #
|
---|
| 53 | # -T <target> ^[QbgÌt@C¼
|
---|
| 54 | # -D <t_dir> ^[QbgÌfBNg¼ðwè·é
|
---|
| 55 | # -d ^[QbgÌfBNgðÛ·é
|
---|
| 56 | # -s ^[QbgÌTtBbNXð ".s" É·éiftHgÍ ".o"j
|
---|
| 57 |
|
---|
| 58 | #
|
---|
| 59 | # IvVÌ
|
---|
| 60 | #
|
---|
| 61 | do Getopt("COTD");
|
---|
| 62 |
|
---|
| 63 | $cc_path = $opt_C;
|
---|
| 64 | $cc_opts = $opt_O;
|
---|
| 65 |
|
---|
| 66 | $suffix = $opt_s ? "s" : "o";
|
---|
| 67 | if ($opt_T) {
|
---|
| 68 | $target_file = $opt_T;
|
---|
| 69 | }
|
---|
| 70 | elsif ($opt_D) {
|
---|
| 71 | $target_dir = $opt_D;
|
---|
| 72 | }
|
---|
| 73 | elsif (!$opt_d) {
|
---|
| 74 | $target_dir = "";
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | #
|
---|
| 78 | # %dependlist Éìçê½Ë¶ÖWðoÍ·é
|
---|
| 79 | #
|
---|
| 80 | sub output_dependlist {
|
---|
| 81 | local($file) = @_;
|
---|
| 82 | local($target, $column, $len);
|
---|
| 83 |
|
---|
| 84 | if ($target_file) {
|
---|
| 85 | $target = $target_file;
|
---|
| 86 | }
|
---|
| 87 | else {
|
---|
| 88 | $target = $file;
|
---|
| 89 | $target =~ s/(.*)\.(.)/$1.$suffix/;
|
---|
| 90 | }
|
---|
| 91 | if (defined($target_dir)) {
|
---|
| 92 | $target =~ s/^.*\/([^\/]+)$/$1/;
|
---|
| 93 | if ($target_dir) {
|
---|
| 94 | $target = $target_dir."/".$target;
|
---|
| 95 | }
|
---|
| 96 | }
|
---|
| 97 | print $target, ": ";
|
---|
| 98 | $column = length($target) + 2;
|
---|
| 99 |
|
---|
| 100 | foreach $file (keys(%dependlist)) {
|
---|
| 101 | $len = length($file) + 1;
|
---|
| 102 | if ($column > 8 && $column + $len >= 70) {
|
---|
| 103 | print "\\\n\t";
|
---|
| 104 | $column = 8;
|
---|
| 105 | }
|
---|
| 106 | $column += $len;
|
---|
| 107 | print "$file ";
|
---|
| 108 | }
|
---|
| 109 | print "\n";
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | #
|
---|
| 113 | # $file Ì˶ÖWð %dependlist Éìé
|
---|
| 114 | #
|
---|
| 115 | sub makedepend_one {
|
---|
| 116 | local($file) = @_;
|
---|
| 117 | local($command, $input, $dir, $filename);
|
---|
| 118 |
|
---|
| 119 | $command = "$cc_path -E $cc_opts";
|
---|
| 120 | if ($opt_X) {
|
---|
| 121 | $command .= " -x c-header";
|
---|
| 122 | }
|
---|
| 123 | unless (open(INPUT, "$command $file |")) {
|
---|
| 124 | print STDERR "makedep: can't open $file\n";
|
---|
| 125 | exit(1);
|
---|
| 126 | }
|
---|
| 127 | while ($line = <INPUT>) {
|
---|
| 128 | if ($line =~ /^\#\s*([0-9]+)\s*\"([^\"]+)\"/) {
|
---|
| 129 | $filename = $2;
|
---|
| 130 | $filename =~ s/ /\\ /;
|
---|
| 131 | if ($filename !~ /^\<.*\>$/ && $filename !~ /\/$/) {
|
---|
| 132 | $dependlist{$filename} = 1;
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | unless (close(INPUT)) {
|
---|
| 137 | print STDERR "makedep: can't execute $command\n";
|
---|
| 138 | exit(1);
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | #
|
---|
| 143 | # C[`
|
---|
| 144 | #
|
---|
| 145 | foreach $file (@ARGV) {
|
---|
| 146 | %dependlist = ();
|
---|
| 147 | do makedepend_one($file);
|
---|
| 148 | do output_dependlist($file) if (%dependlist);
|
---|
| 149 | }
|
---|