42 lines
1.4 KiB
Bash
Executable File
42 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
export target_os="${target_os:=$1}"
|
|
|
|
if [ "$target_os" = "" ]; then
|
|
echo "Usage: $0 <platform>"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$target_os" = "linux" ]; then
|
|
echo "* Compiling: linux ..."
|
|
CC="${CC:=gcc}"
|
|
./lua_translate
|
|
"$CC" -std=gnu89 src/main.c -g -lSDL2 -llua5.3 -lm -o engine -O3 -Werror -Wall $CFLAGS
|
|
exit
|
|
fi
|
|
|
|
if [ "$target_os" = "openbsd" ]; then
|
|
echo "* Compiling: openbsd ..."
|
|
CC="${CC:=egcc}"
|
|
./lua_translate
|
|
"$CC" -std=gnu89 src/main.c -g -lSDL2 -llua5.3 -lm -o engine -O3 -Werror -Wall -I /usr/local/include $CFLAGS
|
|
exit
|
|
fi
|
|
|
|
if [ "$target_os" = "windows" ]; then
|
|
echo "* Compiling: windows ..."
|
|
CC="${CC:=gcc}"
|
|
PYTHON="${PYTHON:=py}" # https://www.python.org/downloads/release/python-344/
|
|
MINGWPATH="${MINGWPATH:=C:\\mingw32}" # https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/
|
|
SDLPATH="${SDLPATH:=SDL2}" # https://github.com/libsdl-org/SDL/releases
|
|
LUAPATH="${LUAPATH:=lua5.3/src}" # https://www.lua.org/ftp/lua-5.3.6.tar.gz
|
|
"$PYTHON" lua_translate
|
|
"$CC" -std=gnu89 src/main.c -g -L"$MINGWPATH\\lib" -w -Wl,-subsystem,windows -lmingw32 -L"$LUAPATH" -I"$LUAPATH" -I"$SDLPATH/include" -L"$SDLPATH/lib" -lSDL2main -lSDL2 -llua53 -lm -o engine.exe -O3 -Werror -Wall $CFLAGS
|
|
exit
|
|
fi
|
|
|
|
echo "Unsupported platform. These platforms are currently available:"
|
|
echo "* linux"
|
|
echo "* openbsd"
|
|
echo "* windows"
|
|
exit 1 |