forked from usgs-coupled/phast3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
395 lines (339 loc) · 10.9 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.61])
AC_INIT([phast], [3.7.6-16807], [dlpark@usgs.gov])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign no-define subdir-objects tar-ustar])
AC_CONFIG_SRCDIR([src/phastinput/accumulate.cpp])
# enable silent rules when available (automake 1.11 or later).
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CANONICAL_HOST
# phastinput defines
AC_DEFINE([ANSI_DECLARATORS], , [Must be set for phastinput])
AC_DEFINE([TRILIBRARY], , [Must be set for phastinput])
AC_DEFINE([PHRQ_IO_INPUT], , [Must be set for phastinput])
# phast defines
AC_DEFINE([SWIG_SHARED_OBJ], , [Must be set for phast])
AC_DEFINE([USE_PHRQ_ALLOC], , [Must be set for phast])
AC_DEFINE([USE_GZ], , [Must be set for phast])
AC_DEFINE([H5Dcreate_vers], [1] , [Must be set to 1 for phast])
AC_DEFINE([H5Gcreate_vers], [1] , [Must be set to 1 for phast])
AC_DEFINE([H5Eset_auto_vers], [1] , [Must be set to 1 for phast])
# check for --with-mpi
# If --with-mpi=auto is used, try to find MPI, but use standard C compiler if it is not found.
# If --with-mpi=yes is used, try to find MPI and fail if it isn't found.
# If --with-mpi=no is used, use a standard C compiler instead.
AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
[compile with MPI (parallelization) support. If none is found,
MPI is not used. Default: no])
],,[with_mpi=no])
# Checks for programs.
##AC_PROG_CXX
AX_PROG_CXX_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
use_mpi=no
if test x"$with_mpi" = xyes; then
AC_MSG_ERROR([MPI compiler requested, but couldn't use MPI.])
fi
])
AC_PROG_AWK
AC_PROG_LN_S
##AC_PROG_CC
AC_PROG_CPP
AC_PROG_F77
##AC_PROG_FC
# c++11 is required
AX_CXX_COMPILE_STDCXX(11, [ext], [mandatory])
AX_PROG_FC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
use_mpi=no
if test x"$with_mpi" = xyes; then
AC_MSG_ERROR([MPI compiler requested, but couldn't use MPI.])
fi
])
AC_FC_LIBRARY_LDFLAGS
AC_FC_WRAPPERS
AC_FC_MAIN
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# ant (used to build phasthdf)
AC_ARG_VAR(ANT, [Ant Java build tool command])
AC_PATH_PROG([ANT], [ant])
# determine f90 module suffix
AX_F90_MODULE_EXTENSION
F90_MODEXT=mod
if test x$ax_cv_f90_modext != xunknown ; then
F90_MODEXT=$ax_cv_f90_modext
fi
AC_SUBST(F90_MODEXT)
# Checks for libraries.
if test x"$with_mpi" = xyes; then
enable_openmp=no
fi
if test x"$enable_openmp" != xno; then
AC_LANG_PUSH(C++)
AC_OPENMP
AC_LANG_POP(C++)
AC_SUBST(AM_CXXFLAGS, $OPENMP_CXXFLAGS)
fi
# Checks for header files.
AC_CHECK_HEADERS([float.h limits.h memory.h stddef.h stdlib.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
# libc functions
AC_CHECK_FUNCS([memmove], , AC_ERROR([memmove not found in libc]))
AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc]))
AC_CHECK_FUNCS([strchr], , AC_ERROR([strchr not found in libc]))
AC_CHECK_FUNCS([strcspn], , AC_ERROR([strcspn not found in libc]))
AC_CHECK_FUNCS([strtol], , AC_ERROR([strtol not found in libc]))
# libm functions
AC_CHECK_FUNCS([floor], , AC_CHECK_LIB(m, floor, , AC_ERROR([cannot find floor])) )
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) )
AC_CHECK_FUNCS([sqrt], , AC_CHECK_LIB(m, sqrt, , AC_ERROR([cannot find sqrt])) )
case $host_os in
solaris*)
CXXFLAGS="$CXXFLAGS -library=stlport4"
LDFLAGS="$LDFLAGS -library=stlport4"
;;
esac
# boost
AX_BOOST_BASE([1.33], , AC_ERROR([Boost is required to build phast]))
if test "X$want_boost" = "Xno"; then
AC_MSG_ERROR([Boost is required to build phast])
fi
# isfinite
AC_LANG_PUSH(C++)
AC_CACHE_CHECK([for isfinite], ac_cv_isfinite,
[AC_TRY_LINK([#include <math.h>],
[double x; int y; y = isfinite(x);],
ac_cv_isfinite=yes,
ac_cv_isfinite=no
)])
if test x"$ac_cv_isfinite" = x"yes"; then
AC_DEFINE(HAVE_ISFINITE, [], [Has isfinite])
fi
AC_LANG_POP(C++)
# finite
AC_LANG_PUSH(C++)
AC_CACHE_CHECK([for finite], ac_cv_finite,
[AC_TRY_LINK([#include <math.h>],
[double x; int y; y = finite(x);],
ac_cv_finite=yes,
ac_cv_finite=no
)])
if test x"$ac_cv_finite" = x"yes"; then
AC_DEFINE(HAVE_FINITE, [], [Has finite])
fi
AC_LANG_POP(C++)
# isnan
AC_CHECK_FUNCS([isnan], , AC_CHECK_LIB(m, isnan))
# --with-xxx from HDF configure
# ----------------------------------------------------------------------
# Fake --with-xxx option to allow us to create a help message for the
# following --with-xxx options which can take either a =DIR or =INC,LIB
# specifier.
#
AC_ARG_WITH([fnord],
[
For the following --with-xxx options, you can specify where the header
files and libraries are in two different ways:
--with-xxx=INC,LIB - Specify individually the include directory and
library directory separated by a comma
--with-xxx=DIR - Specify only the directory which contains the
include/ and lib/ subdirectories
])
# zlib (Note: test for zlib before hdf5 since hdf5 normally depends on zlib)
# ----------------------------------------------------------------------
# Is the zlib present? It has a header file `zlib.h' and a library
# `-lz' and their locations might be specified with the `--with-zlib'
# command-line switch. The value is an include path and/or a library path.
# If the library path is specified then it must be preceded by a comma.
#
AC_ARG_WITH([zlib],
[AC_HELP_STRING([--with-zlib=DIR],
[Use the zlib library [default=auto]])],,withval=yes)
case $withval in
yes)
HAVE_ZLIB="yes"
AC_CHECK_HEADERS(zlib.h, , AC_MSG_ERROR([zlib.h not found]))
AC_CHECK_LIB(z, gzwrite, , AC_MSG_ERROR([couldn't find zlib library]))
;;
*)
HAVE_ZLIB="yes"
case "$withval" in
*,*)
zlib_inc="`echo $withval |cut -f1 -d,`"
zlib_lib="`echo $withval |cut -f2 -d, -s`"
;;
*)
if test -n "$withval"; then
zlib_inc="$withval/include"
zlib_lib="$withval/lib"
fi
;;
esac
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
if test -n "$zlib_inc"; then
CPPFLAGS="$CPPFLAGS -I$zlib_inc"
fi
AC_CHECK_HEADERS(zlib.h,, AC_MSG_ERROR([zlib.h not found]))
if test -n "$zlib_lib"; then
LDFLAGS="$LDFLAGS -L$zlib_lib"
fi
AC_CHECK_LIB(z, gzwrite,, LDFLAGS="$saved_LDFLAGS"; unset HAVE_ZLIB)
if test -z "$HAVE_ZLIB"; then
AC_MSG_ERROR(couldn't find zlib library)
fi
;;
esac
# HDF5
# ----------------------------------------------------------------------
# Is the hdf5 present? It has a header file `hdf5.h' and a library
# `-lhdf5' and their locations might be specified with the `--with-hdf5'
# command-line switch. The value is an include path and/or a library path.
# If the library path is specified then it must be preceded by a comma.
#
##set -x -v
AC_LANG_PUSH(C++)
AC_ARG_WITH([hdf5],
[AC_HELP_STRING([--with-hdf5=DIR],
[Use the HDF5 library [default=auto]])],,withval=yes)
case $withval in
yes)
HAVE_HDF5="yes"
AC_CHECK_HEADERS(hdf5.h, , AC_MSG_ERROR([hdf5.h not found]))
AC_CHECK_LIB(hdf5, H5Fopen, , AC_MSG_ERROR([couldn't find hdf5 library]))
;;
*)
HAVE_HDF5="yes"
case "$withval" in
*,*)
hdf5_inc="`echo $withval |cut -f1 -d,`"
hdf5_lib="`echo $withval |cut -f2 -d, -s`"
;;
*)
if test -n "$withval"; then
hdf5_inc="$withval/include"
hdf5_lib="$withval/lib"
fi
;;
esac
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
if test -n "$hdf5_inc"; then
CPPFLAGS="$CPPFLAGS -I$hdf5_inc"
fi
AC_CHECK_HEADERS(hdf5.h,, AC_MSG_ERROR([hdf5.h not found]))
if test -n "$hdf5_lib"; then
LDFLAGS="$LDFLAGS -L$hdf5_lib"
fi
AC_CHECK_LIB(hdf5, H5Fopen,, LDFLAGS="$saved_LDFLAGS"; unset HAVE_HDF5)
if test -z "$HAVE_HDF5"; then
AC_MSG_ERROR(couldn't find hdf5 library)
fi
;;
esac
AC_LANG_POP(C++)
dnl # Build mpi version
dnl # Check if building mpi version
dnl AC_MSG_CHECKING([if building MPI version])
dnl AC_ARG_ENABLE([mpi],
dnl [AC_HELP_STRING([--enable-mpi],
dnl [build the MPI version @<:@default=no@:>@])],
dnl [PHAST_MPI=yes],[PHAST_MPI=no])
dnl if test "X$PHAST_MPI" = "Xyes"; then
dnl AC_MSG_RESULT(yes)
dnl AC_LANG_PUSH(C++)
dnl AX_MPI(, AC_ERROR([MPI not found]))
dnl AC_LANG_POP(C++)
dnl # extra MPI defines
dnl AC_DEFINE([USE_MPI], , [Set to use MPI])
dnl AC_DEFINE([MERGE_FILES], , [Set to use MPI])
dnl AC_LANG_PUSH(Fortran)
dnl AX_MPI(, AC_ERROR([MPI not found]))
dnl AC_LANG_POP(Fortran)
dnl # set compilers
dnl CXX="$MPICXX"
dnl PHAST_SUFFIX=mpi
dnl #{{
dnl AC_LANG_PUSH(Fortran)
dnl AC_MSG_RESULT("$MPIFC")
dnl FC="$MPIFC"
dnl AC_FC_LIBRARY_LDFLAGS
dnl AC_FC_WRAPPERS
dnl AC_FC_MAIN
dnl AC_LANG_POP(Fortran)
dnl #}}
dnl # disable openmp
dnl enable_openmp=no
dnl else
dnl AC_MSG_RESULT(no)
dnl if test "$enable_openmp" != no; then
dnl AC_SUBST(AM_CXXFLAGS, $OPENMP_CXXFLAGS)
dnl AC_DEFINE(USE_OPENMP)
dnl fi
dnl PHAST_SUFFIX=openmp
dnl fi
AM_CONDITIONAL([BUILD_OPENMP], [test "X$enable_openmp" != "Xno"])
###AM_CONDITIONAL([BUILD_MPI], [test "X$PHAST_MPI" = "Xyes"])
AM_CONDITIONAL([BUILD_MPI], [test "X$with_mpi" = "Xyes"])
AM_CONDITIONAL([BUILD_PHASTHDF], [test -n "$ANT"])
# set phast suffix
if test "X$with_mpi" != "Xno"; then
AC_DEFINE([USE_MPI], [] , [Set to use MPI])
PHAST_SUFFIX=mpi
MPIEXEC=mpiexec
MPIEXEC_NUMPROC_FLAG=-np
else
if test "X$enable_openmp" != "Xno"; then
AC_DEFINE([USE_OPENMP], [], [Set to to use OpenMP])
PHAST_SUFFIX=openmp
else
PHAST_SUFFIX=ser
fi
fi
AC_SUBST(PHAST_SUFFIX)
AC_SUBST(MPIEXEC)
AC_SUBST(MPIEXEC_NUMPROC_FLAG)
AC_CONFIG_FILES([
Makefile
doc/Makefile
examples/Makefile
examples/phrqex11/phrqex11.chem.dat
examples/phrqex11/phrqex11.trans.dat
src/Makefile
src/phast/Makefile
src/phast/PhreeqcRM/irm_dll_export.h
src/phast/phast
src/phasthdf/Makefile
src/phasthdf/build.xml
src/phastinput/Makefile
test/Makefile
])
AC_OUTPUT
echo "*************************************"
echo "Summary:"
echo "C++ Compiler = $CXX"
echo "CPPFLAGS = $CPPFLAGS"
echo "CXXFLAGS = $CXXFLAGS"
echo "Fortran Compiler = $FC"
echo "Fortran Libs = $FCLIBS"
echo "LDFLAGS = $LDFLAGS"
if test "X$enable_openmp" != "Xno"; then
echo "Enable OpenMP = yes"
else
echo "Enable OpenMP = no"
fi
echo "Enable MPI = $with_mpi"
if test -z "$ANT"; then
echo "Build phasthdf (reqs ant) = no"
else
echo "Build phasthdf (reqs ant) = yes"
echo "Ant = $ANT"
fi
echo "*************************************"