1#!/bin/sh
2
3readlink() {
4    local path=$1 ll
5
6    if [ -L "$path" ]; then
7        ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
8        echo "${ll##* -> }"
9    else
10        return 1
11    fi
12}
13
14script=$0
15count=0
16while [ -L "$script" ]
17do
18    script=$(readlink "$script")
19    count=`expr $count + 1`
20    if [ $count -gt 100 ]
21    then
22        echo "Too many symbolic links"
23        exit 1
24    fi
25done
26cd "`dirname $script`"
27
28
29lib=lib
30test -e lib64 && lib=lib64
31
32if test "x$LD_LIBRARY_PATH" = x; then
33	LD_LIBRARY_PATH="`pwd`/$lib"
34else
35	LD_LIBRARY_PATH="`pwd`/$lib:$LD_LIBRARY_PATH"
36fi
37export LD_LIBRARY_PATH
38
39archs=`uname -m`
40case "$archs" in
41	i?86) archs=i386 ;;
42	x86_64) archs="x86_64 i386" ;;
43#	ppc64) archs="ppc64 ppc" ;;
44esac
45
46for arch in $archs; do
47	test -x ./wop-engine.$arch || continue
48	exec ./wop-engine.$arch "$@"
49done
50echo "could not execute wop-engine" >&2
51