translate: add some help text
[ia32rtools.git] / run_imp.sh
CommitLineData
60f7539b 1#!/bin/sh
2
296d81f8 3target_s=$1
4src_asm=$2
5implist=${target_s}_implist
6tmpsym=${target_s}_tmpsym
7shift 2
60f7539b 8
296d81f8 9grep 'extrn ' $src_asm | awk '{print $2}' | \
10 awk -F: '{print $1}' > $implist
60f7539b 11
296d81f8 12echo ".data" > $target_s
13echo ".align 4" >> $target_s
14
15cat $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 44done