-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
62 lines (43 loc) · 1.7 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
CC=g++ # I think this should be set in the environment, rather than in the file
TARGET_EXEC ?= PhysicsSandbox
TEST_TARGET_EXEC ?= Tests
BUILD_DIR ?= ./build
SRC_DIRS ?= ./src
TEST_SRC_DIRS ?= ./Test
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
TEST_SRCS := $(shell find $(TEST_SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s) $(SRCS)
TEST_OBJS := $(filter-out ./build/./src/main.cpp.o, $(TEST_SRCS:%=$(BUILD_DIR)/%.o))
TEST_DEPS := $(TEST_OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
OPENGL_LIBS := -lGL -lGLU -lglut
PLIB_LIBS := -lplibpuaux -lplibpu -lplibsg -lplibul -lplibfnt
BOOST_LIBS := -lboost_system -lboost_timer -lboost_chrono -lboost_thread
# IMAGE_LIBS := -lMagick++ -lMagickCore
# IM_CXXFLAGS=$(Magick++-config --cxxflags)
# IM_LDFLAGS=$(Magick++config --ldflags)
LIBS := $(OPENGL_LIBS) $(PLIB_LIBS) $(BOOST_LIBS) -ljpeg -lrt -fopenmp -Wc++0x-compat
COMPILE_ONLY_OPTION := -c
STANDARD_OPTIONS := -std=c++17
WARNINGS_OPTIONS := -Wall
DEBUG_OPTIONS := -g -O3
COMPILE_OPTIONS = $(DEBUG_OPTIONS) $(WARNINGS_OPTIONS) $(STANDARD_OPTIONS)
CPPFLAGS ?= $(COMPILE_OPTIONS) $(COMPILE_ONLY_OPTION) $(INC_FLAGS) -MMD -MP $(LIBS)
main: $(BUILD_DIR)/$(TARGET_EXEC)
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LIBS)
test: $(BUILD_DIR)/$(TEST_TARGET_EXEC)
$(BUILD_DIR)/$(TEST_TARGET_EXEC): $(TEST_OBJS)
$(CC) $(TEST_OBJS) -o $@ $(LDFLAGS) $(LIBS)
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
all: main test
-include $(DEPS)
MKDIR_P ?= mkdir -p