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