set -e
#this is the new make for windows

OCOMP=o

if [ -n "$1" ]; then
OCOMP=$1
fi

#must also use mingw-w64-i686-dev

${OCOMP} ./src/windows/obj32.oc inplace_reloc 0 ${OFLAGS}
#argc argv? more info at obj.oc. _WinMain@16
i686-w64-mingw32-ld -O3 -s -entry=main ./src/windows/obj32.o -lmsvcrt -luser32 -lkernel32 -lcomdlg32 -lshell32 -o ./o.exe
ounused ./src/windows/obj32.oc.log
\
rm ./src/windows/obj32.o
rm ./src/windows/obj32.oc.log
\
mkdir ocompiler
mv o.exe ocompiler
cp ocompiler.conf ocompiler
echo;echo to ounused;echo
cd ounused && platform=win launcher=wine6 OCOMP=../ocompiler/o.exe make
mv ounused.exe ../ocompiler && make clean && cd ..
echo;echo to otoc;echo
cd otoc && platform=win launcher=wine6 OCOMP="wine6 ../ocompiler/o.exe" OLINK="wine6 ../ocompiler/ounused.exe" OFLAGSEXTRA="inplace_reloc 0" make
echo;echo to tests;echo
mv otoc.exe ../ocompiler && make clean && cd ../tests && OCOMP="wine6 ../ocompiler/o.exe" winlauncher=wine6 OCONV="../ocompiler/otoc.exe" ./db a.out && ./c1 a.out && ./c && cd ..
\
zip -r ocompiler.zip ocompiler
rm -r ./ocompiler
\
unzip -l ocompiler.zip
