Welcome to mirror list, hosted at ThFree Co, Russian Federation.

speclib « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6642414e72481489078f28836de5b9549894056a (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
#!/bin/sh -x
# 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.

case "$1" in
    -v) shift; v() { :; } ;;
    *) v() { /bin/false; } ;;
esac
lib=$1; shift
nm=$1; shift
ar=$1; shift
libdll=$1; shift
cp /dev/null /tmp/$$.objs
trap "cd /tmp; /bin/rm -rf $lib.bak /tmp/$$.dir /tmp/$$.syms /tmp/$$.objs /tmp/$$.raw" 0 1 2 15
$nm --extern-only --defined-only $* | sed -n -e 's%^.* [TD] \(.*\)$%/ \1\$/p%p' > /tmp/$$.syms
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; }

/bin/rm -rf /tmp/$$.dir
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
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;
EOF