source: UsbWattMeter/trunk/asp_dcre/utils/makedep@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 7 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

File size: 4.8 KB
Line 
1#! /usr/bin/perl
2#
3# TOPPERS Software
4# Toyohashi Open Platform for Embedded Real-Time Systems
5#
6# Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7# Toyohashi Univ. of Technology, JAPAN
8# Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
9# Graduate School of Information Science, Nagoya Univ., JAPAN
10#
11# ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
12# ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
13# •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
14# (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
15# Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
16# ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
17# (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
18# —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
19ƒƒ“ƒgi—˜—p
20# ŽÒƒ}ƒjƒ…
21ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
22# ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
23# (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
24# —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
25# ‚ƁD
26# (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
27ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
28ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
29# ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
30# (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
31# •ñ‚·‚邱‚ƁD
32# (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
33# ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
34# ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
35# —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
36# –Ɛӂ·‚邱‚ƁD
37#
38# –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
39# ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
40# ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
41# ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
42# ‚̐ӔC‚𕉂í‚È‚¢D
43#
44# @(#) $Id: makedep 2264 2011-10-27 04:22:01Z ertl-hiro $
45#
46
47use Getopt::Std;
48
49# ƒIƒvƒVƒ‡ƒ“‚Ì’è‹`
50#
51# -C <cc_path> CƒRƒ“ƒpƒCƒ‰‚̃Rƒ}ƒ“ƒh–¼
52# -O <cc_opts> CƒRƒ“ƒpƒCƒ‰/CPP‚É“n‚·ƒIƒvƒVƒ‡ƒ“
53# -X ƒ\[ƒXƒtƒ@ƒCƒ‹‚ð‹­§“I‚ÉCƒwƒbƒ_ƒtƒ@ƒCƒ‹‚ÆŒ©‚È‚·
54#
55# -T <target> ƒ^[ƒQƒbƒg–¼i‚̃ŠƒXƒgj
56# -D <t_dir> ƒ^[ƒQƒbƒg‚̃fƒBƒŒƒNƒgƒŠ–¼‚ðŽw’è‚·‚éi-T‚ð—p‚¢‚½ê
57# ‡‚Í–³Œøj
58# -d ƒ^[ƒQƒbƒg‚̃fƒBƒŒƒNƒgƒŠ•”‚ð•ÛŽ‚·‚éi-T‚ð—p‚¢‚½ê
59# ‡‚Í–³Œøj
60# -S •¡”‚̃^[ƒQƒbƒg‚ª‚ ‚éˆË‘¶ƒ‹[ƒ‹‚ðCƒ^[ƒQƒbƒg–ˆ‚É
61# •ªŠ„‚·‚éi‚±‚¤‚µ‚È‚¢‚ƑΉž‚Å‚«‚È‚¢make‚ª‚ ‚é‚炵‚¢j
62#
63# -R <dirname> CygwinŠÂ‹«‚É‚¨‚¯‚郋[ƒgƒfƒBƒŒƒNƒgƒŠ–¼‚ðŽw’è‚·‚é
64# iƒfƒtƒHƒ‹ƒg‚Ícygdrivej
65
66#
67# ƒIƒvƒVƒ‡ƒ“‚̏ˆ—
68#
69getopt("COTDR");
70
71$cc_path = $opt_C;
72$cc_opts = $opt_O;
73
74if ($opt_T) {
75 $target_name = $opt_T;
76}
77elsif ($opt_D) {
78 $target_dir = $opt_D;
79}
80elsif (!$opt_d) {
81 $target_dir = "";
82}
83
84if ($opt_R) {
85 $cygwin_root = $opt_R;
86}
87else {
88 $cygwin_root = "cygdrive";
89}
90
91#
92# CygwinŠÂ‹«‚Ì”»•Ê
93#
94if ($^O eq 'cygwin') {
95 $cygwin = 1;
96}
97
98#
99# %dependlist ‚ɍì‚ç‚ꂽˆË‘¶ŠÖŒW‚ðo—Í‚·‚é
100#
101sub output_dependlist {
102 local($target) = @_;
103 local($column, $len, $file);
104
105 print $target, ": ";
106 $column = length($target) + 2;
107
108 foreach $file (keys(%dependlist)) {
109 $len = length($file) + 1;
110 if ($column > 8 && $column + $len >= 70) {
111 print "\\\n\t";
112 $column = 8;
113 }
114 $column += $len;
115 print "$file ";
116 }
117 print "\n";
118}
119
120#
121# $file ‚̈ˑ¶ŠÖŒW‚ð %dependlist ‚ɍì‚é
122#
123sub makedepend_one {
124 local($file) = @_;
125 local($command, $input, $dir, $filename);
126
127 $command = "$cc_path -E $cc_opts";
128 if ($opt_X) {
129 $command .= " -x c-header";
130 }
131 unless (open(INPUT, "$command $file |")) {
132 print STDERR "makedep: can't open $file\n";
133 exit(1);
134 }
135 while ($line = <INPUT>) {
136 if ($line =~ /^\#\s*([0-9]+)\s*\"([^\"]+)\"/) {
137 $filename = $2;
138 $filename =~ s/ /\\ /g;
139 if ($filename !~ /^\<.*\>$/ && $filename !~ /\/$/) {
140 if ($cygwin) {
141 $filename =~ s/\\\\/\//g;
142 $filename =~ s/^([a-zA-Z]):/\/$cygwin_root\/$1/;
143 }
144 $dependlist{$filename} = 1;
145 }
146 }
147 }
148 unless (close(INPUT)) {
149 print STDERR "makedep: can't execute $command\n";
150 exit(1);
151 }
152}
153
154#
155# ƒƒCƒ“ƒ‹[ƒ`ƒ“
156#
157foreach $file (@ARGV) {
158 %dependlist = ();
159 makedepend_one($file);
160 if (%dependlist) {
161 if ($target_name) {
162 if ($opt_S) {
163 foreach $target (split(/[ \t]+/, $target_name)) {
164 output_dependlist($target);
165 }
166 }
167 else {
168 output_dependlist($target_name);
169 }
170 }
171 else {
172 $target = $file;
173 $target =~ s/(.*)\.(.*)/$1.o/;
174 if (defined($target_dir)) {
175 $target =~ s/^.*\/([^\/]+)$/$1/;
176 if ($target_dir) {
177 $target = $target_dir."/".$target;
178 }
179 }
180 output_dependlist($target);
181 }
182 }
183}
Note: See TracBrowser for help on using the repository browser.