-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
78 lines (59 loc) · 1.52 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
73
74
75
76
77
78
BUILDDIR := build
PRODUCT := pennant
SRCDIR := src
HDRS := $(wildcard $(SRCDIR)/*.hh)
SRCS := $(wildcard $(SRCDIR)/*.cc)
OBJS := $(SRCS:$(SRCDIR)/%.cc=$(BUILDDIR)/%.o)
DEPS := $(SRCS:$(SRCDIR)/%.cc=$(BUILDDIR)/%.d)
BINARY := $(BUILDDIR)/$(PRODUCT)
# begin compiler-dependent flags
#
# gcc flags:
#CXX := g++
#CXXFLAGS_DEBUG := -g
#CXXFLAGS_OPT := -O3
#CXXFLAGS_OPENMP := -fopenmp
# intel flags:
CXX := icpc
CXXFLAGS_DEBUG := -g
CXXFLAGS_OPT := -O3 -fast -fno-alias
CXXFLAGS_OPENMP := -openmp
# pgi flags:
#CXX := pgCC
#CXXFLAGS_DEBUG := -g
#CXXFLAGS_OPT := -O3 -fastsse
#CXXFLAGS_OPENMP := -mp
# end compiler-dependent flags
# select optimized or debug
CXXFLAGS := $(CXXFLAGS_OPT)
#CXXFLAGS := $(CXXFLAGS_DEBUG)
# add mpi to compile (comment out for serial build)
# the following assumes the existence of an mpi compiler
# wrapper called mpicxx
CXX := mpicxx
CXXFLAGS += -DUSE_MPI
# add openmp flags (comment out for serial build)
CXXFLAGS += $(CXXFLAGS_OPENMP)
LDFLAGS += $(CXXFLAGS_OPENMP)
LD := $(CXX)
# begin rules
all : $(BINARY)
-include $(DEPS)
$(BINARY) : $(OBJS)
@echo linking $@
$(maketargetdir)
$(LD) -o $@ $^ $(LDFLAGS)
$(BUILDDIR)/%.o : $(SRCDIR)/%.cc
@echo compiling $<
$(maketargetdir)
$(CXX) $(CXXFLAGS) $(CXXINCLUDES) -c -o $@ $<
$(BUILDDIR)/%.d : $(SRCDIR)/%.cc
@echo making depends for $<
$(maketargetdir)
@$(CXX) $(CXXFLAGS) $(CXXINCLUDES) -MM $< | sed "1s![^ \t]\+\.o!$(@:.d=.o) $@!" >$@
define maketargetdir
-@mkdir -p $(dir $@) >/dev/null 2>&1
endef
.PHONY : clean
clean :
rm -f $(BINARY) $(OBJS) $(DEPS)