#! /bin/tcsh
#
# Copyright 1999-2019 Intel Corporation All Rights Reserved.
# 
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title
# to such Material remains with Intel Corporation or its suppliers or
# licensors. The Material contains proprietary information of Intel
# or its suppliers and licensors. The Material is protected by worldwide
# copyright laws and treaty provisions. No part of the Material may be used,
# copied, reproduced, modified, published, uploaded, posted, transmitted,
# distributed or disclosed in any way without Intel's prior express written
# permission. No license under any patent, copyright or other intellectual
# property rights in the Material is granted to or conferred upon you,
# either expressly, by implication, inducement, estoppel or otherwise.
# Any license under such intellectual property rights must be express and
# approved by Intel in writing.
# 
# Unless otherwise agreed by Intel in writing,
# you may not remove or alter this notice or any other notice embedded in
# Materials by Intel or Intel's suppliers or licensors in any way.
#

setenv IPPROOT /s/intelcompilers-2019/amd64_rhel6/compilers_and_libraries_2019.5.281/linux/ipp

set __ipp_tmp_target_arch=""
set __ipp_tmp_target_platform=""

if ( $#argv == 0 ) then
  if ($?COMPILERVARS_ARCHITECTURE) then
    set __ipp_tmp_target_arch=$COMPILERVARS_ARCHITECTURE
  endif
  if ($?COMPILERVARS_PLATFORM) then
    set __ipp_tmp_target_platform=$COMPILERVARS_PLATFORM
  endif
endif

while ( "$1" != "" )
  if ( "$1" == "ia32" || "$1" == "intel64" ) then
    set __ipp_tmp_target_arch="$1"
  else if ( "$1" == "android" ) then
    set __ipp_tmp_target_platform="$1"
  endif
  shift
end

if ( "$__ipp_tmp_target_arch" != "ia32" && \
     "$__ipp_tmp_target_arch" != "intel64" ) \
then
  echo "ERROR: architecture is not defined. Accepted values: ia32, intel64"
  goto Help
else

  if !($?CPATH) then
    setenv CPATH ${IPPROOT}/include
  else
    setenv CPATH ${IPPROOT}/include:${CPATH}
  endif

  setenv arch $__ipp_tmp_target_arch

  if ( "$__ipp_tmp_target_platform" == "android" ) then 
    setenv arch ${__ipp_tmp_target_arch}_and
  endif

  if !($?LD_LIBRARY_PATH) then
    setenv LD_LIBRARY_PATH $IPPROOT/lib/${arch}
  else
    setenv LD_LIBRARY_PATH $IPPROOT/lib/${arch}:${LD_LIBRARY_PATH}
  endif

  if !($?LIBRARY_PATH) then
    setenv LIBRARY_PATH $IPPROOT/lib/${arch}
  else
    setenv LIBRARY_PATH $IPPROOT/lib/${arch}:${LIBRARY_PATH}
  endif
endif

goto End

Help:
  echo "Syntax: ippvars.csh <arch> [-arch <arch>] [-platform <platform>]"
  echo ""
  echo "  <arch> must be one of the following:"
  echo "      ia32           : Set up for IA-32 target."
  echo "      intel64        : Set up for Intel(R)64 target."
  echo "  <platform> must be of the following:"
  echo "      linux          : Set to Linux target."
  echo "      mac            : Set to Mac target."
  echo "      android        : Set to Android target."
  echo ""
  echo "If the arguments to the sourced script are ignored (consult docs"
  echo "for your shell) the alternative way to specify target is environment"
  echo "variables COMPILERVARS_ARCHITECTURE to pass <arch> to the script"
  echo "and COMPILERVARS_PLATFORM to pass <platform>"

  exit 1;

End:
  unset __ipp_tmp_target_arch
  unset __ipp_tmp_target_platform

