cd src/
#During compilation you have to link the library files glew32s.lib, libglfw.a,libopengl32.a.
# use -static for mingw?
# -I/usr/i486-mingw32/include -I/usr/i486-mingw32/lib 
#i686-w64-mingw32-gcc -O3 -flto -Wall -Wextra -msse2 -o ../quad.exe main.c text.c input.c shaders.c custom.c geometry.c sky.c terrain.c player.c cjson/cJSON.c -lm -lpthread -I../../_other/glew-2.1.0/include -I../../_other/glew-2.1.0/lib/Release/x64 -lopengl32 -lgdi32 -luser32 -lkernel32 -I../../_other/mingw32/include -I../../_other/mingw32/lib -Werror-implicit-function-declaration -flto=auto -I../../_other/freetype-gl/windows/freetype -g -I/usr/i686-w64-mingw32/include/ -I/usr/i686-w64-mingw32/lib/ 2>&1 | tee ../build_win.log
x86_64-w64-mingw32-gcc -O3 -flto -Wall -Wextra -msse2 -o ../quad.exe main.c text.c input.c shaders.c custom.c geometry.c sky.c terrain.c water.c fire.c player.c cjson/cJSON.c -lm -lpthread -fstack-protector -lglew32 -lopengl32 -lgdi32 -luser32 -lkernel32 -lglfw3 -I../../_other/mingw64/include -Werror-implicit-function-declaration -flto=auto -lfreetype -I../../_other/mingw64/include/freetype2 -L../../_other/mingw64/lib -lftgl -I../../_other/mingw64/include/FTGL -g --static -DWIN32 2>&1 | tee ../build_win.log
#x86_64-w64-mingw32-gcc -O3 -flto -Wall -Wextra -msse2 -o ../quad.exe main.c text.c input.c shaders.c custom.c geometry.c sky.c terrain.c player.c cjson/cJSON.c -lm -lpthread -lGLEW -I../../_other/glew-2.1.0/include -I../../_other/glew-2.1.0/lib/Release/x64 -lopengl32 -lglfw -lgdi32 -I../../_other/glfw-3.4.bin.WIN64/include -I../../_other/glfw-3.4.bin.WIN64/lib-mingw-w64 -Werror-implicit-function-declaration -flto=auto -lfreetype -I/usr/include/freetype2 -g -I/usr/x86_64-w64-mingw32/include/ -I/usr/x86_64-w64-mingw32/lib/ 2>&1 | tee ../build_win.log
#i686-w64-mingw32-gcc-win32 -O3 -flto -Wall -Wextra -msse -o ../quad.exe main.c text.c input.c shaders.c custom.c player.c -lm -lpthread -lGLEW -I../../_other/glew-2.1.0/include -I../../_other/glew-2.1.0/lib/Release/x64 -lopengl32 -lglfw -lgdi32 -I../../_other/glfw-3.4.bin.WIN64/include -I../../_other/glfw-3.4.bin.WIN64/lib-mingw-w64 -Werror-implicit-function-declaration -flto=auto -lfreetype -I/usr/include/freetype2 -g -I/usr/i686-w64-mingw32/include/ -I/usr/i686-w64-mingw32/lib/
#  --static
#-D__MINGW_INTRIN_INLINE
#i686-w64-mingw32-gcc-win32 -O3 -flto -Wall -Wextra -msse -o ../quad.exe main.c text.c input.c shaders.c custom.c player.c -lm -lpthread -lglfw -lGLEW -I/usr/include/GL -lopengl32 -lgdi32 -Werror-implicit-function-declaration -flto=auto -lfreetype -I/usr/include/freetype2 -g --static
#-fsanitize=address,undefined
cd ..
if [ -f "./quad.exe" ]; then
    if [ -f "./win.zip"]; then
        rm win.zip -f
    fi
    zip win.zip {quad.exe,data} -r
else
    echo "no exe no zip"
fi
# Sanitizers are run-time checks. It will report something when you run the program, not when building

# add -g to compile and run exec with gdb for debug segfault
# once in gdb, type run, then backtrace, quit to exit

# -std=gnu99 over -std=c99 (default) enables multiline R"( in plainC gcc
#  -pedantic

# -I/usr/include/freetype2 -I/usr/include/libpng16

# -Werror-implicit-function-declaration or -Werror
