-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
217 lines (164 loc) · 5.87 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#
# Cross Platform Makefile
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
#
# You will need GLFW (http://www.glfw.org):
# Linux:
# apt-get install libglfw-dev
# Mac OS X:
# brew install glfw
# MSYS2:
# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
#
#CXX = g++
#CXX = clang++
TARGET ?= x86_64
IMGUI_DIR = lib/imgui
TINYXML2_DIR = lib/tinyxml2
NATIVEFILEDIALOG_DIR = lib/nativefiledialog
SQLITE3_DIR = lib/sqlite3
RX8_ECU_DUMP_DIR = lib/rx8-ecu-dump
J2534_DIR = $(RX8_ECU_DUMP_DIR)/J2534
SOURCES = src/main.cpp
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
SOURCES += $(TINYXML2_DIR)/tinyxml2.cpp
SOURCES += $(SQLITE3_DIR)/sqlite3.c
SOURCES += $(RX8_ECU_DUMP_DIR)/src/util.cpp
SOURCES += $(RX8_ECU_DUMP_DIR)/src/librx8.cpp
SOURCES += $(RX8_ECU_DUMP_DIR)/src/UDS.cpp
SOURCES += $(J2534_DIR)/J2534.cpp
ifeq ($(TARGET), x86_64)
EXE = conescan
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
endif
ifeq ($(TARGET), wasm)
CC = emcc
CXX = em++
EMSCRIPTEN_EXTRA_DIR = emscripten
WEB_DIR = $(EMSCRIPTEN_EXTRA_DIR)/web
EXE = $(WEB_DIR)/index.html
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
EMS += -s USE_SDL=2
# EMS += -s DISABLE_EXCEPTION_CATCHING=1
# EMS += -g3
# EMS += -sASYNCIFY_IGNORE_INDIRECT
LDFLAGS += -lidbfs.js -s ALLOW_MEMORY_GROWTH=1 -s EXIT_RUNTIME=1 -s ASSERTIONS=1 -sASYNCIFY
# Emscripten allows preloading a file or folder to be accessible at runtime.
# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
USE_FILE_SYSTEM ?= 1
ifeq ($(USE_FILE_SYSTEM), 0)
LDFLAGS += -s NO_FILESYSTEM=1
CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
endif
ifeq ($(USE_FILE_SYSTEM), 1)
# LDFLAGS += --no-heap-copy --preload-file $(IMGUI_DIR)/misc/fonts@/fonts
LDFLAGS += --preload-file lib/metadata@/metadata
LDFLAGS += --preload-file [email protected]
endif
LDFLAGS += --shell-file $(EMSCRIPTEN_EXTRA_DIR)/shell_minimal.html $(EMS)
endif
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
LINUX_GL_LIBS = -lGL
CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
CXXFLAGS += -I$(TINYXML2_DIR)
CXXFLAGS += -I$(NATIVEFILEDIALOG_DIR)/src/include
CXXFLAGS += -I$(SQLITE3_DIR)
CXXFLAGS += -I$(RX8_ECU_DUMP_DIR)/src
CXXFLAGS += -I$(J2534_DIR)
CXXFLAGS += -g # TODO: remove in release builds
CXXFLAGS += -Wall -Wformat -Iinclude
SOURCES += src/conescan.cpp
SOURCES += src/definition.cpp
SOURCES += src/console.cpp
SOURCES += src/conescan_db.cpp
SOURCES += src/history.cpp
SOURCES += src/layout.cpp
SOURCES += src/uds_request_download.cpp
SOURCES += src/file_open_dialog.cpp
SOURCES += src/definition_parse.cpp
##---------------------------------------------------------------------
## OPENGL ES
##---------------------------------------------------------------------
## This assumes a GL ES library available in the system, e.g. libGLESv2.so
# CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2
# LINUX_GL_LIBS = -lGLESv2
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
LIBS =
ifeq ($(TARGET), x86_64)
EXEDEPS += $(NATIVEFILEDIALOG_DIR)/build/lib/Release/x64/libnfd.a
EXELIBS = $(NATIVEFILEDIALOG_DIR)/build/lib/Release/x64/libnfd.a
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3`
LIBS += `pkg-config --static --libs glew`
# for native file dialog
LIBS += $(LINUX_GL_LIBS) `pkg-config --cflags --libs gtk+-3.0`
CXXFLAGS += `pkg-config --cflags glfw3`
CXXFLAGS += -Wl,-R,'$$ORIGIN'
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib
LIBS += -lglfw
CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(OS), Windows_NT)
ECHO_MESSAGE = "MinGW"
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
endif
ifeq ($(TARGET), wasm)
EXEDEPS = $(WEB_DIR)
ECHO_MESSAGE = "WASM"
CXXFLAGS += -DWASM $(EMS)
CFLAGS = $(CXXFLAGS)
endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:src/%.cpp
$(CXX) -std=c++11 $(CXXFLAGS) -c -o $@ $<
%.o:$(SQLITE3_DIR)/%.c
$(CC) $(CXXFLAGS) -c -o $@ $<
%.o:$(IMGUI_DIR)/%.cpp
$(CXX) -std=c++11 $(CXXFLAGS) -c -o $@ $<
%.o:$(TINYXML2_DIR)/%.cpp
$(CXX) -std=c++11 $(CXXFLAGS) -c -o $@ $<
%.o:$(IMGUI_DIR)/backends/%.cpp
$(CXX) -std=c++11 $(CXXFLAGS) -c -o $@ $<
%.o:$(RX8_ECU_DUMP_DIR)/src/%.cpp
$(CXX) -std=c++11 $(CXXFLAGS) -c -o $@ $<
%.o:$(J2534_DIR)/%.cpp
$(CXX) -std=c++11 $(CXXFLAGS) -c -o $@ $<
all: $(EXE)
@echo Build complete for $(ECHO_MESSAGE)
ifeq ($(TARGET), x86_64)
$(EXE): $(OBJS) $(EXEDEPS)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) $(EXELIBS)
$(NATIVEFILEDIALOG_DIR)/build/lib/Release/x64/libnfd.a:
$(MAKE) -C $(NATIVEFILEDIALOG_DIR)/build/gmake_linux config=release_x64
run: $(EXE)
./$(EXE)
debug: $(EXE)
gdb ./$(EXE)
endif
ifeq ($(TARGET), wasm)
$(EXE): $(OBJS) $(WEB_DIR) $(EMSCRIPTEN_EXTRA_DIR)/shell_minimal.html
$(CXX) -o $@ $(OBJS) $(LDFLAGS)
$(WEB_DIR):
mkdir $@
serve: all
python3 -m http.server -d $(WEB_DIR)
endif
clean:
rm -f $(EXE) $(OBJS) $(WEB_DIR)/*.js $(WEB_DIR)/*.wasm $(WEB_DIR)/*.wasm.pre $(WEB_DIR)/index.data