2020-05-09 12:01:28 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-05-21 16:57:05 +02:00
|
|
|
cflags="-Wall -O3 -g -std=gnu11 -Isrc"
|
2020-05-09 12:01:28 +02:00
|
|
|
lflags="-lSDL2 -lm"
|
|
|
|
|
|
|
|
if [[ $* == *windows* ]]; then
|
|
|
|
platform="windows"
|
|
|
|
outfile="lite.exe"
|
|
|
|
compiler="x86_64-w64-mingw32-gcc"
|
2020-05-21 16:57:05 +02:00
|
|
|
cflags="$cflags -DLUA_USE_POPEN -Iwinlib/SDL2-2.0.10/x86_64-w64-mingw32/include"
|
2020-05-09 12:01:28 +02:00
|
|
|
lflags="$lflags -Lwinlib/SDL2-2.0.10/x86_64-w64-mingw32/lib"
|
|
|
|
lflags="-lmingw32 -lSDL2main $lflags -mwindows -o $outfile res.res"
|
|
|
|
x86_64-w64-mingw32-windres res.rc -O coff -o res.res
|
|
|
|
else
|
|
|
|
platform="unix"
|
|
|
|
outfile="lite"
|
|
|
|
compiler="gcc"
|
2020-05-21 16:57:05 +02:00
|
|
|
cflags="$cflags -DLUA_USE_POSIX"
|
2020-05-09 12:01:28 +02:00
|
|
|
lflags="$lflags -o $outfile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if command -v ccache >/dev/null; then
|
|
|
|
compiler="ccache $compiler"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "compiling ($platform)..."
|
|
|
|
for f in `find src -name "*.c"`; do
|
|
|
|
$compiler -c $cflags $f -o "${f//\//_}.o"
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
got_error=true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ ! $got_error ]]; then
|
|
|
|
echo "linking..."
|
|
|
|
$compiler *.o $lflags
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "cleaning up..."
|
|
|
|
rm *.o
|
|
|
|
rm res.res 2>/dev/null
|
|
|
|
echo "done"
|