1#!/bin/sh -e 2# test/with-shlib.sh -- make shared libhts available via $LD_LIBRARY_PATH etc. 3# 4# Copyright (C) 2020 University of Glasgow. 5# 6# Author: John Marshall <John.W.Marshall@glasgow.ac.uk> 7# 8# Permission is hereby granted, free of charge, to any person obtaining a copy 9# of this software and associated documentation files (the "Software"), to deal 10# in the Software without restriction, including without limitation the rights 11# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12# copies of the Software, and to permit persons to whom the Software is 13# furnished to do so, subject to the following conditions: 14# 15# The above copyright notice and this permission notice shall be included in 16# all copies or substantial portions of the Software. 17# 18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24# DEALINGS IN THE SOFTWARE. 25 26libdir=${0%/*}/libdir-$$.tmp 27case $libdir in 28/*) abslibdir=$libdir ;; 29*) abslibdir=$PWD/$libdir ;; 30esac 31 32# Create a directory containing *only* the shared libhts, and add it 33# to the platform-appropriate $LD_LIBRARY_PATH environment variable. 34 35mkdir $libdir 36 37case `uname -s` in 38Darwin) 39 (cd $libdir; ln -s ../../libhts.*.dylib .) 40 export DYLD_LIBRARY_PATH=$abslibdir${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH} 41 ;; 42 43*CYGWIN*) 44 (cd $libdir; ln -s ../../cyghts-*.dll .) 45 export PATH="$abslibdir${PATH:+;$PATH}" 46 ;; 47 48*MSYS*|*MINGW*) 49 (cd $libdir; cp -p ../../hts-*.dll .) 50 export PATH="$abslibdir${PATH:+;$PATH}" 51 ;; 52 53*) 54 (cd $libdir; ln -s ../../libhts.so.* .) 55 export LD_LIBRARY_PATH=$abslibdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} 56 ;; 57esac 58 59status=0 60"$@" || status=$? 61 62rm $libdir/*hts* 63rmdir $libdir 64 65exit $status 66