blob: 78ddee08b1ab1173baf02a5500f6b4efbe1cf520 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!@BUILDLINK_SHELL@
#
# $NetBSD: fake-la,v 1.11 2004/02/21 10:35:57 jlam Exp $
AR="@AR@"
AWK="@AWK@"
BASENAME="@BASENAME@"
CC="@CC@"
CP="@CP@"
DIRNAME="@DIRNAME@"
ECHO="@ECHO@"
LIBTOOL="@LIBTOOL@ --quiet"
MKDIR="@MKDIR@"
MV="@MV@"
RM="@RM@"
SED="@SED@"
TEST="@TEST@"
BUILDLINK_DIR="@BUILDLINK_DIR@"
reallib="$1"
realdir=`${DIRNAME} $reallib`
libname=`${BASENAME} $reallib`
tmpdir=${BUILDLINK_DIR}/.tmp
case $libname in
*.so)
# no version in name which happens e.g. for libpthread.so on Linux
# Suse 8.1, Slackware 8.1 and others, but there, the library is a link
# to a library with a version in it
libbase=`${ECHO} $libname | ${SED} -e "s/\.so$//"`
if ${TEST} -h $reallib; then
liblinked=`ls -l $reallib | ${AWK} '{print $NF}'`
version=`${ECHO} $liblinked | ${SED} -e "s/.*\.so\.//;s/\./:/g"`
else
# bail out
${ECHO} "could not determine version of $reallib"
exit 1
fi
;;
*.so.[0-9]*)
libbase=`${ECHO} $libname | ${SED} -e "s/\.so\.[0-9.]*$//"`
version=`${ECHO} $libname | ${SED} -e "s/.*\.so\.//;s/\./:/g"`
;;
*[0-9].dylib)
libbase=`${ECHO} $libname | ${SED} -e "s/\.[0-9.]*\.dylib$//"`
version=`${ECHO} $libname | ${SED} -e "s/^[^.]*\.\([0-9]*\.[0-9]*\)\.dylib/\1/;s/\./:/g"`
;;
*.a)
libbase=`${ECHO} $libname | ${SED} -e "s/\.a$//"`
ltlib="$realdir/$libbase.la"
# If there's already a libtool .la file, use it.
if ${TEST} -e "$ltlib" ; then
current=`${SED} -n -e'/^current=[[:digit:]]/{ s/^current=//; p; };' "$ltlib"`
rev=`${SED} -n -e'/^revision=[[:digit:]]/{ s/^revision=//; p; };' "$ltlib"`
current=$(($current + 0))
rev=$(($rev + 0))
version="$current.$rev"
else
# Try looking inside the archive
sublibname=`${AR} t "$reallib" | ${AWK} ' /.*\.so\..*/ { print $1 ; exit } '`
case $sublibname in
*.so.*)
version=`${ECHO} "$sublibname" | ${SED} -e "s/.*\.so\.//;s/\./:/g"`
;;
*)
version="0"
;;
esac
fi
;;
*)
# bail out
${ECHO} "$0: unknown library type for $libname"
exit 1
;;
esac
if ${TEST} ! -f $tmpdir/inst/$libbase.la; then
PATH="@PATH@"; export PATH
${MKDIR} $tmpdir/inst
cd $tmpdir
${ECHO} "static int i;" > nonempty.c # create a nonempty input file
${LIBTOOL} --mode=compile ${CC} -c nonempty.c
${LIBTOOL} --mode=link ${CC} @LDFLAGS@ -o $libbase.la nonempty.lo -rpath $tmpdir/inst -version-info $version
${LIBTOOL} --mode=install ${CP} $libbase.la $tmpdir/inst >/dev/null
# Reset the ld.so cache as "libtool --mode=install" may have executed
# ldconfig to add "$tmpdir/inst" to the cache.
#
@RESET_LD_SO_CACHE@ >/dev/null 2>&1
fi
dlname=`${SED} -n -e"/^dlname='/{ s/^dlname='//; s/'$//; p; };" "$tmpdir/inst/$libbase.la"`
library_names=`${SED} -n -e"/^library_names='/{ s/^library_names='//; s/'$//; p; };" "$tmpdir/inst/$libbase.la"`
old_library=`${SED} -n -e"/^old_library='/{ s/^old_library='//; s/'$//; p; };" "$tmpdir/inst/$libbase.la"`
for file in $dlname $library_names $old_library
do
if ! [ -e $realdir/$file ]
then
removal_pattern="$removal_pattern -e s,$file\([^.0-9]\),\1,g"
fi
done
${SED} -e "s,$tmpdir/inst,$realdir,g" $removal_pattern $tmpdir/inst/$libbase.la
|