rpm-build/scripts/fixup-libtool

103 lines
2.4 KiB
Plaintext
Raw Normal View History

#!/bin/sh -e
#
# fixup-libtool - libtool .la-files fixups.
#
# Copyright (C) 2002 Dmitry V. Levin <ldv@altlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
PROG="${0##*/}"
: ${RPM_FIXUP_SKIPLIST:=}
fix_libdir()
{
local f=$1
shift
local fname="${f#$RPM_BUILD_ROOT}"
2002-10-02 18:06:06 +00:00
fname="${fname#.}"
local fdir="${fname%/*}"
2002-10-02 18:06:06 +00:00
local libdir=`sed -ne "s/^libdir='\([^']*\)'\$/\1/pg" "$f" |tail -1`
if [ "$fdir" != "$libdir" ]; then
2002-10-02 16:08:55 +00:00
subst -p "s,^libdir='$libdir'\$,libdir='$fdir',g" "$f"
2002-10-02 18:06:06 +00:00
echo "${fname#.}: libdir: '$libdir' --> '$fdir'" >&2
fi
}
fix_dependency_libs()
{
local f=$1
shift
2002-10-02 18:06:06 +00:00
local fname="${f#$RPM_BUILD_ROOT}"
fname="${fname#.}"
local dependency_libs=`sed -ne "s/^dependency_libs='\([^']*\)'\$/\1/pg" "$f" |tail -1`
local deps="$dependency_libs"
old_deps=
while [ "$deps" != "$old_deps" ]; do
old_deps="$deps"
deps="${deps//\/\///}"
done
old_deps=
while [ "$deps" != "$old_deps" ]; do
old_deps="$deps"
deps=`echo "$deps" |sed -e 's,\(^\| \+\)-L/usr\(/local\)\?/lib\($\| \+\),\1\3,g'`
deps=`echo "$deps" |sed -e 's,\(^\| \+\)-L\('$RPM_BUILD_ROOT'\|/usr/lib/gcc-lib\)[^ ]*\($\| \+\),\1\3,g'`
done
old_deps=
while [ "$deps" != "$old_deps" ]; do
old_deps="$deps"
deps="${deps// / }"
done
deps="${deps## }"
deps="${deps%% }"
if [ "$deps" != "$dependency_libs" ]; then
subst -p "s,^dependency_libs='$dependency_libs'\$,dependency_libs='$deps',g" "$f"
echo "${fname#.}: dependency_libs: '$dependency_libs' --> '$deps'" >&2
fi
}
rc=0
for f in "$@"; do
if [ ! -f "$f" ]; then
echo "$PROG: $f: file unavailable" >&2
rc=1
continue
fi
if [ -n "$RPM_FIXUP_SKIPLIST" ]; then
for skip in $RPM_FIXUP_SKIPLIST; do
if [ -z "${f//$skip}" ]; then
continue 2
fi
done
fi
fix_libdir "$f"
fix_dependency_libs "$f"
done
exit $rc