forked from flexible-atomic-code/fac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
executable file
·295 lines (269 loc) · 6.14 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
# Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_HEADERS([sysdef.h:sysdef.h.in])
AC_PREFIX_DEFAULT("/usr/local")
TOPDIR=`pwd`
AC_SUBST(TOPDIR)
AC_CANONICAL_HOST
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_CHECK_PROG([PYTHON], [python], [python])
AC_SUBST(PYTHON)
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_HEADER_STDC
AC_PROG_F77
AC_F77_LIBRARY_LDFLAGS
# some F77 LDFLAGS have a -lcrt1.o which causes trouble.
# actually any crtn.o may cause trouble, we don't need that.
AC_MSG_CHECKING([for -lcrtn.o in FLIBS])
FLIBS=[`echo $FLIBS | sed 's/-lcrt.*\.o//g'`]
FLIBS=[`echo $FLIBS | sed 's/ */ /g'`]
AC_MSG_RESULT([$FLIBS])
#get optimization option for C and f77 compilers
AC_ARG_ENABLE(copt,
[ --enable-copt=opt optimization option for C compiler],
[copt="$enableval"])
AC_ARG_ENABLE(fopt,
[ --enable-fopt=opt optimization option for F77 Compiler],
[fopt="$enableval"])
# get position independent code option for C and f77 compilers
AC_ARG_ENABLE(cpic,
[ --enable-cpic=opt PIC option for C compiler],
[cpic="$enableval"])
AC_ARG_ENABLE(fpic,
[ --enable-fpic=opt PIC option for F77 Compiler],
[fpic="$enableval"])
# override the default CFLAGS and FFLAGS for GCC and G77
if test -n "$GCC"
then
if test -z "$copt"
then
copt="-Ofast"
fi
if test -z "$cpic"
then
cpic="-fPIC"
fi
fi
if test -n "$G77"
then
if test -z "$fopt"
then
fopt="-O2"
fi
if test -z "$fpic"
then
fpic="-fPIC"
fi
fi
CFLAGS="$copt $cpic"
FFLAGS="$fpic"
# Debugging option
AC_ARG_ENABLE(cdebug,
[ --enable-cdebug=opt Debugging option for C],
[cdebug_opt=$enableval])
if test -n "$cdebug_opt"
then
CFLAGS="$CFLAGS $cdebug_opt"
fi
AC_ARG_ENABLE(fdebug,
[ --enable-fdebug=opt Debugging option for F77],
[fdebug_opt=$enableval])
if test -n "$fdebug_opt"
then
FFLAGS="$FFLAGS $fdebug_opt"
fi
# gcc warnings
AC_ARG_ENABLE(warnings,
[ --enable-warnings GCC warnings],
[gcc_warnings=$enableval])
if test -n "$GCC"
then
if test -n "$gcc_warnings"
then
CFLAGS="$CFLAGS -Wall -W -pedantic -Winline -Wmissing-prototypes \
-Wnested-externs -Wpointer-arith -Wcast-align -Wshadow -Wstrict-prototypes"
CFLAGS=`echo $CFLAGS`
fi
fi
if test -n "$G77"
then
if test -n "$gcc_warnings"
then
FFLAGS="$FFLAGS -Wall"
FFLAGS=`echo $FFLAGS`
fi
fi
# which F77 known by cfortran.h is used
AC_ARG_WITH(cfortran,
[ --with-cfortran=xxFortran Macro to be defined for cfortran.h],
[xxFortran="$withval"])
if test -z "$xxFortran"
then
if test -n "$G77"
then
xxFortran=f2cFortran
else
case "$host_os" in
*linux* )
xxFortran=f2cFortran
;;
*solaris*)
xxFortran=sunFortran
;;
*sunos*)
xxFortran=sunFortran
;;
*hpux*)
xxFortran=hpuxFortran
;;
*)
echo "NOTE: F77 known by cfortran.h is not detected."
echo " using default f2cFortran."
echo " if not, change it using --with-cfortran=xxFortran"
echo " see faclib/cfortran.doc for available options."
xxFortran=f2cFortran
;;
esac
fi
fi
AC_DEFINE_UNQUOTED([$xxFortran])
# MPI
AC_ARG_WITH(mpi,
[ --with-mpi Use MPI],
[use_mpi=$withval])
AC_ARG_WITH(mpicompile,
[ --with-mpicompile MPI compile flags],
[mpicompile=$withval])
AC_ARG_WITH(mpilink,
[ --with-mpilink MPI link flags],
[mpilink=$withval])
AC_ARG_WITH(mpifflag,
[ --with-mpifflag MPI f77 flags],
[mpifflag=$withval])
AC_ARG_WITH(extrainc,
[ --with-extrainc Extra compile flags],
[extrainc=$withval])
AC_ARG_WITH(extralib,
[ --with-extralib Extra Libs],
[extralib=$withval])
AC_ARG_WITH(blaslib,
[ --with-blaslib BLAS Libs],
[blaslib=$withval])
AC_ARG_WITH(lapacklib,
[ --with-lapacklib LAPACK Libs],
[lapacklib=$withval])
# setup libs
if test "x$blaslib" == "x"
then
blaslib="-lmblas"
fi
if test "x$lapacklib" == "x"
then
lapacklib="-lmlapack"
fi
LIBS="$LIBS -lfac $lapacklib $blaslib -lpthread"
fwithm=`echo "$FLIBS " | grep " -lm"`
if test "x$fwithm" = "x"
then
LIBS="$LIBS -lm"
fi
if test "x$use_mpi" != "x"
then
case "$use_mpi" in
*mpi|1)
if test "x$mpicompile" = "x"
then
mpicompile=`mpicc -showme`
mpicompile=[`echo $mpicompile | sed 's/^ *//'`]
mpicompile=[`echo $mpicompile | sed 's/^[^ ]* *//'`]
mpicompile=[`echo $mpicompile | sed 's/ -[Ll][^ ]*//g'`]
mpicompile=[`echo $mpicompile | sed 's/ *$//'`]
fi
if test "x$mpilink" = "x"
then
mpilink=`mpicc -showme`
mpilink=[`echo $mpilink | sed 's/^ *//'`]
mpilink=[`echo $mpilink | sed 's/^[^ ]* *//'`]
mpilink=[`echo $mpilink | sed 's/ -[^Ll][^ ]*//g'`]
mpilink=[`echo $mpilink | sed 's/ *$//'`]
fi
AC_DEFINE_UNQUOTED([USE_MPI])
;;
omp|2)
if test "x$mpicompile" = "x"
then
mpicompile=-fopenmp
mpilink="-fopenmp -lgcc_eh"
fi
if test "x$mpifflag" = "x"
then
mpifflag=-fopenmp
fi
AC_DEFINE_UNQUOTED([USE_MPI], [2])
;;
*)
AC_DEFINE_UNQUOTED([USE_MPI])
;;
esac
CPPFLAGS="$CPPFLAGS $mpicompile"
LIBS="$LIBS $mpilink"
FFLAGS="$FFLAGS $mpifflag"
fi
if test "x$extrainc" != "x"
then
CPPFLAGS="$CPPFLAGS $extrainc"
fi
if test "x$extralib" != "x"
then
LDFLAGS="$LDFLAGS $extralib"
fi
# special flags for some OS
case "$host_os" in
*darwin*)
if test -n "$GCC"
then
AC_CHECK_LIB(cc_dynamic,main,LIBS="$LIBS -lcc_dynamic")
fi
;;
*)
;;
esac
# add fopt
FFLAGSNO="$FFLAGS"
AC_SUBST(FFLAGSNO)
FFLAGS="$FFLAGS $fopt"
# add include pathes.
CPPFLAGS="$CPPFLAGS -I$TOPDIR"
CPPFLAGS="$CPPFLAGS -I$TOPDIR/faclib"
LDFLAGS="$LDFLAGS -L$TOPDIR"
AC_CONFIG_FILES([Makefile
sfac/Makefile
python/Makefile
faclib/Makefile
blas/Makefile
coul/Makefile
ionis/Makefile
lapack/Makefile
minpack/Makefile
mpfun/Makefile
ode/Makefile
toms/Makefile
modqed/Makefile
quadpack/Makefile])
if test -z "$PYTHON"
then
echo "WARNING: NO PYTHON DETECTED ON THIS SYSTEM."
echo "To install PFAC interface,"
echo "download and install Python 2.0 or later"
echo "You may still procede to install SFAC interface, though."
fi
AC_OUTPUT