]> granicus.if.org Git - apache/blob - build/instdso.sh
check: merge warning fixes from feature branch
[apache] / build / instdso.sh
1 #!/bin/sh
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements.  See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License.  You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 #
19 # instdso.sh - install Apache DSO modules
20 #
21 # we use this instead of libtool --install because:
22 # 1) on a few platforms libtool doesn't install DSOs exactly like we'd
23 #    want (weird names, doesn't remove DSO first)
24 # 2) we never want the .la files copied, so we might as well copy
25 #    the .so files ourselves
26
27 if test "$#" -lt "3"; then
28     echo "too few arguments to instdso.sh"
29     echo "Usage: instdso.sh SH_LIBTOOL-value dso-name [dso-name [...]] path-to-modules"
30     exit 1
31 fi
32
33 SH_LIBTOOL=`echo $1 | sed -e 's/^SH_LIBTOOL=//'`
34 shift
35 # get last arg
36 for arg in "$@" ; do
37     DSOARCHIVES="$DSOARCHIVES $TARGETDIR"
38     TARGETDIR=$arg
39 done
40
41 SYS=`uname -s`
42
43 if test "$SYS" = "AIX"
44 then
45     # on AIX, shared libraries remain in storage even when
46     # all processes using them have exited; standard practice
47     # prior to installing a shared library is to rm -f first
48     CMD="rm -f"
49     for DSOARCHIVE in $DSOARCHIVES ; do
50         DSOBASE=`basename $DSOARCHIVE|sed -e 's/\.la$//'`
51         CMD="$CMD $TARGETDIR/$DSOBASE.so"
52     done
53     echo $CMD
54     $CMD || exit $?
55 fi
56
57 case $SYS in
58     SunOS|HP-UX|AIX)
59         INSTALL_CMD=cp
60         ;;
61     *)
62         type install >/dev/null 2>&1 && INSTALL_CMD=install || INSTALL_CMD=cp
63         ;;
64 esac
65
66 CMD="$SH_LIBTOOL --mode=install $INSTALL_CMD $DSOARCHIVES $TARGETDIR/"
67 echo $CMD
68 $CMD || exit $?
69
70 if test "$SYS" = "OS/2"
71 then
72     # on OS/2, aplibtool --install doesn't copy the .la files & we can't
73     # rename DLLs to have a .so extension or they won't load so none of the 
74     # steps below make sense.
75     exit 0
76 fi
77
78 for DSOARCHIVE in $DSOARCHIVES ; do
79 DSOARCHIVE_BASENAME=`basename $DSOARCHIVE`
80 DSOBASE=`echo $DSOARCHIVE_BASENAME | sed -e 's/\.la$//'`
81 TARGET_NAME="$DSOBASE.so"
82
83 if test -s "$TARGETDIR/$DSOARCHIVE_BASENAME"
84 then
85   DLNAME=`sed -n "/^dlname=/{s/.*='\([^']*\)'/\1/;p;}" $TARGETDIR/$DSOARCHIVE_BASENAME`
86   LIBRARY_NAMES=`sed -n "/^library_names/{s/library_names='\([^']*\)'/\1/;p;}" $TARGETDIR/$DSOARCHIVE_BASENAME`
87   LIBRARY_NAMES=`echo $LIBRARY_NAMES | sed -e "s/ *$DLNAME//g"`
88 fi
89
90 if test -z "$DLNAME"
91 then
92   echo "Warning!  dlname not found in $TARGETDIR/$DSOARCHIVE_BASENAME."
93   echo "Assuming installing a .so rather than a libtool archive."
94   continue
95 fi
96
97 if test -n "$LIBRARY_NAMES"
98 then
99     for f in $LIBRARY_NAMES
100     do
101         rm -f $TARGETDIR/$f
102     done
103 fi
104
105 if test "$DLNAME" != "$TARGET_NAME"
106 then
107     mv $TARGETDIR/$DLNAME $TARGETDIR/$TARGET_NAME
108 fi
109
110 rm -f $TARGETDIR/$DSOARCHIVE_BASENAME
111 rm -f $TARGETDIR/$DSOBASE.a
112 rm -f $TARGETDIR/lib$DSOBASE.a
113 rm -f $TARGETDIR/lib$TARGET_NAME
114
115 done
116
117 exit 0