-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (57 loc) · 1.5 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
# Makefile to compile all the source files of the MPI C++ Library
# Directories
SRCDIR := src
LIBDIR := lib
OBJDIR := objs
EXEDIR := exec
# MPI Object Files
LIBOBJ := $(OBJDIR)/mpi.o $(OBJDIR)/socket.o $(OBJDIR)/rio.o
# Executables
EXECUTABLES := helloworld average wireroute dataSize timer
# Compiler - Please run "make clean" after changing the compiler
SELECT_MPI := OUR_MPI
# SELECT_MPI := OPEN_MPI
CXX := g++ -m64 -std=c++11
CXXFLAGS := -pthread -I. -O3 -Wall
ifeq ($(SELECT_MPI), OPEN_MPI)
CXX_APP := mpic++
CXXFLAGS_APP := -I. -O3
else
CXX_APP := $(CXX)
CXXFLAGS_APP := $(CXXFLAGS) -D$(SELECT_MPI)
endif
.PHONY : all clean dirs
default : dirs mpirun $(EXECUTABLES)
@echo "Running with $(SELECT_MPI)"
# Executables
.SECONDEXPANSION:
mpirun : $$(patsubst %,$(OBJDIR)/%.o,$$@) $(LIBOBJ)
$(CXX) $(CXXFLAGS) $^ -o $@
.SECONDEXPANSION:
$(EXECUTABLES) : $$(patsubst %,$(OBJDIR)/%.o,$$@) $(LIBOBJ)
$(CXX_APP) $(CXXFLAGS_APP) $^ -o $(EXEDIR)/$@
# Library Object Files
$(OBJDIR)/%.o : $(LIBDIR)/%.cpp
$(CXX) $(CXXFLAGS) $< -c -o $@
# Application Code Objects
$(OBJDIR)/%.o : $(SRCDIR)/%.cpp
$(CXX_APP) $< $(CXXFLAGS_APP) -c -o $@
dirs :
mkdir -p $(OBJDIR)/ $(EXEDIR)/
clean:
rm -rf $(OBJDIR) $(EXEDIR) mpirun WireRoute
# Makefile Help:
#
# Make Format:
# target: prerequisite
# recipe
#
# Make arguments Help:
# $@ - Represents Target
# $< - First prerequisite
# $? - All prerequisite that are newer
# $^ - All the prerequisites
#
# Assignments
# := - Static Assignment
# = - Dynamic (Recursive) Assignment