54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
|
#! /bin/bash
|
||
|
# Copyright (C) 2010 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||
|
#
|
||
|
# 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; version 3 of the License.
|
||
|
#
|
||
|
# 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, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
|
||
|
## Usage: dso-fixup <build-root> <libdir> <pattern> <libs>*
|
||
|
|
||
|
BR=$1
|
||
|
LIBDIR=$2
|
||
|
PATTERN=$3
|
||
|
shift 3
|
||
|
|
||
|
for i; do
|
||
|
echo -n $(basename "$i")' '
|
||
|
readelf -d $i | sed "\\!(NEEDED).*${PATTERN}!"'s/[^:]\+: \[\(.*\)\]/\1/p;d' | xargs echo -n
|
||
|
echo " ##"
|
||
|
done | ./depsort | while read lib deps; do
|
||
|
link=$BR$LIBDIR/${lib%.so.*}.so
|
||
|
test -L "$link" || {
|
||
|
echo "bad file '$link'" >&2
|
||
|
exit 1
|
||
|
}
|
||
|
rm -f $link
|
||
|
|
||
|
set -- $deps
|
||
|
|
||
|
{
|
||
|
echo -n "INPUT($LIBDIR/$lib"
|
||
|
d=
|
||
|
if test "$#" -gt 0; then
|
||
|
echo -n " AS_NEEDED("
|
||
|
for i; do
|
||
|
echo -n "$d$LIBDIR/$i"
|
||
|
d=' '
|
||
|
done
|
||
|
echo -n ")"
|
||
|
fi
|
||
|
echo ")"
|
||
|
} > "$link"
|
||
|
|
||
|
chmod 0644 "$link"
|
||
|
done
|