2003-08-06 09:40:12 +08:00
|
|
|
#!/bin/sh -x
|
2002-01-14 04:03:03 +08:00
|
|
|
# speclib - Make a special version of the cygwin import library.
|
|
|
|
#
|
|
|
|
# Copyright 2001, 2002 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Cygwin.
|
|
|
|
#
|
|
|
|
# This software is a copyrighted work licensed under the terms of the
|
|
|
|
# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
# details.
|
|
|
|
|
2001-12-31 11:19:29 +08:00
|
|
|
case "$1" in
|
2003-08-06 09:40:12 +08:00
|
|
|
-v) shift; v() { :; } ;;
|
|
|
|
*) v() { /bin/false; } ;;
|
2001-12-31 11:19:29 +08:00
|
|
|
esac
|
|
|
|
lib=$1; shift
|
|
|
|
nm=$1; shift
|
2003-08-06 09:40:12 +08:00
|
|
|
ar=$1; shift
|
|
|
|
libdll=$1; shift
|
|
|
|
cp /dev/null /tmp/$$.objs
|
2003-11-29 04:51:11 +08:00
|
|
|
trap "cd /tmp; /bin/rm -rf $lib.bak /tmp/$$.dir /tmp/$$.syms /tmp/$$.objs /tmp/$$.raw" 0 1 2 15
|
2003-08-19 12:10:42 +08:00
|
|
|
$nm --extern-only --defined-only $* | sed -n -e 's%^.* [TD] \(.*\)$%/ \1\$/p%p' > /tmp/$$.syms
|
2003-08-06 09:40:12 +08:00
|
|
|
v || $nm -Ap --extern-only --defined-only $libdll | egrep ' I __head| I _.*_iname' | awk -F: '{print $2}' > /tmp/$$.objs
|
|
|
|
$nm -Ap --extern-only --defined-only $libdll | sed -n -f /tmp/$$.syms | awk -F: '{print $2}' >> /tmp/$$.objs
|
|
|
|
sort -o /tmp/$$.objs -u /tmp/$$.objs
|
|
|
|
|
|
|
|
[ -s /tmp/$$.objs ] || { echo "speclib: couldn't find symbols for $lib" 1>&2; exit 1; }
|
|
|
|
|
2003-08-28 05:01:14 +08:00
|
|
|
/bin/rm -rf /tmp/$$.dir
|
2003-08-06 09:40:12 +08:00
|
|
|
mkdir /tmp/$$.dir
|
|
|
|
cd /tmp/$$.dir
|
|
|
|
if v; then
|
|
|
|
$ar x $libdll
|
|
|
|
/bin/rm -f `cat /tmp/$$.objs`
|
|
|
|
else
|
|
|
|
$ar x $libdll `cat /tmp/$$.objs`
|
|
|
|
fi
|
|
|
|
/bin/rm -f $lib
|
|
|
|
$ar crus $lib *.o
|
2003-08-21 10:19:25 +08:00
|
|
|
export lib;
|
|
|
|
perl -pi.bak -- - $lib << 'EOF'
|
|
|
|
BEGIN {
|
|
|
|
binmode STDIN;
|
|
|
|
binmode STDOUT;
|
|
|
|
$lib = ($ENV{lib} =~ m!/([^/]+)$!o)[0] || $ENV{lib};
|
|
|
|
$lib =~ s/\.a//o;
|
|
|
|
my $pad = length('cygwin1_dll') - length($lib);
|
|
|
|
die "speclib: library name too long (" . length($lib) . ")\n" if $pad < 0;
|
|
|
|
$lib = "__head_$lib" . "\0" x $pad;
|
|
|
|
}
|
|
|
|
s/__head_cygwin1_dll/$lib/g;
|
2003-11-29 04:51:11 +08:00
|
|
|
EOF
|