Customized fork of github.com/rxi/lite
1#!/bin/bash
2
3cflags="-Wall -O3 -g -std=gnu11 -fno-strict-aliasing -Isrc"
4lflags="-lSDL3 -lm"
5
6if [[ $* == *windows* ]]; then
7 platform="windows"
8 outfile="lite.exe"
9 compiler="x86_64-w64-mingw32-gcc"
10 cflags="$cflags -DLUA_USE_POPEN -Iwinlib/SDL2-2.0.10/x86_64-w64-mingw32/include"
11 lflags="$lflags -Lwinlib/SDL2-2.0.10/x86_64-w64-mingw32/lib"
12 lflags="-lmingw32 -lSDL2main $lflags -mwindows -o $outfile res.res"
13 x86_64-w64-mingw32-windres res.rc -O coff -o res.res
14else
15 platform="unix"
16 outfile="lite"
17 compiler="gcc"
18 cflags="$cflags -DLUA_USE_POSIX"
19 lflags="$lflags -o $outfile"
20fi
21
22if command -v ccache >/dev/null; then
23 compiler="ccache $compiler"
24fi
25
26
27echo "compiling ($platform)..."
28for f in `find src -name "*.c"`; do
29 $compiler -c $cflags $f -o "${f//\//_}.o"
30 if [[ $? -ne 0 ]]; then
31 got_error=true
32 fi
33done
34
35if [[ ! $got_error ]]; then
36 echo "linking..."
37 $compiler *.o $lflags
38fi
39
40echo "cleaning up..."
41rm *.o
42rm res.res 2>/dev/null
43echo "done"