-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
38 lines (30 loc) · 1.03 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
# Compiler and flags
CXX := g++
CXXFLAGS := -Wall -std=c++11 -O3 -march=native -I src -fopenmp
# Directories
SRCDIR := src
OBJDIR := objects
# Main source file (in the main directory)
MAIN := main.cpp
# Source files in src/ (we exclude SmallList.cpp because its implementation
# is handled via explicit instantiation in instantiations.cpp)
SRC_FILES := $(wildcard $(SRCDIR)/*.cpp)
# Object files: main.cpp compiles to objects/main.o,
# and each .cpp in src compiles to objects/<name>.o
MAIN_OBJ := $(OBJDIR)/main.o
SRC_OBJS := $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(SRC_FILES))
OBJECTS := $(MAIN_OBJ) $(SRC_OBJS)
# Default target: produce a.out in the main directory.
a.out: $(OBJECTS)
$(CXX) $(CXXFLAGS) -o a.out $(OBJECTS)
# Rule to compile main.cpp
$(OBJDIR)/main.o: main.cpp
@mkdir -p $(OBJDIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Rule to compile source files in src/
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@mkdir -p $(OBJDIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -rf $(OBJDIR) a.out