#!/bin/sh -

FILES="$*"
[ "$FILES" = "" ] && FILES="lib/*.a"

for i in $FILES
do
   ID="`dd bs=8 count=1 < $i 2>/dev/null | cat -v`"
   [ "$ID" != "!<arch>" ] && {
      make ld86r || exit $?

      echo Translating archive $i
      rm -rf libconv.d 
      mkdir libconv.d
      cd libconv.d 
      ar x ../$i
      cd ..

      bin/ld86r -o $i libconv.d/* || exit $?
      rm -rf libconv.d 
   }
done

exit 0
