-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
137 lines (113 loc) · 3.84 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
# OpenGL + GLFW + gl3w + imgui Makefile
#
# Target Platform: Linux
TARGET = mvr
TARGET_LIB = libmvr.so.1.2.3
TARGET_LIB_SONAME = libmvr.so.1
BUILD_DIR = build
SOURCES = src/main.cpp src/mvr.cpp
SOURCES += src/util/util.cpp src/util/texture.cpp src/util/geometry.cpp
SOURCES += src/configraw.cpp src/util/transferfunc.cpp
SOURCES += libs/imgui/imgui_impl_glfw.cpp libs/imgui/imgui_impl_opengl3.cpp
SOURCES += libs/imgui/imgui.cpp libs/imgui/imgui_demo.cpp
SOURCES += libs/imgui/imgui_draw.cpp libs/imgui/imgui_widgets.cpp
SOURCES += libs/imgui/imgui_stdlib.cpp
SOURCES += libs/gl3w/GL/gl3w.c
OBJS = $(addsuffix .o, $(basename $(SOURCES)))
INCLUDE = -I./src -I./include -I./libs/gl3w -I./libs/imgui -I./libs/nlohmann
CC = cc
CXX = g++
LINKER = ld
CXXFLAGS = $(INCLUDE) -std=c++14 -fopenmp `pkg-config --cflags glfw3`
CXXFLAGS += -Wall -Wextra
DEBUG_CXXFLAGS = -DDEBUG -g
RELEASE_CXXFLAGS = -DRELEASE -O3
CFLAGS = $(INCLUDE) -std=c11 -fopenmp `pkg-config --cflags glfw3`
CFLAGS += -Wall -Wextra
DEBUG_CFLAGS = -DDEBUG -g
RELEASE_CFLAGS = -DRELEASE -O3
LDFLAGS = -lGL `pkg-config --static --libs glfw3`
LDFLAGS += -lboost_system -lboost_filesystem -lboost_regex
LDFLAGS += -lboost_program_options
LDFLAGS += -lfreeimage
LDFLAGS += -fopenmp
.PHONY: clean start all
default: debug
all:
@echo Building debug version...
@echo
@make debug
@echo
@echo
@echo
@echo --------------------------------------------------------------------------------
@echo Building release version...
@echo
@make release
@echo
@echo
@echo
@echo --------------------------------------------------------------------------------
@echo Building shared library...
@echo
@make shared
debug: CADDITIONALFLAGS = $(DEBUG_CFLAGS)
debug: CXXADDITIONALFLAGS = $(DEBUG_CXXFLAGS)
debug: TARGET_DIR = $(BUILD_DIR)/debug
debug: $(BUILD_DIR) $(BUILD_DIR)/debug start $(TARGET)
@echo Build of standalone executable complete!
release: CADDITIONALFLAGS = $(RELEASE_CFLAGS)
release: CXXADDITIONALFLAGS = $(RELEASE_CXXFLAGS)
release: TARGET_DIR = $(BUILD_DIR)/release
release: $(BUILD_DIR) $(BUILD_DIR)/release start $(TARGET)
@echo Build of standalone executable complete!
shared: CADDITIONALFLAGS = $(RELEASE_CFLAGS) -fpic
shared: CXXADDITIONALFLAGS = $(RELEASE_CXXFLAGS) -fpic
shared: TARGET_DIR = $(BUILD_DIR)/lib
shared: LDADDITIONALFLAGS = -shared -Wl,-soname,$(TARGET_LIB_SONAME)
shared: $(BUILD_DIR) $(BUILD_DIR)/lib start $(TARGET_LIB)
@echo Build of shared library complete!
start:
@echo -------------------------------------------------------------------------------
@echo Compiling...
@echo
@echo CXXFLAGS: $(CXXFLAGS) $(CXXADDITIONALFLAGS)
@echo CFLAGS: $(CFLAGS) $(CADDITIONALFLAGS)
@echo TARGET_DIR $(TARGET_DIR)
@echo
%.o: %.cpp
@echo $<
@$(CXX) $(CXXFLAGS) $(CXXADDITIONALFLAGS) -c -o $(TARGET_DIR)/$(@F) $<
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $(CADDITIONALFLAGS) -c -o $(TARGET_DIR)/$(@F) $<
$(BUILD_DIR):
@echo Creating build directory...
@mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%:
@echo Creating target directory...
@mkdir -p $@
$(TARGET): $(OBJS)
@echo -------------------------------------------------------------------------------
@echo Linking executable...
@echo
@echo LDFLAGS: $(LDFLAGS) $(LDADDITIONALFLAGS)
@echo TARGET_DIR: $(TARGET_DIR)
@echo TARGET: $(TARGET)
@echo
@$(CXX) $(addprefix $(TARGET_DIR)/, $(notdir $^)) $(LDFLAGS) $(LDADDITIONALFLAGS) -o $(TARGET_DIR)/$(TARGET)
$(TARGET_LIB): $(OBJS)
@echo -------------------------------------------------------------------------------
@echo Linking shared library...
@echo
@echo LDFLAGS: $(LDFLAGS) $(LDADDITIONALFLAGS)
@echo TARGET_DIR: $(TARGET_DIR)
@echo TARGET_LIB: $(TARGET_LIB)
@echo
@$(CXX) $(addprefix $(TARGET_DIR)/, $(notdir $^)) $(LDFLAGS) $(LDADDITIONALFLAGS) -o $(TARGET_DIR)/$(TARGET_LIB)
clean:
@echo Cleaning up...
@rm -rf ./$(BUILD_DIR)/debug
@rm -rf ./$(BUILD_DIR)/release
@rm -rf ./$(BUILD_DIR)/lib
@echo Done!