blob: 012767e161e15d22f47a1cdb89ce44570a83f1ac [file] [log] [blame]
Jim Cownie5e8470a2013-09-27 10:38:44 +00001#
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#
11package LibOMP;
12
13use strict;
14use warnings;
15
16use tools;
17
18sub empty($) {
19 my ( $var ) = @_;
Andrey Churbanov42211eb2016-07-08 14:35:41 +000020 return (not exists($ENV{$var})) or (not defined($ENV{$var})) or ($ENV{$var} eq "");
Jim Cownie5e8470a2013-09-27 10:38:44 +000021}; # sub empty
22
23my ( $base, $out, $tmp );
24if ( 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
33if ( empty( "LIBOMP_EXPORTS" ) ) {
34 $out = cat_dir( $base, "exports" );
35} else {
36 $out = abs_path( $ENV{ LIBOMP_EXPORTS } );
37}; # if
38
39if ( 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
49return 1;
50
51__END__
52
53=pod
54
55=head1 NAME
56
57B<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
71The module checks C<LIBOMP_WORK>, C<LIBOMP_EXPORTS>, and C<LIBOMP_TMP> environments variables.
72If a variable set, the module makes sure it is absolute. If a variable does not exist, the module
73sets it to default value.
74
75Default value for C<LIBOMP_EXPORTS> is C<$LIBOMP_WORK/exports>, for C<LIBOMP_TMP> --
76C<$LIBOMP_WORK/tmp>.
77
78Value for C<LIBOMP_WORK> is guessed. The module assumes the script (which uses the module) is
79located in C<tools/> directory of libomp directory tree, and uses path of the script to calculate
80C<LIBOMP_WORK>,
81
82=cut
83
84# end of file #
85