[26] | 1 | #! /usr/bin/perl
|
---|
| 2 | #
|
---|
| 3 | # TOPPERS/JSP Kernel
|
---|
| 4 | # Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 5 | # Just Standard Profile Kernel
|
---|
| 6 | #
|
---|
| 7 | # Copyright (C) 2001-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 8 | # Toyohashi Univ. of Technology, JAPAN
|
---|
| 9 | # Copyright (C) 2003-2004,2010 by Naoki Saito
|
---|
| 10 | # Nagoya Municipal Industrial Research Institute, JAPAN
|
---|
| 11 | #
|
---|
| 12 | # ä¸è¨èä½æ¨©è
|
---|
| 13 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 14 | # ã«ãã£ã¦å
|
---|
| 15 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 16 | # è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 17 | # ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 18 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 19 | # å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 20 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 21 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 22 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 23 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 24 | # ç¨ã§ããå½¢ã§åé
|
---|
| 25 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 26 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 27 | # è
|
---|
| 28 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 29 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 30 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 31 | # ç¨ã§ããªãå½¢ã§åé
|
---|
| 32 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 33 | # ã¨ï¼
|
---|
| 34 | # (a) åé
|
---|
| 35 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 36 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 37 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 38 | # (b) åé
|
---|
| 39 | å¸ã®å½¢æ
|
---|
| 40 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 41 | # å ±åãããã¨ï¼
|
---|
| 42 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 43 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 44 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 45 | 責ãããã¨ï¼
|
---|
| 46 | #
|
---|
| 47 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 48 | ã
|
---|
| 49 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 50 | # å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 51 | # æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 52 | #
|
---|
| 53 | # @(#) $Id: configure.m16c,v 1.5 2007/03/23 08:25:47 honda Exp $
|
---|
| 54 | #
|
---|
| 55 |
|
---|
| 56 | require "getopt.pl";
|
---|
| 57 |
|
---|
| 58 | # ãªãã·ã§ã³ã®å®ç¾©
|
---|
| 59 | #
|
---|
| 60 | # -C <cpu> ããã»ããµå
|
---|
| 61 | # -S <sys> ã·ã¹ãã å
|
---|
| 62 | # -T <tool> éçºç°å¢å
|
---|
| 63 | # -A <uname> ã¢ããªã±ã¼ã·ã§ã³ããã°ã©ã å
|
---|
| 64 | # -U <utask> ä»ã®ã¢ããªã±ã¼ã·ã§ã³ããã°ã©ã ãã¡ã¤ã«
|
---|
| 65 | # ï¼.r30 ãã¡ã¤ã«åã§æå®ï¼è¤æ°æå®å¯ï¼
|
---|
| 66 | # -L <kernel_lib> ã«ã¼ãã«ã©ã¤ãã©ãªï¼libkernel.libï¼ã®ãã£ã¬ã¯ããªå
|
---|
| 67 | # ï¼çç¥ããå ´åï¼ã«ã¼ãã«ã©ã¤ãã©ãªã make ããï¼
|
---|
| 68 | # -D <srcdir> ã«ã¼ãã«çã®ã½ã¼ã¹ã®ç½®ããã¦ãããã£ã¬ã¯ããª
|
---|
| 69 | # -P <prefix> éçºç°å¢ã¤ã³ã¹ãã¼ã«æã® PREFIX
|
---|
| 70 | # ï¼ç¾å¨ã¯ PREFIX ã使ã£ã¦ãããã¡ã¤ã«ã¯ãªãï¼
|
---|
| 71 | # -p <perl> perl ã®ãã¹åï¼æ示çã«æå®ããå ´åï¼
|
---|
| 72 | # -l <lang> ããã°ã©ãã³ã°è¨èªï¼ç¾æç¹ã§ã¯C++ã®ã¿ãµãã¼ãï¼
|
---|
| 73 | # -d <dir> ãã³ãã¬ã¼ããã£ã¬ã¯ããªãæå®ï¼ããã©ã«ãã¯sampleï¼
|
---|
| 74 |
|
---|
| 75 | # 使ç¨ä¾(1)
|
---|
| 76 | #
|
---|
| 77 | # % ..\utils\m16c-renesas\configure -C m16c -S oaks16 -T renesas -D .. -A test1 -U test_support.r30 -L .
|
---|
| 78 | #
|
---|
| 79 | # 使ç¨ä¾(2)
|
---|
| 80 | #
|
---|
| 81 | # % ../configure -C linux
|
---|
| 82 | # ã¢ããªã±ã¼ã·ã§ã³ããã°ã©ã 㯠sample1 ã«ãªãï¼
|
---|
| 83 |
|
---|
| 84 | #
|
---|
| 85 | # ãªãã·ã§ã³ã®å¦ç
|
---|
| 86 | #
|
---|
| 87 | Getopt("CSTAULDPpld");
|
---|
| 88 |
|
---|
| 89 | $cpu = $opt_C ? $opt_C : "m16c";
|
---|
| 90 | $sys = $opt_S ? $opt_S : "oaks16";
|
---|
| 91 | $tool = $opt_T ? $opt_T : "renesas";
|
---|
| 92 | $uname = $opt_A ? $opt_A : "sample1";
|
---|
| 93 | $utask = $opt_U ? $opt_U : "";
|
---|
| 94 | $kernel_lib = $opt_L ? $opt_L : "";
|
---|
| 95 | $prefix = $opt_P ? $opt_P : "\\mtool";
|
---|
| 96 | $perl = $opt_p ? $opt_p : get_path("perl.exe", ("\\perl\\bin"));
|
---|
| 97 | $lang = $opt_l ? $opt_l : "";
|
---|
| 98 | $templatedir = $opt_d ? $opt_d : "sample";
|
---|
| 99 |
|
---|
| 100 | #
|
---|
| 101 | # ãªãã¸ã§ã¯ããã¡ã¤ã«åã®æ¡å¼µåãè¿ã
|
---|
| 102 | #
|
---|
| 103 | sub get_objext {
|
---|
| 104 | local(@uname);
|
---|
| 105 |
|
---|
| 106 | use POSIX;
|
---|
| 107 | @uname = uname();
|
---|
| 108 | if ($uname[0] =~ /^cygwin/i) {
|
---|
| 109 | return("exe");
|
---|
| 110 | }
|
---|
| 111 | else {
|
---|
| 112 | return("");
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | #
|
---|
| 117 | # ããã°ã©ã ã®å ´æãæ¤ç´¢ãã
|
---|
| 118 | #
|
---|
| 119 | sub get_path {
|
---|
| 120 | local($progname, @pathlist) = @_;
|
---|
| 121 | local($path);
|
---|
| 122 |
|
---|
| 123 | foreach $path (@pathlist) {
|
---|
| 124 | if (-x $path."\\".$progname) {
|
---|
| 125 | return($path."\\".$progname);
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | return("");
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | #
|
---|
| 132 | # ãã¡ã¤ã«ãå¤æãã
|
---|
| 133 | #
|
---|
| 134 | sub convert {
|
---|
| 135 | local($infile, $outfile) = @_;
|
---|
| 136 | local($line, $varname, $varval);
|
---|
| 137 |
|
---|
| 138 | print STDERR "configure: Generating $outfile from $infile.\n";
|
---|
| 139 | if (-f $outfile) {
|
---|
| 140 | print STDERR "configure: $outfile exists.",
|
---|
| 141 | " Save as $outfile.bak.\n";
|
---|
| 142 | rename($outfile, $outfile.".bak");
|
---|
| 143 | }
|
---|
| 144 | unless (open(INFILE, $infile)) {
|
---|
| 145 | print STDERR "configure: can't open $infile\n";
|
---|
| 146 | exit(1);
|
---|
| 147 | }
|
---|
| 148 | unless (open(OUTFILE, "> ".$outfile)) {
|
---|
| 149 | print STDERR "configure: can't open $outfile\n";
|
---|
| 150 | exit(1);
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | while ($line = <INFILE>) {
|
---|
| 154 | chop $line;
|
---|
| 155 | while ($line =~ /^(.*)\@\(([A-Za-z_]+)\)(.*)$/) {
|
---|
| 156 | $line = $1.$vartable{$2}.$3;
|
---|
| 157 | }
|
---|
| 158 | print OUTFILE $line,"\n";
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | close(INFILE);
|
---|
| 162 | close(OUTFILE);
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | #
|
---|
| 166 | # ãµã³ãã«ãè¦ã¤ãã¦ãã¡ã¤ã«ãçæãã
|
---|
| 167 | #
|
---|
| 168 | sub generate {
|
---|
| 169 | local($file, $mandatory) = @_;
|
---|
| 170 | local($path);
|
---|
| 171 |
|
---|
| 172 | if ($sys) {
|
---|
| 173 | $path = $sampledir.$file.".".$cpu."-".$sys;
|
---|
| 174 | if (-f $path) {
|
---|
| 175 | convert($path, $file);
|
---|
| 176 | return;
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | $path = $sampledir.$file.".".$sys;
|
---|
| 180 | if (-f $path) {
|
---|
| 181 | convert($path, $file);
|
---|
| 182 | return;
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | $path = $sampledir.$file.".".$cpu;
|
---|
| 187 | if (-f $path) {
|
---|
| 188 | convert($path, $file);
|
---|
| 189 | return;
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | $path = $sampledir.$file;
|
---|
| 193 | if ($mandatory || -f $path) {
|
---|
| 194 | convert($path, $file);
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | #
|
---|
| 199 | # å¤æ°ã®åæå
|
---|
| 200 | #
|
---|
| 201 |
|
---|
| 202 | #
|
---|
| 203 | # ã½ã¼ã¹ãã£ã¬ã¯ããªåãåãåºã
|
---|
| 204 | #
|
---|
| 205 | $pwd = `chdir`; chop $pwd;
|
---|
| 206 | if ($opt_D) {
|
---|
| 207 | $srcabsdir = $srcdir = $opt_D;
|
---|
| 208 | }
|
---|
| 209 | elsif ($0 =~ /(.*)\\utils\\$cpu-$tool\\configure\.m16c/) {
|
---|
| 210 | $srcdir = $1;
|
---|
| 211 | if ($srcdir =~ /^([a-zA-Z]:)*\\/) {
|
---|
| 212 | $srcabsdir = $srcdir;
|
---|
| 213 | }
|
---|
| 214 | else {
|
---|
| 215 | $srcabsdir = $pwd."\\".$srcdir;
|
---|
| 216 | }
|
---|
| 217 | }
|
---|
| 218 | else {
|
---|
| 219 | $srcabsdir = $srcdir = $pwd;
|
---|
| 220 | }
|
---|
| 221 | $sampledir = $srcdir."\\".$templatedir."\\";
|
---|
| 222 |
|
---|
| 223 | #
|
---|
| 224 | # å¤æ°ãã¼ãã«ã®ä½æ
|
---|
| 225 | #
|
---|
| 226 | %vartable = ();
|
---|
| 227 | $vartable{"CPU"} = $cpu;
|
---|
| 228 | $vartable{"SYS"} = $sys;
|
---|
| 229 | $vartable{"TOOL"} = $tool;
|
---|
| 230 | $vartable{"UNAME"} = $uname;
|
---|
| 231 | $vartable{"UTASK"} = $utask;
|
---|
| 232 | $vartable{"KERNEL_LIB"} = $kernel_lib;
|
---|
| 233 | $vartable{"SRCDIR"} = $srcdir;
|
---|
| 234 | $vartable{"SRCABSDIR"} = $srcabsdir;
|
---|
| 235 | $vartable{"PREFIX"} = $prefix;
|
---|
| 236 | $vartable{"OBJEXT"} = get_objext();
|
---|
| 237 | $vartable{"PERL"} = $perl;
|
---|
| 238 | $vartable{"LANG"} = $lang;
|
---|
| 239 |
|
---|
| 240 | #
|
---|
| 241 | # ãã£ã¬ã¯ããªã®ãã§ãã¯
|
---|
| 242 | #
|
---|
| 243 |
|
---|
| 244 | if (! $tool && ! $sys && ! -d $srcdir."\\config\\".$cpu) {
|
---|
| 245 | print STDERR "configure: $srcdir/config/$cpu not exist\n";
|
---|
| 246 | exit(1);
|
---|
| 247 | }
|
---|
| 248 | if (! $tool && $sys && ! -d $srcdir."\\config\\".$cpu."\\".$sys) {
|
---|
| 249 | print STDERR "configure: $srcdir/config/$cpu/$sys not exist\n";
|
---|
| 250 | exit(1);
|
---|
| 251 | }
|
---|
| 252 | if ($tool && ! $sys && ! -d $srcdir."\\config\\".$cpu."-".$tool) {
|
---|
| 253 | print STDERR "configure: $srcdir/config/$cpu-$tool not exist\n";
|
---|
| 254 | exit(1);
|
---|
| 255 | }
|
---|
| 256 | if ($tool && $sys && ! -d $srcdir."\\config\\".$cpu."-".$tool."\\".$sys) {
|
---|
| 257 | print STDERR "configure: $srcdir/config/$cpu-$tool/$sys not exist\n";
|
---|
| 258 | exit(1);
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | #
|
---|
| 262 | # Makefile ã¨ã¢ããªã±ã¼ã·ã§ã³ãã¡ã¤ã«ã®çæ
|
---|
| 263 | #
|
---|
| 264 |
|
---|
| 265 | generate("Makefile", 1);
|
---|
| 266 | generate($uname.".c", 0);
|
---|
| 267 | generate($uname.".cpp", 0);
|
---|
| 268 | generate($uname.".h", 0);
|
---|
| 269 | generate($uname.".cfg", 0);
|
---|