yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | use strict; |
| 2 | use warnings; |
| 3 | |
| 4 | my $debug = 0; |
| 5 | |
| 6 | my $chk_flag = $ARGV[0]; |
| 7 | my $compiler = $ARGV[1]; |
| 8 | my $compiler_arch = $ARGV[2]; |
| 9 | my $compiler_isa = $ARGV[3]; |
| 10 | |
| 11 | my $wrong_ver_flag = 0; |
| 12 | my $wrong_gcc_toolchain_ver = 0; |
| 13 | my $host_gcc_wrong_ver_flag = 0; |
| 14 | |
| 15 | my $compiler_ver_setting = "v4.9.2(2016.05-08)"; |
| 16 | my $grep_string = "mips-mti-elf-gcc"; |
| 17 | if ($compiler_arch eq "MIPS_GCCV4") { |
| 18 | $compiler_ver_setting = "MIPS v4.9.2(2016.05-08)"; |
| 19 | } elsif ($compiler_arch eq "MIPS_GCCV6") { |
| 20 | if ($compiler_isa ne "NANOMIPS"){ |
| 21 | $compiler_ver_setting = "MIPS v6.3.0"; |
| 22 | } else { |
| 23 | $compiler_ver_setting = "NANOMIPS v6.3.0"; |
| 24 | $grep_string = "nanomips-elf-gcc"; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | if ($debug eq 1) { |
| 29 | print "chk_flag = $chk_flag\n"; |
| 30 | print "compiler = $compiler\n"; |
| 31 | print "comiler_arch = $compiler_arch\n"; |
| 32 | print "comiler_isa = $compiler_isa\n"; |
| 33 | } |
| 34 | |
| 35 | print <<"__EOFUSAGE"; |
| 36 | ******************************************************************* |
| 37 | Recommended Build Environment |
| 38 | ******************************************************************* |
| 39 | * [OS] : Ubuntu 18.04 | Ubuntu 14.04 * |
| 40 | * [PERL] : v5.26.1 | v5.18.4 * |
| 41 | * [PYTHON] : 2.7.17 | 2.7.6 * |
| 42 | * [MAKE] : GNU Make v4.1 | GNU Make v3.81 * |
| 43 | * [SHELL] : GNU v4.4.19 | GNU v4.3.11 * |
| 44 | * [HOST GCC] : gcc version 7.5.0 | gcc version 4.8.4 * |
| 45 | * [COMPILER] : $compiler_ver_setting * |
| 46 | * [PERL MODULE]: Switch.pm, File/Copy/Recursive.pm, XML/Simple.pm * |
| 47 | |
| 48 | __EOFUSAGE |
| 49 | |
| 50 | print "*******************************************************************\n"; |
| 51 | print " Start checking current Build Environment \n"; |
| 52 | print "*******************************************************************\n"; |
| 53 | |
| 54 | #******************************************************************** |
| 55 | # checking perl version |
| 56 | #******************************************************************** |
| 57 | my $perl_version = `perl --version | grep "This is perl" 2>&1`; |
| 58 | |
| 59 | if($perl_version =~ /\bv5.18.4/i) |
| 60 | { |
| 61 | print "* [PERL] : v5.18.4 [OK] !!!\n"; |
| 62 | } |
| 63 | elsif($perl_version =~ /\bv5.26.1/i) |
| 64 | { |
| 65 | print "* [PERL] : v5.26.1 [OK] !!!\n"; |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | if($perl_version =~ /.*?(v[\d\.]+)\s*/i) |
| 70 | { |
| 71 | print "* [PERL] : $1 [NOT RECOMMENDED] !!!\n"; |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | print "* [PERL] : [UNKNOWN VERSION] !!!\n"; |
| 76 | $wrong_ver_flag = 1; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | #******************************************************************** |
| 81 | # checking perl module |
| 82 | #******************************************************************** |
| 83 | my $perl_module = 0; |
| 84 | my $perl_switch = `perl -e "use Switch" 2>&1`; |
| 85 | my $perl_recursive = `perl -e "use File::Copy::Recursive" 2>&1`; |
| 86 | my $perl_simple = `perl -e "use XML::Simple" 2>&1`; |
| 87 | |
| 88 | if (($perl_switch ne "") || ($perl_recursive ne "") || ($perl_simple ne "")) { |
| 89 | $perl_module = 1; |
| 90 | if ($perl_switch ne "") { |
| 91 | print "* [Perl Module]: Switch.pm [NOT DETECTED] !!!\n"; |
| 92 | } |
| 93 | if ($perl_recursive ne "") { |
| 94 | print "* [Perl Module]: File/Copy/Recursive.pm [NOT DETECTED] !!!\n"; |
| 95 | } |
| 96 | if ($perl_simple ne "") { |
| 97 | print "* [Perl Module]: XML/Simple.pm [NOT DETECTED] !!!\n"; |
| 98 | } |
| 99 | } else { |
| 100 | print "* [Perl Module]: All Perl Module [OK] !!!\n"; |
| 101 | } |
| 102 | |
| 103 | #******************************************************************** |
| 104 | # checking python version |
| 105 | #******************************************************************** |
| 106 | my $python_version = `python --version 2>&1`; |
| 107 | |
| 108 | if($python_version =~ /2.7.6/i) |
| 109 | { |
| 110 | print "* [PYTHON] : v2.7.6 [OK] !!!\n"; |
| 111 | } |
| 112 | elsif($python_version =~ /\b2.7.17/i) |
| 113 | { |
| 114 | print "* [PYTHON] : v2.7.17 [OK] !!!\n"; |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | if($python_version =~ /Python\s*([\d\.]+)\s*/i) |
| 119 | { |
| 120 | print "* [PYTHON] : v$1 [NOT RECOMMENDED] !!!\n"; |
| 121 | $wrong_ver_flag = 1; |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | print "* [PYTHON] : [UNKNOWN VERSION] !!!\n"; |
| 126 | $wrong_ver_flag = 1; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | #******************************************************************** |
| 131 | # checking GNU make version |
| 132 | #******************************************************************** |
| 133 | my $make_version = `make --version | grep "GNU Make" 2>&1`; |
| 134 | |
| 135 | if($make_version =~ /\b3.81/i) |
| 136 | { |
| 137 | print "* [MAKE] : GNU Make v3.81 [OK] !!!\n"; |
| 138 | } |
| 139 | elsif($make_version =~ /\b4.1/i) |
| 140 | { |
| 141 | print "* [MAKE] : GNU Make v4.1 [OK] !!!\n"; |
| 142 | } |
| 143 | else |
| 144 | { |
| 145 | if($make_version =~ /GNU\s*Make\s*([\d\.]+)\s*/i) |
| 146 | { |
| 147 | print "* [MAKE] : GUN Make v$1 [NOT RECOMMENDED] !!!\n"; |
| 148 | $wrong_ver_flag = 1; |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | print "* [MAKE] : [UNKNOWN VERSION] !!!\n"; |
| 153 | $wrong_ver_flag = 1; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | #******************************************************************** |
| 158 | # checking shell version |
| 159 | #******************************************************************** |
| 160 | my $shell_version = `bash --version | grep "GNU bash" 2>&1`; |
| 161 | my $shell_is_gnu = "false"; |
| 162 | my $shell_is_recommend = "false"; |
| 163 | my $shell_number = "UNKNOWN"; |
| 164 | my @recommend_number = ('4.3.11', '4.4.19'); |
| 165 | |
| 166 | if ($shell_version =~ /\bGNU bash/i) { |
| 167 | $shell_is_gnu = "true"; |
| 168 | } |
| 169 | |
| 170 | foreach my $num (@recommend_number) |
| 171 | { |
| 172 | if ($shell_version =~ /\b$num/i) { |
| 173 | $shell_number = $num; |
| 174 | $shell_is_recommend = "true"; |
| 175 | } |
| 176 | |
| 177 | } |
| 178 | |
| 179 | if ($shell_is_recommend eq "false" and $shell_version =~ /.*?([\d\.]+)\s*/i) { |
| 180 | $shell_number = $1; |
| 181 | } |
| 182 | |
| 183 | if ($shell_is_gnu eq "true" and $shell_is_recommend eq "true"){ |
| 184 | print "* [SHELL] : GNU bash v$shell_number [OK] !!!\n"; |
| 185 | } |
| 186 | else |
| 187 | { |
| 188 | if ($shell_is_gnu eq "true") { |
| 189 | if ($shell_number eq "UNKNOWN") { |
| 190 | print "* [SHELL] : GNU bash [UNKNOWN VERSION NUMBER] !!!\n"; |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | print "* [SHELL] : GNU bash v$shell_number [NOT RECOMMENDED]\n"; |
| 195 | } |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | print "* [SHELL] : [UNKNOWN VERSION] !!!\n"; |
| 200 | $wrong_ver_flag = 1; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | #******************************************************************** |
| 205 | # checking Host GCC version |
| 206 | #******************************************************************** |
| 207 | my $host_gcc_ver = `gcc --version | grep "gcc" 2>&1`; |
| 208 | my @host_gcc_rec_num = ('4.8.4', '7.5.0'); |
| 209 | my $host_gcc_num; |
| 210 | my $host_gcc_is_rec = "false"; |
| 211 | |
| 212 | foreach my $num (@host_gcc_rec_num) { |
| 213 | if ($host_gcc_ver =~ /\b$num/i) { |
| 214 | $host_gcc_num = $num; |
| 215 | $host_gcc_is_rec = "true"; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if ($host_gcc_is_rec eq "false" and $host_gcc_ver =~ /.*?([\d\.]+)\s*/i) { |
| 220 | $host_gcc_num = $1; |
| 221 | } |
| 222 | |
| 223 | if($host_gcc_is_rec eq "true") { |
| 224 | print "* [Host GCC] : gcc version $host_gcc_num [OK] !!!\n"; |
| 225 | } else { |
| 226 | my @tmp_host_gcc_ver = split /\./,$host_gcc_num; |
| 227 | if (($tmp_host_gcc_ver[0]<4) || ($tmp_host_gcc_ver[0] == 4 && $tmp_host_gcc_ver[1] <= 6) || ($tmp_host_gcc_ver[0] == 4 && $tmp_host_gcc_ver[1] == 6 && $tmp_host_gcc_ver[2] <= 3)) #can not support 4.6.3 |
| 228 | { |
| 229 | print "* [Host GCC] : gcc version $host_gcc_num [NOT RECOMMENDED] !!!\n"; |
| 230 | $host_gcc_wrong_ver_flag = 1; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | #******************************************************************** |
| 235 | # checking compiler version |
| 236 | #******************************************************************** |
| 237 | # common/tools/GCC/MIPS/4.9.2/linux/bin/mips-mti-elf-gcc -mthumb --version |
| 238 | # common/tools/GCC/MIPS/6.3.0/linux/bin/mips-mti-elf-gcc -mthumb --version |
| 239 | # common/tools/GCC/NANOMIPS/6.3.0/linux/bin/mips-mti-elf-gcc -mthumb --version |
| 240 | my @tmp = split (' ',$compiler); |
| 241 | my $compiler_location = $tmp[0]; |
| 242 | my $compiler_is_existing = "true"; |
| 243 | |
| 244 | print "$compiler_location\n" if($debug eq 1); |
| 245 | print "$grep_string\n" if($debug eq 1); |
| 246 | |
| 247 | if (!-e $compiler_location) { |
| 248 | print "* [COMPILER] : $compiler_location [CANNOT FOUND] !!!\n"; |
| 249 | $wrong_ver_flag = 1; |
| 250 | $compiler_is_existing = "false"; |
| 251 | } else { |
| 252 | my $compiler_version = `$compiler --version | grep "$grep_string" 2>&1`; |
| 253 | print "$compiler_version\n" if ($debug eq 1); |
| 254 | if ($compiler_arch eq "MIPS_GCCV4") { |
| 255 | if ($compiler_version =~ /\b4.9.2/i) { |
| 256 | if ($compiler_version =~ /\b2016.05-08/i){ |
| 257 | print "* [COMPILER] : v4.9.2(2016.05-08) [OK] !!!\n"; |
| 258 | } elsif ($compiler_version =~ /\b2016.05-06/i) { |
| 259 | print "* [COMPILER] : v4.9.2(2016.05-06) [LOWER THAN RECOMMENDED] !!!\n"; |
| 260 | $wrong_gcc_toolchain_ver = 1; |
| 261 | } elsif ($compiler_version =~ /\b2016.05-03/i) { |
| 262 | print "* [COMPILER] : v4.9.2(2016.05-03) [LOWER THAN RECOMMENDED] !!!\n"; |
| 263 | $wrong_gcc_toolchain_ver = 2; |
| 264 | } |
| 265 | else { |
| 266 | print "* [COMPILER] : [UNKNOWN VERSION] !!!\n"; |
| 267 | $wrong_gcc_toolchain_ver = 3; |
| 268 | } |
| 269 | } else { |
| 270 | if($compiler_version =~ /.*?\(.*\)\s*([\d\.]+)/i) { |
| 271 | my @tmp_ver = split /\./,$1; |
| 272 | if (($tmp_ver[0] < 4 ) || ($tmp_ver[0] == 4 && $tmp_ver[1] < 9) || ($tmp_ver[0] == 4 && $tmp_ver[1] == 9 && $tmp_ver[2] < 2)) { |
| 273 | print "* [COMPILER] : v$1 [LOWER THAN RECOMMENDED] !!!\n"; |
| 274 | $wrong_gcc_toolchain_ver = 3; |
| 275 | }else { |
| 276 | print "* [COMPILER] : v$1 [HIGHER THAN RECOMMENDED] !!!\n"; |
| 277 | $wrong_gcc_toolchain_ver = 3; |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } elsif ($compiler_arch eq "MIPS_GCCV6") { |
| 282 | if ($compiler_version =~ /\b6.3.0/i) { |
| 283 | my $version_str = "MIPS v6.3.0 [OK] !!!"; |
| 284 | if ($compiler_isa eq "NANOMIPS") { |
| 285 | $version_str = "NANOMIPS v6.3.0 [OK] !!!"; |
| 286 | } |
| 287 | print "* [COMPILER] : $version_str\n"; |
| 288 | } elsif ($compiler_version =~ /.*?\(.*\)\s*([\d\.]+)/i){ |
| 289 | my @tmp_ver = split /\./,$1; |
| 290 | if (($tmp_ver[0] < 6 ) || ($tmp_ver[0] == 6 && $tmp_ver[1] < 3)) { |
| 291 | print "* [COMPILER] : v$1 [LOWER THAN RECOMMENDED] !!!\n"; |
| 292 | $wrong_gcc_toolchain_ver = 3; |
| 293 | } else { |
| 294 | print "* [COMPILER] : v$1 [HIGHER THAN RECOMMENDED] !!!\n"; |
| 295 | $wrong_gcc_toolchain_ver = 3; |
| 296 | } |
| 297 | } else { |
| 298 | print "* [COMPILER] : [UNKNOWN VERSION] !!!\n"; |
| 299 | $wrong_gcc_toolchain_ver = 3; |
| 300 | } |
| 301 | } else { |
| 302 | print "* [COMPILER] : [UNKNOWN VERSION] !!!\n"; |
| 303 | $wrong_gcc_toolchain_ver = 3; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | #******************************************************************** |
| 308 | # un-expected version handle |
| 309 | #******************************************************************** |
| 310 | if ($chk_flag eq "-chkenv" and $compiler_is_existing eq "false") { |
| 311 | print "\nPlease install the GCC Cross-Compiler on correct path:\n"; |
| 312 | print "$compiler_location\n\n"; |
| 313 | exit(1); |
| 314 | } |
| 315 | if ($wrong_ver_flag == 1){ |
| 316 | print "\ncurrent Build Env. is not recommendation \nTo avoid unexpected errors , please install the recommended Tool Chain.\n"; |
| 317 | print "*******************************************************************\n"; |
| 318 | print " Build Environment is NOT RECOMMENDED!\n"; |
| 319 | print "*******************************************************************\n\n"; |
| 320 | |
| 321 | } elsif ($wrong_gcc_toolchain_ver == 1) |
| 322 | { |
| 323 | print "\nCurrent Build Env. of GCC MIPS Tool Chain v4.9.2(2016.05-06) is not recommendation.\n"; |
| 324 | print "To avoid unexpected errors , please install the recommended GCC MIPS Tool Chain $compiler_ver_setting.\n"; |
| 325 | print "*******************************************************************\n"; |
| 326 | print " Build Environment is NOT RECOMMENDED!\n"; |
| 327 | print "*******************************************************************\n\n"; |
| 328 | exit(1); |
| 329 | } |
| 330 | elsif ($wrong_gcc_toolchain_ver == 2) |
| 331 | { |
| 332 | print "\nCurrent Build Env. of GCC MIPS Tool Chain v4.9.2(2016.05-03) is not recommendation.\n"; |
| 333 | print "To avoid unexpected errors , please install the recommended GCC MIPS Tool Chain $compiler_ver_setting.\n"; |
| 334 | print "*******************************************************************\n"; |
| 335 | print " Build Environment is NOT RECOMMENDED!\n"; |
| 336 | print "*******************************************************************\n\n"; |
| 337 | exit(1); |
| 338 | } |
| 339 | elsif ($wrong_gcc_toolchain_ver == 3) |
| 340 | { |
| 341 | print "\nCurrent Build Env. of GCC MIPS Tool Chain is not recommendation.\n"; |
| 342 | print "To avoid unexpected errors , please install the recommended GCC MIPS Tool Chain $compiler_ver_setting.\n"; |
| 343 | print "*******************************************************************\n"; |
| 344 | print " Build Environment is NOT RECOMMENDED!\n"; |
| 345 | print "*******************************************************************\n\n"; |
| 346 | exit(1); |
| 347 | } |
| 348 | elsif ($host_gcc_wrong_ver_flag == 1) |
| 349 | { |
| 350 | print "\nCurrent Build Env. of Host GCC is not recommendation.\n"; |
| 351 | print "To avoid unexpected errors , please install the recommended(or higher) version of Host GCC @host_gcc_rec_num.\n"; |
| 352 | print "*******************************************************************\n"; |
| 353 | print " Build Environment is NOT RECOMMENDED!\n"; |
| 354 | print "*******************************************************************\n\n"; |
| 355 | exit(1); |
| 356 | } |
| 357 | elsif ($perl_module == 1) { |
| 358 | print "\nCurrent Build Env. of Perl Module is not recommendation.\n"; |
| 359 | print "To avoid unexpected errors, please install the recommended Perl Module: Switch.pm, File/Copy/Recursive.pm, XML/Simple.pm.\n"; |
| 360 | print "*******************************************************************\n"; |
| 361 | print " Build Environment is NOT RECOMMENDED!\n"; |
| 362 | print "*******************************************************************\n\n"; |
| 363 | exit(1); |
| 364 | } |
| 365 | else |
| 366 | { |
| 367 | print "*******************************************************************\n"; |
| 368 | print " Build Environment is ready!\n"; |
| 369 | print "*******************************************************************\n\n"; |
| 370 | } |