-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (100 loc) · 3.29 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# We'll expect that ./bin, ./build, and ./doc exist later
GEN_FOLDERS = ./bin ./build ./doc
#INCLUDE_PATH_FLAGS := -I"$(shell pwd)/include"
#LINK_PATH_FLAGS := -L/usr/local/lib/
UNAME = $(shell uname -s)
# === "I'll just have one of everything on the menu" ===
ifdef AWESOME
VISUALS = "yes"
PNG_VIS = "oh, yes"
override undefine DEBUGGING
endif
# === External Library Flags ===
ifdef VISUALS
SDL_LINK_FLAGS = $(shell sdl-config --libs)
SDL_COMPILER_FLAGS = $(shell sdl-config --cflags)
ifdef PNG_VIS
PNG_LINKER_FLAGS = $(shell libpng-config --ldflags)
PNG_COMPILER_FLAGS = $(shell libpng-config --cflags)
endif
endif
GSL_LINK_FLAGS = $(shell gsl-config --libs)
GSL_COMPILER_FLAGS = $(shell gsl-config --cflags)
# Possibly ensure that the GFLAGS_DIR is the location where gflags was installed
GFLAGS_DIR = /usr/local/lib
GFLAGS = -L$(GFLAGS_DIR) -lgflags -Wl,-rpath -Wl,$(GFLAGS_DIR)
MPI_COMPILER_FLAGS = $(shell mpic++ --showme:compile)
MPI_LINK_FLAGS = $(shell mpic++ --showme:link)
ifeq ($(UNAME),Linux)
GL_FLAGS = -lGL -lGLU
endif
ifeq ($(UNAME),Darwin)
GL_FLAGS = -framework OpenGL
endif
# === Compilation Flags ===
COMPILER = g++
COMPILER_FLAGS = -c -std=c++0x -pthread $(PNG_COMPILER_FLAGS) $(SDL_COMPILER_FLAGS) $(GL_FLAGS) $(GSL_COMPILER_FLAGS) $(MPI_COMPILER_FLAGS)#-ldl
ifeq ($(UNAME),Linux)
COMPILER_FLAGS += -DLINUX
endif
ifeq ($(UNAME),Darwin)
COMPILER_FLAGS += -DOSX
endif
NODEBUG = -O3
DEBUG = -O0 -g
ifdef DEBUGGING
COMPILER_FLAGS += $(DEBUG)
endif
ifndef DEBUGGING
COMPILER_FLAGS += $(NODEBUG)
endif
ifdef VISUALS
COMPILER_FLAGS += -DVISUALS
ifdef PNG_VIS
COMPILER_FLAGS += -DPNG_VIS
endif
endif
LINKER = g++
LINKER_FLAGS = $(GFLAGS) -pthread $(PNG_LINKER_FLAGS) $(SDL_LINK_FLAGS) $(GL_FLAGS) $(GSL_LINK_FLAGS) $(MPI_LINK_FLAGS) $(LINK_PATH_FLAGS)
# === Common Files ===
COMMON = build/threadpool.o $(GEN_FOLDERS)
COMMON_OBJECTS = build/threadpool.o
ifdef VISUALS
COMMON += build/viewer.o
COMMON_OBJECTS += build/viewer.o
endif
# ===================================================================
.PHONY : clean tidy backup
all : xychain backup
build/%.o : source/%.cpp $(GEN_FOLDERS)
$(COMPILER) $(COMPILER_FLAGS) -c $< -o $@
# ====== Backup =======
ALL_SOURCES = $(shell echo ./source/*) $(shell echo ./scripts/*) ./Makefile
TIMESTAMP = $(shell date +%s)
backup : ./backups ./backups/latest
backups/latest : $(ALL_SOURCES)
zip -r ./backups/$(TIMESTAMP).zip $(ALL_SOURCES)
ln -s -f $(TIMESTAMP).zip ./backups/latest
# ====== Folders =======
./bin :
mkdir -p bin
./build :
mkdir -p build
./doc :
mkdir -p doc
./backups :
mkdir -p backups
# ====== Executables =======
xychain : build/xychain.o build/xychain-cli.o build/xychain-cli-main.o $(COMMON)
$(LINKER) build/xychain.o build/xychain-cli.o build/xychain-cli-main.o $(COMMON_OBJECTS) $(LINKER_FLAGS) -o bin/$@
xychain-mpi : build/xychain-mpi.o build/xychain-cli-mpi.o build/xychain-cli-mpi-main.o $(COMMON)
$(LINKER) build/xychain-mpi.o build/xychain-cli-mpi.o build/xychain-cli-mpi-main.o $(COMMON_OBJECTS) $(LINKER_FLAGS) -o bin/$@
avg-runs: scripts/AverageRuns.cpp
g++ --std=c++0x scripts/AverageRuns.cpp -o bin/avg-runs
bin2ascii: scripts/bin2ascii.cpp
g++ --std=c++0x scripts/bin2ascii.cpp -o bin/bin2ascii
# ======= Clean up ============
clean :
-rm -f -r ./*.o ./build/*.o ./bin/* ./doc/*
tidy :
-rm -f *.png *.root *.dat