# Require $prefix, $hscpipe_ver, $workdir, $lsst_home, $patchelf_src
build_patchelf()
(
  set -e
  [[ -e "$workdir"/bin/patchelf ]] && exit 0

  source "${lsst_home}"/loadLSST.bash
  setup hscPipe "${hscpipe_ver}"

  mkdir -p "$workdir"/patchelf
  cd "$workdir"/patchelf

  curl -L "$patchelf_src" | tar xjf -
  pushd *
  ./configure --prefix="$workdir"
  make
  make install
  popd

  rm -rf "$workdir"/patchelf
)
