-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
189 lines (142 loc) · 5.32 KB
/
Makefile
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Dr.LUT - Lookup Table Generator
#
# Copyright (c) 2021 by ppelikan
# github.com/ppelikan
IMGUI_DIR = ../imgui
IMPLOT_DIR = ../implot
SRC_DIR = src
TE_DIR = ext/TinyExpr
FD_DIR = ext/ImGuiFileDialog
SOURCES = $(SRC_DIR)/main.cpp\
$(SRC_DIR)/gui_app_main.cpp\
$(SRC_DIR)/lut_builder.cpp\
$(SRC_DIR)/wave_generator.cpp\
$(SRC_DIR)/multitype_array.cpp
SOURCES += $(IMGUI_DIR)/imgui.cpp\
$(IMGUI_DIR)/imgui_draw.cpp\
$(IMGUI_DIR)/imgui_tables.cpp\
$(IMGUI_DIR)/imgui_widgets.cpp\
$(IMGUI_DIR)/misc/cpp/imgui_stdlib.cpp\
$(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp\
$(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp\
$(IMPLOT_DIR)/implot.cpp\
$(IMPLOT_DIR)/implot_items.cpp\
$(TE_DIR)/tinyexpr.c
INCLUDES = -I$(IMGUI_DIR)\
-I$(IMGUI_DIR)/misc/cpp\
-I$(IMGUI_DIR)/backends\
-I$(IMPLOT_DIR)\
-I$(TE_DIR)
PORT_SOURCES = $(SOURCES) $(FD_DIR)/ImGuiFileDialog.cpp
PORT_INCLUDES = $(INCLUDES) -I$(FD_DIR)
FLAGS = -DIMGUI_DEFINE_MATH_OPERATORS
##---------------------------------------------------------------------
## EMSCRIPTEN OPTIONS
##---------------------------------------------------------------------
WASM_BUILD_DIR = build/wasm
WASM_CC = emcc
WASM_CXX = em++
WEB_DIR = $(WASM_BUILD_DIR)/web
WASM_EXE = $(WEB_DIR)/index.html
WASM_EMS += -s USE_SDL=2
WASM_EMS += -s DISABLE_EXCEPTION_CATCHING=1
# WASM_EMS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1
# WASM_EMS += -s ASSERTIONS=1 -s NO_FILESYSTEM=1 -s NO_EXIT_RUNTIME=0
WASM_EMS += -DIMGUI_DISABLE_FILE_FUNCTIONS $(FLAGS)
WASM_CPPFLAGS = $(INCLUDES)
WASM_CPPFLAGS += -Wall -Wformat -Os
WASM_CPPFLAGS += $(WASM_EMS) -DWASM_BUILD
WASM_LIBS += $(WASM_EMS)
WASM_LDFLAGS += -sASYNCIFY -Os --shell-file shell.html
##---------------------------------------------------------------------
## PORTABLE OPTIONS
##---------------------------------------------------------------------
PORT_BUILD_DIR = build/portable
PORT_CC = gcc
PORT_CXX = g++
PORT_EXE = $(PORT_BUILD_DIR)/app_executable
LINUX_GL_LIBS = -lGLESv2
PORT_CXXFLAGS = $(PORT_INCLUDES)
# Debugging:
PORT_CXXFLAGS += -Wall -Wformat -g
# Release:
#PORT_CXXFLAGS += -O2
PORT_LIBS =
PORT_CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2 $(FLAGS)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
PORT_LIBS += $(LINUX_GL_LIBS) -ldl `sdl2-config --libs`
PORT_CXXFLAGS += `sdl2-config --cflags`
PORT_CFLAGS = $(PORT_CXXFLAGS)
endif
# ifeq ($(UNAME_S), Darwin) #APPLE
# ECHO_MESSAGE = "Mac OS X"
# PORT_LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
# PORT_LIBS += -L/usr/local/lib -L/opt/local/lib
# PORT_CXXFLAGS += `sdl2-config --cflags`
# PORT_CXXFLAGS += -I/usr/local/include -I/opt/local/include
# PORT_CFLAGS = $(PORT_CXXFLAGS)
# endif
# ifeq ($(OS), Windows_NT)
# ECHO_MESSAGE = "MinGW"
# PORT_LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
# PORT_CXXFLAGS += `pkg-config --cflags sdl2`
# PORT_CFLAGS = $(PORT_CXXFLAGS)
# endif
WASM_OBJS = $(addprefix $(WASM_BUILD_DIR)/, $(addsuffix .o, $(basename $(notdir $(SOURCES)))))
PORT_OBJS = $(addprefix $(PORT_BUILD_DIR)/, $(addsuffix .o, $(basename $(notdir $(PORT_SOURCES)))))
ICON = favicon.ico
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
all: $(PORT_EXE) $(WASM_EXE)
@echo Build ALL completed
portable: $(PORT_EXE)
web: $(WASM_EXE)
serve: $(WASM_EXE)
python3 -m http.server -d $(WEB_DIR)
clean:
rm -rf $(WASM_OBJS) $(WEB_DIR) $(WASM_BUILD_DIR) $(PORT_BUILD_DIR)
$(WEB_DIR):
mkdir $@
$(WASM_BUILD_DIR):
mkdir -p $@
$(WASM_EXE): $(WASM_BUILD_DIR) $(WASM_OBJS) $(WEB_DIR) $(WEB_DIR)/favicon.ico shell.html
$(WASM_CXX) -o $@ $(WASM_OBJS) $(WASM_LIBS) $(WASM_LDFLAGS)
@echo Building for WEB completed
$(WASM_BUILD_DIR)/%.o:$(SRC_DIR)/%.cpp
$(WASM_CXX) $(WASM_CPPFLAGS) $(WASM_CXXFLAGS) -c -o $@ $<
$(WASM_BUILD_DIR)/%.o:$(IMGUI_DIR)/%.cpp
$(WASM_CXX) $(WASM_CPPFLAGS) $(WASM_CXXFLAGS) -c -o $@ $<
$(WASM_BUILD_DIR)/%.o:$(IMGUI_DIR)/misc/cpp/%.cpp
$(WASM_CXX) $(WASM_CPPFLAGS) $(WASM_CXXFLAGS) -c -o $@ $<
$(WASM_BUILD_DIR)/%.o:$(IMGUI_DIR)/backends/%.cpp
$(WASM_CXX) $(WASM_CPPFLAGS) $(WASM_CXXFLAGS) -c -o $@ $<
$(WASM_BUILD_DIR)/%.o:../libs/gl3w/GL/%.c
$(WASM_CC) $(WASM_CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(WASM_BUILD_DIR)/%.o:$(IMPLOT_DIR)/%.cpp
$(WASM_CXX) $(WASM_CPPFLAGS) $(WASM_CXXFLAGS) -c -o $@ $<
$(WASM_BUILD_DIR)/%.o:$(TE_DIR)/%.c
$(WASM_CC) $(WASM_CPPFLAGS) $(WASM_CXXFLAGS) -c -o $@ $<
$(WEB_DIR)/favicon.ico: $(ICON)
cp $(ICON) $(WEB_DIR)/favicon.ico
$(PORT_BUILD_DIR):
mkdir -p $@
$(PORT_EXE): $(PORT_BUILD_DIR) $(PORT_OBJS)
$(PORT_CXX) -o $@ $(PORT_OBJS) $(PORT_CXXFLAGS) $(PORT_LIBS)
@echo Building for $(ECHO_MESSAGE) completed
$(PORT_BUILD_DIR)/%.o:$(SRC_DIR)/%.cpp
$(PORT_CXX) $(PORT_CXXFLAGS) -c -o $@ $<
$(PORT_BUILD_DIR)/%.o:$(IMGUI_DIR)/%.cpp
$(PORT_CXX) $(PORT_CXXFLAGS) -c -o $@ $<
$(PORT_BUILD_DIR)/%.o:$(IMGUI_DIR)/misc/cpp/%.cpp
$(PORT_CXX) $(PORT_CXXFLAGS) -c -o $@ $<
$(PORT_BUILD_DIR)/%.o:$(IMGUI_DIR)/backends/%.cpp
$(PORT_CXX) $(PORT_CXXFLAGS) -c -o $@ $<
$(PORT_BUILD_DIR)/%.o:$(IMPLOT_DIR)/%.cpp
$(PORT_CXX) $(PORT_CXXFLAGS) -c -o $@ $<
$(PORT_BUILD_DIR)/%.o:$(FD_DIR)/%.cpp
$(PORT_CXX) $(PORT_CXXFLAGS) -c -o $@ $<
$(PORT_BUILD_DIR)/%.o:$(TE_DIR)/%.c
$(PORT_CC) $(PORT_CXXFLAGS) -c -o $@ $<