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