xref: /aoo42x/main/solenv/bin/checkdll.sh (revision fce70c9b)
1cdf0e10cSrcweir#! /bin/sh
2*fce70c9bSAndrew Rist#**************************************************************
3*fce70c9bSAndrew Rist#
4*fce70c9bSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5*fce70c9bSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6*fce70c9bSAndrew Rist#  distributed with this work for additional information
7*fce70c9bSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8*fce70c9bSAndrew Rist#  to you under the Apache License, Version 2.0 (the
9*fce70c9bSAndrew Rist#  "License"); you may not use this file except in compliance
10*fce70c9bSAndrew Rist#  with the License.  You may obtain a copy of the License at
11*fce70c9bSAndrew Rist#
12*fce70c9bSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*fce70c9bSAndrew Rist#
14*fce70c9bSAndrew Rist#  Unless required by applicable law or agreed to in writing,
15*fce70c9bSAndrew Rist#  software distributed under the License is distributed on an
16*fce70c9bSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*fce70c9bSAndrew Rist#  KIND, either express or implied.  See the License for the
18*fce70c9bSAndrew Rist#  specific language governing permissions and limitations
19*fce70c9bSAndrew Rist#  under the License.
20*fce70c9bSAndrew Rist#
21*fce70c9bSAndrew Rist#**************************************************************
22cdf0e10cSrcweir# checkdll.sh - execute checkdll with all -L arguments to this script
23cdf0e10cSrcweir#               prepended to LD_LIBRARY_PATH
24cdf0e10cSrcweir
25cdf0e10cSrcweirset -- `getopt "L:" "$@"` ||  {
26cdf0e10cSrcweir    echo "Usage: `basename $0` [-L library_path] <shared_library>" 1>&2
27cdf0e10cSrcweir    exit 1
28cdf0e10cSrcweir}
29cdf0e10cSrcweir
30cdf0e10cSrcweircheckdll="$SOLARVERSION/$INPATH/bin$UPDMINOREXT/checkdll"
31cdf0e10cSrcweir
32cdf0e10cSrcweirif [ -x $checkdll ]; then
33cdf0e10cSrcweir    while :
34cdf0e10cSrcweir    do
35cdf0e10cSrcweir	case $1 in
36cdf0e10cSrcweir	    -L) shift; option=$1;;
37cdf0e10cSrcweir	    --) break;;
38cdf0e10cSrcweir	esac
39cdf0e10cSrcweir	case "${libpath:+X}" in
40cdf0e10cSrcweir	    X) libpath=$libpath:$option;;
41cdf0e10cSrcweir	    *) libpath=$option;;
42cdf0e10cSrcweir	esac
43cdf0e10cSrcweir	shift
44cdf0e10cSrcweir    done
45cdf0e10cSrcweir    shift  # remove the trailing ---
46cdf0e10cSrcweir
47cdf0e10cSrcweir    case `uname -s` in
48cdf0e10cSrcweir    Darwin) case "${DYLD_LIBRARY_PATH:+X}" in
49cdf0e10cSrcweir	    X) DYLD_LIBRARY_PATH=$libpath:$DYLD_LIBRARY_PATH;;
50cdf0e10cSrcweir	    *) DYLD_LIBRARY_PATH=$libpath;;
51cdf0e10cSrcweir        esac
52cdf0e10cSrcweir        export DYLD_LIBRARY_PATH;;
53cdf0e10cSrcweir	*)  case "${LD_LIBRARY_PATH:+X}" in
54cdf0e10cSrcweir	    X) LD_LIBRARY_PATH=$libpath:$LD_LIBRARY_PATH;;
55cdf0e10cSrcweir	    *) LD_LIBRARY_PATH=$libpath;;
56cdf0e10cSrcweir        esac
57cdf0e10cSrcweir        export LD_LIBRARY_PATH;;
58cdf0e10cSrcweir    esac
59cdf0e10cSrcweir
60cdf0e10cSrcweir    $checkdll "$@"
61cdf0e10cSrcweir    if [ $? -ne 0 ]; then exit 1 ; fi
62cdf0e10cSrcweir
63cdf0e10cSrcweir    for parameter in $*; do
64cdf0e10cSrcweir        library=$parameter;
65cdf0e10cSrcweir    done
66cdf0e10cSrcweir    realname=`echo $library | sed "s/check_//"`
67cdf0e10cSrcweir    if [ $library != $realname ]; then
68cdf0e10cSrcweir		LD_LIBRARY_PATH=
69cdf0e10cSrcweir		export LD_LIBRARY_PATH
70cdf0e10cSrcweir        mv $library $realname
71cdf0e10cSrcweir    fi
72cdf0e10cSrcweirelse
73cdf0e10cSrcweir	echo "WARNING: checkdll not found!" 1>&2
74cdf0e10cSrcweirfi
75cdf0e10cSrcweir
76cdf0e10cSrcweirexit 0
77cdf0e10cSrcweir
78