#!/bin/bash

set -e

# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
do_ldconfig() {
  if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
    echo @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/x86_64-libhsakmt.conf
    ldconfig
  fi
}

case "$1" in
  ( configure )
    do_ldconfig
  ;;
  ( abort-upgrade | abort-remove | abort-deconfigure )
    echo "$1"
  ;;
  ( * )
    exit 0
  ;;
esac
