Revert patchset for c++/16253: it causes a large performance regression.
[deliverable/binutils-gdb.git] / readline / support / shlib-install
CommitLineData
c862e87b
JM
1#! /bin/sh
2#
3# shlib-install - install a shared library and do any necessary host-specific
4# post-installation configuration (like ldconfig)
5#
cc88a640 6# usage: shlib-install [-D] -O host_os [-V host_vendor] -d installation-dir [-b bin-dir] -i install-prog [-U] library
c862e87b
JM
7#
8# Chet Ramey
9# chet@po.cwru.edu
10
11#
12# defaults
13#
14INSTALLDIR=/usr/local/lib
15LDCONFIG=ldconfig
16
17PROGNAME=`basename $0`
cc88a640 18USAGE="$PROGNAME [-D] -O host_os [-V host_vendor] -d installation-dir [-b bin-dir] -i install-prog [-U] library"
c862e87b
JM
19
20# process options
21
22while [ $# -gt 0 ]; do
23 case "$1" in
24 -O) shift; host_os="$1"; shift ;;
cc88a640 25 -V) shift; host_vendor="$1"; shift ;;
c862e87b 26 -d) shift; INSTALLDIR="$1"; shift ;;
5bdf8622 27 -b) shift; BINDIR="$1" ; shift ;;
c862e87b
JM
28 -i) shift; INSTALLPROG="$1" ; shift ;;
29 -D) echo=echo ; shift ;;
30 -U) uninstall=true ; shift ;;
31 -*) echo "$USAGE" >&2 ; exit 2;;
32 *) break ;;
33 esac
34done
35
36# set install target name
37LIBNAME="$1"
38
39if [ -z "$LIBNAME" ]; then
40 echo "$USAGE" >&2
41 exit 2
42fi
43
44OLDSUFF=old
45MV=mv
46RM="rm -f"
47LN="ln -s"
48
49# pre-install
50
51if [ -z "$uninstall" ]; then
52 ${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
53 if [ -f "$INSTALLDIR/$LIBNAME" ]; then
1b17e766 54 ${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
c862e87b
JM
55 fi
56fi
57
58# install/uninstall
59
60if [ -z "$uninstall" ] ; then
61 ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
62else
63 ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
64fi
65
66# post-install/uninstall
67
9255ee31 68# HP-UX and Darwin/MacOS X require that a shared library have execute permission
cc88a640 69# Linux does, too, and ldd warns about it
5bdf8622
DJ
70# Cygwin installs both a dll (which must go in $BINDIR) and an implicit
71# link library (in $libdir)
1b17e766 72case "$host_os" in
cc88a640 73hpux*|darwin*|macosx*|linux*)
9255ee31
EZ
74 if [ -z "$uninstall" ]; then
75 chmod 555 ${INSTALLDIR}/${LIBNAME}
1b17e766 76 fi ;;
cc88a640 77cygwin*|mingw*)
5bdf8622
DJ
78 IMPLIBNAME=`echo ${LIBNAME} \
79 | sed -e 's,^cyg,lib,' -e 's,[0-9]*.dll$,.dll.a,'`
80 if [ -z "$uninstall" ]; then
81 ${echo} $RM ${BINDIR}/${LIBNAME}.${OLDSUFF}
82 if [ -f "$BINDIR/$LIBNAME" ]; then
83 ${echo} $MV $BINDIR/$LIBNAME $BINDIR/$LIBNAME.$OLDSUFF
84 fi
85 ${echo} $MV ${INSTALLDIR}/${LIBNAME} ${BINDIR}/${LIBNAME}
86 ${echo} chmod a+x ${BINDIR}/${LIBNAME}
87 ${echo} eval ${INSTALLPROG} ${LIBNAME}.a \
88 ${INSTALLDIR}/${IMPLIBNAME}
89 else
90 ${echo} ${RM} ${BINDIR}/${LIBNAME}
91 ${echo} ${RM} ${INSTALLDIR}/${IMPLIBNAME}
92 fi ;;
93
1b17e766
EZ
94*) ;;
95esac
96
c862e87b
JM
97case "$LIBNAME" in
98*.*.[0-9].[0-9]) # libname.so.M.N
99 LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
100 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
101 ;;
102*.*.[0-9]) # libname.so.M
103 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
104 ;;
1b17e766
EZ
105*.[0-9]) # libname.M
106 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
107 ;;
9255ee31
EZ
108*.[0-9].[0-9].dylib) # libname.M.N.dylib
109 LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
110 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
c862e87b
JM
111esac
112
5bdf8622
DJ
113INSTALL_LINK1='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
114INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
9255ee31 115
c862e87b
JM
116#
117# Create symlinks to the installed library. This section is incomplete.
118#
cc88a640
JK
119case "$host_os-$host_vendor" in
120*linux*|freebsd*-gentoo)
5bdf8622
DJ
121 # libname.so.M -> libname.so.M.N
122 ${echo} ${RM} ${INSTALLDIR}/$LINK2
123 if [ -z "$uninstall" ]; then
124 eval $INSTALL_LINK2
125 fi
126
127 # libname.so -> libname.so.M
128 ${echo} ${RM} ${INSTALLDIR}/$LINK1
129 if [ -z "$uninstall" ]; then
130 ${echo} cd $INSTALLDIR && ${echo} ${LN} $LINK2 $LINK1
131 fi
132 ;;
133
cc88a640 134bsdi4*|*gnu*|darwin*|macosx*|netbsd*)
c862e87b
JM
135 # libname.so.M -> libname.so.M.N
136 ${echo} ${RM} ${INSTALLDIR}/$LINK2
137 if [ -z "$uninstall" ]; then
5bdf8622 138 eval $INSTALL_LINK2
c862e87b
JM
139 fi
140
141 # libname.so -> libname.so.M.N
142 ${echo} ${RM} ${INSTALLDIR}/$LINK1
143 if [ -z "$uninstall" ]; then
5bdf8622 144 eval $INSTALL_LINK1
c862e87b
JM
145 fi
146 ;;
147
cc88a640 148solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*)
c862e87b
JM
149 # libname.so -> libname.so.M
150 ${echo} ${RM} ${INSTALLDIR}/$LINK1
151 if [ -z "$uninstall" ]; then
5bdf8622 152 eval $INSTALL_LINK1
c862e87b
JM
153 fi
154 ;;
155
1b17e766 156
9255ee31 157# FreeBSD 3.x and above can have either a.out or ELF shared libraries
cc88a640 158freebsd3*|freebsdaout*)
1b17e766
EZ
159 if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
160 # libname.so -> libname.so.M
161 ${echo} ${RM} ${INSTALLDIR}/$LINK1
162 if [ -z "$uninstall" ]; then
5bdf8622 163 eval $INSTALL_LINK1
1b17e766
EZ
164 fi
165 else
166 # libname.so.M -> libname.so.M.N
167 ${echo} ${RM} ${INSTALLDIR}/$LINK2
168 if [ -z "$uninstall" ]; then
5bdf8622 169 eval $INSTALL_LINK2
1b17e766
EZ
170 fi
171
172 # libname.so -> libname.so.M.N
173 ${echo} ${RM} ${INSTALLDIR}/$LINK1
174 if [ -z "$uninstall" ]; then
5bdf8622 175 eval $INSTALL_LINK1
1b17e766
EZ
176 fi
177 fi
178 ;;
179
cc88a640
JK
180freebsd[4-9]*|freebsdelf*|dragonfly*)
181 # libname.so -> libname.so.M
182 ${echo} ${RM} ${INSTALLDIR}/$LINK1
183 if [ -z "$uninstall" ]; then
184 eval $INSTALL_LINK1
185 fi
186 ;;
187
1b17e766
EZ
188hpux1*)
189 # libname.sl -> libname.M
190 ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
191 if [ -z "$uninstall" ]; then
5bdf8622 192 eval $INSTALL_LINK1
1b17e766
EZ
193 fi
194 ;;
195
cc88a640 196cygwin*|mingw*)
5bdf8622
DJ
197 # Links to .dlls don't work. Hence shobj-conf used DLLVERSION.dll
198 # instead of so.SHLIB_MAJOR.SHLIB_MINOR. The postinstall above
199 # took care of everything else.
200 ;;
201
c862e87b
JM
202*) ;;
203esac
204
205exit 0
This page took 0.670927 seconds and 4 git commands to generate.