-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.in
307 lines (271 loc) · 8.46 KB
/
configure.in
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
# Copyright (C) 2006 Imperial College London and others.
#
# Please see the AUTHORS file in the main source directory for a full list
# of copyright holders.
#
# Prof. C Pain
# Applied Modelling and Computation Group
# Department of Earth Science and Engineering
# Imperial College London
#
# C.Pain@Imperial.ac.uk
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation,
# version 2.1 of the License.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
dnl Process this file with autoconf to produce a configure script.
AC_INIT(include/spud.h)
LT_INIT
LT_LANG([CXX])
LT_LANG([FC])
# This is to get around some odd behavious of some fortran compilers
FCFLAGS="$FCFLAGS -I/usr/include"
#
# Name spud
#
AC_ARG_ENABLE(debugging,
[AC_HELP_STRING([--enable-debugging],
[turns on debugging flags])])
# Check system type
AC_CANONICAL_HOST
# Find compilers
AC_MSG_NOTICE([*** Fishing for legacy fortran compiler.])
AC_PROG_F77(ifort ifc efc sunf95 gfortran pgf95 pathf95 g95 f90,,f90,$PATH)
AC_F77_LIBRARY_LDFLAGS
fcompiler=`basename $F77`
AC_MSG_NOTICE([*** Fishing for modern Fortran compiler])
AC_PROG_FC(ifort ifc efc sunf95 gfortran pgf95 pathf95 g95 f90,,f90,$PATH)
AC_FC_LIBRARY_LDFLAGS
fccompiler=`basename $FC`
if test "$fcompiler" = "sunf95" ; then
MODINC_FLAG="-M"
FFLAGS="-M../include $FFLAGS"
FCFLAGS="-M../include $FCFLAGS"
else
MODINC_FLAG="-I"
fi
if test "$F77" = "$FC" ; then
smart_fortran="yes"
AC_MSG_NOTICE([*** Assuming that $FC can process both free and fixed form fortran files.])
else
AC_MSG_NOTICE([*** Assuming that $FC cannot process both free and fixed form fortran files (silly fortran).])
smart_fortran="no"
fi
AC_PROG_CXX(icpc icc ecc sunCC pgCC g++ CC)
AC_PROG_CPP
LINKER=$CXX
AC_LONG_64_BITS
# Find fortran libraries required when linking with C++ main.
AC_FC_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
# Check for standard libraries
AC_LANG_PUSH([C])
AC_CHECK_LIB(stdc++,main,,)
AC_CHECK_LIB(m,main,,)
AC_CHECK_LIB(pthread,main,,)
LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FCLIBS $FLIBS"
LINKER=$CXX
##
## what compiler options work
##
if test "$FC" = "g95"; then
FCFLAGS="-ffast-math -fno-second-underscore $FCFLAGS"
fi
if test "$FC" = "gfortran"; then
if test "$enable_debugging" = "yes" ; then
FCFLAGS="-frecord-marker=4 $FCFLAGS"
else
FCFLAGS="-ffast-math -frecord-marker=4 $FCFLAGS"
fi
CPPFLAGS="$CPPFLAGS -DUSING_GFORTRAN=1"
fi
AC_LANG_PUSH(Fortran 77)
AC_MSG_CHECKING([how do we get fortran 77 to allow long lines])
old_FLAGS="$FFLAGS"
extended_source_flag=none
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
AC_MSG_RESULT(no extra flags required)
extended_source_flag=happy
],[])
if test "$extended_source_flag" != happy ; then
if test "$extended_source_flag" = none ; then
FFLAGS="-extend_source"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-132"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffree-line-length-none -ffixed-line-length-none"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffixed-line-length-huge -ffree-line-length-huge"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffixed-line-length-132 -ffree-line-length-huge"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffixed-line-length-132"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-Mextend"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-qfixed=256"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-e"
AC_TRY_COMPILE([],
[
PRINT*, "hello world "],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
],[])
fi
if test "$extended_source_flag" = none ; then
AC_MSG_RESULT([we cannot])
else
FCFLAGS="$FCFLAGS $extended_source_flag"
fi
fi
AC_LANG_POP([Fortran 77])
AC_PROG_INSTALL
AC_CHECK_PROG(MAKE, gmake, gmake, make, $PATH)
# Set default for ARFLAGS, since autoconf does not have a macro for
# it. This allows people to set it when running configure or make.
AC_CHECK_PROG(AR, ar, ar, ,$PATH)
test -n "$ARFLAGS" || ARFLAGS="cr"
AC_PROG_RANLIB
AC_ARG_ENABLE(verbose,
[AC_HELP_STRING([--enable-verbose],
[turns on super verbosity])])
if test "$enable_verbose" = "yes" ; then
CPPFLAGS="$CPPFLAGS -DVERBOSE_MESSAGES=1"
fi
if test "$enable_debugging" = "yes" ; then
CXXFLAGS="-g -O0 `echo $CXXFLAGS | sed 's/-O2//g'`"
FCFLAGS="-g -O0 `echo $FCFLAGS | sed 's/-O2//g'`"
if test "$fcompiler" = "ifort" ; then
FCFLAGS="-C -traceback -check nooutput_conversion -check noarg_temp_created ${FCFLAGS}"
CXXFLAGS="-fno-omit-frame-pointer ${CXXFLAGS}"
elif test "$fcompiler" = "gfortran" ; then
FCFLAGS="-fbounds-check -Wall ${FCFLAGS}"
CXXFLAGS="-fbounds-check -Wall ${CXXFLAGS}"
LDFLAGS="-rdynamic ${LDFLAGS}"
elif test "$fcompiler" = "g95" ; then
FCFLAGS="-fbounds-check -ftrace=full ${FCFLAGS}"
elif test "$fcompiler" = "sunf95" ; then
FCFLAGS="-C -ftrap=invalid -fpover ${FCFLAGS}"
CXXFLAGS="-ftrap=invalid ${CXXFLAGS}"
else
FCFLAGS="-C ${FCFLAGS}"
fi
else
AC_MSG_NOTICE([Setting optimisation flags])
CPPFLAGS="$CPPFLAGS -DNDEBUG=1"
FCFLAGS="-O3 `echo $FCFLAGS | sed 's/-g -O2//g'`"
CXXFLAGS="-O3 `echo $CXXFLAGS | sed 's/-g -O2//g'`"
fi
if test "$FC" = "ifc" ; then
FCFLAGS="-implicitnone -w95 $FCFLAGS"
fi
##############################################################
# enable gprof profiling
AC_ARG_ENABLE(profiling,
[AC_HELP_STRING([--enable-profiling],
[enable gprof profiling])])
if test "$enable_profiling" = "yes" ; then
PROFILING_FLAG="-pg"
CPPFLAGS="-pg $CPPFLAGS"
FCFLAGS="-pg $FCFLAGS"
LINKER="$LINKER -pg"
else
PROFILING_FLAG=""
fi
AC_SUBST(PROFILING_FLAG)
AC_SUBST(ARFLAGS)
AC_SUBST(LINKER)
AC_SUBST(MAKE)
AC_SUBST(LIBS)
AC_OUTPUT(Makefile src/tests/Makefile examples/Makefile
bin/spud-preprocess
diamond/setup.py diamond/diamond/plugins.py diamond/diamond/preprocess.py)