#%Module1.0###################################################################
#===============================================================================
# Copyright 2020 Intel Corporation
# Copyright contributors to the oneDAL project
#
# 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: oneAPI Data Analytics Library"
module-whatis "Version: $modulefilename/$modulefilever"
module-whatis "Description: Library for building compute-intense applications optimized for Intel CPUs and GPUs."
module-whatis "URL: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onedal.html"
module-whatis "Dependencies: none"

set moduleinfoname [file dirname [module-info name]]

proc ModulesHelp { } {
    global moduleinfoname
    puts "module whatis ${moduleinfoname}"
}

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

# Define environment variables needed for an isolated component install.

# Set intermediate variables
set dalroot "$componentroot"

set daal_target_arch "intel64"

# Setup environment variables
setenv          DAL_MAJOR_BINARY   1
setenv          DAL_MINOR_BINARY   1
setenv          DALROOT            "$dalroot"

prepend-path    LD_LIBRARY_PATH    "$dalroot/lib"
prepend-path    LIBRARY_PATH       "$dalroot/lib"
prepend-path    CPLUS_INCLUDE_PATH "$dalroot/include/dal"
prepend-path    CMAKE_PREFIX_PATH  "$dalroot"
prepend-path    PKG_CONFIG_PATH    "$dalroot/lib/pkgconfig"
