super basic UI layouting
[fishladder.git] / build.sh
1 # Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
2
3 src="fishladder.c"
4 target="fishladder"
5 lib="-I. -L./lib -L./"
6 libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl" # -l:steam/libsteam_api.so"
7 flags="-fsanitize=address -ggdb3 -Wno-unused-function -DNO_STEAM"
8
9 if [[ "$OSTYPE" != "linux-gnu"* ]]; then
10 echo "Operating system is not GNU/Linux, windows will be assumed."
11 target="fishladder.exe"
12 libs="-lglfw3 -lopengl32 -lm -mwindows"
13 flags="-ggdb3 -Wno-unused-function -DNO_STEAM"
14 fi
15
16 run_after=false
17 do_build=true
18 compile_tools=false
19 compile_models=false
20
21 while (( "$#" )); do
22 case $1 in
23 -r|--release)
24 flags="-O3"
25 echo "Release mode"
26 ;;
27 -p|--play)
28 run_after=true
29 echo "& Run"
30 ;;
31 -n|--nobuild)
32 do_build=false
33 echo "no-build"
34 ;;
35 -t|--tools)
36 compile_tools=true
37 echo "build-tools"
38 ;;
39 -m|--models)
40 compile_models=true
41 echo "build-models"
42 ;;
43 *)
44 echo "Unkown param: $1"
45 exit 1
46 ;;
47 esac
48 shift
49 done
50
51 # Tools
52 if [ "$compile_tools" = true ]; then
53 echo "Building tools"
54 mkdir tools -p
55 gcc -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs -Wl,-rpath=./ $defines
56 fi
57
58 # Resources
59 if [ "$compile_models" = true ]; then
60 echo "Recompiling models"
61 for f in models/*.obj;
62 do echo "Compiling $f..";
63 ./tools/mdlcomp $f $f.h
64 done
65 fi
66
67 # Main build
68 if [ "$do_build" = true ]; then
69 gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs -Wl,-rpath=./ $defines
70
71 if [ $? -ne 0 ]; then
72 echo "GCC build failed"
73 exit 1
74 fi
75
76 echo "Build succeeded"
77 fi
78
79 if [[ "$OSTYPE" == "linux-gnu"* ]]; then
80 # Directories to initialize
81 mkdir build.linux/cfg -p
82 mkdir build.linux/textures -p
83
84 cp $target ./build.linux/$target
85 cp ./steam/libsteam_api.so ./build.linux/libsteam_api.so
86 cp -r ./textures/ ./build.linux/
87
88 if [ "$run_after" = true ]; then
89 echo "Playing"
90
91 cd ./build.linux/
92 ./$target
93 cd ./../
94 fi
95 else
96 mkdir build.win32/cfg -p
97 mkdir build.win32/textures -p
98
99 cp $target ./build.win32/$target
100 cp -r ./textures/ ./build.win32/
101 cp ./lib/glfw3.dll ./build.win32/glfw3.dll
102
103 if [ "$run_after" = true ]; then
104 echo "Playing"
105
106 cd ./build.win32/
107 ./$target
108 cd ./../
109 fi
110 fi