-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (58 loc) · 2.28 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
# Compiler
CXX = g++
# Default build type
BUILD_TYPE ?= release
# Flags
CXXFLAGS = -MMD -MP -std=c++20 -Werror -Wall -Wextra -Wpedantic -Wformat -Wmissing-include-dirs -Wuninitialized -Wunreachable-code -Wshadow -Wconversion -Wsign-conversion -Wredundant-decls -Winit-self -Wswitch-default -Wfloat-equal -Wunused-parameter
ifeq ($(BUILD_TYPE),debug)
CXXFLAGS += -g
BIN_DIR = bin/debug
else ifeq ($(BUILD_TYPE),release)
CXXFLAGS += -O2
BIN_DIR = bin/release
else
$(error BUILD_TYPE $(BUILD_TYPE) not supported)
endif
LDFLAG = -lstdc++ -lm -lboost_program_options -lboost_system
# Directories
SRC_DIR = src
# Source and object files
SRCS = $(wildcard $(SRC_DIR)/*.cpp)
OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(BIN_DIR)/%.o, $(SRCS))
DEPS = $(OBJS:.o=.d)
# Rules
.PHONY: default toolchain clean
default: toolchain
toolchain: next_cluster make_image make_states simulate_one simulate_many
core = $(addprefix $(BIN_DIR)/, fregex.o logger.o pgm8.o program_options.o simulation_misc.o simulation_parse_state.o simulation_run.o simulation_save_state.o util.o term.o)
next_cluster: $(core) $(BIN_DIR)/next_cluster_main.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LDFLAG)
@echo 'compiling next_cluster...'
make_image: $(core) $(BIN_DIR)/make_image_main.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LDFLAG)
@echo 'compiling make_image...'
make_states: $(core) $(BIN_DIR)/make_states_main.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LDFLAG)
@echo 'compiling make_states...'
simulate_one: $(core) $(BIN_DIR)/simulate_one_main.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LDFLAG)
@echo 'compiling simulate_one...'
simulate_many: $(core) $(BIN_DIR)/simulate_many_main.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LDFLAG)
@echo 'compiling simulate_many...'
tests: $(core) $(BIN_DIR)/ntest.o $(BIN_DIR)/testing_main.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LDFLAG)
@echo 'compiling tests...'
file_write_benchmark: $(BIN_DIR)/file_write_benchmark.o
@$(CXX) $(CXXFLAGS) -o $(BIN_DIR)/file_write_benchmark $^ $(LDFLAG)
@echo 'compiling file_write_benchmark...'
$(BIN_DIR):
@mkdir -p $(BIN_DIR)
$(BIN_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BIN_DIR)
@echo 'compiling [$<]...'
@$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -r -f bin/debug bin/release
find . -name "*.d" -type f -delete
# Include the generated .d files
-include $(DEPS)