me.fier.engine/compile

42 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-05-14 10:21:03 +00:00
#!/usr/bin/env bash
set -e
export target_os="${target_os:=$1}"
2023-08-10 17:47:28 +00:00
if [ "$target_os" = "" ]; then
2023-08-12 04:24:26 +00:00
echo "Usage: $0 <platform>"
2023-08-10 17:47:28 +00:00
exit 1
fi
2023-08-11 12:35:10 +00:00
if [ "$target_os" = "linux" ]; then
echo "* Compiling: linux ..."
2023-08-11 12:41:11 +00:00
CC="${CC:=gcc}"
2023-08-11 12:35:10 +00:00
./lua_translate
2023-08-12 04:23:49 +00:00
"$CC" -std=gnu89 src/main.c -g -lSDL2 -llua5.3 -lm -o engine -O3 -Werror -Wall $CFLAGS
2023-08-11 12:35:10 +00:00
exit
fi
if [ "$target_os" = "openbsd" ]; then
echo "* Compiling: openbsd ..."
2023-08-11 12:41:11 +00:00
CC="${CC:=egcc}"
2023-08-11 12:35:10 +00:00
./lua_translate
2023-08-12 04:23:49 +00:00
"$CC" -std=gnu89 src/main.c -g -lSDL2 -llua5.3 -lm -o engine -O3 -Werror -Wall -I /usr/local/include $CFLAGS
2023-08-11 12:35:10 +00:00
exit
fi
2023-08-12 04:24:26 +00:00
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"
2023-08-11 12:35:10 +00:00
exit 1