forked from genetics-statistics/GEMMA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
263 lines (219 loc) · 6.64 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# Generic Makefile for GEMMA
#
# Supported platforms
#
# Unix / Linux LNX (default)
# Mac OSX
# GNU Guix GUIX (set to profile)
#
# Compilation options
# static compilation FORCE_STATIC
#
# Examples:
#
# Make GEMMA on Linux without OPENBLAS support:
#
# make WITH_OPENBLAS=
#
# Disable debug info and checks (release mode is slightly faster)
#
# make debug
#
# Force static compilation
#
# make static
#
# Run tests with
#
# make check
#
# Run quick (development) tests with
#
# make fast-check
#
# Run full (lengthy) tests with
#
# make check-all
#
# To compile with CLANG
#
# make CXX=clang++
#
# See also the INSTALL.md document in the source tree at
#
# https://github.com/genetics-statistics/GEMMA/blob/master/INSTALL.md
GEMMA_VERSION = $(shell cat ./VERSION)
# Set this variable to either LNX or OSX
ifeq ($(OS),Windows_NT)
SYS = WIN
VGEN = scripts/gen_version_info.cmd
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SYS = OSX
else
SYS = LNX # default to linux
endif
VGEN = scripts/gen_version_info.sh
endif
# Leave blank after "=" to disable; put "= 1" to enable
DIST_NAME = gemma-$(GEMMA_VERSION)
DEBUG = 1 # DEBUG mode, set DEBUG=0 for a release
PROFILING = # Add profiling info
SHOW_COMPILER_WARNINGS =
WITH_OPENBLAS = 1 # Without OpenBlas uses LAPACK
WITH_ATLAS = # In place of OpenBlas(?)
WITH_LAPACK = # Force linking LAPACK (if OpenBlas lacks it)
WITH_GSLCBLAS = # Force linking gslcblas (if OpenBlas lacks it)
WITH_GFORTRAN = # Add -lgfortran (if OpenBlas does not pull it in)
OPENBLAS_LEGACY = # Using older OpenBlas
FORCE_STATIC = # Static linking of libraries
GCC_FLAGS = -DHAVE_INLINE -pthread -Wall -std=gnu++11 # extra flags -Wl,--allow-multiple-definition
GSL_INCLUDE_PATH =
ifeq ($(SYS), WIN)
GSL_INCLUDE_PATH = -isystemc:/MinGW/include -LC:/MinGW/lib
EIGEN_INCLUDE_PATH = ../eigen-git-mirror
OPENBLAS_INCLUDE_PATH = ../OpenBLAS-v0.2.19-Win64-int32/include -L../OpenBLAS-v0.2.19-Win64-int32/lib
else
OPENBLAS_INCLUDE_PATH = /usr/local/opt/openblas/include
ifeq ($(SYS), OSX)
EIGEN_INCLUDE_PATH = /usr/local/include/eigen3
else
EIGEN_INCLUDE_PATH = /usr/include/eigen3
endif
ifndef GUIX
ifdef GUIX_ENVIRONMENT
GUIX=$(GUIX_ENVIRONMENT)
endif
endif
ifdef GUIX
# Effectively disable paths for GNU Guix
OPENBLAS_INCLUDE_PATH = .
EIGEN_INCLUDE_PATH = $(GUIX)/include/eigen3
# RPATH = -Xlinker --rpath=$(GUIX)/lib
ifdef FORCE_STATIC
LIBS = -L$(GUIX)/lib
endif
GUIX_PROFILE =$(realpath $(GUIX))
endif
endif
# --------------------------------------------------------------------
# Edit below this line with caution
# --------------------------------------------------------------------
BIN_DIR = ./bin
SRC_DIR = ./src
TEST_SRC_DIR = ./test/src
ifdef CXX # CXX defined in environment
CPP = $(CXX)
CC = $(CXX)
else
CPP = g++
endif
ifeq ($(CPP), clang++)
GCC_FLAGS=-std=c++11 -isystem$(OPENBLAS_INCLUDE_PATH) -isystem$(EIGEN_INCLUDE_PATH)
ifdef GUIX
CPPFLAGS += -I$(GUIX)/include/c++ -I$(GUIX)/include/c++/x86_64-unknown-linux-gnu
endif
endif
ifdef WITH_OPENBLAS
OPENBLAS=1
# WITH_LAPACK = # OPENBLAS usually includes LAPACK
CPPFLAGS += -DOPENBLAS -isystem$(OPENBLAS_INCLUDE_PATH)
ifdef OPENBLAS_LEGACY
# Legacy version (mostly for Travis-CI)
CPPFLAGS += -DOPENBLAS_LEGACY
endif
else
ifdef WITH_ATLAS
CPPFLAGS += -DUSE_BLAS=atlas
endif
endif
ifneq ($(CXX), clang++)
# Clang does not like this switch
debug check fast-check: CPPFLAGS += -Og
endif
debug check fast-check: CPPFLAGS += -g $(GCC_FLAGS) $(GSL_INCLUDE_PATH) -isystem$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc
profile: CPPFLAGS += -pg
release: CPPFLAGS += -DNDEBUG -O3 $(GCC_FLAGS) $(GSL_INCLUDE_PATH) -isystem$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc
static: CPPFLAGS += -DNDEBUG -O3 $(GCC_FLAGS) $(GSL_INCLUDE_PATH) -isystem$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc
ifeq ($(SYS), WIN)
CPPFLAGS += -Duint="unsigned int" -D__CRT__NO_INLINE -D__STRING="__STRINGIFY" -DWINDOWS -DWITH_GSLCBLAS=1
endif
ifdef SHOW_COMPILER_WARNINGS
CPPFLAGS += -Wall
endif
static: CPPFLAGS += -static
LIBS += -lgsl -lz
ifdef WITH_OPENBLAS
LIBS += -lopenblas
else
LIBS += -latlas -lcblas -llapack -lblas
endif
ifdef WITH_GSLCBLAS
LIBS += -lgslcblas
endif
ifdef WITH_GFORTRAN
LIBS += -lgfortran -lquadmath
endif
.PHONY: all test
OUTPUT = $(BIN_DIR)/gemma
# Detailed libary paths, D for dynamic and S for static
ifdef WITH_LAPACK
LIBS += -llapack
endif
LIBS_OSX_D_LAPACK = -framework Accelerate
ifdef WITH_LAPACK
ifeq ($(SYS), OSX)
LIBS += $(LIBS_OSX_D_LAPACK)
ifdef WITH_OPENBLAS
LIBS += -Wl,-L/usr/local/opt/openblas/lib
endif
endif
endif
HDR = $(wildcard src/*.h) ./src/version.h
SOURCES = $(wildcard src/*.cpp)
# all
OBJS = $(SOURCES:.cpp=.o)
all: release
release: $(OUTPUT)
static: $(OUTPUT)
debug: $(OUTPUT)
./src/version.h: ./VERSION
$(shell bash $(VGEN) $(GUIX_PROFILE) > src/version.h)
$(OUTPUT): $(OBJS)
$(CPP) $(CPPFLAGS) $(OBJS) $(LIBS) -o $(OUTPUT)
$(OBJS): $(HDR)
.SUFFIXES : .cpp .c .o $(SUFFIXES)
./bin/unittests-gemma: contrib/catch-1.9.7/catch.hpp $(TEST_SRC_DIR)/unittests-main.o $(TEST_SRC_DIR)/unittests-math.o $(OBJS)
$(CPP) $(CPPFLAGS) $(TEST_SRC_DIR)/unittests-main.o $(TEST_SRC_DIR)/unittests-math.o $(filter-out src/main.o, $(OBJS)) $(LIBS) -o ./bin/unittests-gemma
unittests: all ./bin/unittests-gemma
./bin/unittests-gemma
fast-check: all unittests
rm -vf test/output/*
cd test && ./dev_test_suite.sh | tee ../dev_test.log
grep -q 'success rate: 100%' dev_test.log
slow-check: all
rm -vf test/output/*
cd test && ./test_suite.sh | tee ../test.log
grep -q 'success rate: 100%' test.log
lengthy-check: all
rm -vf test/output/*
cd test && ./lengthy_test_suite.sh | tee ../lengthy_test.log
grep -q 'success rate: 100%' lengthy_test.log
check: fast-check slow-check
check-all: check lengthy-check
clean:
rm -vf $(SRC_DIR)/*.o
rm -vf $(SRC_DIR)/*~
rm -vf $(TEST_SRC_DIR)/*.o
rm -vf $(OUTPUT)
rm -vf ./bin/unittests-gemma
DIST_COMMON = *.md LICENSE VERSION Makefile
DIST_SUBDIRS = src doc example bin
tar: version all
@echo "Creating $(DIST_NAME)"
mkdir -p ./$(DIST_NAME)
cp $(DIST_COMMON) ./$(DIST_NAME)/
cp -r $(DIST_SUBDIRS) ./$(DIST_NAME)/
tar cvzf $(DIST_NAME).tar.gz ./$(DIST_NAME)/
rm -r ./$(DIST_NAME)