summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..fc0232f
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+WINDOWS=1
+
+
+if [[ "$WINDOWS" == 1 ]]; then
+WARNING_FLAGS="
+ -Wall -Wextra \
+ -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable \
+ -Wno-missing-field-initializers -Wno-sign-compare -Wno-write-strings -Wno-unused-but-set-parameter \
+ -Wno-missing-braces -Wno-format-security
+ -fno-exceptions -Wno-strict-aliasing \
+ -DDEBUG=1 -DARM=0 -DTHREADED=1 -DPACKEDRGB=1 -DWINDOWS=1 \
+"
+else
+WARNING_FLAGS="
+ -Wall -Wextra \
+ -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable \
+ -Wno-missing-field-initializers -Wno-sign-compare -Wno-write-strings -Wno-unused-but-set-parameter \
+ -Wno-missing-braces -Wno-format-security
+ -fno-exceptions -Wno-strict-aliasing \
+ -DDEBUG=1 -DARM=0 -DTHREADED=1 -DPACKEDRGB=1 -DWINDOWS=0 \
+"
+fi
+
+
+FFMPEG_LIBS="
+ libavdevice
+ libavformat
+ libavfilter
+ libavcodec
+ libswresample
+ libswscale
+ libavutil
+"
+
+IMGUI_FILES="
+ imgui
+ imgui_demo
+ imgui_draw
+ imgui_tables
+ imgui_widgets
+"
+
+IMGUI_FILES_IMPL="
+ imgui_impl_sdl
+ imgui_impl_opengl3
+"
+
+if [[ "$OSTYPE" =~ ^darwin ]]; then
+IMGUI_FLAGS="
+ -std=c++11 -Iimgui -Iimgui/backends -g -Wall -Wformat `sdl2-config --cflags` -I/usr/local/include -I/opt/local/include -c
+"
+else
+IMGUI_FLAGS="
+ -Iimgui -Iimgui/backends -g -Wall -Wformat `sdl2-config --cflags` -c
+"
+fi
+imgui() {
+ for i in $IMGUI_FILES
+ do
+ clang $IMGUI_FLAGS -o bin/$i.o imgui/$i.cpp
+ done
+ for i in $IMGUI_FILES_IMPL
+ do
+ clang $IMGUI_FLAGS -o bin/$i.o imgui/backends/$i.cpp
+ done
+}
+
+if [[ "$OSTYPE" =~ ^darwin ]]; then
+ SDL_ARGS="`sdl2-config --cflags` -framework OpenGL -ldl `sdl2-config --libs`"
+else
+ SDL_ARGS="`sdl2-config --cflags` -lGL -ldl `sdl2-config --libs`"
+fi
+
+if [[ "$WINDOWS" == 1 ]]; then
+clang++ $WARNING_FLAGS -g -target x86_64-pc-windows-gnu -march=x86-64-v3 -I .. -Iimgui -Iimgui/backends \
+ main.cpp imgui/imgui*.cpp imgui/backends/imgui_impl_sdl.cpp imgui/backends/imgui_impl_opengl3.cpp \
+ -I/usr/x86_64-w64-mingw32/include/SDL2 -I/usr/x86_64-w64-mingw32/include/GL \
+ -lmingw32 -lopengl32 -lSDL2main -lSDL2 -llibavcodec -llibswscale -llibavformat -llibavutil \
+ -o bin/real2d
+else
+clang main.cpp $WARNING_FLAGS -g -O0 -march=native -o bin/real2d bin/*.o \
+ -std=c++11 -lstdc++ -Iimgui -Iimgui/backends \
+ $SDL_ARGS \
+ -I . \
+ -lm $(pkg-config --cflags --libs $FFMPEG_LIBS)
+fi