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