Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 1 | # |
| 2 | # This is not a runnable script, it is a Perl module, a collection of variables, subroutines, etc. |
| 3 | # to be used in Perl scripts. |
| 4 | # |
| 5 | # To get help about exported variables and subroutines, execute the following command: |
| 6 | # |
| 7 | # perldoc Platform.pm |
| 8 | # |
| 9 | # or see POD (Plain Old Documentation) imbedded to the source... |
| 10 | # |
| 11 | # |
| 12 | # |
| 13 | #//===----------------------------------------------------------------------===// |
| 14 | #// |
| 15 | #// The LLVM Compiler Infrastructure |
| 16 | #// |
| 17 | #// This file is dual licensed under the MIT and the University of Illinois Open |
| 18 | #// Source Licenses. See LICENSE.txt for details. |
| 19 | #// |
| 20 | #//===----------------------------------------------------------------------===// |
| 21 | # |
| 22 | |
| 23 | package Platform; |
| 24 | |
| 25 | use strict; |
| 26 | use warnings; |
| 27 | |
| 28 | use base "Exporter"; |
| 29 | |
| 30 | use Uname; |
| 31 | |
| 32 | my @vars; |
| 33 | |
| 34 | BEGIN { |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 35 | @vars = qw{ $host_arch $host_os $host_platform $target_arch $target_mic_arch $target_os $target_platform }; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | our $VERSION = "0.014"; |
| 39 | our @EXPORT = qw{}; |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 40 | our @EXPORT_OK = ( qw{ canon_arch canon_os canon_mic_arch legal_arch arch_opt }, @vars ); |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 41 | our %EXPORT_TAGS = ( all => [ @EXPORT_OK ], vars => \@vars ); |
| 42 | |
| 43 | # Canonize architecture name. |
| 44 | sub canon_arch($) { |
| 45 | my ( $arch ) = @_; |
| 46 | if ( defined( $arch ) ) { |
| 47 | if ( $arch =~ m{\A\s*(?:32|IA-?32|IA-?32 architecture|i[3456]86|x86)\s*\z}i ) { |
| 48 | $arch = "32"; |
| 49 | } elsif ( $arch =~ m{\A\s*(?:48|(?:ia)?32e|Intel\s*64|Intel\(R\)\s*64|x86[_-]64|x64|AMD64)\s*\z}i ) { |
| 50 | $arch = "32e"; |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 51 | } elsif ( $arch =~ m{\Aarm(?:v7\D*)?\z} ) { |
| 52 | $arch = "arm"; |
Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 +0000 | [diff] [blame] | 53 | } elsif ( $arch =~ m{\Appc64le} ) { |
| 54 | $arch = "ppc64le"; |
Jim Cownie | 3051f97 | 2014-08-07 10:12:54 +0000 | [diff] [blame] | 55 | } elsif ( $arch =~ m{\Appc64} ) { |
Jonathan Peyton | 0c3a85a | 2016-05-17 20:54:10 +0000 | [diff] [blame^] | 56 | $arch = "ppc64"; |
| 57 | } elsif ( $arch =~ m{\Aaarch64} ) { |
Andrey Churbanov | cbda868 | 2015-01-13 14:43:35 +0000 | [diff] [blame] | 58 | $arch = "aarch64"; |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 59 | } elsif ( $arch =~ m{\Amic} ) { |
| 60 | $arch = "mic"; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 61 | } else { |
| 62 | $arch = undef; |
| 63 | }; # if |
| 64 | }; # if |
| 65 | return $arch; |
| 66 | }; # sub canon_arch |
| 67 | |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 68 | # Canonize Intel(R) Many Integrated Core Architecture name. |
| 69 | sub canon_mic_arch($) { |
| 70 | my ( $mic_arch ) = @_; |
| 71 | if ( defined( $mic_arch ) ) { |
| 72 | if ( $mic_arch =~ m{\Aknf} ) { |
| 73 | $mic_arch = "knf"; |
| 74 | } elsif ( $mic_arch =~ m{\Aknc}) { |
| 75 | $mic_arch = "knc"; |
| 76 | } elsif ( $mic_arch =~ m{\Aknl} ) { |
| 77 | $mic_arch = "knl"; |
| 78 | } else { |
| 79 | $mic_arch = undef; |
| 80 | }; # if |
| 81 | }; # if |
| 82 | return $mic_arch; |
| 83 | }; # sub canon_mic_arch |
| 84 | |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 85 | { # Return legal approved architecture name. |
| 86 | my %legal = ( |
| 87 | "32" => "IA-32 architecture", |
| 88 | "32e" => "Intel(R) 64", |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 89 | "arm" => "ARM", |
Andrey Churbanov | cbda868 | 2015-01-13 14:43:35 +0000 | [diff] [blame] | 90 | "aarch64" => "AArch64", |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 91 | "mic" => "Intel(R) Many Integrated Core Architecture", |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 92 | ); |
| 93 | |
| 94 | sub legal_arch($) { |
| 95 | my ( $arch ) = @_; |
| 96 | $arch = canon_arch( $arch ); |
| 97 | if ( defined( $arch ) ) { |
| 98 | $arch = $legal{ $arch }; |
| 99 | }; # if |
| 100 | return $arch; |
| 101 | }; # sub legal_arch |
| 102 | } |
| 103 | |
| 104 | { # Return architecture name suitable for Intel compiler setup scripts. |
| 105 | my %option = ( |
| 106 | "32" => "ia32", |
| 107 | "32e" => "intel64", |
| 108 | "64" => "ia64", |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 109 | "arm" => "arm", |
Andrey Churbanov | cbda868 | 2015-01-13 14:43:35 +0000 | [diff] [blame] | 110 | "aarch64" => "aarch", |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 111 | "mic" => "intel64", |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 112 | ); |
| 113 | |
| 114 | sub arch_opt($) { |
| 115 | my ( $arch ) = @_; |
| 116 | $arch = canon_arch( $arch ); |
| 117 | if ( defined( $arch ) ) { |
| 118 | $arch = $option{ $arch }; |
| 119 | }; # if |
| 120 | return $arch; |
| 121 | }; # sub arch_opt |
| 122 | } |
| 123 | |
| 124 | # Canonize OS name. |
| 125 | sub canon_os($) { |
| 126 | my ( $os ) = @_; |
| 127 | if ( defined( $os ) ) { |
| 128 | if ( $os =~ m{\A\s*(?:Linux|lin|l)\s*\z}i ) { |
| 129 | $os = "lin"; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 130 | } elsif ( $os =~ m{\A\s*(?:Mac(?:\s*OS(?:\s*X)?)?|mac|m|Darwin)\s*\z}i ) { |
| 131 | $os = "mac"; |
| 132 | } elsif ( $os =~ m{\A\s*(?:Win(?:dows)?(?:(?:_|\s*)?(?:NT|XP|95|98|2003))?|w)\s*\z}i ) { |
| 133 | $os = "win"; |
| 134 | } else { |
| 135 | $os = undef; |
| 136 | }; # if |
| 137 | }; # if |
| 138 | return $os; |
| 139 | }; # sub canon_os |
| 140 | |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 141 | my ( $_host_os, $_host_arch, $_target_os, $_target_arch, $_target_mic_arch, $_default_mic_arch); |
| 142 | |
| 143 | # Set the default mic-arch value. |
| 144 | $_default_mic_arch = "knc"; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 145 | |
| 146 | sub set_target_arch($) { |
| 147 | my ( $arch ) = canon_arch( $_[ 0 ] ); |
| 148 | if ( defined( $arch ) ) { |
| 149 | $_target_arch = $arch; |
| 150 | $ENV{ LIBOMP_ARCH } = $arch; |
| 151 | }; # if |
| 152 | return $arch; |
| 153 | }; # sub set_target_arch |
| 154 | |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 155 | sub set_target_mic_arch($) { |
| 156 | my ( $mic_arch ) = canon_mic_arch( $_[ 0 ] ); |
| 157 | if ( defined( $mic_arch ) ) { |
| 158 | $_target_mic_arch = $mic_arch; |
| 159 | $ENV{ LIBOMP_MIC_ARCH } = $mic_arch; |
| 160 | }; # if |
| 161 | return $mic_arch; |
| 162 | }; # sub set_target_mic_arch |
| 163 | |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 164 | sub set_target_os($) { |
| 165 | my ( $os ) = canon_os( $_[ 0 ] ); |
| 166 | if ( defined( $os ) ) { |
| 167 | $_target_os = $os; |
| 168 | $ENV{ LIBOMP_OS } = $os; |
| 169 | }; # if |
| 170 | return $os; |
| 171 | }; # sub set_target_os |
| 172 | |
| 173 | sub target_options() { |
| 174 | my @options = ( |
| 175 | "target-os|os=s" => |
| 176 | sub { |
| 177 | set_target_os( $_[ 1 ] ) or |
| 178 | die "Bad value of --target-os option: \"$_[ 1 ]\"\n"; |
| 179 | }, |
| 180 | "target-architecture|targert-arch|architecture|arch=s" => |
| 181 | sub { |
| 182 | set_target_arch( $_[ 1 ] ) or |
| 183 | die "Bad value of --target-architecture option: \"$_[ 1 ]\"\n"; |
| 184 | }, |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 185 | "target-mic-architecture|targert-mic-arch|mic-architecture|mic-arch=s" => |
| 186 | sub { |
| 187 | set_target_mic_arch( $_[ 1 ] ) or |
| 188 | die "Bad value of --target-mic-architecture option: \"$_[ 1 ]\"\n"; |
| 189 | }, |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 190 | ); |
| 191 | return @options; |
| 192 | }; # sub target_options |
| 193 | |
| 194 | # Detect host arch. |
| 195 | { |
| 196 | my $hardware_platform = Uname::hardware_platform(); |
| 197 | if ( 0 ) { |
| 198 | } elsif ( $hardware_platform eq "i386" ) { |
| 199 | $_host_arch = "32"; |
| 200 | } elsif ( $hardware_platform eq "ia64" ) { |
| 201 | $_host_arch = "64"; |
| 202 | } elsif ( $hardware_platform eq "x86_64" ) { |
| 203 | $_host_arch = "32e"; |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 204 | } elsif ( $hardware_platform eq "arm" ) { |
| 205 | $_host_arch = "arm"; |
Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 +0000 | [diff] [blame] | 206 | } elsif ( $hardware_platform eq "ppc64le" ) { |
| 207 | $_host_arch = "ppc64le"; |
Jim Cownie | 3051f97 | 2014-08-07 10:12:54 +0000 | [diff] [blame] | 208 | } elsif ( $hardware_platform eq "ppc64" ) { |
| 209 | $_host_arch = "ppc64"; |
Jonathan Peyton | 0c3a85a | 2016-05-17 20:54:10 +0000 | [diff] [blame^] | 210 | } elsif ( $hardware_platform eq "aarch64" ) { |
| 211 | $_host_arch = "aarch64"; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 212 | } else { |
| 213 | die "Unsupported host hardware platform: \"$hardware_platform\"; stopped"; |
| 214 | }; # if |
| 215 | } |
| 216 | |
| 217 | # Detect host OS. |
| 218 | { |
| 219 | my $operating_system = Uname::operating_system(); |
| 220 | if ( 0 ) { |
| 221 | } elsif ( $operating_system eq "GNU/Linux" ) { |
| 222 | $_host_os = "lin"; |
Alp Toker | 763b939 | 2014-02-28 09:42:41 +0000 | [diff] [blame] | 223 | } elsif ( $operating_system eq "FreeBSD" ) { |
| 224 | # Host OS resembles Linux. |
| 225 | $_host_os = "lin"; |
Joerg Sonnenberger | 40252ce | 2015-09-21 19:42:05 +0000 | [diff] [blame] | 226 | } elsif ( $operating_system eq "NetBSD" ) { |
| 227 | # Host OS resembles Linux. |
| 228 | $_host_os = "lin"; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 229 | } elsif ( $operating_system eq "Darwin" ) { |
| 230 | $_host_os = "mac"; |
| 231 | } elsif ( $operating_system eq "MS Windows" ) { |
| 232 | $_host_os = "win"; |
| 233 | } else { |
| 234 | die "Unsupported host operating system: \"$operating_system\"; stopped"; |
| 235 | }; # if |
| 236 | } |
| 237 | |
| 238 | # Detect target arch. |
| 239 | if ( defined( $ENV{ LIBOMP_ARCH } ) ) { |
| 240 | # Use arch specified in LIBOMP_ARCH. |
| 241 | $_target_arch = canon_arch( $ENV{ LIBOMP_ARCH } ); |
| 242 | if ( not defined( $_target_arch ) ) { |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 243 | die "Unknown architecture specified in LIBOMP_ARCH environment variable: \"$ENV{ LIBOMP_ARCH }\""; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 244 | }; # if |
| 245 | } else { |
| 246 | # Otherwise use host architecture. |
| 247 | $_target_arch = $_host_arch; |
| 248 | }; # if |
| 249 | $ENV{ LIBOMP_ARCH } = $_target_arch; |
| 250 | |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 251 | # Detect target Intel(R) Many Integrated Core Architecture. |
| 252 | if ( defined( $ENV{ LIBOMP_MIC_ARCH } ) ) { |
| 253 | # Use mic arch specified in LIBOMP_MIC_ARCH. |
| 254 | $_target_mic_arch = canon_mic_arch( $ENV{ LIBOMP_MIC_ARCH } ); |
| 255 | if ( not defined( $_target_mic_arch ) ) { |
| 256 | die "Unknown architecture specified in LIBOMP_MIC_ARCH environment variable: \"$ENV{ LIBOMP_MIC_ARCH }\""; |
| 257 | }; # if |
| 258 | } else { |
| 259 | # Otherwise use default Intel(R) Many Integrated Core Architecture. |
| 260 | $_target_mic_arch = $_default_mic_arch; |
| 261 | }; # if |
| 262 | $ENV{ LIBOMP_MIC_ARCH } = $_target_mic_arch; |
| 263 | |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 264 | # Detect target OS. |
| 265 | if ( defined( $ENV{ LIBOMP_OS } ) ) { |
| 266 | # Use OS specified in LIBOMP_OS. |
| 267 | $_target_os = canon_os( $ENV{ LIBOMP_OS } ); |
| 268 | if ( not defined( $_target_os ) ) { |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 269 | die "Unknown OS specified in LIBOMP_OS environment variable: \"$ENV{ LIBOMP_OS }\""; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 270 | }; # if |
| 271 | } else { |
| 272 | # Otherwise use host OS. |
| 273 | $_target_os = $_host_os; |
| 274 | }; # if |
| 275 | $ENV{ LIBOMP_OS } = $_target_os; |
| 276 | |
| 277 | use vars @vars; |
| 278 | |
| 279 | tie( $host_arch, "Platform::host_arch" ); |
| 280 | tie( $host_os, "Platform::host_os" ); |
| 281 | tie( $host_platform, "Platform::host_platform" ); |
| 282 | tie( $target_arch, "Platform::target_arch" ); |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 283 | tie( $target_mic_arch, "Platform::target_mic_arch" ); |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 284 | tie( $target_os, "Platform::target_os" ); |
| 285 | tie( $target_platform, "Platform::target_platform" ); |
| 286 | |
| 287 | { package Platform::base; |
| 288 | |
| 289 | use Carp; |
| 290 | |
| 291 | use Tie::Scalar; |
| 292 | use base "Tie::StdScalar"; |
| 293 | |
| 294 | sub STORE { |
| 295 | my $self = shift( @_ ); |
| 296 | croak( "Modifying \$" . ref( $self ) . " is not allowed; stopped" ); |
| 297 | }; # sub STORE |
| 298 | |
| 299 | } # package Platform::base |
| 300 | |
| 301 | { package Platform::host_arch; |
| 302 | use base "Platform::base"; |
| 303 | sub FETCH { |
| 304 | return $_host_arch; |
| 305 | }; # sub FETCH |
| 306 | } # package Platform::host_arch |
| 307 | |
| 308 | { package Platform::host_os; |
| 309 | use base "Platform::base"; |
| 310 | sub FETCH { |
| 311 | return $_host_os; |
| 312 | }; # sub FETCH |
| 313 | } # package Platform::host_os |
| 314 | |
| 315 | { package Platform::host_platform; |
| 316 | use base "Platform::base"; |
| 317 | sub FETCH { |
| 318 | return "${_host_os}_${_host_arch}"; |
| 319 | }; # sub FETCH |
| 320 | } # package Platform::host_platform |
| 321 | |
| 322 | { package Platform::target_arch; |
| 323 | use base "Platform::base"; |
| 324 | sub FETCH { |
| 325 | return $_target_arch; |
| 326 | }; # sub FETCH |
| 327 | } # package Platform::target_arch |
| 328 | |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 329 | { package Platform::target_mic_arch; |
| 330 | use base "Platform::base"; |
| 331 | sub FETCH { |
| 332 | return $_target_mic_arch; |
| 333 | }; # sub FETCH |
| 334 | } # package Platform::target_mic_arch |
| 335 | |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 336 | { package Platform::target_os; |
| 337 | use base "Platform::base"; |
| 338 | sub FETCH { |
| 339 | return $_target_os; |
| 340 | }; # sub FETCH |
| 341 | } # package Platform::target_os |
| 342 | |
| 343 | { package Platform::target_platform; |
| 344 | use base "Platform::base"; |
| 345 | sub FETCH { |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 346 | if ($_target_arch eq "mic") { |
| 347 | return "${_target_os}_${_target_mic_arch}"; |
| 348 | } else { |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 349 | return "${_target_os}_${_target_arch}"; |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 350 | } |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 351 | }; # sub FETCH |
| 352 | } # package Platform::target_platform |
| 353 | |
| 354 | |
| 355 | return 1; |
| 356 | |
| 357 | __END__ |
| 358 | |
| 359 | =pod |
| 360 | |
| 361 | =head1 NAME |
| 362 | |
| 363 | B<Platform.pm> -- Few subroutines to get OS, architecture and platform name in form suitable for |
| 364 | naming files, directories, macros, etc. |
| 365 | |
| 366 | =head1 SYNOPSIS |
| 367 | |
| 368 | use Platform ":all"; |
| 369 | use tools; |
| 370 | |
| 371 | my $arch = canon_arch( "em64T" ); # Returns "32e". |
| 372 | my $legal = legal_arch( "em64t" ); # Returns "Intel(R) 64". |
| 373 | my $option = arch_opt( "em64t" ); # Returns "intel64". |
| 374 | my $os = canon_os( "Windows NT" ); # Returns "win". |
| 375 | |
| 376 | print( $host_arch, $host_os, $host_platform ); |
| 377 | print( $taregt_arch, $target_os, $target_platform ); |
| 378 | |
| 379 | tools::get_options( |
| 380 | Platform::target_options(), |
| 381 | ... |
| 382 | ); |
| 383 | |
| 384 | |
| 385 | =head1 DESCRIPTION |
| 386 | |
| 387 | Environment variable LIBOMP_OS specifies target OS to report. If LIBOMP_OS id not defined, |
| 388 | the script assumes host OS is target OS. |
| 389 | |
| 390 | Environment variable LIBOMP_ARCH specifies target architecture to report. If LIBOMP_ARCH is not defined, |
| 391 | the script assumes host architecture is target one. |
| 392 | |
| 393 | =head2 Functions. |
| 394 | |
| 395 | =over |
| 396 | |
| 397 | =item B<canon_arch( $arch )> |
| 398 | |
| 399 | Input string is an architecture name to canonize. The function recognizes many variants, for example: |
| 400 | C<32e>, C<Intel64>, C<Intel(R) 64>, etc. Returned string is a canononized architecture name, |
Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 +0000 | [diff] [blame] | 401 | one of: C<32>, C<32e>, C<64>, C<arm>, C<ppc64le>, C<ppc64>, C<mic>, or C<undef> is input string is not recognized. |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 402 | |
| 403 | =item B<legal_arch( $arch )> |
| 404 | |
| 405 | Input string is architecture name. The function recognizes the same variants as C<arch_canon()> does. |
| 406 | Returned string is a name approved by Intel Legal, one of: C<IA-32 architecture>, C<Intel(R) 64> |
| 407 | or C<undef> if input string is not recognized. |
| 408 | |
| 409 | =item B<arch_opt( $arch )> |
| 410 | |
| 411 | Input string is architecture name. The function recognizes the same variants as C<arch_canon()> does. |
| 412 | Returned string is an architecture name suitable for passing to compiler setup scripts |
| 413 | (e. g. C<iccvars.sh>), one of: C<IA-32 architecture>, C<Intel(R) 64> or C<undef> if input string is not |
| 414 | recognized. |
| 415 | |
| 416 | =item B<canon_os( $os )> |
| 417 | |
Andrey Churbanov | d315cea | 2015-01-16 12:54:51 +0000 | [diff] [blame] | 418 | Input string is OS name to canonize. The function recognizes many variants, for example: C<mac>, C<OS X>, etc. Returned string is a canonized OS name, one of: C<lin>, |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 419 | C<mac>, C<win>, or C<undef> is input string is not recognized. |
| 420 | |
| 421 | =item B<target_options()> |
| 422 | |
| 423 | Returns array suitable for passing to C<tools::get_options()> to let a script recognize |
| 424 | C<--target-architecture=I<str>> and C<--target-os=I<str>> options. Typical usage is: |
| 425 | |
| 426 | use tools; |
| 427 | use Platform; |
| 428 | |
| 429 | my ( $os, $arch, $platform ); # Global variables, not initialized. |
| 430 | |
| 431 | ... |
| 432 | |
| 433 | get_options( |
| 434 | Platform::target_options(), # Let script recognize --target-os and --target-arch options. |
| 435 | ... |
| 436 | ); |
| 437 | # Initialize variabls after parsing command line. |
| 438 | ( $os, $arch, $platform ) = ( Platform::target_os(), Platform::target_arch(), Platform::target_platform() ); |
| 439 | |
| 440 | =back |
| 441 | |
| 442 | =head2 Variables |
| 443 | |
| 444 | =item B<$host_arch> |
| 445 | |
| 446 | Canonized name of host architecture. |
| 447 | |
| 448 | =item B<$host_os> |
| 449 | |
| 450 | Canonized name of host OS. |
| 451 | |
| 452 | =item B<$host_platform> |
| 453 | |
| 454 | Host platform name (concatenated canonized OS name, underscore, and canonized architecture name). |
| 455 | |
| 456 | =item B<$target_arch> |
| 457 | |
| 458 | Canonized name of target architecture. |
| 459 | |
| 460 | =item B<$target_os> |
| 461 | |
| 462 | Canonized name of target OS. |
| 463 | |
| 464 | =item B<$target_platform> |
| 465 | |
| 466 | Target platform name (concatenated canonized OS name, underscore, and canonized architecture name). |
| 467 | |
| 468 | =back |
| 469 | |
| 470 | =cut |
| 471 | |
| 472 | # end of file # |
| 473 | |