#!/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-activate"; then
  (>&2 printf "\nError:\tkim-api-activate must be sourced.\n"
   printf "\tRun 'source kim-api-activate' not "
   printf "'kim-api-activate'.\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="${ORIGIN}:${PATH}"
if test -n "${PKG_CONFIG_PATH+x}"; then export PKG_CONFIG_PATH=":${PKG_CONFIG_PATH}"; fi
_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=${_libdir_rel}/pkgconfig${PKG_CONFIG_PATH}
unset _libdir_rel
_installdir_rel=$(cd "${ORIGIN}/../" && pwd)
export KIM_API_CMAKE_PREFIX_DIR=${_installdir_rel}
unset _installdir_rel

if test -n "${ZSH_VERSION}"; then
  source "${ORIGIN}/../etc/zsh_completion.d/_kim-api-collections-management"
else
  source "${ORIGIN}/../etc/bash_completion.d/kim-api-collections-management.bash"
fi

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