#!/bin/sh

export PATH=/bin:/c/Windows/System32:$TOOLCHAIN

$GXX $DEFINES -O2 -c "../sources/All/*.cpp" "../sources/Win/*.cpp"
$WINDRES -D_WINDOWS_PLATFORM_ "../sources/Win/resources/WinCaml$CONTEXT.rc" WinCaml$CONTEXT.o
$GXX -o WinCaml.exe -static-libgcc -static-libstdc++ -mwindows *.o -lmingw32 -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lshell32 -lole32 -lcomctl32 -lshlwapi
$STRIP WinCaml.exe
rm *.o

test -d WinCaml5 || mkdir WinCaml5
mv WinCaml.exe WinCaml5
cp ../sources/Win/WinCamlInit.bat WinCaml5
test -d WinCaml5/ocaml || mkdir WinCaml5/ocaml
cp -R ../caml/ocaml/windows WinCaml5/ocaml
cp -R ../caml/ocaml/htmlman WinCaml5/ocaml
cp -R ../caml/caml-light  WinCaml5
rm -f WinCaml5/caml-light/bin/lin*
rm -f WinCaml5/caml-light/bin/mac*
cp -R ../caml/exemples WinCaml5
