-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·62 lines (49 loc) · 1.72 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
version=1.0
cflags=${CFLAGS:-"-march=native -O3 -Wall -Wextra"}
cflags="${cflags} -std=c11 -I./external/include -DVERSION=\"$version\""
ldflags=${LDFLAGS:-"-flto"}
ldflags="$ldflags -lraylib -lm"
output="colourpicker"
debug=${DEBUG}
cc=${CC:-cc}
system_raylib=${USE_SYSTEM_RAYLIB:-$debug}
case $(uname -s) in
MINGW64*)
output="Colour Picker"
windres assets/colourpicker.rc assets/colourpicker.rc.o
ldflags="assets/colourpicker.rc.o $ldflags -mwindows -lgdi32 -lwinmm"
;;
esac
# NOTE: clones and builds a static raylib if system lib is not requested
# NOTE: this requires cmake
if [ "$system_raylib" ]; then
ldflags="-L/usr/local/lib $ldflags"
else
if [ ! -f external/lib/libraylib.a ]; then
git submodule update --init --checkout --depth=1 external/raylib
cmake --install-prefix="${PWD}/external" \
-G "Ninja" -B external/raylib/build -S external/raylib \
-D CMAKE_INSTALL_LIBDIR=lib -D CMAKE_BUILD_TYPE="Release" \
-D CUSTOMIZE_BUILD=ON -D WITH_PIC=ON -D BUILD_EXAMPLES=OFF
cmake --build external/raylib/build
cmake --install external/raylib/build
fi
ldflags="-L./external/lib $ldflags"
fi
[ ! -s "config.h" ] && cp config.def.h config.h
if [ ! -e "external/include/shader_inc.h" ] || [ "slider_lerp.glsl" -nt "external/include/shader_inc.h" ]; then
${cc} $cflags -o gen_incs gen_incs.c $ldflags
./gen_incs
mv lora_sb*.h external/include/
fi
if [ "$debug" ]; then
# Hot Reloading/Debugging
cflags="$cflags -O0 -ggdb -D_DEBUG -Wno-unused-function"
# NOTE: needed for sync(3p)
cflags="$cflags -D_XOPEN_SOURCE=700"
libcflags="$cflags -fPIC"
libldflags="$ldflags -shared"
${cc} $libcflags colourpicker.c -o libcolourpicker.so $libldflags
fi
${cc} $cflags -o "$output" main.c $ldflags