forked from SPECFEM/specfem2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
242 lines (193 loc) · 6.09 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
dnl -*- Autoconf -*-
dnl
dnl Process this file with autoconf to produce the 'configure' script:
dnl
dnl autoreconf -I m4
dnl
dnl You must have recent versions of Autoconf and Automake installed.
AC_PREREQ(2.61)
AC_INIT([Specfem 2D], [6.2.0], [see the wiki], [Specfem2D])
AC_CONFIG_SRCDIR([README])
AC_CONFIG_HEADER([setup/config.h])
AC_CONFIG_MACRO_DIR([m4])
# 'configure' options
AC_ARG_WITH([mpi],
[AC_HELP_STRING([--with-mpi],
[build parallel version @<:@default=yes@:>@])],
[want_mpi="$withval"],
[want_mpi=no])
AM_CONDITIONAL([COND_MPI], [test "$want_mpi" = yes])
AC_ARG_ENABLE([double-precision],
[AC_HELP_STRING([--enable-double-precision],
[solver in double precision @<:@default=no@:>@])],
[want_double_precision="$enableval"],
[want_double_precision=no])
if test "$want_double_precision" = no; then
CUSTOM_REAL=SIZE_REAL
CUSTOM_MPI_TYPE=MPI_REAL
else
CUSTOM_REAL=SIZE_DOUBLE
CUSTOM_MPI_TYPE=MPI_DOUBLE_PRECISION
fi
AC_SUBST([CUSTOM_REAL])
AC_SUBST([CUSTOM_MPI_TYPE])
# Checks for programs.
# a courtesy to the installed base of users
if test x"$FC" = x && test x"$F90" != x; then
FC="$F90"
fi
if test x"$MPIFC" = x && test x"$MPIF90" != x; then
MPIFC="$MPIF90"
fi
AC_PROG_FC
export FC
export MPIFC
F77="$FC"
FFLAGS="$FCFLAGS"
AC_PROVIDE([AC_PROG_F77])
AC_SUBST([FCENV])
flags_guess="$SHELL flags.guess"
AC_MSG_NOTICE([running $flags_guess])
flags=`$flags_guess` ||
AC_MSG_ERROR([$flags_guess failed])
eval $flags
AC_FC_WRAPPERS
AC_LANG(Fortran)
AC_FC_SRCEXT(f90)
AC_FC_FREEFORM()
CIT_FC_PP_DEFINE()
AC_SUBST([FC_DEFINE])
AC_PROG_CC
AC_LANG_PUSH(C)
AC_CHECK_HEADER(emmintrin.h,AC_DEFINE([HAVE_EMMINTRIN],[1],[Define if emmintrin.h]))
AC_CHECK_HEADER(xmmintrin.h,AC_DEFINE([HAVE_XMMINTRIN],[1],[Define if xmmintrin.h]))
AC_LANG_POP(C)
#checks for Scotch
export SCOTCH_DIR
export SCOTCH_LIBDIR
export SCOTCH_INCLUDEDIR
export USE_BUNDLED_SCOTCH
AC_ARG_WITH([scotch-dir],
AC_HELP_STRING([--with-scotch-dir],[define the root path to Scotch (e.g. /opt/scotch/)]),
[
ac_scotch_dir="$withval";
])
AC_ARG_WITH([scotch-includedir],
AC_HELP_STRING([--with-scotch-includedir],[define the path to the Scotch headers (e.g. /opt/scotch/include)]),
[
ac_scotch_include_dir="$withval";
])
AC_ARG_WITH([scotch-libdir],
AC_HELP_STRING([--with-scotch-libdir],[define the path to the Scotch libraries (e.g. /opt/scotch/lib)]),
[
ac_scotch_lib_dir="$withval";
])
if test "${USE_BUNDLED_SCOTCH}" != "1"; then
#daniel: scotch will be needed in directory src/meshfem2D/
builddir=`pwd`
cd src/meshfem2D/
if test -z "${ac_scotch_lib_dir}"; then
if test -n "${ac_scotch_dir}"; then
ac_scotch_lib_dir="${ac_scotch_dir}/lib";
else
ac_scotch_lib_dir="/usr/lib";
fi
fi
if test -z "${ac_scotch_include_dir}"; then
if test -n "${ac_scotch_dir}"; then
ac_scotch_include_dir="${ac_scotch_dir}/include";
else
ac_scotch_include_dir="/usr/include/scotch";
fi
fi
scotch_lib=""
ac_save_ldflags=${LDFLAGS}
if test -n "${ac_scotch_lib_dir}"; then
LDFLAGS="${LDFLAGS} -L${ac_scotch_lib_dir}";
fi
AC_CHECK_LIB(scotch,scotchfarchinit ,[scotch_lib="yes";],[scotch_lib="no";LDFLAGS=${ac_save_ldflags}], -lscotcherr)
scotch_include=""
ac_save_cppflags=${CPPFLAGS}
# scotch only needed for fortran code
#if test -n "${ac_scotch_include_dir}"; then
# CPPFLAGS="${CPPFLAGS} -I${ac_scotch_include_dir}";
#fi
dnl This does not work because we are in Fortran mode, which does not
dnl handle headers.
dnl
dnl AC_CHECK_HEADER(scotchf.h,[scotch_include="yes";],[scotch_include="no";CPPFLAGS=${ac_save_cppflags}])
scotch_usable="${scotch_lib}"
# back to root directory
cd $builddir
fi
AC_MSG_CHECKING([whether Scotch is usable])
if test "x${scotch_usable}" = "xyes"; then
AC_DEFINE([HAVE_SCOTCH],[1],[defined if Scotch is installed])
USE_BUNDLED_SCOTCH=0
SCOTCH_DIR="${ac_scotch_dir}"
SCOTCH_LIBDIR="${ac_scotch_lib_dir}"
SCOTCH_INCLUDEDIR="${ac_scotch_include_dir}"
AC_MSG_RESULT([yes])
else
AC_DEFINE([HAVE_SCOTCH],[1],[defined if Scotch is installed])
AC_MSG_RESULT([no, using bundled scotch instead])
AC_PROG_LEX
if test -z "$LEX" || test "X$LEX" = "Xno"; then
AC_MSG_ERROR([No suitable lex found])
fi
AC_PROG_YACC
if test -z "$YACC" || test "X$YACC" = "Xno"; then
AC_MSG_ERROR([No suitable yacc or bison found])
fi
# scotch only needed with mpi support
if test "$want_mpi" = yes; then
#daniel: scotch bundle
# uses bundled scotch: current version 5.1.12b
USE_BUNDLED_SCOTCH=1
SCOTCH_DIR="scotch_5.1.12b"
SCOTCH_LIBDIR="${SCOTCH_DIR}/lib"
SCOTCH_INCLUDEDIR="${SCOTCH_DIR}/include"
else
# no mpi support, scotch not needed
USE_BUNDLED_SCOTCH=0
fi # want_mpi
fi
LDFLAGS=${ac_save_ldflags}
# influential environment variables
AC_ARG_VAR(USE_BUNDLED_SCOTCH, [Set to 1 to always use the bundled Scotch library])
AC_ARG_VAR(SCOTCH_DIR, [Directory where Scotch is installed])
AC_ARG_VAR(SCOTCH_INCLUDEDIR, [Directory where Scotch headers are installed])
AC_ARG_VAR(SCOTCH_LIBDIR, [Directory where Scotch libraries are installed])
AC_ARG_VAR(MPIFC, [MPI Fortran compiler command])
AC_ARG_VAR(MPILIBS, [extra libraries for linking MPI programs])
AC_ARG_VAR(MPICC, [MPI C compiler command])
AC_ARG_VAR(DEF_FFLAGS, [Fortran compiler flags])
if test x"$MPIFC" = x; then
MPIFC=mpif90
fi
if test x"$MPICC" = x; then
MPICC=mpicc
fi
AC_ARG_VAR(LOCAL_PATH_IS_ALSO_GLOBAL, [files on a local path on each node are also seen as global with same path @<:@default=true@:>@])
if test x"$LOCAL_PATH_IS_ALSO_GLOBAL" = x; then
LOCAL_PATH_IS_ALSO_GLOBAL=true
fi
# Checks for libraries.
# Checks for header files.
# if test "$want_mpi" = yes; then
# CIT_FC_MPI_MODULE([mpif.h], [$MPIFC], [$DEF_FFLAGS], [], [
# AC_MSG_FAILURE([cannot compile a trivial MPI program using $MPIFC])
# ])
# fi
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([
Makefile
src/meshfem2D/Makefile
src/specfem2D/Makefile
setup/constants.h
setup/precision.h
src/meshfem2D/scotch_5.1.12b/src/Makefile.inc
])
AC_OUTPUT
dnl end of configure.ac