Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
79 lines (62 loc) · 1.87 KB
/
Copy pathmakefile
File metadata and controls
79 lines (62 loc) · 1.87 KB
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
# BUILD CONFIGURATION
# Set to 1 to build with Modern OpenGL, set to 0 to build with Legacy OpenGL
MODERN_GL_ENABLED = 1
CXX = clang++
# CXXFLAGS = -std=c++17 -Wall -Wextra -g # to build with debugging flags
CXXFLAGS = -std=c++17 -Wall -Wextra -O2
CXXFLAGS += -Wuninitialized -Wshadow -Wformat -Wconversion -Wdeprecated-declarations
CXXFLAGS += -Ivendor/imgui
CXXFLAGS += -Ivendor/implot
ifeq ($(MODERN_GL_ENABLED),1)
CXXFLAGS += -DMODERN_GL
endif
ALL_PKGS = sdl2 glew glm
CXXFLAGS += $(shell pkg-config --cflags $(ALL_PKGS))
LDFLAGS += $(shell pkg-config --libs $(ALL_PKGS))
# Platform-Specific Flags
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LDFLAGS += -framework OpenGL
else ifeq ($(UNAME_S),Linux)
LDFLAGS += -lGL
endif
# Target executable
TARGET = ising
BASE_SRC = main.cpp \
IsingSimulation.cpp \
ExperimentController.cpp \
globals.cpp \
random.cpp \
StatisticsTracker.cpp \
vendor/imgui/imgui.cpp \
vendor/imgui/imgui_draw.cpp \
vendor/imgui/imgui_tables.cpp \
vendor/imgui/imgui_widgets.cpp \
vendor/imgui/imgui_impl_sdl2.cpp \
vendor/implot/implot.cpp \
vendor/implot/implot_items.cpp
# Conditionally add the correct ImGui OpenGL backend
ifeq ($(MODERN_GL_ENABLED),1)
BASE_SRC += vendor/imgui/imgui_impl_opengl3.cpp
else
BASE_SRC += vendor/imgui/imgui_impl_opengl2.cpp
endif
ifeq ($(MODERN_GL_ENABLED),1)
SRC = $(BASE_SRC) rendering/ModernGLRenderer.cpp shader_utils.cpp
else
SRC = $(BASE_SRC) rendering/LegacyGLRenderer.cpp
endif
OBJS = $(SRC:.cpp=.o)
# Default rule: compile program
$(TARGET): $(OBJS)
$(CXX) -o $@ $^ $(LDFLAGS)
# Remove the .o files after linking the executable
rm -f $(OBJS)
# Run the executable after successful compilation
./$(TARGET)
# Compile individual .cpp files into .o
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean up generated files
clean:
rm -f $(OBJS) $(TARGET)