source: uKadecot/trunk/ssp/configure@ 101

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

TOPPERS/uKadecotのソースコードを追加

File size: 7.3 KB
Line 
1#! /usr/bin/perl
2#
3# TOPPERS Software
4# Toyohashi Open Platform for Embedded Real-Time Systems/
5#
6# Copyright (C) 2001-2003 by Embedded and Real-Time Systems Laboratory
7# Toyohashi Univ. of Technology, JAPAN
8# Copyright (C) 2006-2009 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: configure 1733 2010-02-03 03:50:52Z ertl-hiro $
45#
46
47use Getopt::Std;
48
49# ƒIƒvƒVƒ‡ƒ“‚Ì’è‹`
50#
51# -T <target> ƒ^[ƒQƒbƒg–¼i•K{j
52# -A <applname> ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ƒvƒƒOƒ‰ƒ€–¼iƒfƒtƒHƒ‹ƒg‚Ísample1j
53# -a <appldir> ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̃fƒBƒŒƒNƒgƒŠ–¼
54# -U <applobjs> ‘¼‚̃AƒvƒŠƒP[ƒVƒ‡ƒ“ƒvƒƒOƒ‰ƒ€ƒtƒ@ƒCƒ‹
55# i.oƒtƒ@ƒCƒ‹–¼‚ÅŽw’èD•¡”Žw’è‰Âj
56# -L <kernel_lib> ƒJ[ƒlƒ‹ƒ‰ƒCƒuƒ‰ƒŠilibkernel.aj‚̃fƒBƒŒƒNƒgƒŠ–¼
57# iÈ—ª‚µ‚½ê‡CƒJ[ƒlƒ‹ƒ‰ƒCƒuƒ‰ƒŠ‚àmake‚·‚éj
58# -f ƒJ[ƒlƒ‹‚ðŠÖ”’PˆÊ‚ŃRƒ“ƒpƒCƒ‹‚·‚é‚©‚Ç‚¤‚©‚ÌŽw’è
59# -D <srcdir> ƒJ[ƒlƒ‹“™‚̃\[ƒX‚Ì’u‚©‚ê‚Ä‚¢‚éƒfƒBƒŒƒNƒgƒŠ
60# -l <srclang> ƒvƒƒOƒ‰ƒ~ƒ“ƒOŒ¾ŒêiŒ»Žž“_‚Å‚Íc‚Æc++‚̂݃Tƒ|[ƒgj
61# -t <templatedir> ƒeƒ“ƒvƒŒ[ƒgƒfƒBƒŒƒNƒgƒŠ‚ÌŽw’èiƒfƒtƒHƒ‹ƒg‚Ísamplej
62# -m <makefile> ƒeƒ“ƒvƒŒ[ƒgMakefile–¼‚ÌŽw’èiƒfƒtƒHƒ‹ƒg‚ÍMakefilej
63# -d <dbgenv> ŽÀsŠÂ‹«‚Ì–¼Ì
64# -r ƒgƒŒ[ƒXƒƒO‹L˜^‚̃Tƒ“ƒvƒ‹ƒR[ƒh‚ðŽg—p‚·‚é‚©‚Ç‚¤‚©
65# ‚ÌŽw’è
66# -p <perl> perl‚̃pƒX–¼i–¾Ž¦“I‚ÉŽw’è‚·‚éê‡j
67# -g <cfg> ƒRƒ“ƒtƒBƒMƒ…
68ƒŒ[ƒ^icfgj‚̃pƒX–¼
69
70# Žg—p—á(1)
71#
72# % ../configure -T dve68k_gcc -D GDB_STUB -A perf1 -a ../test -U histogram.o
73#
74# Žg—p—á(2)
75#
76# % ../configure -T macosx_gcc -L .
77# ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ƒvƒƒOƒ‰ƒ€‚Í sample1 ‚É‚È‚éD
78
79#
80# ƒIƒvƒVƒ‡ƒ“‚̏ˆ—
81#
82getopt("TAaULDltmdpg");
83
84#
85# •Ï”‚̏‰Šú‰»
86#
87
88$target = $opt_T;
89$applname = $opt_A ? $opt_A : "sample1";
90$appldir = $opt_a ? $opt_a : "";
91$applobjs = $opt_U ? $opt_U : "";
92$kernel_lib = $opt_L ? $opt_L : "";
93$kernel_funcobjs = $opt_f ? "true" : "";
94$srclang = $opt_l ? $opt_l : "c";
95$makefile = $opt_m ? $opt_m : "Makefile";
96$dbgenv = $opt_d ? "TOPPERS_".$opt_d : "";
97$enable_trace = $opt_r ? "true" : "";
98
99#
100# ƒIƒuƒWƒFƒNƒgƒtƒ@ƒCƒ‹–¼‚ÌŠg’£Žq‚ð•Ô‚·
101#
102sub get_objext {
103 local(@uname);
104
105 use POSIX;
106 @uname = uname();
107 if ($uname[0] =~ /^cygwin/i) {
108 return("exe");
109 }
110 else {
111 return("");
112 }
113}
114
115#
116# ƒvƒƒOƒ‰ƒ€‚̏ꏊ‚ðŒŸõ‚·‚é
117#
118sub get_path {
119 local($progname, @pathlist) = @_;
120 local($path);
121
122 foreach $path (@pathlist) {
123 if (-x $path."/".$progname) {
124 return($path."/".$progname);
125 }
126 }
127 return("");
128}
129
130#
131# ƒtƒ@ƒCƒ‹‚ð•ÏŠ·‚·‚é
132#
133sub convert {
134 local($infile, $outfile) = @_;
135 local($line, $varname, $varval);
136
137 print STDERR "configure: Generating $outfile from $infile.\n";
138 if (-f $outfile) {
139 print STDERR "configure: $outfile exists.",
140 " Save as $outfile.bak.\n";
141 rename($outfile, $outfile.".bak");
142 }
143 unless (open(INFILE, $infile)) {
144 print STDERR "configure: can't open $infile\n";
145 exit(1);
146 }
147 unless (open(OUTFILE, "> ".$outfile)) {
148 print STDERR "configure: can't open $outfile\n";
149 exit(1);
150 }
151
152 while ($line = <INFILE>) {
153 chop $line;
154 while ($line =~ /^(.*)\@\(([A-Za-z_]+)\)(.*)$/) {
155 $line = $1.$vartable{$2}.$3;
156 }
157 print OUTFILE $line,"\n";
158 }
159
160 close(INFILE);
161 close(OUTFILE);
162}
163
164#
165# ƒTƒ“ƒvƒ‹‚ðŒ©‚Â‚¯‚ătƒ@ƒCƒ‹‚𐶐¬‚·‚é
166#
167sub generate {
168 local($file, $mandatory) = @_;
169 local($path);
170
171 if ($sys) {
172 $path = $templatedir."/".$file.".".$cpu."-".$sys;
173 if (-f $path) {
174 convert($path, $file);
175 return;
176 }
177
178 $path = $templatedir."/".$file.".".$sys;
179 if (-f $path) {
180 convert($path, $file);
181 return;
182 }
183 }
184
185 $path = $templatedir."/".$file.".".$cpu;
186 if (-f $path) {
187 convert($path, $file);
188 return;
189 }
190
191 $path = $templatedir."/".$file;
192 if ($mandatory || -f $path) {
193 convert($path, $file);
194 }
195}
196
197#
198# ƒ\[ƒXƒfƒBƒŒƒNƒgƒŠ–¼‚ðŽæ‚èo‚·
199#
200$pwd = `pwd`; chop $pwd;
201if ($opt_D) {
202 $srcabsdir = $srcdir = $opt_D;
203}
204elsif ($0 =~ /(.*)\/configure/) {
205 $srcdir = $1;
206 if ($srcdir =~ /^\//) {
207 $srcabsdir = $srcdir;
208 }
209 else {
210 $srcabsdir = $pwd."/".$srcdir;
211 }
212}
213else {
214 $srcabsdir = $srcdir = $pwd;
215}
216
217$perl = $opt_p ? $opt_p : get_path("perl", ("/usr/local/bin", "/usr/bin"));
218$cfg = $opt_g ? $opt_g : "\$(SRCDIR)/cfg/cfg/cfg";
219$cfgfile = $opt_g ? $opt_g : $srcdir."/cfg/cfg/cfg";
220$templatedir = $opt_t ? $opt_t : $srcdir."/sample";
221
222#
223# -TƒIƒvƒVƒ‡ƒ“‚ÌŠm”F
224#
225unless ($opt_T) {
226 print STDERR "configure: -T option is mandatory\n";
227 print STDERR "Installed targets are:\n";
228 foreach $targetname (<$srcdir/target/[a-zA-Z1-9]*>) {
229 $targetname =~ s|$srcdir/target/||;
230 print STDERR "\t$targetname\n";
231 }
232 exit(1);
233}
234
235#
236# •Ï”ƒe[ƒuƒ‹‚̍쐬
237#
238%vartable = ();
239$vartable{"TARGET"} = $target;
240$vartable{"APPLNAME"} = $applname;
241$vartable{"APPLDIR"} = $appldir;
242$vartable{"APPLOBJS"} = $applobjs;
243$vartable{"KERNEL_LIB"} = $kernel_lib;
244$vartable{"KERNEL_FUNCOBJS"} = $kernel_funcobjs;
245$vartable{"SRCDIR"} = $srcdir;
246$vartable{"SRCABSDIR"} = $srcabsdir;
247$vartable{"SRCLANG"} = $srclang;
248$vartable{"DBGENV"} = $dbgenv;
249$vartable{"ENABLE_TRACE"} = $enable_trace;
250$vartable{"PERL"} = $perl;
251$vartable{"CFG"} = $cfg;
252$objext = get_objext();
253$vartable{"OBJEXT"} = $objext;
254
255#
256# ƒ^[ƒQƒbƒgƒfƒBƒŒƒNƒgƒŠ‚̃`ƒFƒbƒN
257#
258
259if (! -d $srcdir."/target/".$target) {
260 print STDERR "configure: $srcdir/target/$target not exist\n";
261 exit(1);
262}
263
264#
265# Makefile ‚ƃAƒvƒŠƒP[ƒVƒ‡ƒ“ƒtƒ@ƒCƒ‹‚̐¶¬
266#
267
268generate($makefile, 1);
269generate($applname.".c", 0);
270generate($applname.".cpp", 0);
271generate($applname.".h", 0);
272generate($applname.".cfg", 0);
273
274#
275# cfg ‚ª‚Å‚«‚Ä‚¢‚é‚©‚̃`ƒFƒbƒN
276#
277
278if (!(-x ($objext == "" ? $cfgfile : $cfgfile.".".$objext))) {
279 print STDERR "Executable file of the configurator (cfg) is not found.\n";
280}
Note: See TracBrowser for help on using the repository browser.