forked from potfit/potfit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.inc
289 lines (252 loc) · 9.16 KB
/
Makefile.inc
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
###########################################################################
#
# potfit - open-source force-matching
#
# Copyright 2002-2018 - the potfit development team
#
# https://www.potfit.net/
#
###########################################################################
#
# This file is part of potfit.
#
# potfit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# potfit is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with potfit; if not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
#
# Customizing this Makefile
#
# As potfit supports a large number of compile options, you will have to
# compile potfit freqently. Before doing so, however, you must check whether
# the settings in this Makefile fit your needs. You possibly have to
# customize these setttings. Before you can do that, we have to explain
# a bit how the compilation process works.
#
# The compilation process requires the SYSTEM variable in the Makefile to be
# set to any of the predefined values. It specifies what system you have, and
# what compiler you are using. The flags for the compiler and the linker
# are then selected as a function of this variable.
#
# Another important ingredient is the parallelization method, which is
# determined from the make target. The parallelization method is stored
# in the variable PARALLEL, which takes as value SERIAL or MPI.
#
# Depending on the value of ${SYSTEM}, a number of variables must be
# set, from which everything else is constructed.
#
# CC_SERIAL defines the compiler for serial compilation, CC_MPI the one
# to be used for parallelization
#
# BIN_DIR defines the directory where the potfit binary is put. Note that
# this directory must exist.
#
# The compilation options are stored in the variable CFLAGS.
# The initial value of CFLAGS is set to the variable FLAGS,
# which can be given on the command line.
#
# If the option debug was specified, ${DEBUG_FLAGS} is then appended
# to ${CFLAGS}, otherwise ${OPT_FLAGS}. If the option prof was specified
# (for profiling), ${PROF_FLAGS} is also appended to ${CFLAGS}. However,
# before appending ${OPT_FLAGS} or ${DEBUG_FLAGS} to ${CFLAGS}, some
# parallelization specific flags are appended to them:
#
# OPT_FLAGS += ${${PARALLEL}_FLAGS} ${OPT_${PARALLEL}_FLAGS}
# DEBUG_FLAGS += ${${PARALLEL}_FLAGS} ${DEBUG_${PARALLEL}_FLAGS}
#
# If any of these variables is not defined, it is assumed to be empty.
# This setup should provide sufficient flexibility to set one's favorite
# flags, depending on parallelization, profiling, and optimization/debugging.
#
# Similarly, the link libraries are stored in the variable LIBS,
# to which ${${PARALLEL}_LIBS} and possibly ${PROF_LIBS} (for profiling)
# is appended.
#
# You may have to change the setting for an existing value of SYSTEM.
# or you have to add support for a new value of SYSTEM. The latter is
# best done by using the folloing template for SYSTEM=custom:
#
# ifeq (custom,${SYSTEM})
# CC_SERIAL = serial-compiler
# CC_MPI = MPI-compiler
# OMPI_CC = compiler for mpicc
# OMPI_CLINKER = linker for mpicc
# OPT_FLAGS += generic flags for optimization
# DEBUG_FLAGS += generic flags for debugging
# PROF_FLAGS += flags for profiling
# PROF_LIBS += libraries for profiling
# LFLAGS_SERIAL += flags for serial linking
# LFLAGS_MPI += flags for MPI linking
# export MPICH_CC MPICH_CLINKER
# endif
#
# Variables remaining empty need not be mentioned.
#
############################################################################
SHELL = /bin/bash
###########################################################################
#
# Adjust these variables to your system
#
###########################################################################
# Currently the following SYSTEMs are available:
# x86_64-icc 64bit Intel Compiler
# x86_64-gcc 64bit GNU Compiler
# x86_64-clang 64bit LLVM Compiler
# i686-icc 32bit Intel Compiler
# i686-gcc 32bit GNU Compiler
SYSTEM = x86_64-gcc
# Base directory of your installation of the MKL
MKLDIR = /opt/intel/composer_xe_2015.1.133/mkl
###########################################################################
#
# Do not change anything below unless you know what you are doing
#
###########################################################################
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
#uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
#uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
#uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
#uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
#uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
ifeq (${uname_S},Darwin)
TARGET = MACOS
else
TARGET = LINUX
endif
ifneq (,$(strip $(findstring mkl,${MAKETARGET})))
MATH_LIB = MKL
else
ifeq (${TARGET},MACOS)
# accelerate is the default for Mac OS
MATH_LIB = __ACCELERATE__
else
MATH_LIB = MKL
endif
endif
############################################################################
#
# flags for 64bit
#
############################################################################
ifeq (x86_64-icc,${SYSTEM})
# compiler
CC_SERIAL = icc
CC_MPI = mpicc
OMPI_CC = icc
OMPI_CLINKER = icc
# general optimization flags
OPT_FLAGS += -fast -xHost -std=c99
# profiling and debug flags
PROF_FLAGS += --profile-functions
PROF_LIBS += --profile-functions
DEBUG_FLAGS += -g -Wall -std=c99
ifeq (${MATH_LIB},__ACCELERATE__)
LIBS += -framework Accelerate
else ifeq (${MATH_LIB},MKL)
CINCLUDE += -I${MKLDIR}/include
LIBS += -Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential \
-lmkl_core -Wl,--end-group -lpthread
endif
endif # x86_64-icc
ifeq (x86_64-gcc,${SYSTEM})
# compiler
CC_SERIAL = gcc
CC_MPI = mpicc
OMPI_CC = gcc
OMPI_CLINKER = gcc
# general optimization flags
OPT_FLAGS += -m64 -O3 -march=native -std=c99
# profiling and debug flags
PROF_FLAGS += -m64 -g3 -pg
PROF_LIBS += -m64 -g3 -pg
DEBUG_FLAGS += -m64 -g3 -Wall -Werror -pedantic -std=c99
ASAN_FLAGS += -g -fsanitize=address -fno-omit-frame-pointer
ASAN_LFLAGS = -g -fsanitize=address
ifeq (${MATH_LIB},__ACCELERATE__)
OPT_FLAGS += -Wa,-q
LIBS += -framework Accelerate
else ifeq (${MATH_LIB},MKL)
CINCLUDE += -I${MKLDIR}/include
LIBS += -Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential -lmkl_core \
-Wl,--end-group -lpthread -Wl,--as-needed
endif
endif # x86_64-gcc
ifeq (x86_64-clang,${SYSTEM})
# compiler
CC_SERIAL = clang
CC_MPI = mpicc
OMPI_CC = clang
OMPI_CLINKER = clang
# general optimization flags
OPT_FLAGS += -O3 -march=native -std=c99
# profiling and debug flags
PROF_FLAGS += -g
PROF_LIBS += -g
DEBUG_FLAGS += -g -Wall -Werror -pedantic -std=c99
ASAN_FLAGS += -g -fsanitize=address -fno-omit-frame-pointer
ASAN_LFLAGS = -g -fsanitize=address
ifeq (${MATH_LIB},__ACCELERATE__)
LIBS += -framework Accelerate
else ifeq (${MATH_LIB},MKL)
CINCLUDE += -I${MKLDIR}/include
LIBS += -Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential -lmkl_core \
-Wl,--end-group -lpthread -Wl,--as-needed
endif
endif # x86_64-clang
###########################################################################
#
# flags for 32bit
#
###########################################################################
ifeq (i686-icc,${SYSTEM})
# compiler
CC_SERIAL = icc
CC_MPI = mpicc
OMPI_CC = icc
OMPI_CLINKER = icc
# general optimization flags
OPT_FLAGS += -fast -xHost -std=c99
# profiling and debug flags
PROF_FLAGS += -prof-gen
PROF_LIBS += -prof-gen
DEBUG_FLAGS += -g -Wall -std=c99
ifeq (${MATH_LIB},__ACCELERATE__)
LIBS += -framework Accelerate
else ifeq (${MATH_LIB},MKL)
CINCLUDE += -I${MKLDIR}/include
LIBS += -Wl,--start-group -lmkl_intel -lmkl_sequential -lmkl_core \
-Wl,--end-group -lpthread
endif
endif # i686-icc
ifeq (i686-gcc,${SYSTEM})
# compiler
CC_SERIAL = gcc
CC_MPI = mpicc
OMPI_CC = gcc
OMPI_CLINKER = gcc
# general optimization flags
OPT_FLAGS += -m32 -O3 -march=native -Wno-unused -std=c99
LIBS += -m32
# profiling and debug flags
PROF_FLAGS += -m32 -g3 -pg
PROF_LIBS += -m32 -g3 -pg
DEBUG_FLAGS += -m32 -g3 -Wall -std=c99
ifeq (${MATH_LIB},__ACCELERATE__)
LIBS += -framework Accelerate
else ifeq (${MATH_LIB},MKL)
CINCLUDE += -I${MKLDIR}/include
LIBS += -Wl,--start-group -lmkl_intel -lmkl_sequential -lmkl_core \
-Wl,--end-group -lpthread -Wl,--as-needed
endif
endif # i686-gcc