Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # |
| 4 | #//===----------------------------------------------------------------------===// |
| 5 | #// |
| 6 | #// The LLVM Compiler Infrastructure |
| 7 | #// |
| 8 | #// This file is dual licensed under the MIT and the University of Illinois Open |
| 9 | #// Source Licenses. See LICENSE.txt for details. |
| 10 | #// |
| 11 | #//===----------------------------------------------------------------------===// |
| 12 | # |
| 13 | |
| 14 | # Pragmas. |
| 15 | use strict; |
| 16 | use warnings; |
| 17 | |
| 18 | use FindBin; |
| 19 | use lib "$FindBin::Bin/lib"; |
| 20 | |
| 21 | # LIBOMP modules. |
| 22 | use Platform ":vars"; |
| 23 | use tools; |
| 24 | |
| 25 | our $VERSION = "0.015"; |
| 26 | |
| 27 | my $pedantic; |
| 28 | |
| 29 | # -------------------------------------------------------------------------------------------------- |
| 30 | # Helper functions |
| 31 | # -------------------------------------------------------------------------------------------------- |
| 32 | |
| 33 | |
| 34 | sub run($\$\$;\$) { |
| 35 | my ( $cmd, $stdout, $stderr, $path ) = @_; |
| 36 | my ( @path, $rc ); |
| 37 | @path = which( $cmd->[ 0 ], -all => 1 ); |
| 38 | if ( @path > 0 ) { |
| 39 | if ( @path > 1 and $pedantic ) { |
| 40 | warning( "More than one \"$cmd->[ 0 ]\" found in PATH:", map( " $_", @path ) ); |
| 41 | }; # if |
| 42 | debug( "\"$cmd->[ 0 ]\" full path is \"$path[ 0 ]\"." ); |
| 43 | if ( defined( $path ) ) { |
| 44 | $$path = $path[ 0 ]; |
| 45 | }; # if |
| 46 | debug( "Executing command: \"" . join ( " ", @$cmd ) . "\"." ); |
| 47 | $rc = |
| 48 | execute( |
| 49 | $cmd, |
| 50 | -ignore_signal => 1, -ignore_status => 1, |
| 51 | -stdout => $stdout, -stderr => $stderr, -stdin => undef |
| 52 | ); |
| 53 | if ( $rc < 0 ) { |
| 54 | warning( "Cannot run \"$cmd->[ 0 ]\": $@" ); |
| 55 | }; # if |
| 56 | debug( "stdout:", $$stdout, "(eof)", "stderr:", $$stderr, "(eof)" ); |
| 57 | } else { |
| 58 | warning( "No \"$cmd->[ 0 ]\" found in PATH." ); |
| 59 | $rc = -1; |
| 60 | }; # if |
| 61 | return $rc; |
| 62 | }; # sub run |
| 63 | |
| 64 | |
| 65 | sub get_arch($$$) { |
| 66 | my ( $name, $str, $exps ) = @_; |
| 67 | my ( $arch, $count ); |
| 68 | $count = 0; |
| 69 | foreach my $re ( keys( %$exps ) ) { |
| 70 | if ( $str =~ $re ) { |
| 71 | $arch = $exps->{ $re }; |
| 72 | ++ $count; |
| 73 | }; # if |
| 74 | }; # for |
| 75 | if ( $count != 1 or not Platform::canon_arch( $arch ) ) { |
| 76 | warning( "Cannot detect $name architecture: $str" ); |
| 77 | return undef; |
| 78 | }; # if |
| 79 | return $arch; |
| 80 | }; # sub get_arch |
| 81 | |
| 82 | sub encode($) { |
| 83 | my ( $str ) = @_; |
| 84 | $str =~ s{ }{_}g; |
| 85 | return $str; |
| 86 | }; # sub encode |
| 87 | |
| 88 | |
| 89 | # -------------------------------------------------------------------------------------------------- |
| 90 | # get_xxx_version subroutines. |
| 91 | # -------------------------------------------------------------------------------------------------- |
| 92 | # |
| 93 | # Some of get_xxx_version() subroutines accept an argument -- a tool name. For example, |
| 94 | # get_intel_compiler_version() can report version of C, C++, or Fortran compiler. The tool for |
| 95 | # report should be specified by argument, for example: get_intel_compiler_version( "ifort" ). |
| 96 | # |
| 97 | # get_xxx_version() subroutines returns list of one or two elements: |
| 98 | # 1. The first element is short tool name (like "gcc", "g++", "icl", etc). |
| 99 | # 2. The second element is version string. |
| 100 | # If returned list contain just one element, it means there is a problem with the tool. |
| 101 | # |
| 102 | |
| 103 | sub get_perl_version() { |
| 104 | my ( $rc, $stdout, $stderr, $version ); |
| 105 | my $tool = "perl"; |
| 106 | my ( @ret ) = ( $tool ); |
| 107 | $rc = run( [ $tool, "--version" ], $stdout, $stderr ); |
| 108 | if ( $rc >= 0 ) { |
| 109 | # Typical perl output: |
| 110 | # This is perl, v5.10.0 built for x86_64-linux-thread-multi |
| 111 | # This is perl, v5.8.8 built for MSWin32-x64-multi-thread |
| 112 | # This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi |
| 113 | if ( $stdout !~ m{^This is perl.*v(\d+\.\d+(?:\.\d+)).*built for}m ) { |
| 114 | warning( "Cannot parse perl output:", $stdout, "(oef)" ); |
| 115 | }; # if |
| 116 | $version = $1; |
| 117 | if ( $target_os eq "win" ) { |
| 118 | if ( $stdout !~ m{Binary build (.*) provided by ActiveState } ) { |
| 119 | warning( "Perl is not ActiveState one" ); |
| 120 | }; # if |
| 121 | }; # if |
| 122 | }; # if |
| 123 | push( @ret, $version ); |
| 124 | return @ret; |
| 125 | }; # sub get_perl_version |
| 126 | |
| 127 | |
| 128 | sub get_gnu_make_version() { |
| 129 | my ( $rc, $stdout, $stderr, $version ); |
| 130 | my $tool = "make"; |
| 131 | my ( @ret ) = ( $tool ); |
| 132 | my ( $path ); |
| 133 | $rc = run( [ $tool, "--version" ], $stdout, $stderr, $path ); |
| 134 | if ( $rc >= 0 ) { |
| 135 | # Typical make output: |
| 136 | # GNU Make version 3.79.1, by Richard Stallman and Roland McGrath. |
| 137 | # GNU Make 3.81 |
| 138 | if ( $stdout =~ m{^GNU Make (?:version )?(\d+\.\d+(?:\.\d+)?)(?:,|\s)} ) { |
| 139 | $version = $1; |
| 140 | }; # if |
| 141 | if ( $target_os eq "win" and $stdout =~ m{built for ([a-z0-9-]+)} ) { |
| 142 | my $built_for = $1; |
| 143 | debug( "GNU Make built for: \"$built_for\"." ); |
| 144 | if ( $built_for =~ m{cygwin}i ) { |
| 145 | warning( "\"$path\" is a Cygwin make, it is *not* suitable." ); |
| 146 | return @ret; |
| 147 | }; # if |
| 148 | }; # if |
| 149 | }; # if |
| 150 | push( @ret, $version ); |
| 151 | return @ret; |
| 152 | }; # sub get_gnu_make_version |
| 153 | |
| 154 | |
| 155 | sub get_intel_compiler_version($) { |
| 156 | my ( $tool ) = @_; # Tool name, like "icc", "icpc", "icl", or "ifort". |
| 157 | my ( @ret ) = ( $tool ); |
| 158 | my ( $rc, $stdout, $stderr, $tool_re ); |
| 159 | my $version; |
| 160 | my $ic_archs = { |
| 161 | qr{32-bit|IA-32} => "32", |
| 162 | qr{Intel\(R\) 64} => "32e", |
| 163 | qr{Intel\(R\) [M][I][C] Architecture} => "32e", |
| 164 | }; |
| 165 | $tool_re = quotemeta( $tool ); |
| 166 | $rc = run( [ $tool, ( $target_os eq "win" ? () : ( "-V" ) ) ], $stdout, $stderr ); |
| 167 | if ( $rc < 0 ) { |
| 168 | return @ret; |
| 169 | }; # if |
| 170 | # Intel compiler version string is in the first line of stderr. Get it. |
| 171 | #$stderr =~ m{\A(.*\n?)}; |
| 172 | # AC: Let's look for version string in the first line which contains "Intel" string. |
| 173 | # This allows to use 11.1 and 12.0 compilers on new MAC machines by ignoring |
| 174 | # huge number of warnings issued by old compilers. |
| 175 | $stderr =~ m{^(Intel.*)$}m; |
| 176 | my $vstr = $1; |
| 177 | my ( $apl, $ver, $bld, $pkg ); |
| 178 | if ( 0 ) { |
| 179 | } elsif ( $vstr =~ m{^Intel.*?Compiler\s+(.*?),?\s+Version\s+(.*?)\s+Build\s+(\S+)(?:\s+Package ID: (\S+))?} ) { |
| 180 | # 9.x, 10.x, 11.0. |
| 181 | ( $apl, $ver, $bld, $pkg ) = ( $1, $2, $3, $4 ); |
| 182 | } elsif ( $vstr =~ m{^Intel's (.*?) Compiler,?\s+Version\s+(.*?)\s+Build\s+(\S+)} ) { |
| 183 | # 11.1 |
| 184 | ( $apl, $ver, $bld ) = ( $1, $2, $3 ); |
| 185 | } else { |
| 186 | warning( "Cannot parse ${tool}'s stderr:", $stderr, "(eof)" ); |
| 187 | return @ret; |
| 188 | }; # if |
| 189 | my $ic_arch = get_arch( "Intel compiler", $apl, $ic_archs ); |
| 190 | if ( not defined( $ic_arch ) ) { |
| 191 | return @ret; |
| 192 | }; # if |
| 193 | if ( Platform::canon_arch( $ic_arch ) ne $target_arch ) { |
| 194 | warning( "Target architecture is $target_arch, $tool for $ic_arch found." ); |
| 195 | return @ret; |
| 196 | }; # if |
| 197 | # Normalize version. |
| 198 | my $stage; |
| 199 | $ver =~ s{\s+}{ }g; |
| 200 | $ver = lc( $ver ); |
| 201 | if ( $ver =~ m{\A(\d+\.\d+(?:\.\d+)?) ([a-z]+)\a}i ) { |
| 202 | ( $version, $stage ) = ( $1, $2 ); |
| 203 | } else { |
| 204 | ( $version, $stage ) = ( $ver, "" ); |
| 205 | }; # if |
| 206 | # Parse package. |
| 207 | if ( defined( $pkg ) ) { |
| 208 | if ( $pkg !~ m{\A[lwm]_[a-z]+_[a-z]_(\d+\.\d+\.\d+)\z}i ) { |
| 209 | warning( "Cannot parse Intel compiler package: $pkg" ); |
| 210 | return @ret; |
| 211 | }; # if |
| 212 | $pkg = $1; |
| 213 | $version = $pkg; |
| 214 | }; # if |
| 215 | push( @ret, "$version " . ( $stage ? "$stage " : "" ) . "($bld) for $ic_arch" ); |
| 216 | # Ok, version of Intel compiler found successfully. Now look at config file. |
| 217 | # Installer of Intel compiler tends to add a path to MS linker into compiler config file. |
| 218 | # It leads to troubles. For example, all the environment set up for MS VS 2005, but Intel |
| 219 | # compiler uses lnker from MS VS 2003 because it is specified in config file. |
| 220 | # To avoid such troubles, make sure: |
| 221 | # ICLCFG/IFORTCFG environment variable exists or |
| 222 | # compiler config file does not exist, or |
| 223 | # compiler config file does not specify linker. |
| 224 | if ( $target_os eq "win" ) { |
| 225 | if ( not exists( $ENV{ uc( $tool . "cfg" ) } ) ) { |
| 226 | # If ICLCFG/IFORTCFG environment varianle exists, everything is ok. |
| 227 | # Otherwise check compiler's config file. |
| 228 | my $path = which( $tool ); |
| 229 | $path =~ s{\.exe\z}{}i; # Drop ".exe" suffix. |
| 230 | $path .= ".cfg"; # And add ".cfg" one. |
| 231 | if ( -f $path ) { |
| 232 | # If no config file exists, it is ok. |
| 233 | # Otherwise analyze its content. |
| 234 | my $bulk = read_file( $path ); |
| 235 | $bulk =~ s{#.*\n}{}g; # Remove comments. |
| 236 | my @options = ( "Qvc", "Qlocation,link," ); |
| 237 | foreach my $opt ( @options ) { |
| 238 | if ( $bulk =~ m{[-/]$opt} ) { |
| 239 | warning( "Compiler config file \"$path\" contains \"-$opt\" option." ); |
| 240 | }; # if |
| 241 | }; # foreach |
| 242 | }; # if |
| 243 | }; # if |
| 244 | }; # if |
| 245 | return @ret; |
| 246 | }; # sub get_intel_compiler_version |
| 247 | |
| 248 | |
| 249 | sub get_gnu_compiler_version($) { |
| 250 | my ( $tool ) = @_; |
| 251 | my ( @ret ) = ( $tool ); |
| 252 | my ( $rc, $stdout, $stderr, $version ); |
| 253 | $rc = run( [ $tool, "--version" ], $stdout, $stderr ); |
| 254 | if ( $rc >= 0 ) { |
| 255 | my ( $ver, $bld ); |
| 256 | if ( $target_os eq "mac" ) { |
| 257 | # i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367) |
| 258 | # i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5484) |
| 259 | # i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00) |
| 260 | $stdout =~ m{^.*? \(GCC\) (\d+\.\d+\.\d+) \(.*Apple.*?Inc\. build (\d+)\)}m; |
| 261 | ( $ver, $bld ) = ( $1, $2 ); |
| 262 | } else { |
| 263 | if ( 0 ) { |
| 264 | } elsif ( $stdout =~ m{^.*? \(GCC\) (\d+\.\d+\.\d+)(?: (\d+))?}m ) { |
| 265 | # g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20) |
| 266 | # GNU Fortran (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) |
| 267 | ( $ver, $bld ) = ( $1, $2 ); |
| 268 | } elsif ( $stdout =~ m{^.*? \(SUSE Linux\) (\d+\.\d+\.\d+)\s+\[.*? (\d+)\]}m ) { |
| 269 | # gcc (SUSE Linux) 4.3.2 [gcc-4_3-branch revision 141291] |
| 270 | ( $ver, $bld ) = ( $1, $2 ); |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 271 | } elsif ( $stdout =~ m{^.*? \(SUSE Linux\) (\d+\.\d+\.\d+)\s+\d+\s+\[.*? (\d+)\]}m ) { |
| 272 | # gcc (SUSE Linux) 4.7.2 20130108 [gcc-4_7-branch revision 195012] |
| 273 | ( $ver, $bld ) = ( $1, $2 ); |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 274 | } elsif ( $stdout =~ m{^.*? \((Debian|Ubuntu).*?\) (\d+\.\d+\.\d+)}m ) { |
| 275 | # gcc (Debian 4.7.2-22) 4.7.2 |
| 276 | # Debian support from Sylvestre Ledru |
| 277 | # Thanks! |
| 278 | $ver = $2; |
| 279 | }; # if |
| 280 | }; # if |
| 281 | if ( defined( $ver ) ) { |
| 282 | $version = $ver . ( defined( $bld ) ? " ($bld)" : "" ); |
| 283 | } else { |
| 284 | warning( "Cannot parse GNU compiler version:", $stdout, "(eof)" ); |
| 285 | }; # if |
| 286 | }; # if |
| 287 | push( @ret, $version ); |
| 288 | return @ret; |
| 289 | }; # sub get_gnu_compiler_version |
| 290 | |
| 291 | |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 292 | sub get_clang_compiler_version($) { |
| 293 | my ( $tool ) = @_; |
| 294 | my ( @ret ) = ( $tool ); |
| 295 | my ( $rc, $stdout, $stderr, $version ); |
| 296 | $rc = run( [ $tool, "--version" ], $stdout, $stderr ); |
| 297 | if ( $rc >= 0 ) { |
| 298 | my ( $ver, $bld ); |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 299 | if ( $target_os eq "mac" ) { |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 300 | # Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 301 | $stdout =~ m{^.*? (\d+\.\d+) \(.*-(\d+\.\d+\.\d+)\)}m; |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 302 | ( $ver, $bld ) = ( $1, $2 ); |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 303 | # For custom clang versions. |
| 304 | if ( not defined($ver) and $stdout =~ m{^.*? (\d+\.\d+)( \((.*)\))?}m ) { |
| 305 | ( $ver, $bld ) = ( $1, $3 ); |
| 306 | } |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 307 | } else { |
| 308 | if ( 0 ) { |
Alp Toker | c5df02f | 2014-02-24 12:29:09 +0000 | [diff] [blame] | 309 | } elsif ( $stdout =~ m{^.*? (\d+\.\d+)( \((.*)\))?}m ) { |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 310 | # clang version 3.3 (tags/RELEASE_33/final) |
Alp Toker | c5df02f | 2014-02-24 12:29:09 +0000 | [diff] [blame] | 311 | ( $ver, $bld ) = ( $1, $3 ); |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 312 | } |
| 313 | }; # if |
| 314 | if ( defined( $ver ) ) { |
| 315 | $version = $ver . ( defined( $bld ) ? " ($bld)" : "" ); |
| 316 | } else { |
| 317 | warning( "Cannot parse Clang compiler version:", $stdout, "(eof)" ); |
| 318 | }; # if |
| 319 | }; # if |
| 320 | push( @ret, $version ); |
| 321 | return @ret; |
| 322 | }; # sub get_gnu_compiler_version |
| 323 | |
| 324 | |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 325 | sub get_ms_compiler_version() { |
| 326 | my ( $rc, $stdout, $stderr, $version ); |
| 327 | my $tool = "cl"; |
| 328 | my ( @ret ) = ( $tool ); |
| 329 | my $mc_archs = { |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 330 | qr{80x86|x86} => "IA-32 architecture", |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 331 | qr{AMD64|x64} => "Intel(R) 64", |
| 332 | }; |
| 333 | $rc = run( [ $tool ], $stdout, $stderr ); |
| 334 | if ( $rc < 0 ) { |
| 335 | return @ret; |
| 336 | }; # if |
| 337 | if ( $stderr !~ m{^Microsoft .* Compiler Version (.*?) for (.*)\s*$}m ) { |
| 338 | warning( "Cannot parse MS compiler output:", $stderr, "(eof)" ); |
| 339 | return @ret; |
| 340 | }; # if |
| 341 | my ( $ver, $apl ) = ( $1, $2 ); |
| 342 | if ( $ver !~ m{\A\d+(?:\.\d+)+\z} ) { |
| 343 | warning( "Cannot parse MS compiler version: $ver" ); |
| 344 | return @ret; |
| 345 | }; # if |
| 346 | my $mc_arch = get_arch( "MS compiler", $apl, $mc_archs ); |
| 347 | if ( not defined( $mc_arch ) ) { |
| 348 | return @ret; |
| 349 | }; # if |
| 350 | if ( Platform::canon_arch( $mc_arch ) ne $target_arch ) { |
| 351 | warning( "Target architecture is $target_arch, $tool for $mc_arch found" ); |
| 352 | return @ret; |
| 353 | }; # if |
| 354 | $version = "$ver for $target_arch"; |
| 355 | push( @ret, $version ); |
| 356 | return @ret; |
| 357 | }; # sub get_ms_compiler_version |
| 358 | |
| 359 | |
| 360 | sub get_ms_linker_version() { |
| 361 | my ( $rc, $stdout, $stderr, $version ); |
| 362 | my $tool = "link"; |
| 363 | my ( @ret ) = ( $tool ); |
| 364 | my ( $path ); |
| 365 | $rc = run( [ $tool ], $stdout, $stderr, $path ); |
| 366 | if ( $rc < 0 ) { |
| 367 | return @ret; |
| 368 | }; # if |
| 369 | if ( $stdout !~ m{^Microsoft \(R\) Incremental Linker Version (\d+(?:\.\d+)+)\s*$}m ) { |
| 370 | warning( "Cannot parse MS linker output:", $stdout, "(eof)" ); |
| 371 | if ( $stderr =~ m{^link: missing operand} ) { |
| 372 | warning( "Seems \"$path\" is a Unix-like \"link\" program, not MS linker." ); |
| 373 | }; # if |
| 374 | return @ret; |
| 375 | }; # if |
| 376 | $version = ( $1 ); |
| 377 | push( @ret, $version ); |
| 378 | return @ret; |
| 379 | }; # sub get_ms_linker_version |
| 380 | |
| 381 | |
| 382 | # -------------------------------------------------------------------------------------------------- |
| 383 | # "main" program. |
| 384 | # -------------------------------------------------------------------------------------------------- |
| 385 | |
| 386 | my $make; |
| 387 | my $intel = 1; # Check Intel compilers. |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 388 | my $fortran = 0; # Check for corresponding Fortran compiler, ifort for intel |
| 389 | # gfortran for gnu |
| 390 | # gfortran for clang |
| 391 | my $clang = 0; # Check Clang Compilers. |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 392 | my $intel_compilers = { |
| 393 | "lin" => { c => "icc", cpp => "icpc", f => "ifort" }, |
| 394 | "lrb" => { c => "icc", cpp => "icpc", f => "ifort" }, |
| 395 | "mac" => { c => "icc", cpp => "icpc", f => "ifort" }, |
| 396 | "win" => { c => "icl", cpp => undef, f => "ifort" }, |
| 397 | }; |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 398 | my $gnu_compilers = { |
| 399 | "lin" => { c => "gcc", cpp => "g++", f => "gfortran" }, |
| 400 | "mac" => { c => "gcc", cpp => "g++", f => "gfortran" }, |
| 401 | }; |
| 402 | my $clang_compilers = { |
| 403 | "lin" => { c => "clang", cpp => "clang++" }, |
| 404 | "mac" => { c => "clang", cpp => "clang++" }, |
| 405 | }; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 406 | |
| 407 | get_options( |
| 408 | Platform::target_options(), |
| 409 | "intel!" => \$intel, |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 410 | "fortran" => \$fortran, |
| 411 | "clang" => \$clang, |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 412 | "make" => \$make, |
| 413 | "pedantic" => \$pedantic, |
| 414 | ); |
| 415 | |
| 416 | my @versions; |
| 417 | push( @versions, [ "Perl", get_perl_version() ] ); |
| 418 | push( @versions, [ "GNU Make", get_gnu_make_version() ] ); |
| 419 | if ( $intel ) { |
| 420 | my $ic = $intel_compilers->{ $target_os }; |
| 421 | push( @versions, [ "Intel C Compiler", get_intel_compiler_version( $ic->{ c } ) ] ); |
| 422 | if ( defined( $ic->{ cpp } ) ) { |
| 423 | # If Intel C++ compiler has a name different from C compiler, check it as well. |
| 424 | push( @versions, [ "Intel C++ Compiler", get_intel_compiler_version( $ic->{ cpp } ) ] ); |
| 425 | }; # if |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 426 | # fortran check must be explicitly specified on command line with --fortran |
| 427 | if ( $fortran ) { |
| 428 | if ( defined( $ic->{ f } ) ) { |
| 429 | push( @versions, [ "Intel Fortran Compiler", get_intel_compiler_version( $ic->{ f } ) ] ); |
| 430 | }; # if |
| 431 | }; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 432 | }; # if |
| 433 | if ( $target_os eq "lin" or $target_os eq "mac" ) { |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 434 | # check for clang/gnu tools because touch-test.c is compiled with them. |
| 435 | if ( $clang or $target_os eq "mac" ) { # OS X* >= 10.9 discarded GNU compilers. |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 436 | push( @versions, [ "Clang C Compiler", get_clang_compiler_version( $clang_compilers->{ $target_os }->{ c } ) ] ); |
| 437 | push( @versions, [ "Clang C++ Compiler", get_clang_compiler_version( $clang_compilers->{ $target_os }->{ cpp } ) ] ); |
Alp Toker | 0032b4d | 2014-02-24 11:47:00 +0000 | [diff] [blame] | 438 | } else { |
| 439 | push( @versions, [ "GNU C Compiler", get_gnu_compiler_version( $gnu_compilers->{ $target_os }->{ c } ) ] ); |
| 440 | push( @versions, [ "GNU C++ Compiler", get_gnu_compiler_version( $gnu_compilers->{ $target_os }->{ cpp } ) ] ); |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 441 | }; |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 442 | # if intel fortran has been checked then gnu fortran is unnecessary |
| 443 | # also, if user specifies clang as build compiler, then gfortran is assumed fortran compiler |
| 444 | if ( $fortran and not $intel ) { |
| 445 | push( @versions, [ "GNU Fortran Compiler", get_gnu_compiler_version( $gnu_compilers->{ $target_os }->{ f } ) ] ); |
| 446 | }; |
| 447 | }; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 448 | if ( $target_os eq "win" ) { |
| 449 | push( @versions, [ "MS C/C++ Compiler", get_ms_compiler_version() ] ); |
| 450 | push( @versions, [ "MS Linker", get_ms_linker_version() ] ); |
| 451 | }; # if |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 452 | |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 453 | my $count = 0; |
| 454 | foreach my $item ( @versions ) { |
| 455 | my ( $title, $tool, $version ) = @$item; |
| 456 | if ( not defined( $version ) ) { |
| 457 | $version = "--- N/A ---"; |
| 458 | ++ $count; |
| 459 | }; # if |
| 460 | if ( $make ) { |
| 461 | printf( "%s=%s\n", encode( $tool ), encode( $version ) ); |
| 462 | } else { |
| 463 | printf( "%-25s: %s\n", $title, $version ); |
| 464 | }; # if |
| 465 | }; # foreach |
| 466 | |
| 467 | exit( $count == 0 ? 0 : 1 ); |
| 468 | |
| 469 | __END__ |
| 470 | |
| 471 | =pod |
| 472 | |
| 473 | =head1 NAME |
| 474 | |
| 475 | B<check-tools.pl> -- Check development tools availability and versions. |
| 476 | |
| 477 | =head1 SYNOPSIS |
| 478 | |
| 479 | B<check-tools.pl> I<OPTION>... |
| 480 | |
| 481 | =head1 OPTIONS |
| 482 | |
| 483 | =over |
| 484 | |
| 485 | =item B<--make> |
| 486 | |
| 487 | Produce output suitable for using in makefile: short tool names (e. g. "icc" instead of "Intel C |
| 488 | Compiler"), spaces in version strings replaced with underscores. |
| 489 | |
| 490 | =item Tools selection |
| 491 | |
| 492 | =over |
| 493 | |
| 494 | =item B<-->[B<no->]B<-gnu-fortran> |
| 495 | |
| 496 | Check GNU Fortran compiler. By default, it is not checked. |
| 497 | |
| 498 | =item B<-->[B<no->]B<intel> |
| 499 | |
| 500 | Check Intel C, C++ and Fortran compilers. This is default. |
| 501 | |
| 502 | =back |
| 503 | |
| 504 | =item Platform selection |
| 505 | |
| 506 | =over |
| 507 | |
| 508 | =item B<--architecture=>I<str> |
| 509 | |
| 510 | Specify target architecture. Used in cross-builds, for example when building 32-bit applications on |
| 511 | Intel(R) 64 machine. |
| 512 | |
| 513 | If architecture is not specified explicitly, value of LIBOMP_ARCH environment variable is used. |
| 514 | If LIBOMP_ARCH is not defined, host architecture detected. |
| 515 | |
| 516 | =item B<--os=>I<str> |
| 517 | |
| 518 | Specify target OS name. Used in cross-builds, for example when building Intel(R) Many Integrated Core Architecture applications on |
| 519 | Windows* OS. |
| 520 | |
| 521 | If OS is not specified explicitly, value of LIBOMP_OS environment variable is used. |
| 522 | If LIBOMP_OS is not defined, host OS detected. |
| 523 | |
| 524 | =back |
| 525 | |
| 526 | =back |
| 527 | |
| 528 | =head2 Standard Options |
| 529 | |
| 530 | =over |
| 531 | |
| 532 | =item B<--doc> |
| 533 | |
| 534 | =item B<--manual> |
| 535 | |
| 536 | Print full help message and exit. |
| 537 | |
| 538 | =item B<--help> |
| 539 | |
| 540 | Print short help message and exit. |
| 541 | |
| 542 | =item B<--usage> |
| 543 | |
| 544 | Print very short usage message and exit. |
| 545 | |
| 546 | =item B<--verbose> |
| 547 | |
| 548 | Do print informational messages. |
| 549 | |
| 550 | =item B<--version> |
| 551 | |
| 552 | Print version and exit. |
| 553 | |
| 554 | =item B<--quiet> |
| 555 | |
| 556 | Work quiet, do not print informational messages. |
| 557 | |
| 558 | =back |
| 559 | |
| 560 | =head1 DESCRIPTION |
| 561 | |
| 562 | This script checks availability and versions of development tools. By default, the script checks: |
| 563 | Perl, GNU Make, Intel compilers, GNU C and C++ compilers (Linux* OS and OS X*), |
| 564 | Microsoft C/C++ compiler and linker (Windows* OS). |
| 565 | |
| 566 | The sript prints nice looking table or machine-readable strings. |
| 567 | |
| 568 | =head2 EXIT |
| 569 | |
| 570 | =over |
| 571 | |
| 572 | =item * |
| 573 | |
| 574 | 0 -- All programs found. |
| 575 | |
| 576 | =item * |
| 577 | |
| 578 | 1 -- Some of tools are not found. |
| 579 | |
| 580 | =back |
| 581 | |
| 582 | =head1 EXAMPLES |
| 583 | |
| 584 | $ check-tools.pl |
| 585 | Perl : 5.8.0 |
| 586 | GNU Make : 3.79.1 |
| 587 | Intel C Compiler : 11.0 (20080930) for 32e |
| 588 | Intel C++ Compiler : 11.0 (20080930) for 32e |
| 589 | Intel Fortran Compiler : 10.1.008 (20070913) for 32e |
| 590 | GNU C Compiler : 3.2.3 (20030502) |
| 591 | GNU C++ Compiler : 3.2.3 (20030502) |
| 592 | |
| 593 | > check-tools.pl --make |
| 594 | perl=5.8.8 |
| 595 | make=3.81 |
| 596 | icl=10.1_(20070913)_for_32e |
| 597 | ifort=10.1_(20070913)_for_32e |
| 598 | cl=14.00.40310.41_for_32e |
| 599 | link=8.00.40310.39 |
| 600 | |
| 601 | =back |
| 602 | |
| 603 | =cut |
| 604 | |
| 605 | # end of file # |
| 606 | |