summaryrefslogtreecommitdiff
path: root/build.sh
blob: 433bfc6a9d0efff50c0095c94bf3529f864a0782 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash

WINDOWS=0

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 \
"

if [[ "$WINDOWS" == 1 ]]; then
WARNING_FLAGS="$WARNING_FLAGS -DWINDOWS=1"
fi


FFMPEG_LIBS="
    libavdevice
    libavformat
    libavfilter
    libavcodec
    libswresample
    libswscale
    libavutil
"

# IMGUI_FILES="
#     imgui/imgui
#     imgui/imgui_demo
#     imgui/imgui_draw
#     imgui/imgui_tables
#     imgui/imgui_widgets
#     my_imgui_internal_widgets
# "

IMGUI_FILES="
    my_imgui_internal_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 $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

imgui

   # -lm $(pkg-config --cflags --libs $FFMPEG_LIBS) -MJresult.json

if [[ "$WINDOWS" == 1 ]]; then
clang++ -g $WARNING_FLAGS -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 -march=native -o bin/real2d bin/*.o  \
   -std=c++11 -lstdc++ -Iimgui -Iimgui/backends  \
   $SDL_ARGS \
   -I . \
   -lm -I /usr/local/include ~/.local/src/ffmpeg/bin/*.so
fi