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