Type in OSF1 platform name.
[openssl.git] / util / shlib_wrap.sh
1 #!/bin/sh
2
3 [ $# -ne 0 ] || set -x          # debug mode without arguments:-)
4
5 THERE="`echo $0 | sed -e 's|[^/]*$||' 2>/dev/null`.."
6 [ -d "${THERE}" ] || exec "$@"  # should never happen...
7
8 # Alternative to this is to parse ${THERE}/Makefile...
9 LIBCRYPTOSO="${THERE}/libcrypto.so"
10 if [ -f "$LIBCRYPTOSO" ]; then
11     while [ -h "$LIBCRYPTOSO" ]; do
12         LIBCRYPTOSO="${THERE}/`ls -l "$LIBCRYPTOSO" | sed -e 's|.*\-> ||'`"
13     done
14     SOSUFFIX=`echo ${LIBCRYPTOSO} | sed -e 's|.*\.so||' 2>/dev/null`
15     LIBSSLSO="${THERE}/libssl.so${SOSUFFIX}"
16 fi
17
18 SYSNAME=`(uname -s) 2>/dev/null`;
19 case "$SYSNAME" in
20 SunOS|IRIX*)
21         # SunOS and IRIX run-time linkers evaluate alternative
22         # variables depending on target ABI...
23         rld_var=LD_LIBRARY_PATH
24         case "`(/usr/bin/file "$LIBCRYPTOSO") 2>/dev/null`" in
25         *ELF\ 64*SPARC*)
26                 [ -n "$LD_LIBRARY_PATH_64" ] && rld_var=LD_LIBRARY_PATH_64
27                 ;;
28         *ELF\ N32*MIPS*)
29                 [ -n "$LD_LIBRARYN32_PATH" ] && rld_var=LD_LIBRARYN32_PATH
30                 _RLDN32_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLDN32_LIST
31                 ;;
32         *ELF\ 64*MIPS*)
33                 [ -n "$LD_LIBRARY64_PATH"  ] && rld_var=LD_LIBRARY64_PATH
34                 _RLD64_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD64_LIST
35                 ;;
36         esac
37         eval $rld_var=\"${THERE}:'$'$rld_var\"; export $rld_var
38         unset rld_var
39         ;;
40 *)      LD_LIBRARY_PATH="${THERE}:$LD_LIBRARY_PATH"     # Linux, ELF HP-UX
41         DYLD_LIBRARY_PATH="${THERE}:$DYLD_LIBRARY_PATH" # MacOS X
42         SHLIB_PATH="${THERE}:$SHLIB_PATH"               # legacy HP-UX
43         LIBPATH="${THERE}:$LIBPATH"                     # AIX, OS/2
44         export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH
45         # Even though $PATH is adjusted [for Windows sake], it doesn't
46         # necessarily does the trick. Trouble is that with introduction
47         # of SafeDllSearchMode in XP/2003 it's more appropriate to copy
48         # .DLLs in vicinity of executable, which is done elsewhere...
49         if [ "$OSTYPE" != msdosdjgpp ]; then
50                 PATH="${THERE}:$PATH"; export PATH
51         fi
52         ;;
53 esac
54
55 if [ -f "$LIBCRYPTOSO" ]; then
56         # Following three lines are major excuse for isolating them into
57         # this wrapper script. Original reason for setting LD_PRELOAD
58         # was to make it possible to pass 'make test' when user linked
59         # with -rpath pointing to previous version installation. Wrapping
60         # it into a script makes it possible to do so on multi-ABI
61         # platforms.
62         case "$SYSNAME" in
63         *BSD)   LD_PRELOAD="$LIBCRYPTOSO:$LIBSSLSO" ;;  # *BSD
64         *)      LD_PRELOAD="$LIBCRYPTOSO $LIBSSLSO" ;;  # SunOS, Linux, ELF HP-UX
65         esac
66         _RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"      # Tru64, o32 IRIX
67         export LD_PRELOAD _RLD_LIST
68 fi
69
70 exec "$@"