shlib revision 50276
1166124Srafan#!/bin/sh 2174993Srafan############################################################################## 3166124Srafan# Copyright (c) 1998 Free Software Foundation, Inc. # 4166124Srafan# # 5166124Srafan# Permission is hereby granted, free of charge, to any person obtaining a # 6166124Srafan# copy of this software and associated documentation files (the "Software"), # 7166124Srafan# to deal in the Software without restriction, including without limitation # 8166124Srafan# the rights to use, copy, modify, merge, publish, distribute, distribute # 9166124Srafan# with modifications, sublicense, and/or sell copies of the Software, and to # 10166124Srafan# permit persons to whom the Software is furnished to do so, subject to the # 11166124Srafan# following conditions: # 12166124Srafan# # 13166124Srafan# The above copyright notice and this permission notice shall be included in # 14166124Srafan# all copies or substantial portions of the Software. # 15166124Srafan# # 16166124Srafan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 17166124Srafan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 18166124Srafan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 19166124Srafan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 20166124Srafan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 21166124Srafan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 22166124Srafan# DEALINGS IN THE SOFTWARE. # 23166124Srafan# # 24166124Srafan# Except as contained in this notice, the name(s) of the above copyright # 25166124Srafan# holders shall not be used in advertising or otherwise to promote the sale, # 26166124Srafan# use or other dealings in this Software without prior written # 27166124Srafan# authorization. # 28174993Srafan############################################################################## 29166124Srafan# 3050276Speter# Author: Thomas E. Dickey <dickey@clark.net> 1996 3150276Speter# 3250276Speter# $Id: shlib,v 1.5 1998/05/31 00:29:38 mooney Exp $ 3350276Speter# Use this script as a wrapper when running executables linked to shared 3450276Speter# libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed 35166124Srafan# the soname's path within the linked executable (such as IRIX), e.g, 3650276Speter# 37166124Srafan# shlib knight 3850276Speter# 3950276Speter# Setting LD_LIBRARY_PATH, overrides/supplements the loader's normal search 4050276Speter# path, and works on most systems. The drawback is that then the environment 41166124Srafan# variable has to be set to run the programs within this directory tree. 42166124Srafan# 43166124Srafan# For Linux (and other systems using the GNU loader), we can use the rpath 4450276Speter# directive, which embeds the pathname of the library within the executable. 45166124Srafan# Using the Linux loader's rpath directive introduces a constraint, since 4650276Speter# it's embedded into the binary, and means that the binary cannot be moved 4750276Speter# around (though it'll work if the $exec_prefix convention that puts the bin 48166124Srafan# and lib directories under the same parent is followed). 4950276Speter# 5050276Speter# Using the actual soname (e.g., ../lib/libncurses.so) alone, is a more 5150276Speter# flexible solution; you can link without having to set the environment 5250276Speter# variable, and on some systems (IRIX) you can even run the resulting binaries 5350276Speter# without setting LD_LIBRARY_PATH. 54166124Srafan# 55166124Srafan# Using a conventional link, with -L and -l options on Linux results in a 56166124Srafan# statically linked executable, which we don't want at all. 5750276Speter# 58166124Srafan 59166124Srafan# 6050276Speter# Make sure that we use the PATH that was set in run_tic.sh 61166124Srafan# 62166124Srafanif test X$NEWPATH != X ; then 63166124Srafan PATH=$NEWPATH 6450276Speter export PATH 6550276Speterfi 66166124Srafan 67166124Srafanq="" 68166124Srafanfor p in lib ../lib 69166124Srafando 70166124Srafan if test -d $p; then 71166124Srafan q="$p" 72166124Srafan fi 7350276Speterdone 74166124Srafanif test -n "$q" ; then 75174993Srafan if test -n "$LD_LIBRARY_PATH"; then 76174993Srafan LD_LIBRARY_PATH="$q:$LD_LIBRARY_PATH" 77174993Srafan else 78174993Srafan LD_LIBRARY_PATH="$q" 79174993Srafan fi 80174993Srafan export LD_LIBRARY_PATH 8150276Speterfi 82166124Srafaneval "$*" 83166124Srafan