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 | # Standard modules. |
| 19 | use Data::Dumper; # Not actually used, but useful for debugging dumps. |
| 20 | |
| 21 | # Enable `libomp/tools/lib/' module directory. |
| 22 | use FindBin; |
| 23 | use lib "$FindBin::Bin/lib"; |
| 24 | |
| 25 | # LIBOMP modules. |
| 26 | use Build; |
| 27 | use LibOMP; |
| 28 | use Platform ":vars"; |
| 29 | use Uname; |
| 30 | use tools; |
| 31 | |
| 32 | our $VERSION = "0.017"; |
| 33 | |
| 34 | # -------------------------------------------------------------------------------------------------- |
| 35 | # Important variables. |
| 36 | # -------------------------------------------------------------------------------------------------- |
| 37 | |
| 38 | my $root_dir = $ENV{ LIBOMP_WORK }; |
| 39 | |
| 40 | my %makefiles = ( |
| 41 | rtl => cat_file( $root_dir, "src", "makefile.mk" ), |
| 42 | timelimit => cat_file( $root_dir, "tools", "src", "timelimit", "makefile.mk" ), |
| 43 | ); |
| 44 | |
| 45 | # -------------------------------------------------------------------------------------------------- |
| 46 | # Parse command line. |
| 47 | # -------------------------------------------------------------------------------------------------- |
| 48 | |
| 49 | # Possible options. |
| 50 | # * targets: comma separated list of targets the option has meaning for. For example, |
| 51 | # "version" option (4 or 5) has a meaning only for "rtl" target, while "mode" option has |
| 52 | # meaning for all targets. |
| 53 | # * base: If base is true this is a base option. All the possible values of base options are |
| 54 | # iterated if "--all" option is specified. If base is 0, this is an extra option. |
| 55 | # * params: A hash of possible option values. "*" denotes default option value. For example, |
| 56 | # if "versio" option is not specified, "--version=5" will be used implicitly. |
| 57 | # * suffux: Only for extra options. Subroutine returning suffix for build and output |
| 58 | # directories. |
| 59 | my $opts = { |
| 60 | "target" => { targets => "", base => 1, parms => { map( ( $_ => "" ), keys( %makefiles ) ), rtl => "*" }, }, |
| 61 | "version" => { targets => "rtl", base => 1, parms => { 5 => "*", 4 => "" }, }, |
| 62 | "lib-type" => { targets => "rtl", base => 1, parms => { normal => "*", stubs => "" }, }, |
| 63 | "link-type" => { targets => "rtl", base => 1, parms => { dynamic => "*", static => "" }, }, |
| 64 | "target-compiler" => { targets => "rtl,dsl", base => 0, parms => { 12 => "*", 11 => "" }, suffix => sub { $_[ 0 ]; } }, |
| 65 | "mode" => { targets => "rtl,dsl,timelimit", base => 0, parms => { release => "*", diag => "", debug => "" }, suffix => sub { substr( $_[ 0 ], 0, 3 ); } }, |
| 66 | "omp-version" => { targets => "rtl", base => 0, parms => { 40 => "*", 30 => "", 25 => "" }, suffix => sub { $_[ 0 ]; } }, |
| 67 | "coverage" => { targets => "rtl", base => 0, parms => { off => "*", on => "" }, suffix => sub { $_[ 0 ] eq "on" ? "c1" : "c0"; } }, |
| 68 | "tcheck" => { targets => "rtl", base => 0, parms => { 0 => "*", 1 => "", 2 => "" }, suffix => sub { "t" . $_[ 0 ]; } }, |
| 69 | "mic-arch" => { targets => "rtl", base => 0, parms => { knf => "*", knc => "", knl => "" }, suffix => sub { $_[ 0 ]; } }, |
| 70 | "mic-os" => { targets => "rtl", base => 0, parms => { bsd => "*", lin => "" }, suffix => sub { $_[ 0 ]; } }, |
| 71 | "mic-comp" => { targets => "rtl", base => 0, parms => { native => "*", offload => "" }, suffix => sub { substr( $_[ 0 ], 0, 3 ); } }, |
| 72 | }; |
| 73 | my $synonyms = { |
| 74 | "debug" => [ qw{ dbg debg } ], |
| 75 | }; |
| 76 | # This array specifies order of options to process, so it cannot be initialized with keys( %$opts ). |
| 77 | my @all_opts = qw{ target version lib-type link-type target-compiler mode omp-version coverage tcheck mic-arch mic-os mic-comp }; |
| 78 | # This is the list of base options. |
| 79 | my @base_opts = grep( $opts->{ $_ }->{ base } == 1, @all_opts ); |
| 80 | # This is the list of extra options. |
| 81 | my @extra_opts = grep( $opts->{ $_ }->{ base } == 0, @all_opts ); |
| 82 | |
| 83 | sub suffix($$$) { |
| 84 | my ( $opt, $value, $skip_if_default ) = @_; |
| 85 | my $suffix = ""; |
| 86 | if ( not $skip_if_default or $value ne $opts->{ $opt }->{ dflt } ) { |
| 87 | $suffix = $opts->{ $opt }->{ suffix }->( $value ); |
| 88 | }; # if |
| 89 | return $suffix; |
| 90 | }; # sub suffix |
| 91 | |
| 92 | my $scuts = {}; # Shortcuts. Will help to locate proper item in $opts. |
| 93 | foreach my $opt ( keys( %$opts ) ) { |
| 94 | foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { |
| 95 | if ( $parm !~ m{\A(?:[012]|on|off)\z} ) { |
| 96 | $scuts->{ $parm } = $opts->{ $opt }; |
| 97 | }; # if |
| 98 | if ( $opts->{ $opt }->{ parms }->{ $parm } eq "*" ) { |
| 99 | $opts->{ $opt }->{ dflt } = $parm; |
| 100 | }; # if |
| 101 | }; # foreach $parm |
| 102 | }; # foreach $opt |
| 103 | |
| 104 | sub parse_option(@) { |
| 105 | # This function is called to process every option. $name is option name, $value is option value. |
| 106 | # For boolean options $value is either 1 or 0, |
| 107 | my ( $name, $value ) = @_; |
| 108 | if ( $name eq "all" or $name eq "ALL" ) { |
| 109 | foreach my $opt ( keys( %$opts ) ) { |
| 110 | if ( $opts->{ $opt }->{ base } or $name eq "ALL" ) { |
| 111 | foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { |
| 112 | $opts->{ $opt }->{ parms }->{ $parm } = 1; |
| 113 | }; # foreach $parm |
| 114 | }; # if |
| 115 | }; # foreach $opt |
| 116 | return; |
| 117 | }; # if |
| 118 | if ( exists( $opts->{ $name } ) ) { |
| 119 | # Suppose it is option with explicit value, like "target=normal". |
| 120 | if ( $value eq "all" ) { |
| 121 | foreach my $parm ( keys( %{ $opts->{ $name }->{ parms } } ) ) { |
| 122 | $opts->{ $name }->{ parms }->{ $parm } = 1; |
| 123 | }; # foreach |
| 124 | return; |
| 125 | } elsif ( exists( $opts->{ $name }->{ parms }->{ $value } ) ) { |
| 126 | $opts->{ $name }->{ parms }->{ $value } = 1; |
| 127 | return; |
| 128 | } elsif ( $value eq "" and exists( $opts->{ $name }->{ parms }->{ on } ) ) { |
| 129 | $opts->{ $name }->{ parms }->{ on } = 1; |
| 130 | return; |
| 131 | } else { |
| 132 | cmdline_error( "Illegal value of \"$name\" option: \"$value\"" ); |
| 133 | }; # if |
| 134 | }; # if |
| 135 | # Ok, it is not an option with explicit value. Try to treat is as a boolean option. |
| 136 | if ( exists( $scuts->{ $name } ) ) { |
| 137 | ( $value eq "1" or $value eq "0" ) or die "Internal error; stopped"; |
| 138 | $scuts->{ $name }->{ parms }->{ $name } = $value; |
| 139 | return; |
| 140 | }; # if |
| 141 | # No, it is not a valid option at all. |
| 142 | cmdline_error( "Illegal option: \"$name\"" ); |
| 143 | }; # sub parse_option |
| 144 | |
| 145 | my $clean = 0; |
| 146 | my $clean_common = 0; |
| 147 | my $clobber = 0; |
| 148 | my $test_deps = 1; |
| 149 | my $test_touch = 1; |
| 150 | my @goals; |
| 151 | |
| 152 | sub synonyms($) { |
| 153 | my ( $opt ) = @_; |
| 154 | return exists( $synonyms->{ $opt } ) ? "|" . join( "|", @{ $synonyms->{ $opt } } ) : ""; |
| 155 | }; # sub synonyms |
| 156 | |
| 157 | my @specs = ( |
| 158 | map( ( "$_" . synonyms( $_ ) . "=s" => \&parse_option ), keys( %$opts ) ), |
| 159 | map( ( "$_" . synonyms( $_ ) . "!" => \&parse_option ), keys( %$scuts ) ), |
| 160 | ); |
| 161 | my $answer; |
| 162 | get_options( |
| 163 | @specs, |
| 164 | Platform::target_options(), |
| 165 | "all" => \&parse_option, |
| 166 | "ALL" => \&parse_option, |
| 167 | "answer=s" => \$answer, |
| 168 | "test-deps!" => \$test_deps, |
| 169 | "test-touch!" => \$test_touch, |
| 170 | "version|ver:s" => |
| 171 | sub { |
| 172 | # It is a tricky option. It specifies library version to build and it is also a standard |
| 173 | # option to request tool version. |
| 174 | if ( $_[ 1 ] eq "" ) { |
| 175 | # No arguments => version request. |
| 176 | print( "$tool version $VERSION\n" ); |
| 177 | exit( 0 ); |
| 178 | } else { |
| 179 | # Arguments => version to build. |
| 180 | parse_option( @_ ) |
| 181 | }; |
| 182 | }, |
| 183 | ); |
| 184 | @goals = @ARGV; |
| 185 | if ( grep( $_ eq "clobber", @goals ) ) { |
| 186 | $clobber = 1; |
| 187 | }; # if |
| 188 | if ( grep( $_ eq "clean", @goals ) ) { |
| 189 | $clean = 1; |
| 190 | }; # if |
| 191 | |
| 192 | # Ok, now $opts is fulfilled with 0, 1 (explicitly set by the user) and "" and "*" (original |
| 193 | # values). In each option at least one 1 should be present (otherwise there is nothing to build). |
| 194 | foreach my $opt ( keys( %$opts ) ) { |
| 195 | if ( not grep( $_ eq "1", values( %{ $opts->{ $opt }->{ parms } } ) ) ) { |
| 196 | # No explicit "1" found. Enable default choice by replacing "*" with "1". |
| 197 | foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { |
| 198 | if ( $opts->{ $opt }->{ parms }->{ $parm } eq "*" ) { |
| 199 | $opts->{ $opt }->{ parms }->{ $parm } = 1; |
| 200 | }; # if |
| 201 | }; # foreach $parm |
| 202 | }; # if |
| 203 | }; # foreach $opt |
| 204 | |
| 205 | # Clear $opts. Leave only "1". |
| 206 | foreach my $opt ( keys( %$opts ) ) { |
| 207 | foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { |
| 208 | if ( $opts->{ $opt }->{ parms }->{ $parm } ne "1" ) { |
| 209 | delete( $opts->{ $opt }->{ parms }->{ $parm } ); |
| 210 | }; # if |
| 211 | }; # foreach $parm |
| 212 | }; # foreach $opt |
| 213 | |
| 214 | # -------------------------------------------------------------------------------------------------- |
| 215 | # Fill job queue. |
| 216 | # -------------------------------------------------------------------------------------------------- |
| 217 | |
| 218 | sub enqueue_jobs($$@); |
| 219 | sub enqueue_jobs($$@) { |
| 220 | my ( $jobs, $set, @rest ) = @_; |
| 221 | if ( @rest ) { |
| 222 | my $opt = shift( @rest ); |
| 223 | if ( |
| 224 | exists( $set->{ target } ) |
| 225 | and |
| 226 | $opts->{ $opt }->{ targets } !~ m{(?:\A|,)$set->{ target }(?:,|\z)} |
| 227 | ) { |
| 228 | # This option does not have meananing for the target, |
| 229 | # do not iterate, just use default value. |
| 230 | enqueue_jobs( $jobs, { $opt => $opts->{ $opt }->{ dflt }, %$set }, @rest ); |
| 231 | } else { |
| 232 | foreach my $parm ( sort( keys( %{ $opts->{ $opt }->{ parms } } ) ) ) { |
| 233 | enqueue_jobs( $jobs, { $opt => $parm, %$set }, @rest ); |
| 234 | }; # foreach $parm |
| 235 | }; # if |
| 236 | } else { |
| 237 | my $makefile = $makefiles{ $set->{ target } }; |
| 238 | my @base = map( substr( $set->{ $_ }, 0, 3 ), @base_opts ); |
| 239 | my @extra = map( suffix( $_, $set->{ $_ }, 0 ), @extra_opts ); |
| 240 | my @ex = grep( $_ ne "", map( suffix( $_, $set->{ $_ }, 1 ), @extra_opts ) ); |
| 241 | # Shortened version of @extra -- only non-default values. |
| 242 | my $suffix = ( @extra ? "." . join( ".", @extra ) : "" ); |
| 243 | my $knights = index( $suffix, "kn" ) - 1; |
| 244 | if ( $target_platform !~ "lrb" and $knights > 0 ) { |
| 245 | $suffix = substr( $suffix, 0, $knights ); |
| 246 | } |
| 247 | my $suf = ( @ex ? "." . join( ".", @ex ) : "" ); |
| 248 | # Shortened version of $siffix -- only non-default values. |
| 249 | my $build_dir = join( "-", $target_platform, join( "_", @base ) . $suffix, Uname::host_name() ); |
| 250 | my $out_arch_dir = cat_dir( $ENV{ LIBOMP_EXPORTS }, $target_platform . $suf ); |
| 251 | my $out_cmn_dir = cat_dir( $ENV{ LIBOMP_EXPORTS }, "common" ); |
| 252 | push( |
| 253 | @$jobs, |
| 254 | { |
| 255 | makefile => $makefile, |
| 256 | make_args => [ |
| 257 | "os=" . $target_os, |
| 258 | "arch=" . $target_arch, |
| 259 | "MIC_OS=" . $set->{ "mic-os" }, |
| 260 | "MIC_ARCH=" . $set->{ "mic-arch" }, |
| 261 | "MIC_COMP=" . $set->{ "mic-comp" }, |
| 262 | "date=" . Build::tstr( $Build::start ), |
| 263 | "TEST_DEPS=" . ( $test_deps ? "on" : "off" ), |
| 264 | "TEST_TOUCH=" . ( $test_touch ? "on" : "off" ), |
| 265 | "CPLUSPLUS=on", |
| 266 | "COVERAGE=" . $set->{ coverage }, |
| 267 | # Option "mode" controls 3 make flags: |
| 268 | # debug => Full debugging : diagnostics, debug info, no optimization. |
| 269 | # diag => Only diagnostics : diagnostics, debug info, optimization. |
| 270 | # release => Production build : no diagnostics, no debug info, optimization. |
| 271 | "DEBUG_INFO=" . ( $set->{ mode } ne "release" ? "on" : "off" ), |
| 272 | "DIAG=" . ( $set->{ mode } ne "release" ? "on" : "off" ), |
| 273 | "OPTIMIZATION=" . ( $set->{ mode } ne "debug" ? "on" : "off" ), |
| 274 | "LIB_TYPE=" . substr( $set->{ "lib-type" }, 0, 4 ), |
| 275 | "LINK_TYPE=" . substr( $set->{ "link-type" }, 0, 4 ), |
| 276 | "OMP_VERSION=" . $set->{ "omp-version" }, |
| 277 | "USE_TCHECK=" . $set->{ tcheck }, |
| 278 | "VERSION=" . $set->{ version }, |
| 279 | "TARGET_COMPILER=" . $set->{ "target-compiler" }, |
| 280 | "suffix=" . $suf, |
| 281 | @goals, |
| 282 | ], |
| 283 | build_dir => $build_dir |
| 284 | } |
| 285 | ); # push |
| 286 | }; # if |
| 287 | }; # sub enqueue_jobs |
| 288 | |
| 289 | my @jobs; |
| 290 | enqueue_jobs( \@jobs, {}, @all_opts ); |
| 291 | |
| 292 | # -------------------------------------------------------------------------------------------------- |
| 293 | # Do the work. |
| 294 | # -------------------------------------------------------------------------------------------------- |
| 295 | |
| 296 | my $exit = 0; |
| 297 | |
| 298 | Build::init(); |
| 299 | |
| 300 | if ( $clobber ) { |
| 301 | my @dirs = ( $ENV{ LIBOMP_TMP }, $ENV{ LIBOMP_EXPORTS }, cat_dir( $root_dir, "tools", "bin" ) ); |
| 302 | my $rc = 0; |
| 303 | question( |
| 304 | "Clobber " . join( ", ", map( "\"" . Build::shorter( $_ ) . "\"", @dirs ) ) . " dirs? ", |
| 305 | $answer, |
| 306 | qr{\A(y|yes|n|no)\z}i |
| 307 | ); |
| 308 | if ( $answer =~ m{\Ay}i ) { |
| 309 | info( "Clobbering..." ); |
| 310 | $rc = Build::clean( @dirs ); |
| 311 | info( Build::rstr( $rc ) ); |
| 312 | }; # if |
| 313 | if ( $rc != 0 ) { |
| 314 | $exit = 3; |
| 315 | }; # if |
| 316 | } else { # Build or clean. |
| 317 | if ( @jobs ) { |
| 318 | my $total = @jobs; # Total number of jobs. |
| 319 | my $n = 0; # Current job number. |
| 320 | Build::progress( "", "" ); # Output empty line to log file. |
| 321 | my $goals = join( " ", @goals ); |
| 322 | Build::progress( "Goals", $goals eq "" ? "(all)" : $goals ); |
| 323 | Build::progress( "Configurations", scalar( @jobs ) ); |
| 324 | foreach my $job ( @jobs ) { |
| 325 | ++ $n; |
| 326 | my $base = get_file( $job->{ build_dir } ); |
| 327 | Build::progress( "Making", "%3d of %3d : %s", $n, $total, $base ); |
| 328 | $job->{ rc } = Build::make( $job, $clean, sprintf( "%d/%d", $n, $total ) ); |
| 329 | }; # my $job |
| 330 | my $failures = Build::summary(); |
| 331 | if ( $failures > 0 ) { |
| 332 | $exit = 3; |
| 333 | }; # if |
| 334 | } else { |
| 335 | info( "Nothing to do." ); |
| 336 | }; # if |
| 337 | }; # if |
| 338 | |
| 339 | # And exit. |
| 340 | exit( $exit ); |
| 341 | |
| 342 | __END__ |
| 343 | |
| 344 | =pod |
| 345 | |
| 346 | =head1 NAME |
| 347 | |
| 348 | |
| 349 | B<build.pl> -- Build one or more configurations of OMP RTL libraries. |
| 350 | |
| 351 | =head1 SYNOPSIS |
| 352 | |
| 353 | B<build.pl> I<option>... [B<-->] I<make-option>... I<variable>... I<goal>... |
| 354 | |
| 355 | =head1 OPTIONS |
| 356 | |
| 357 | =over |
| 358 | |
| 359 | =item B<--all> |
| 360 | |
| 361 | Build all base configurations. |
| 362 | |
| 363 | =item B<--ALL> |
| 364 | |
| 365 | Build really all configurations, including extra ones. |
| 366 | |
| 367 | =item B<--answer=>I<str> |
| 368 | |
| 369 | Use specified string as default answer to all questions. |
| 370 | |
| 371 | =item B<--architecture=>I<arch> |
| 372 | |
| 373 | Specify target architecture to build. Default is architecture of host machine. I<arch> can be C<32>, |
| 374 | C<32e>, or one of known aliases like C<IA32>. |
| 375 | |
| 376 | If architecture is not specified explicitly, value of LIBOMP_ARCH environment variable is used. |
| 377 | If LIBOMP_ARCH is not defined, host architecture detected. |
| 378 | |
| 379 | =item B<--os=>I<os> |
| 380 | |
| 381 | Specify target OS. Default is OS of host machine. I<os> can be C<lin>, C<lrb>, C<mac>, C<win>, |
| 382 | or one of known aliases like C<Linux>, C<WinNT>, etc. |
| 383 | |
| 384 | =item B<--mic-os=>I<os> |
| 385 | |
| 386 | Specify OS on Intel(R) Many Integrated Core Architecture card. Default is C<bsd>. I<os> can be C<bsd>, C<lin>. |
| 387 | |
| 388 | =item B<--mic-arch=>I<arch> |
| 389 | |
| 390 | Specify architecture of Intel(R) Many Integrated Core Architecture card. Default is C<knf>. I<arch> can be C<knf>, C<knc>, C<knl>. |
| 391 | |
| 392 | =item B<--mic-comp=>I<compiler-type> |
| 393 | |
| 394 | Specify whether the Intel(R) Many Integrated Core Compiler is native or offload. Default is C<native>. |
| 395 | I<compiler-type> can be C<native> or C<offload>. |
| 396 | |
| 397 | =item B<-->[B<no->]B<test-deps> |
| 398 | |
| 399 | Enable or disable C<test-deps>. The test runs in any case, but result of disabled test is ignored. |
| 400 | By default, test is enabled. |
| 401 | |
| 402 | =item B<-->[B<no->]B<test-touch> |
| 403 | |
| 404 | Enable or disable C<test-touch>. The test runs in any case, but result of disabled test is ignored. |
| 405 | By default, test is enabled. |
| 406 | |
| 407 | =item Base Configuration Selection Options |
| 408 | |
| 409 | =over |
| 410 | |
| 411 | =item B<--target=>I<target> |
| 412 | |
| 413 | Build specified target, either C<rtl> (OMP Runtime Library; default), |
| 414 | or C<timelimit> (program used in testing), or C<all>. |
| 415 | |
| 416 | =item B<--lib-type=>I<lib> |
| 417 | |
| 418 | Build specified library, either C<normal> (default), or C<stubs>, or C<all>. |
| 419 | |
| 420 | =item B<--link-type=>I<type> |
| 421 | |
| 422 | Build specified link type, either C<dynamic> (default) or C<all>. |
| 423 | |
| 424 | =back |
| 425 | |
| 426 | =item Extra Configuration Selection Options |
| 427 | |
| 428 | =over |
| 429 | |
| 430 | =item B<--cover=>I<switch> |
| 431 | |
| 432 | Build for code coverage data collection. I<switch> can be C<off> (default), C<on> |
| 433 | or C<all>. |
| 434 | |
| 435 | =item B<--mode=>I<mode> |
| 436 | |
| 437 | Build library of specified I<mode>, either C<debug>, C<diag>, C<release> (default), or C<all>. |
| 438 | Mode controls 3 features: |
| 439 | |
| 440 | --------------------------------------------------- |
| 441 | feature/mode debug diag release |
| 442 | --------------------------------------------------- |
| 443 | debug info o o |
| 444 | diagnostics (asserts, traces) o o |
| 445 | code optimization o o |
| 446 | --------------------------------------------------- |
| 447 | |
| 448 | =item B<--target-compiler=>I<version> |
| 449 | |
| 450 | Build files for specified target compiler, C<11> or C<12>. |
| 451 | |
| 452 | =back |
| 453 | |
| 454 | =item Shortcuts |
| 455 | |
| 456 | If option with C<no> prefix is used, corresponding configuration will B<not> be built. |
| 457 | Useful for excluding some configurations if one or more other options specified with C<all> |
| 458 | value (see Examples). |
| 459 | |
| 460 | =over |
| 461 | |
| 462 | =item B<-->[B<no>]B<11> |
| 463 | |
| 464 | Build files for compiler C<11>. |
| 465 | |
| 466 | =item B<-->[B<no>]B<12> |
| 467 | |
| 468 | Build files for compiler C<12>. |
| 469 | |
| 470 | =item B<-->[B<no>]B<debug> |
| 471 | |
| 472 | =item B<-->[B<no>]B<debg> |
| 473 | |
| 474 | =item B<-->[B<no>]B<dbg> |
| 475 | |
| 476 | Build debuggable library. |
| 477 | |
| 478 | =item B<-->[B<no>]B<diag> |
| 479 | |
| 480 | Build library with diagnostics enabled. |
| 481 | |
| 482 | =item B<-->[B<no>]B<dynamic> |
| 483 | |
| 484 | Build dynamic library (default). |
| 485 | |
| 486 | =item B<-->[B<no>]B<normal> |
| 487 | |
| 488 | Build normal library (default). |
| 489 | |
| 490 | =item B<-->[B<no>]B<release> |
| 491 | |
| 492 | Build release library (default). |
| 493 | |
| 494 | =item B<-->[B<no>]B<rtl> |
| 495 | |
| 496 | Build OMP RTL (default). |
| 497 | |
| 498 | =item B<-->[B<no>]B<stubs> |
| 499 | |
| 500 | Build stubs library. |
| 501 | |
| 502 | =item B<-->[B<no>]B<timelimit> |
| 503 | |
| 504 | Build timelimit utility program. |
| 505 | |
| 506 | =back |
| 507 | |
| 508 | =item Standard Options |
| 509 | |
| 510 | =over |
| 511 | |
| 512 | =item B<--doc> |
| 513 | |
| 514 | =item B<--manual> |
| 515 | |
| 516 | Print full help message and exit. |
| 517 | |
| 518 | =item B<--help> |
| 519 | |
| 520 | Print short help message and exit. |
| 521 | |
| 522 | =item B<--usage> |
| 523 | |
| 524 | Print very short usage message and exit. |
| 525 | |
| 526 | =item B<--verbose> |
| 527 | |
| 528 | Do print informational messages. |
| 529 | |
| 530 | =item B<--version> |
| 531 | |
| 532 | Print program version and exit. |
| 533 | |
| 534 | =item B<--quiet> |
| 535 | |
| 536 | Work quiet, do not print informational messages. |
| 537 | |
| 538 | =back |
| 539 | |
| 540 | =back |
| 541 | |
| 542 | =head1 ARGUMENTS |
| 543 | |
| 544 | =over |
| 545 | |
| 546 | =item I<make-option> |
| 547 | |
| 548 | Any option for makefile, for example C<-k> or C<-n>. If you pass some options to makefile, C<--> |
| 549 | delimiter is mandatory, otherwise C<build.pl> processes all the options internally. |
| 550 | |
| 551 | =item I<variable> |
| 552 | |
| 553 | Define makefile variable in form I<name>B<=>I<value>. Most makefile capabilities are |
| 554 | accessible through C<build.pl> options, so there is no need in defining make variables in command |
| 555 | line. |
| 556 | |
| 557 | =item I<goal> |
| 558 | |
| 559 | Makefile goal to build (or clean). |
| 560 | |
| 561 | =over |
| 562 | |
| 563 | =item B<all> |
| 564 | |
| 565 | Build C<lib>, C<tests>, C<inc>. |
| 566 | |
| 567 | =item B<common> |
| 568 | |
| 569 | Build common (architecture-independent) files. Common files are not configuration-dependent, so |
| 570 | there is no point in building it for more than one configuration (thought it is harmless). |
| 571 | However, do not build common files on many machines simultaneously. |
| 572 | |
| 573 | =item B<clean> |
| 574 | |
| 575 | Delete the export files and clean build directory of configuration(s) specified by options. Note |
| 576 | that C<clean> goal cannot be mixed with other goals (except for C<clean-common>). |
| 577 | |
| 578 | =item B<clean-common> |
| 579 | |
| 580 | Delete the common files in F<exports/> directory. |
| 581 | |
| 582 | =item B<clobber> |
| 583 | |
| 584 | Clean F<export/> and F<tmp/> directories. If C<clobber> is specified, other goals and/or options |
| 585 | do not matter. |
| 586 | |
| 587 | Note: Clobbering is potentialy dangerous operation, because it deletes content of directory |
| 588 | pointed by If C<LIBOMP_TMP> environment variable, so C<build.pl> asks a confirmation before |
| 589 | clobbering. To suppress the question, use option C<--answer=yes>. |
| 590 | |
| 591 | =item B<fat> |
| 592 | |
| 593 | C<mac_32e> only: Build fat libraries for both mac_32 and mac_32e. Should be run when C<lib> |
| 594 | goal is built on both C<mac_32> and C<mac_32e>. |
| 595 | |
| 596 | =item I<file.o> |
| 597 | |
| 598 | (Windows* OS: I<file.obj>) Build specified object file only. |
| 599 | |
| 600 | =item I<file.i> |
| 601 | |
| 602 | Create preprocessed source file. |
| 603 | |
| 604 | =item B<force-tests> |
| 605 | |
| 606 | Force performing tests. |
| 607 | |
| 608 | =item B<force-test-deps> |
| 609 | |
| 610 | Force performing test-deps. |
| 611 | |
| 612 | =item B<force-test-instr> |
| 613 | |
| 614 | Force performing test-instr. |
| 615 | |
| 616 | =item B<force-test-relo> |
| 617 | |
| 618 | Force performing test-relo. |
| 619 | |
| 620 | =item B<force-test-touch> |
| 621 | |
| 622 | Force performing test-touch. |
| 623 | |
| 624 | =item B<inc> |
| 625 | |
| 626 | Build Fortran include files, omp_lib.h, omp_lib.mod and omp_lib_kinds.mod. |
| 627 | |
| 628 | =item B<lib> |
| 629 | |
| 630 | Build library (on Windows* OS in case of dynamic linking, it also builds import library). |
| 631 | |
| 632 | =item B<tests> |
| 633 | |
| 634 | Perform tests: C<test-deps>, C<test-instr>, C<test-relo>, and C<test-touch>. |
| 635 | |
| 636 | =item B<test-deps> |
| 637 | |
| 638 | Check the library dependencies. |
| 639 | |
| 640 | =item B<test-instr> |
| 641 | |
| 642 | Intel(R) Many Integrated Core Architecture only: check the library does not contain undesired instructions. |
| 643 | |
| 644 | =item B<test-relo> |
| 645 | |
| 646 | Linux* OS with dynamic linking only: check the library does not contain position-dependent |
| 647 | code. |
| 648 | |
| 649 | =item B<test-touch> |
| 650 | |
| 651 | Build a very simple application with native compiler (GNU on Linux* OS and OS X*, MS |
| 652 | on Windows* OS), check it does not depend on C<libirc> library, and run it. |
| 653 | |
| 654 | =back |
| 655 | |
| 656 | =back |
| 657 | |
| 658 | =head1 DESCRIPTION |
| 659 | |
| 660 | C<build.pl> constructs the name of a build directory, creates the directory if it |
| 661 | does not exist, changes to it, and runs make to build the goals in specified configuration. |
| 662 | If more than one configuration are specified in command line C<build.pl> builds them all. |
| 663 | |
| 664 | Being run with C<clean> goal, C<build.pl> does not build but deletes export files and |
| 665 | cleans build directories of configuration specified by other options. For example, |
| 666 | C<build.pl --all clean> means "clean build directories for all configurations", |
| 667 | it does B<not> mean "clean then build all". |
| 668 | |
| 669 | C<clear-common> goal deletes common files in F<exports/> directory. |
| 670 | Since common files are really common and not architecture and/or configuration dependent, |
| 671 | there are no much meaning in combining C<clear-common> with configuration selection options. |
| 672 | For example, C<build.pl --all clean-common> deletes the same files 13 times. |
| 673 | However, it does not hurt and can be used in conjunction with C<clear> goal. |
| 674 | |
| 675 | C<clobber> goal instructs C<build.pl> to clean exports and all build |
| 676 | directories, e. g. clean everything under F<exports/> and F<tmp/> directories. |
| 677 | |
| 678 | Logs are saved automatically, there is no need in explicit output redirection. |
| 679 | Log file for each particular configuration is named F<build.log> and located in build directory. |
| 680 | Summary log file (just result of each configuration) is saved in F<tmp/> directory. |
| 681 | |
| 682 | Log files are never overwritten. C<build.pl> always appends output to log files. |
| 683 | However (obviously), C<clear> deletes log file for cleared configurations, |
| 684 | and C<clobber> deletes all summary log files. |
| 685 | |
| 686 | =head2 Environment Variables |
| 687 | |
| 688 | =over |
| 689 | |
| 690 | =item B<LIBOMP_ARCH> |
| 691 | |
| 692 | Specifies target architecture. If not present, host architecture is used. Environment variable may |
| 693 | be overriden by C<--architecture> command line option. |
| 694 | |
| 695 | =item B<LIBOMP_EXPORTS> |
| 696 | |
| 697 | Specifies directory for output files. If not set, C<$LIBOMP_WORK/exports/> used by default. |
| 698 | |
| 699 | =item B<LIBOMP_OS> |
| 700 | |
| 701 | Specifies target OS. If not present, host OS is used. Environment variable may |
| 702 | be overriden by C<--os> command line option. |
| 703 | |
| 704 | =item B<LIBOMP_TMP> |
| 705 | |
| 706 | Directory for temporary files. C<build.pl> creates build directories there. If not set, |
| 707 | C<$LIBOMP_WORK/tmp/> used by default. |
| 708 | |
| 709 | On Windows* OS F<tmp/> directory on local drive speeds up the build process. |
| 710 | |
| 711 | =item B<LIBOMP_WORK> |
| 712 | |
| 713 | Root of libomp directory tree, contains F<src/>, F<tools/>, and F<exports/> subdirs. |
| 714 | If not set, C<build.pl> guesses the root dir (it is a parent of dir containing C<build.pl>). |
| 715 | |
| 716 | Note: Guessing it not reliable. Please set C<LIBOMP_WORK> environment variable appropriately. |
| 717 | |
| 718 | =back |
| 719 | |
| 720 | =head1 EXAMPLES |
| 721 | |
| 722 | =head2 Development |
| 723 | |
| 724 | Build normal (performance) dynamic library for debugging: |
| 725 | |
| 726 | $ build.pl --debug |
| 727 | |
| 728 | Build all libraries (normal, stub; dynamic RTL) for debugging: |
| 729 | |
| 730 | $ build.pl --all --debug |
| 731 | |
| 732 | Do a clean build for all: |
| 733 | |
| 734 | $ build.pl --all --debug clean && build.pl --all --debug |
| 735 | |
| 736 | Debugging libraries are saved in F<exports/I<platform>.deb/>. |
| 737 | |
| 738 | =head2 Promotion |
| 739 | |
| 740 | =over |
| 741 | |
| 742 | =item 1 |
| 743 | |
| 744 | Clobber everything; on one machine: |
| 745 | |
| 746 | $ build.pl clobber |
| 747 | |
| 748 | =item 2 |
| 749 | |
| 750 | Build common headers, on one machine: |
| 751 | |
| 752 | $ build.pl common |
| 753 | |
| 754 | =item 3 |
| 755 | |
| 756 | Build all platform-dependent files, on all machines: |
| 757 | |
| 758 | $ build.pl --all |
| 759 | |
| 760 | =item 4 |
| 761 | |
| 762 | Build OS X* universal (fat) libraries, on C<mac_32e>: |
| 763 | |
| 764 | $ build.pl fat |
| 765 | |
| 766 | =back |
| 767 | |
| 768 | =cut |
| 769 | |
| 770 | # end of file # |