3 # To test this OpenSSL version's applications against another version's
4 # shared libraries, simply set
6 # OPENSSL_REGRESSION=/path/to/other/OpenSSL/build/tree
7 if [ -n "$OPENSSL_REGRESSION" ]; then
8 shlibwrap
="$OPENSSL_REGRESSION/util/shlib_wrap.sh"
9 if [ -x "$shlibwrap" ]; then
10 # We clear OPENSSL_REGRESSION to avoid a loop, should the shlib_wrap.sh
11 # we exec also support that mechanism...
12 OPENSSL_REGRESSION
= exec "$shlibwrap" "$@"
14 if [ -f "$shlibwrap" ]; then
15 echo "Not permitted to run $shlibwrap" >&2
17 echo "No $shlibwrap, perhaps OPENSSL_REGRESSION isn't properly set?" >&2
23 [ $# -ne 0 ] ||
set -x # debug mode without arguments:-)
25 THERE
="`echo $0 | sed -e 's|[^/]*$||' 2>/dev/null`.."
26 [ -d "${THERE}" ] ||
exec "$@" # should never happen...
28 # Alternative to this is to parse ${THERE}/Makefile...
29 LIBCRYPTOSO
="${THERE}/libcrypto.so"
30 if [ -f "$LIBCRYPTOSO" ]; then
31 while [ -h "$LIBCRYPTOSO" ]; do
32 LIBCRYPTOSO
="${THERE}/`ls -l "$LIBCRYPTOSO" | sed -e 's|.*\-> ||'`"
34 SOSUFFIX
=`echo ${LIBCRYPTOSO} | sed -e 's|.*\.so||' 2>/dev/null`
35 LIBSSLSO
="${THERE}/libssl.so${SOSUFFIX}"
38 SYSNAME
=`(uname -s) 2>/dev/null`;
41 # SunOS and IRIX run-time linkers evaluate alternative
42 # variables depending on target ABI...
43 rld_var
=LD_LIBRARY_PATH
44 case "`(/usr/bin/file "$LIBCRYPTOSO") 2>/dev/null`" in
45 *ELF\
64*SPARC
*|
*ELF\
64*AMD64
*)
46 [ -n "$LD_LIBRARY_PATH_64" ] && rld_var
=LD_LIBRARY_PATH_64
47 LD_PRELOAD_64
="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_64
48 preload_var
=LD_PRELOAD_64
50 *ELF\
32*SPARC
*|
*ELF\
32*80386*)
51 # We only need to change LD_PRELOAD_32 and LD_LIBRARY_PATH_32
52 # on a multi-arch system. Otherwise, trust the fallbacks.
53 if [ -f /lib
/64/ld.so
.1 ]; then
54 [ -n "$LD_LIBRARY_PATH_32" ] && rld_var
=LD_LIBRARY_PATH_32
55 LD_PRELOAD_32
="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_32
56 preload_var
=LD_PRELOAD_32
59 # Why are newly built .so's preloaded anyway? Because run-time
60 # .so lookup path embedded into application takes precedence
61 # over LD_LIBRARY_PATH and as result application ends up linking
62 # to previously installed .so's. On IRIX instead of preloading
63 # newly built .so's we trick run-time linker to fail to find
64 # the installed .so by setting _RLD_ROOT variable.
66 #_RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD_LIST
67 _RLD_ROOT
=/no
/such
/dir
; export _RLD_ROOT
68 eval $rld_var=\"/usr
/lib
'${'$rld_var':+:$'$rld_var'}'\"
72 [ -n "$LD_LIBRARYN32_PATH" ] && rld_var
=LD_LIBRARYN32_PATH
73 #_RLDN32_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLDN32_LIST
74 _RLDN32_ROOT
=/no
/such
/dir
; export _RLDN32_ROOT
75 eval $rld_var=\"/usr
/lib32
'${'$rld_var':+:$'$rld_var'}'\"
76 preload_var
=_RLDN32_LIST
79 [ -n "$LD_LIBRARY64_PATH" ] && rld_var
=LD_LIBRARY64_PATH
80 #_RLD64_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD64_LIST
81 _RLD64_ROOT
=/no
/such
/dir
; export _RLD64_ROOT
82 eval $rld_var=\"/usr
/lib64
'${'$rld_var':+:$'$rld_var'}'\"
83 preload_var
=_RLD64_LIST
86 eval $rld_var=\"${THERE}'${'$rld_var':+:$'$rld_var'}'\"; export $rld_var
89 *) LD_LIBRARY_PATH
="${THERE}:$LD_LIBRARY_PATH" # Linux, ELF HP-UX
90 DYLD_LIBRARY_PATH
="${THERE}:$DYLD_LIBRARY_PATH" # MacOS X
91 SHLIB_PATH
="${THERE}:$SHLIB_PATH" # legacy HP-UX
92 LIBPATH
="${THERE}:$LIBPATH" # AIX, OS/2
93 export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH
94 # Even though $PATH is adjusted [for Windows sake], it doesn't
95 # necessarily does the trick. Trouble is that with introduction
96 # of SafeDllSearchMode in XP/2003 it's more appropriate to copy
97 # .DLLs in vicinity of executable, which is done elsewhere...
98 if [ "$OSTYPE" != msdosdjgpp
]; then
99 PATH
="${THERE}:$PATH"; export PATH
104 {- output_off
() unless
grep (/-rpath\b/, @
{$config{LDFLAGS
}}); ""; -}
105 if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
106 # Following three lines are major excuse for isolating them into
107 # this wrapper script. Original reason for setting LD_PRELOAD
108 # was to make it possible to pass 'make test' when user linked
109 # with -rpath pointing to previous version installation. Wrapping
110 # it into a script makes it possible to do so on multi-ABI
113 *BSD
) LD_PRELOAD
="$LIBCRYPTOSO:$LIBSSLSO" ;; # *BSD
114 *) LD_PRELOAD
="$LIBCRYPTOSO $LIBSSLSO" ;; # SunOS, Linux, ELF HP-UX
116 _RLD_LIST
="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT" # Tru64, o32 IRIX
117 DYLD_INSERT_LIBRARIES
="$LIBCRYPTOSO:$LIBSSLSO" # MacOS X
118 export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES
120 {- output_on
() unless
grep (/-rpath\b/, @
{$config{LDFLAGS
}}); ""; -}
122 cmd
="$1"; [ -x "$cmd" ] || cmd
="$cmd${EXE_EXT}"
124 if [ $# -eq 0 ]; then
125 exec "$cmd" # old sh, such as Tru64 4.x, fails to expand empty "$@"