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