Blame build/instdso.sh

Packit 90a5c9
#!/bin/sh
Packit 90a5c9
#
Packit 90a5c9
# Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
# contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
# this work for additional information regarding copyright ownership.
Packit 90a5c9
# The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
# (the "License"); you may not use this file except in compliance with
Packit 90a5c9
# the License.  You may obtain a copy of the License at
Packit 90a5c9
#
Packit 90a5c9
#     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
#
Packit 90a5c9
# Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
# distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
# See the License for the specific language governing permissions and
Packit 90a5c9
# limitations under the License.
Packit 90a5c9
#
Packit 90a5c9
#
Packit 90a5c9
# instdso.sh - install Apache DSO modules
Packit 90a5c9
#
Packit 90a5c9
# we use this instead of libtool --install because:
Packit 90a5c9
# 1) on a few platforms libtool doesn't install DSOs exactly like we'd
Packit 90a5c9
#    want (weird names, doesn't remove DSO first)
Packit 90a5c9
# 2) we never want the .la files copied, so we might as well copy
Packit 90a5c9
#    the .so files ourselves
Packit 90a5c9
Packit 90a5c9
if test "$#" != "3"; then
Packit 90a5c9
    echo "wrong number of arguments to instdso.sh"
Packit 90a5c9
    echo "Usage: instdso.sh SH_LIBTOOL-value dso-name path-to-modules"
Packit 90a5c9
    exit 1
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
SH_LIBTOOL=`echo $1 | sed -e 's/^SH_LIBTOOL=//'`
Packit 90a5c9
DSOARCHIVE=$2
Packit 90a5c9
DSOARCHIVE_BASENAME=`basename $2`
Packit 90a5c9
TARGETDIR=$3
Packit 90a5c9
DSOBASE=`echo $DSOARCHIVE_BASENAME | sed -e 's/\.la$//'`
Packit 90a5c9
TARGET_NAME="$DSOBASE.so"
Packit 90a5c9
Packit 90a5c9
SYS=`uname -s`
Packit 90a5c9
Packit 90a5c9
if test "$SYS" = "AIX"
Packit 90a5c9
then
Packit 90a5c9
    # on AIX, shared libraries remain in storage even when
Packit 90a5c9
    # all processes using them have exited; standard practice
Packit 90a5c9
    # prior to installing a shared library is to rm -f first
Packit 90a5c9
    CMD="rm -f $TARGETDIR/$TARGET_NAME"
Packit 90a5c9
    echo $CMD
Packit 90a5c9
    $CMD || exit $?
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
case $SYS in
Packit 90a5c9
    SunOS|HP-UX)
Packit 90a5c9
        INSTALL_CMD=cp
Packit 90a5c9
        ;;
Packit 90a5c9
    *)
Packit 90a5c9
        type install >/dev/null 2>&1 && INSTALL_CMD=install || INSTALL_CMD=cp
Packit 90a5c9
        ;;
Packit 90a5c9
esac
Packit 90a5c9
Packit 90a5c9
CMD="$SH_LIBTOOL --mode=install $INSTALL_CMD $DSOARCHIVE $TARGETDIR/"
Packit 90a5c9
echo $CMD
Packit 90a5c9
$CMD || exit $?
Packit 90a5c9
Packit 90a5c9
if test "$SYS" = "OS/2"
Packit 90a5c9
then
Packit 90a5c9
    # on OS/2, aplibtool --install doesn't copy the .la files & we can't
Packit 90a5c9
    # rename DLLs to have a .so extension or they won't load so none of the 
Packit 90a5c9
    # steps below make sense.
Packit 90a5c9
    exit 0
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
if test -s "$TARGETDIR/$DSOARCHIVE_BASENAME"
Packit 90a5c9
then
Packit 90a5c9
  DLNAME=`sed -n "/^dlname=/{s/.*='\([^']*\)'/\1/;p;}" $TARGETDIR/$DSOARCHIVE_BASENAME`
Packit 90a5c9
  LIBRARY_NAMES=`sed -n "/^library_names/{s/library_names='\([^']*\)'/\1/;p;}" $TARGETDIR/$DSOARCHIVE_BASENAME`
Packit 90a5c9
  LIBRARY_NAMES=`echo $LIBRARY_NAMES | sed -e "s/ *$DLNAME//g"`
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
if test -z "$DLNAME"
Packit 90a5c9
then
Packit 90a5c9
  echo "Warning!  dlname not found in $TARGETDIR/$DSOARCHIVE_BASENAME."
Packit 90a5c9
  echo "Assuming installing a .so rather than a libtool archive."
Packit 90a5c9
  exit 0
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
if test -n "$LIBRARY_NAMES"
Packit 90a5c9
then
Packit 90a5c9
    for f in $LIBRARY_NAMES
Packit 90a5c9
    do
Packit 90a5c9
        rm -f $TARGETDIR/$f
Packit 90a5c9
    done
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
if test "$DLNAME" != "$TARGET_NAME"
Packit 90a5c9
then
Packit 90a5c9
    mv $TARGETDIR/$DLNAME $TARGETDIR/$TARGET_NAME
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
rm -f $TARGETDIR/$DSOARCHIVE_BASENAME
Packit 90a5c9
rm -f $TARGETDIR/$DSOBASE.a
Packit 90a5c9
rm -f $TARGETDIR/lib$DSOBASE.a
Packit 90a5c9
rm -f $TARGETDIR/lib$TARGET_NAME
Packit 90a5c9
Packit 90a5c9
exit 0