X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=run_imp.sh;h=665b3f9bb59db89dc9143e4c3e19e65151af7b88;hb=2b70f6d33838eccf24330e79cf939f2d5632a1c7;hp=7c103767b07ee81cf64f223a197b1cf18e2e0394;hpb=1f906263984019d6804c760d7ca6f8c162c5b78d;p=ia32rtools.git diff --git a/run_imp.sh b/run_imp.sh index 7c10376..665b3f9 100755 --- a/run_imp.sh +++ b/run_imp.sh @@ -1,12 +1,23 @@ #!/bin/sh -grep 'extrn ' StarCraft.asm | awk '{print $2}' | awk -F: '{print $1}' > implist +# warning: i686-w64-mingw32- on Ubuntu 14.04 +# contains broken InterlockedDecrement +test -n "$mingwb" || mingwb=i686-w64-mingw32 -echo ".data" > $1 -echo ".align 4" >> $1 +target_s=$1 +src_asm=$2 +implist=${target_s}_implist +tmpsym=${target_s}_tmpsym +shift 2 -cat implist | while read i; do - rm -f tmpsym +grep 'extrn ' $src_asm | awk '{print $2}' | \ + awk -F: '{print $1}' > $implist + +echo ".data" > $target_s +echo ".align 4" >> $target_s + +cat $implist | while read i; do + rm -f $tmpsym case $i in __imp_*) si=`echo $i | cut -c 7-` @@ -16,22 +27,22 @@ cat implist | while read i; do ;; esac - grep "\<_$si\>" /usr/i586-mingw32msvc/lib/lib* *.lib | awk '{print $3}' | \ + grep "\<_\?_$si\>" /usr/$mingwb/lib/lib* "$@" | awk '{print $3}' | \ while read f; do - sym=`i586-mingw32msvc-nm $f | grep "\<_$si\>" | grep ' T ' | awk '{print $3}'` + sym=`${mingwb}-nm $f | grep "\<_\?_$si\>" | grep ' T ' | awk '{print $3}'` if test -n "$sym"; then - echo $sym > tmpsym + echo $sym > $tmpsym break fi done - sym=`cat tmpsym` + sym=`cat $tmpsym` if test -z "$sym"; then echo "no file/sym for $i, lf $f" exit 1 fi - echo ".globl $i" >> $1 - echo "$i:" >> $1 - echo " .long $sym" >> $1 - echo >> $1 + echo ".globl $i" >> $target_s + echo "$i:" >> $target_s + echo " .long $sym" >> $target_s + echo >> $target_s done