• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2{-
3    use lib '.';
4    use configdata;
5    use lib catdir($config{sourcedir}, 'Configurations');
6    use platform;
7-}
8# To test this OpenSSL version's applications against another version's
9# shared libraries, simply set
10#
11#     OPENSSL_REGRESSION=/path/to/other/OpenSSL/build/tree
12if [ -n "$OPENSSL_REGRESSION" ]; then
13    shlibwrap="$OPENSSL_REGRESSION/util/shlib_wrap.sh"
14    if [ -x "$shlibwrap" ]; then
15        # We clear OPENSSL_REGRESSION to avoid a loop, should the shlib_wrap.sh
16        # we exec also support that mechanism...
17        OPENSSL_REGRESSION= exec "$shlibwrap" "$@"
18    else
19        if [ -f "$shlibwrap" ]; then
20            echo "Not permitted to run $shlibwrap" >&2
21        else
22            echo "No $shlibwrap, perhaps OPENSSL_REGRESSION isn't properly set?" >&2
23        fi
24        exit 1
25    fi
26fi
27
28[ $# -ne 0 ] || set -x		# debug mode without arguments:-)
29
30THERE="`echo $0 | sed -e 's|[^/]*$||' 2>/dev/null`.."
31[ -d "${THERE}" ] || exec "$@"	# should never happen...
32
33LIBCRYPTOSO="${THERE}/{- platform->sharedlib('libcrypto') -}"
34LIBSSLSO="${THERE}/{- platform->sharedlib('libssl') -}"
35
36SYSNAME=`(uname -s) 2>/dev/null`;
37case "$SYSNAME" in
38SunOS|IRIX*)
39	# SunOS and IRIX run-time linkers evaluate alternative
40	# variables depending on target ABI...
41	rld_var=LD_LIBRARY_PATH
42	case "`(/usr/bin/file "$LIBCRYPTOSO") 2>/dev/null`" in
43	*ELF\ 64*SPARC*|*ELF\ 64*AMD64*)
44		[ -n "$LD_LIBRARY_PATH_64" ] && rld_var=LD_LIBRARY_PATH_64
45		LD_PRELOAD_64="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_64
46		preload_var=LD_PRELOAD_64
47		;;
48	*ELF\ 32*SPARC*|*ELF\ 32*80386*)
49		# We only need to change LD_PRELOAD_32 and LD_LIBRARY_PATH_32
50		# on a multi-arch system.  Otherwise, trust the fallbacks.
51		if [ -f /lib/64/ld.so.1 ]; then
52		    [ -n "$LD_LIBRARY_PATH_32" ] && rld_var=LD_LIBRARY_PATH_32
53		    LD_PRELOAD_32="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_32
54		    preload_var=LD_PRELOAD_32
55		fi
56		;;
57	# Why are newly built .so's preloaded anyway? Because run-time
58	# .so lookup path embedded into application takes precedence
59	# over LD_LIBRARY_PATH and as result application ends up linking
60	# to previously installed .so's. On IRIX instead of preloading
61	# newly built .so's we trick run-time linker to fail to find
62	# the installed .so by setting _RLD_ROOT variable.
63	*ELF\ 32*MIPS*)
64		#_RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD_LIST
65		_RLD_ROOT=/no/such/dir; export _RLD_ROOT
66		eval $rld_var=\"/usr/lib'${'$rld_var':+:$'$rld_var'}'\"
67		preload_var=_RLD_LIST
68		;;
69	*ELF\ N32*MIPS*)
70		[ -n "$LD_LIBRARYN32_PATH" ] && rld_var=LD_LIBRARYN32_PATH
71		#_RLDN32_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLDN32_LIST
72		_RLDN32_ROOT=/no/such/dir; export _RLDN32_ROOT
73		eval $rld_var=\"/usr/lib32'${'$rld_var':+:$'$rld_var'}'\"
74		preload_var=_RLDN32_LIST
75		;;
76	*ELF\ 64*MIPS*)
77		[ -n "$LD_LIBRARY64_PATH"  ] && rld_var=LD_LIBRARY64_PATH
78		#_RLD64_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD64_LIST
79		_RLD64_ROOT=/no/such/dir; export _RLD64_ROOT
80		eval $rld_var=\"/usr/lib64'${'$rld_var':+:$'$rld_var'}'\"
81		preload_var=_RLD64_LIST
82		;;
83	esac
84	eval $rld_var=\"${THERE}'${'$rld_var':+:$'$rld_var'}'\"; export $rld_var
85	unset rld_var
86	;;
87NONSTOP_KERNEL)
88	# HPE NonStop has a proprietary mechanism for specifying
89	# the location of DLLs. It does not use PATH or variables
90	# commonly used on other platforms. The platform has a limited
91	# environment space keeping extraneous variables to a minimum
92	# is recommended.
93	_RLD_LIB_PATH="${THERE}:$LD_LIBRARY_PATH"
94	export _RLD_LIB_PATH
95	;;
96*)	LD_LIBRARY_PATH="${THERE}:$LD_LIBRARY_PATH"	# Linux, ELF HP-UX
97	DYLD_LIBRARY_PATH="${THERE}:$DYLD_LIBRARY_PATH"	# MacOS X
98	SHLIB_PATH="${THERE}:$SHLIB_PATH"		# legacy HP-UX
99	LIBPATH="${THERE}:$LIBPATH"			# AIX, OS/2
100	export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH
101	# Even though $PATH is adjusted [for Windows sake], it doesn't
102	# necessarily does the trick. Trouble is that with introduction
103	# of SafeDllSearchMode in XP/2003 it's more appropriate to copy
104	# .DLLs in vicinity of executable, which is done elsewhere...
105	if [ "$OSTYPE" != msdosdjgpp ]; then
106		PATH="${THERE}:$PATH"; export PATH
107	fi
108	;;
109esac
110
111{- output_off() unless grep (/-rpath\b/, @{$config{LDFLAGS}}); ""; -}
112if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
113	# Following three lines are major excuse for isolating them into
114	# this wrapper script. Original reason for setting LD_PRELOAD
115	# was to make it possible to pass 'make test' when user linked
116	# with -rpath pointing to previous version installation. Wrapping
117	# it into a script makes it possible to do so on multi-ABI
118	# platforms.
119	case "$SYSNAME" in
120	*BSD)	LD_PRELOAD="$LIBCRYPTOSO:$LIBSSLSO" ;;	# *BSD
121	*)	LD_PRELOAD="$LIBCRYPTOSO $LIBSSLSO" ;;	# SunOS, Linux, ELF HP-UX
122	esac
123	_RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"	# Tru64, o32 IRIX
124	DYLD_INSERT_LIBRARIES="$LIBCRYPTOSO:$LIBSSLSO"	# MacOS X
125	export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES
126fi
127{- output_on() unless grep (/-rpath\b/, @{$config{LDFLAGS}}); ""; -}
128
129cmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}"
130shift
131if [ $# -eq 0 ]; then
132	exec "$cmd"	# old sh, such as Tru64 4.x, fails to expand empty "$@"
133else
134	exec "$cmd" "$@"
135fi
136