-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (35 loc) · 896 Bytes
/
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
CXX = g++
CXXFLAGS = -std=c++11 -O3
ifeq ($(CXX), icpc)
CXXFLAGS += -qopenmp
else
CXXFLAGS += -fopenmp
endif
INCLUDES = -I$(PWD)/include
LDFLAGS = -lm -ldl
SRCDIR := src
SRCS = $(sort $(wildcard $(SRCDIR)/*.cpp))
OBJSDIR := .objs
OBJS = $(patsubst $(SRCDIR)/%.cpp, $(OBJSDIR)/%.o, $(SRCS))
TARGET = main
DEPSDIR := .deps
MAKES := Makefile
DEPGEN = -MT $@ -MMD -MP -MF $(DEPSDIR)/$*.d
.PHONY: all clean distclean
all: $(TARGET)
$(OBJS): $(OBJSDIR)/%.o: $(SRCDIR)/%.cpp $(DEPSDIR)/%.d $(MAKES) | $(DEPSDIR) $(OBJSDIR)
$(CXX) $(DEPGEN) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<
$(DEPSDIR):
@mkdir -p $@
$(OBJSDIR):
@mkdir -p $@
DEPSINCS = $(patsubst $(SRCDIR)/%.cpp, $(DEPSDIR)/%.d, $(SRCS))
$(DEPSINCS):
include $(sort $(wildcard $(DEPSINCS)))
$(TARGET): $(OBJS)
$(CXX) -o $@ $^ $(LDFLAGS) -fopenmp
clean:
-rm -rvf $(OBJSDIR)
-rm -rvf $(DEPSDIR)
-rm -f $(TARGET)
distclean: clean