#! /bin/bash

# Public Domain

[ -z "$DOSEMU" ] && DOSEMU=dosemu
[ -z "$CONVLIST" ] && CONVLIST=convlist.pl

nasm -fobj -I../lmacros/ machlink.nas -l machlink.lst
nasm -fobj -I../lmacros/ mlsetup.nas -l mlsetup.lst
nasm -fobj -I../lmacros/ mlgetarg.nas -l mlgetarg.lst
nasm -fobj -I../lmacros/ mlcredit.nas -l mlcredit.lst
nasm -fobj -I../lmacros/ mlsum.nas -l mlsum.lst
nasm -fobj -I../lmacros/ mlclean.nas -l mlclean.lst
nasm -fobj -I../lmacros/ mlerror.nas -l mlerror.lst
nasm -fobj -I../lmacros/ mlpass1.nas -l mlpass1.lst
nasm -fobj -I../lmacros/ mlpass1a.nas -l mlpass1a.lst
nasm -fobj -I../lmacros/ mlpass1b.nas -l mlpass1b.lst
nasm -fobj -I../lmacros/ mlpass1c.nas -l mlpass1c.lst
nasm -fobj -I../lmacros/ mlcomm.nas -l mlcomm.lst
nasm -fobj -I../lmacros/ mlpass2.nas -l mlpass2.lst
nasm -fobj -I../lmacros/ mlpass2a.nas -l mlpass2a.lst
nasm -fobj -I../lmacros/ mlpass2b.nas -l mlpass2b.lst
nasm -fobj -I../lmacros/ mlpass2c.nas -l mlpass2c.lst
nasm -fobj -I../lmacros/ mlpass2d.nas -l mlpass2d.lst
nasm -fobj -I../lmacros/ mlpass2e.nas -l mlpass2e.lst
nasm -fobj -I../lmacros/ mlimage1.nas -l mlimage1.lst
nasm -fobj -I../lmacros/ mlimage2.nas -l mlimage2.lst
nasm -fobj -I../lmacros/ mllib1.nas -l mllib1.lst
nasm -fobj -I../lmacros/ mllib2.nas -l mllib2.lst
nasm -fobj -I../lmacros/ mlmemory.nas -l mlmemory.lst
nasm -fobj -I../lmacros/ mlshared.nas -l mlshared.lst
nasm -fobj -I../lmacros/ mlparse.nas -l mlparse.lst
nasm -fobj -I../lmacros/ mlmap.nas -l mlmap.lst
nasm -fobj -I../lmacros/ mlparovl.nas -l mlparovl.lst
nasm -fobj -I../lmacros/ mlovl1.nas -l mlovl1.lst
nasm -fobj -I../lmacros/ mlovlfil.nas -l mlovlfil.lst
nasm -fobj -I../lmacros/ mlovlres.nas -l mlovlres.lst
nasm -fobj -I../lmacros/ mlclip.nas -l mlclip.lst
nasm -fobj -I../lmacros/ mlddl1.nas -l mlddl1.lst
nasm -fobj -I../lmacros/ mlddl2.nas -l mlddl2.lst
nasm -fobj -I../lmacros/ mlquick.nas -l mlquick.lst
"$DOSEMU" -quiet -q -dumb -K "$PWD" -E "warplink @wl.rsp" < /dev/null
echo
nasm -fobj -I../lmacros/ ovlmgr.nas -l ovlmgr.lst -o ovlmgr.tob -Pnasm2.mac
fixupp ovlmgr.tob ovlmgr.obj
echo === Creating trace listing
"$CONVLIST" wl.map $(cat WL.RSP |
  grep -Eio 'machlink|ml[a-zA-Z0-9]+' |
  sed -re 's/$/.lst/' ) > wl.tls
