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