Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 1 | # |
| 2 | #//===----------------------------------------------------------------------===// |
| 3 | #// |
| 4 | #// The LLVM Compiler Infrastructure |
| 5 | #// |
| 6 | #// This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | #// Source Licenses. See LICENSE.txt for details. |
| 8 | #// |
| 9 | #//===----------------------------------------------------------------------===// |
| 10 | # |
| 11 | package LibOMP; |
| 12 | |
| 13 | use strict; |
| 14 | use warnings; |
| 15 | |
| 16 | use tools; |
| 17 | |
| 18 | sub empty($) { |
| 19 | my ( $var ) = @_; |
Andrey Churbanov | 42211eb | 2016-07-08 14:35:41 +0000 | [diff] [blame] | 20 | return (not exists($ENV{$var})) or (not defined($ENV{$var})) or ($ENV{$var} eq ""); |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 21 | }; # sub empty |
| 22 | |
| 23 | my ( $base, $out, $tmp ); |
| 24 | if ( empty( "LIBOMP_WORK" ) ) { |
| 25 | # $FindBin::Bin is not used intentionally because it gives real path. I want to use absolute, |
| 26 | # but not real one (real path does not contain symlinks while absolute path may contain |
| 27 | # symlinks). |
| 28 | $base = get_dir( get_dir( abs_path( $0 ) ) ); |
| 29 | } else { |
| 30 | $base = abs_path( $ENV{ LIBOMP_WORK } ); |
| 31 | }; # if |
| 32 | |
| 33 | if ( empty( "LIBOMP_EXPORTS" ) ) { |
| 34 | $out = cat_dir( $base, "exports" ); |
| 35 | } else { |
| 36 | $out = abs_path( $ENV{ LIBOMP_EXPORTS } ); |
| 37 | }; # if |
| 38 | |
| 39 | if ( empty( "LIBOMP_TMP" ) ) { |
| 40 | $tmp = cat_dir( $base, "tmp" ); |
| 41 | } else { |
| 42 | $tmp = abs_path( $ENV{ LIBOMP_TMP } ); |
| 43 | }; # if |
| 44 | |
| 45 | $ENV{ LIBOMP_WORK } = $base; |
| 46 | $ENV{ LIBOMP_EXPORTS } = $out; |
| 47 | $ENV{ LIBOMP_TMP } = $tmp; |
| 48 | |
| 49 | return 1; |
| 50 | |
| 51 | __END__ |
| 52 | |
| 53 | =pod |
| 54 | |
| 55 | =head1 NAME |
| 56 | |
| 57 | B<LibOMP.pm> -- |
| 58 | |
| 59 | =head1 SYNOPSIS |
| 60 | |
| 61 | use FindBin; |
| 62 | use lib "$FindBin::Bin/lib"; |
| 63 | use LibOMP; |
| 64 | |
| 65 | $ENV{ LIBOMP_WORK } |
| 66 | $ENV{ LIBOMP_TMP } |
| 67 | $ENV{ LIBOMP_EXPORTS } |
| 68 | |
| 69 | =head1 DESCRIPTION |
| 70 | |
| 71 | The module checks C<LIBOMP_WORK>, C<LIBOMP_EXPORTS>, and C<LIBOMP_TMP> environments variables. |
| 72 | If a variable set, the module makes sure it is absolute. If a variable does not exist, the module |
| 73 | sets it to default value. |
| 74 | |
| 75 | Default value for C<LIBOMP_EXPORTS> is C<$LIBOMP_WORK/exports>, for C<LIBOMP_TMP> -- |
| 76 | C<$LIBOMP_WORK/tmp>. |
| 77 | |
| 78 | Value for C<LIBOMP_WORK> is guessed. The module assumes the script (which uses the module) is |
| 79 | located in C<tools/> directory of libomp directory tree, and uses path of the script to calculate |
| 80 | C<LIBOMP_WORK>, |
| 81 | |
| 82 | =cut |
| 83 | |
| 84 | # end of file # |
| 85 | |