60f7539b |
1 | #!/bin/sh |
2 | |
296d81f8 |
3 | target_s=$1 |
4 | src_asm=$2 |
5 | implist=${target_s}_implist |
6 | tmpsym=${target_s}_tmpsym |
7 | shift 2 |
60f7539b |
8 | |
296d81f8 |
9 | grep 'extrn ' $src_asm | awk '{print $2}' | \ |
10 | awk -F: '{print $1}' > $implist |
60f7539b |
11 | |
296d81f8 |
12 | echo ".data" > $target_s |
13 | echo ".align 4" >> $target_s |
14 | |
15 | cat $implist | while read i; do |
16 | rm -f $tmpsym |
60f7539b |
17 | case $i in |
18 | __imp_*) |
19 | si=`echo $i | cut -c 7-` |
20 | ;; |
21 | *) |
22 | si=$i |
23 | ;; |
24 | esac |
25 | |
296d81f8 |
26 | grep "\<_$si\>" /usr/i586-mingw32msvc/lib/lib* "$@" | awk '{print $3}' | \ |
60f7539b |
27 | while read f; do |
28 | sym=`i586-mingw32msvc-nm $f | grep "\<_$si\>" | grep ' T ' | awk '{print $3}'` |
29 | if test -n "$sym"; then |
296d81f8 |
30 | echo $sym > $tmpsym |
60f7539b |
31 | break |
32 | fi |
33 | done |
296d81f8 |
34 | sym=`cat $tmpsym` |
60f7539b |
35 | if test -z "$sym"; then |
36 | echo "no file/sym for $i, lf $f" |
37 | exit 1 |
38 | fi |
39 | |
296d81f8 |
40 | echo ".globl $i" >> $target_s |
41 | echo "$i:" >> $target_s |
42 | echo " .long $sym" >> $target_s |
43 | echo >> $target_s |
60f7539b |
44 | done |