#%Module1.0###################################################################
#
# Copyright (c) 2020-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This modulefile requires Environment Modules 4.1 or later.
# Type `module --version` to determine the current installed version.

##############################################################################

set min_tcl_ver 8.4
if { $tcl_version < $min_tcl_ver } {
    puts stderr " "
    puts stderr "ERROR: This modulefile requires tcl $min_tcl_ver or greater."
    puts stderr "Your system reports that tclsh version $tcl_version is installed."
    exit 1
}

# if modulefile script name is a symlink, resolve it to get the fully
# qualified pathname that points to the actual modulefile script
# see: https://wiki.tcl-lang.org/page/file+normalize
set scriptpath "${ModulesCurrentModulefile}"
set scriptpath "[file dirname [file normalize "$scriptpath/___"]]"

# define componentroot, modulefilepath, modulefilename and modulefilever
set modulefilename "[file tail [file dirname "${scriptpath}"]]"
set modulefilever "[file tail "${scriptpath}"]"
set modulefilepath "${scriptpath}"
set componentroot "[file dirname [file dirname [file dirname [file dirname "${scriptpath}"]]]]"

##############################################################################

module-whatis "Name: Intel(R) oneAPI Threading Building Blocks"
module-whatis "Version: $modulefilename/$modulefilever"
module-whatis "Description: Flexible threading library for adding parallelism to complex applications across accelerated architectures."
module-whatis "URL: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html"
module-whatis "Dependencies: none"

proc ModulesHelp { } {
    global modulefilename
    global modulefilever
    puts "module whatis ${modulefilename}/${modulefilever}"
}

##############################################################################

# Define environment variables needed for an isolated component install.

set tbbroot "$componentroot"
set tbb_target_arch "ia32"

setenv TBBROOT "$tbbroot"

prepend-path CPATH "$tbbroot/include32:$tbbroot/include"
prepend-path LIBRARY_PATH "$tbbroot/lib32"
prepend-path LD_LIBRARY_PATH "$tbbroot/lib32"
prepend-path CMAKE_PREFIX_PATH "$tbbroot"
prepend-path PKG_CONFIG_PATH "$tbbroot/lib32/pkgconfig"
