-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure.ac
307 lines (286 loc) · 7.83 KB
/
configure.ac
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Name / version / website
AC_INIT([x3div], [alpha], [https://github.com/xcompact3d/x3div/])
AC_LANG(Fortran)
AC_CONFIG_MACRO_DIR([./m4])
AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects])
#
# Make sure flags are initialized.
#
AM_FCFLAGS="${AM_FCFLAGS}"
AM_LDFLAGS="${AM_LDFLAGS}"
FCFLAGS="${FCFLAGS}"
LDFLAGS="${LDFLAGS}"
#
# Save the flags provided by the user
#
user_FCFLAGS="$FCFLAGS"
#user_LDFLAGS="$LDFLAGS"
#
# Check for a MPI Fortran compiler if FC is not provided
#
AX_PROG_FC_MPI([],[],[])
AC_MSG_NOTICE([Compiler detected : $FC])
#
# Single precision build, off by default
#
AC_ARG_ENABLE([single], AS_HELP_STRING([--enable-single], [single precision build [default is double]]))
#
# Single precision snapshots, off by default
#
AC_ARG_ENABLE([single-snapshot], AS_HELP_STRING([--enable-single-snapshot], [single precision snapshot for double precision build [default is double]]))
#
# Debug mode, off by default
#
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [enable debugging [default is no]]))
#
# FFT engine fftw3 ?
#
AC_ARG_WITH(fftw3,
[AS_HELP_STRING([--with-fftw3=PATH],[prefix directory for fftw3])],
[if test "x$withval" = "x"; then
with_fftw3=check
fi],
[with_fftw3=check])
AC_ARG_WITH(fftw3-include,
[AS_HELP_STRING([--with-fftw3-include=PATH], [directory for fftw3 include files])],
[if test "x$with_fftw3" = "xcheck"; then
with_fftw3=yes
fi
FFTW3_FCFLAGS="-I$with_fftw3_include"],
[if test "x$with_fftw3" != "xno" -a "x$with_fftw3" != "xyes" \
-a "x$with_fftw3" != "xcheck"; then
FFTW3_FCFLAGS="-I$with_fftw3/include"
fi])
AC_ARG_WITH(fftw3-lib,
[AS_HELP_STRING([--with-fftw3-lib=PATH], [directory for fftw3 library])],
[if test "x$with_fftw3" = "xcheck"; then
with_fftw3=yes
fi
FFTW3_LDFLAGS="-L$with_fftw3_lib"],
[if test "x$with_fftw3" != "xno" -a "x$with_fftw3" != "xyes" \
-a "x$with_fftw3" != "xcheck"; then
FFTW3_LDFLAGS="-L$with_fftw3/lib"
fi])
#
# FFT engine intel mkl ?
#
AC_ARG_WITH(mkl,
[AS_HELP_STRING([--with-mkl=PATH],[prefix directory for mkl])],
[if test "x$withval" = "x"; then
with_mkl=check
fi],
[with_mkl=check])
AC_ARG_WITH(mkl-include,
[AS_HELP_STRING([--with-mkl-include=PATH], [directory for mkl include files])],
[if test "x$with_mkl" = "xcheck"; then
with_mkl=yes
fi
MKL_FCFLAGS="-I$with_mkl_include"],
[if test "x$with_mkl" != "xno" -a "x$with_mkl" != "xyes" \
-a "x$with_mkl" != "xcheck"; then
MKL_FCFLAGS="-I$with_mkl/include"
fi])
AC_ARG_WITH(mkl-lib,
[AS_HELP_STRING([--with-mkl-lib=PATH], [directory for mkl library])],
[if test "x$with_mkl" = "xcheck"; then
with_mkl=yes
fi
MKL_LDFLAGS="-L$with_mkl_lib"],
[if test "x$with_mkl" != "xno" -a "x$with_mkl" != "xyes" \
-a "x$with_mkl" != "xcheck"; then
MKL_LDFLAGS="-L$with_mkl/lib/intel64"
fi])
#
# FFT engine is generic if fftw3 or mkl is not provided
#
if test "x$with_fftw3" != "xno" -a "x$with_fftw3" != "xcheck"; then
AC_MSG_NOTICE([FFT engine fftw3 was provided])
AC_SUBST(FFTENGINE, fftw3)
AC_SUBST(FFTW3FCFLAGS, ${FFTW3_FCFLAGS})
AC_SUBST(FFTW3LDFLAGS, ${FFTW3_LDFLAGS})
if test "x$enable_single" = "xyes"; then
AC_SUBST(FFTW3LDADD, -lfftw3f)
else
AC_SUBST(FFTW3LDADD, -lfftw3)
fi
else
if test "x$with_mkl" != "xno" -a "x$with_mkl" != "xcheck"; then
AC_MSG_NOTICE([FFT engine mkl was provided])
AC_SUBST(FFTENGINE, mkl)
AC_SUBST(MKLFCFLAGS, ${MKL_FCFLAGS})
AC_SUBST(MKLLDFLAGS, ${MKL_LDFLAGS})
else
AC_MSG_NOTICE([FFT engine is generic])
AC_SUBST(FFTENGINE, generic)
fi
fi
AM_CONDITIONAL(HAVE_FFTW3, [test "x$with_fftw3" != "xno" -a "x$with_fftw3" != "xcheck"])
AM_CONDITIONAL(HAVE_MKL, [test "x$with_mkl" != "xno" -a "x$with_mkl" != "xcheck"])
#
# pfunit unit tests
#
AC_ARG_WITH(pfunit,
[AS_HELP_STRING([--with-pfunit=PATH],[prefix directory for pfunit])],
[if test "x$withval" = "x"; then
with_pfunit=no
fi],
[with_pfunit=no])
if test "x$with_pfunit" != "xno"; then
AC_MSG_NOTICE([Unit tests activated])
AC_SUBST(PFUNITDIR, ${with_pfunit})
fi
AM_CONDITIONAL(HAVE_PFUNIT, [test "x$with_pfunit" != "xno"])
#
# Check the Fortran compiler
#
Fcompiler=none
#
# 1. gfortran ?
#
if test "x$Fcompiler" != "xok"; then
echo `$FC --version 2>&1 | head -1` | grep 'GNU Fortran' > /dev/null
if test "$?" = "0" ; then
Fcompiler=ok
fc_version="`$FC -dumpversion | cut -f1 -d.`"
AC_MSG_NOTICE([GNU Fortran version $fc_version])
if test "x$enable_single" = "xyes"; then
FCFLAGS="-cpp"
else
FCFLAGS="-cpp -DDOUBLE_PREC"
if test "x$enable_single_snapshot" = "xyes"; then
FCFLAGS="$FCFLAGS -DSAVE_SINGLE"
fi
fi
AS_IF([test "x$enable_debug" = "xyes"],
[FCFLAGS="$FCFLAGS -Og -g3 -ffpe-trap=invalid,zero -fcheck=all -fimplicit-none -DDEBUG"],
[FCFLAGS="$FCFLAGS -O3 -DNDEBUG"])
OMPFLAG="-fopenmp"
fi
fi
#
# 2. ifort classic ?
#
if test "x$Fcompiler" != "xok"; then
echo `$FC --version 2>&1 | head -1` | grep 'ifort' > /dev/null
if test "$?" = "0"; then
Fcompiler=ok
fc_version="`$FC -dumpversion | cut -f1 -d.`"
AC_MSG_NOTICE([Intel ifort version $fc_version])
if test "x$enable_single" = "xyes"; then
FCFLAGS="-fpp"
else
FCFLAGS="-fpp -DDOUBLE_PREC"
if test "x$enable_single_snapshot" = "xyes"; then
FCFLAGS="$FCFLAGS -DSAVE_SINGLE"
fi
fi
AS_IF([test "x$enable_debug" = "xyes"],
[FCFLAGS="$CFLAGS -g -O0 -traceback -check all -check nopointer -fpe0 -ftrapuv -DDEBUG"],
[FCFLAGS="$FCFLAGS -O3 -DNDEBUG"])
OMPFLAG="-qopenmp"
fi
fi
#
# 3. nvfortran ?
#
#
# 4. TODO (Cray, IBM XL, ...)
#
#
# Provide the git version
# or the one defined in AC_INIT
#
if test -d ${srcdir}/.git; then
X3DVERSION="`git $(srcdir) describe --tag --long --always`"
# Add "-modif" if any diff
echo `git diff $(srcdir)` | grep index > /dev/null
if test "$?" = "0"; then
X3DVERSION="${X3DVERSION}-modif"
fi
else
X3DVERSION=${PACKAGE_VERSION}
fi
AC_SUBST(X3DVERSION)
#
# Combine default flags with the user ones
#
FCFLAGS="$FCFLAGS $user_FCFLAGS"
#LDFLAGS="$LDFLAGS $user_LDFLAGS"
#
# Propagate specific flag
#
AC_SUBST(OMPFLAG)
#
# Maintainer mode if a .git folder is found
# ("rebuild rules" for out of date Makefiles, configure, ...)
#
AS_IF([test -d ${srcdir}/.git],
[AM_MAINTAINER_MODE([enable])],
[AM_MAINTAINER_MODE([disable])])
#
# Create libtool, needed for shared/static libraries.
#
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT([dlopen])
AC_CONFIG_FILES([\
Makefile \
src/Makefile \
decomp2d/Makefile \
verification/Makefile \
verification/lib/Makefile \
verification/verif/Makefile])
AC_OUTPUT
#
#
# Listing at the end of configure
#
#
echo
echo
echo "Configuration options:"
echo
#
if test "x$enable_single" = "xyes"; then
echo " Precision: single"
else
echo " Precision: double"
if test "x$enable_single_snapshot" = "xyes"; then
echo " Snapshop precision: single"
else
echo " Snapshot precision: double"
fi
fi
#
if test "x$enable_debug" = "xyes"; then
echo " Build: debug"
else
echo " Build; production"
fi
#
if test "x$with_fftw3" != "xno" -a "x$with_fftw3" != "xcheck"; then
echo " FFT engine: FFTW3"
else
if test "x$with_mkl" != "xno" -a "x$with_mkl" != "xcheck"; then
echo " FFT engine: MKL"
else
echo " FFT engine: generic"
fi
fi
#
if test "x$with_pfunit" != "xno"; then
echo " unit tests activated (pFunit)"
else
echo " no unit test"
fi
echo
echo "Configuration is complete. Compile and install the code using:"
echo " make -j"
if test "x$with_pfunit" != "xno"; then
echo " make -j check"
fi
echo " make -j install"
echo
echo "Please note that it is best to run configure outside of the source folder"
echo
echo "In case of issue, check the section \"Output variables\" in the file config.log"
echo