Customized fork of github.com/rxi/lite
1#!/bin/bash
2
3cflags="-Wall -O3 -g -std=gnu11 -Isrc -DLUA_USE_POPEN"
4lflags="-lSDL2 -lm"
5
6if [[ $* == *windows* ]]; then
7 platform="windows"
8 outfile="lite.exe"
9 compiler="x86_64-w64-mingw32-gcc"
10 cflags="$cflags -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 lflags="$lflags -o $outfile"
19fi
20
21if command -v ccache >/dev/null; then
22 compiler="ccache $compiler"
23fi
24
25
26echo "compiling ($platform)..."
27for f in `find src -name "*.c"`; do
28 $compiler -c $cflags $f -o "${f//\//_}.o"
29 if [[ $? -ne 0 ]]; then
30 got_error=true
31 fi
32done
33
34if [[ ! $got_error ]]; then
35 echo "linking..."
36 $compiler *.o $lflags
37fi
38
39echo "cleaning up..."
40rm *.o
41rm res.res 2>/dev/null
42echo "done"