#!/bin/sh
#

#
# KIM-API: An API for interatomic models
# Copyright (c) 2013--2022, Regents of the University of Minnesota.
# All rights reserved.
#
# Contributors:
#    Ryan S. Elliott
#    Yaser Afshar
#
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#

#
# Release: This file is part of the kim-api-2.4.2 package.
#


# Ensure that this script is sourced, not executed
BASENAME_SOURCE=`basename -- "$0" 2> /dev/null`

if test -n "${ZSH_VERSION}"; then
  if test $options[posixargzero] != "on"; then
    setopt posixargzero
    BASENAME_SOURCE=`basename -- "$0" 2> /dev/null`
    setopt posixargzero
  fi
fi

if test x"${BASENAME_SOURCE}" = x"kim-api-deactivate"; then
  (>&2 printf "\nError:\tkim-api-deactivate must be sourced.\n"
   printf "\tRun 'source kim-api-deactivate' not "
   printf "'kim-api-deactivate'.\n\n")
  exit 1
fi


if test -n "${ORIGIN}"; then
  OLD_KIM_ORIGIN="${ORIGIN}"
fi
if test -n "${ZSH_VERSION}"; then
  ORIGIN=$(cd "$(dirname "${(%):-%x}")" && pwd)
else
  # Get ORIGIN location of this script:
  SOURCE="${BASH_SOURCE[0]}"
  # https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
  if command -v readlink >/dev/null 2>&1; then
    while test -h "$SOURCE"; do # resolve $SOURCE until the file is no longer a symlink
      DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
      SOURCE="$(readlink "$SOURCE")"
      [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    done
  fi
  ORIGIN="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
fi

export PATH=`printf "${PATH}" | sed -e "s|:${ORIGIN}|:|g" \
                                    -e "s|^${ORIGIN}:*||" \
                                    -e "s|:${ORIGIN}$||"`
_libdir_rel=$(cd "/Users/runner/miniforge3/conda-bld/kim-api_1772803436465/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/lib" && pwd)
export PKG_CONFIG_PATH=`printf "${PKG_CONFIG_PATH}" | \
                                sed -e "s|:${_libdir_rel}/pkgconfig|:|g" \
                                    -e "s|^${_libdir_rel}/pkgconfig:*||" \
                                    -e "s|:${_libdir_rel}/pkgconfig$||"`
unset _libdir_rel
if test -z "${PKG_CONFIG_PATH}"; then unset PKG_CONFIG_PATH; fi

unset KIM_API_CMAKE_PREFIX_DIR

if test -n "${ZSH_VERSION}"; then
  _completion_dir="${ORIGIN}/../etc/zsh_completion.d"
else
  _completion_dir="${ORIGIN}/../etc/bash_completion.d"
fi

for _func in `grep "_kim_api_.*[[:space:]]*()" \
    "${_completion_dir}/kim-api-collections-management.bash"`; do
  _func=`printf "${_func}" | sed -e 's|[[:space:]]*().*||'`
  unset -f "${_func}"
done

unset _func
unset _completion_dir

if test -n "${OLD_KIM_ORIGIN}"; then
  ORIGIN="${OLD_KIM_ORIGIN}"
  unset OLD_KIM_ORIGIN
else
  unset ORIGIN
fi
