]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - readline/support/shlib-install
This commit was manufactured by cvs2svn to create branch
[thirdparty/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#
6# usage: shlib-install [-D] -O host_os -d installation-dir -i install-prog [-U] library
7#
8# Chet Ramey
9# chet@po.cwru.edu
10
11#
12# defaults
13#
14INSTALLDIR=/usr/local/lib
15LDCONFIG=ldconfig
16
17PROGNAME=`basename $0`
18USAGE="$PROGNAME [-D] -O host_os -d installation-dir -i install-prog [-U] library"
19
20# process options
21
22while [ $# -gt 0 ]; do
23 case "$1" in
24 -O) shift; host_os="$1"; shift ;;
25 -d) shift; INSTALLDIR="$1"; shift ;;
26 -i) shift; INSTALLPROG="$1" ; shift ;;
27 -D) echo=echo ; shift ;;
28 -U) uninstall=true ; shift ;;
29 -*) echo "$USAGE" >&2 ; exit 2;;
30 *) break ;;
31 esac
32done
33
34# set install target name
35LIBNAME="$1"
36
37if [ -z "$LIBNAME" ]; then
38 echo "$USAGE" >&2
39 exit 2
40fi
41
42OLDSUFF=old
43MV=mv
44RM="rm -f"
45LN="ln -s"
46
47# pre-install
48
49if [ -z "$uninstall" ]; then
50 ${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
51 if [ -f "$INSTALLDIR/$LIBNAME" ]; then
1b17e766 52 ${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
c862e87b
JM
53 fi
54fi
55
56# install/uninstall
57
58if [ -z "$uninstall" ] ; then
59 ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
60else
61 ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
62fi
63
64# post-install/uninstall
65
9255ee31 66# HP-UX and Darwin/MacOS X require that a shared library have execute permission
1b17e766 67case "$host_os" in
9255ee31
EZ
68hpux*|darwin*|macosx*)
69 if [ -z "$uninstall" ]; then
70 chmod 555 ${INSTALLDIR}/${LIBNAME}
1b17e766
EZ
71 fi ;;
72*) ;;
73esac
74
c862e87b
JM
75case "$LIBNAME" in
76*.*.[0-9].[0-9]) # libname.so.M.N
77 LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
78 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
79 ;;
80*.*.[0-9]) # libname.so.M
81 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
82 ;;
1b17e766
EZ
83*.[0-9]) # libname.M
84 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
85 ;;
9255ee31
EZ
86*.[0-9].[0-9].dylib) # libname.M.N.dylib
87 LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
88 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
c862e87b
JM
89esac
90
9255ee31
EZ
91INSTALL_LINK1='cd $INSTALLDIR ; ln -s $LIBNAME $LINK1'
92INSTALL_LINK2='cd $INSTALLDIR ; ln -s $LIBNAME $LINK2'
93
c862e87b
JM
94#
95# Create symlinks to the installed library. This section is incomplete.
96#
97case "$host_os" in
9255ee31 98*linux*|bsdi4*|*gnu*|darwin*|macosx*)
c862e87b
JM
99 # libname.so.M -> libname.so.M.N
100 ${echo} ${RM} ${INSTALLDIR}/$LINK2
101 if [ -z "$uninstall" ]; then
9255ee31 102 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
c862e87b
JM
103 fi
104
105 # libname.so -> libname.so.M.N
106 ${echo} ${RM} ${INSTALLDIR}/$LINK1
107 if [ -z "$uninstall" ]; then
9255ee31 108 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
c862e87b
JM
109 fi
110 ;;
111
9255ee31 112solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
c862e87b
JM
113 # libname.so -> libname.so.M
114 ${echo} ${RM} ${INSTALLDIR}/$LINK1
115 if [ -z "$uninstall" ]; then
9255ee31 116 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
c862e87b
JM
117 fi
118 ;;
119
1b17e766 120
9255ee31
EZ
121# FreeBSD 3.x and above can have either a.out or ELF shared libraries
122freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
1b17e766
EZ
123 if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
124 # libname.so -> libname.so.M
125 ${echo} ${RM} ${INSTALLDIR}/$LINK1
126 if [ -z "$uninstall" ]; then
9255ee31 127 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
1b17e766
EZ
128 fi
129 else
130 # libname.so.M -> libname.so.M.N
131 ${echo} ${RM} ${INSTALLDIR}/$LINK2
132 if [ -z "$uninstall" ]; then
9255ee31 133 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
1b17e766
EZ
134 fi
135
136 # libname.so -> libname.so.M.N
137 ${echo} ${RM} ${INSTALLDIR}/$LINK1
138 if [ -z "$uninstall" ]; then
9255ee31 139 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
1b17e766
EZ
140 fi
141 fi
142 ;;
143
144hpux1*)
145 # libname.sl -> libname.M
146 ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
147 if [ -z "$uninstall" ]; then
9255ee31
EZ
148# ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}.sl
149 ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}
1b17e766
EZ
150 fi
151 ;;
152
c862e87b
JM
153*) ;;
154esac
155
156exit 0