-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (36 loc) · 1.17 KB
/
Makefile
File metadata and controls
47 lines (36 loc) · 1.17 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
# Compiler and flags
CXXFLAGS := -Wall -Wextra -std=c++17 -O2
# Directories
BUILD_DIR := build
OBJ_DIR := $(BUILD_DIR)/obj
BIN_DIR := $(BUILD_DIR)/bin
SRC_DIR := src/cpp
# Target names
TARGET := $(BIN_DIR)/simAnnSingle.out
LIB_OBJECT := $(OBJ_DIR)/simAnn.o
TEST_OBJECT := $(OBJ_DIR)/simAnnSingle.o
BENCH_OBJECT := $(OBJ_DIR)/simAnnBench.o
BENCH_TARGET := $(BIN_DIR)/simAnnBench.out
# Create build directory if it doesn't exist
$(shell mkdir -p $(OBJ_DIR) $(BIN_DIR))
# Default rule
all: $(TARGET) $(BENCH_TARGET)
# Rule to create the executable
$(TARGET): $(LIB_OBJECT) $(TEST_OBJECT)
$(CXX) $(CXXFLAGS) -o $@ $^
# Rule to compile the library implementation
$(LIB_OBJECT): $(SRC_DIR)/simAnn.cpp $(SRC_DIR)/simAnn.hpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Rule to compile the test file
$(TEST_OBJECT): $(SRC_DIR)/simAnnSingle.cpp $(SRC_DIR)/simAnn.hpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Rule to compile the bench file
$(BENCH_OBJECT): $(SRC_DIR)/simAnnBench.cpp $(SRC_DIR)/simAnn.hpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Rule to create the bench executable
$(BENCH_TARGET): $(LIB_OBJECT) $(BENCH_OBJECT)
$(CXX) $(CXXFLAGS) -o $@ $^
# Clean rule
clean:
rm -rf $(BUILD_DIR)
.PHONY: all clean