forked from huiscliu/itsol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
220 lines (187 loc) · 6.71 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
AC_PREREQ(2.59)
AC_INIT()
m4_ifdef([AC_DISABLE_OPTION_CHECKING], [AC_DISABLE_OPTION_CHECKING()], [])
dnl This MUST precede any other macro
AC_CONFIG_AUX_DIR([utils])
AC_CONFIG_HEADER([include/config.h])
AC_CONFIG_FILES([Makefile Makefile.inc])
ITSOL_DIR="`pwd`"
AC_MSG_NOTICE(============================== compilers ===========================)
#--------------------------------------- config files and compilers
# Checks for programs.
AC_PROG_CC(gcc clang icc)
AC_PROG_FC(gfortran g77 f77 ifort)
AC_PROG_CPP
if test "$GCC" = "yes"; then
if $CC -V 2>&1 | grep -q Intel; then
CFLAGS="$CFLAGS -Wall"
elif $CC -v 2>&1 | grep -q clang; then
CFLAGS="$CFLAGS -Wall -Wextra -Warray-bounds"
elif $CC -v 2>&1 | grep -q gcc; then
CFLAGS="$CFLAGS -Wall -Wextra"
for d in -Wmissing-declarations -Wmissing-prototypes -Wimplicit-function-declaration \
-Wunused -Wuninitialized -Wvla -Wformat -Wformat-security -Wmain -Wsequence-point \
-Wshadow -Wbad-function-cast -Wcomments -Wdeclaration-after-statement \
-Waddress -Wpointer-sign -Wempty-body -Wnested-externs -Wold-style-declaration \
-Wold-style-definition -Wmissing-field-initializers -Wmaybe-uninitialized \
-Wno-return-local-addr -Wreturn-type -Wsequence-point -Wundef -Wunknown-pragmas \
-Wunused-label; do
AC_MSG_CHECKING([whether $CC supports $d ])
AC_LANG(C)
CFLAGS_bak="$CFLAGS"
CFLAGS="$CFLAGS $d"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([main(){}])], tmp=yes, tmp=no)
if test $tmp = yes; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
CFLAGS="$CFLAGS_bak"
fi
done
fi
fi
# Fortran
AC_FC_WRAPPERS
AC_FC_LIBRARY_LDFLAGS
LIBS="-L/usr/local/lib $LIBS -lm"
AC_ADD_LIBS(LIBS, ${FCLIBS}, append)
dnl Change relative path in compilers to full path
AC_FULLPATH(CC)
AC_FULLPATH(FC)
AC_FULLPATH(CPP)
# The default linker
AC_SUBST(LINKER, "$LINKER")
AC_PREFIX_DEFAULT(/usr/local/itsol)
AC_CHECK_PROGS(AR,[ar], no)
if test $AR = "no" ; then
AC_MSG_ERROR(* AR is nott found!);
fi
AC_SUBST(AR)
AC_PROG_RANLIB
#--------------------------------------- rpath
AC_SUBST(RPATH_FLAG, "")
AC_ARG_ENABLE(rpath,
[ --enable-rpath enable use of rpath (default)
--disable-rpath disable use of rpath
--with-rpath-flag=FLAG compiler flag for rpath (e.g., "-Wl,-rpath,")],,
enable_rpath=yes)
if test -z "$with_rpath_flag" -a "$enable_rpath" != "no"; then
AC_MSG_CHECKING([for compiler flag for specifying rpath ])
LIBS_bak="$LIBS"
for with_rpath_flag in "-Wl,-rpath," "-Wl,-rpath " "-Wl,--rpath " \
"-rpath " "--rpath " "-Wl,-R" "-R" "-R " ; do
LIBS="$LIBS_bak ${with_rpath_flag}/usr/lib"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], enable_rpath=yes, enable_rpath=no)
if test "$enable_rpath" = "yes"; then break; fi
done
LIBS="$LIBS_bak"
if test "$enable_rpath" = "yes"; then
AC_MSG_RESULT("$with_rpath_flag")
RPATH_FLAG="$with_rpath_flag"
else
AC_MSG_RESULT(unknown)
RPATH_FLAG="unknown"
fi
fi
#--------------------------------------- header files
AC_HEADER_STDC
AC_HEADER_ASSERT
AC_HEADER_TIME
AC_CHECK_HEADERS([limits.h ctype.h])
AC_CHECK_HEADERS([sys/time.h sys/resource.h unistd.h])
#--------------------------------------- library functions.
AC_CHECK_FUNCS([gettimeofday getrusage])
# fpe needs -lm
LIBS="$LIBS -lm"
AC_ADD_FLAGS(CPPFLAGS, -I/usr/local/include)
AC_ADD_FLAGS(LDFLAGS, -L/usr/local/lib)
#--------------------------------------- basic flags
# Note: -I`pwd`/include and -L`pwd`/src must be the first term in CPPFLAGS
# and LDFLAGS respectively, which will be changed to ITSOL_INSTDIR/include by
# 'make install'
CPPFLAGS="-I${ITSOL_DIR}/include $CPPFLAGS"
LDFLAGS="-L${ITSOL_DIR}/src $LDFLAGS"
#--------------------------------------- Fortran
AC_FC_FUNC(dgemm,DGEMM) dnl BLAS
AC_FC_FUNC(dgels,DGELS) dnl LAPACK
AC_FC_FUNC(pdsygvx,PDSYGVX) dnl SCALAPACK
#--------------------------------------- BLAS
AC_LANG(C)
AC_ARG_ENABLE(blas,
[ --enable-blas enable BLAS support (default)
--disable-blas disable BLAS support
--with-blas=blas BLAS lib],,enable_blas=yes)
if test "$enable_blas" != no; then
AC_MSG_CHECKING([whether we have BLAS ])
if test "$enable_blas" != no -a "$with_blas" == ""; then
for d in /usr/local/lib /usr/local/lib64 /usr/local/blas/lib /usr/local/blas*/lib \
/usr/lib /usr/lib64 /opt/blas/lib /opt/blas*/lib; do
if test -r ${d}/libblas.*; then
with_blas_libdir="$d"
with_blas="-L$d -lblas"
break
fi
done
fi
AC_ADD_LIBS(LIBS, $with_blas)
if test "$enable_blas" != no; then
AC_CHECK_FORTRAN([AC_LANG_SOURCE([main(){$DGEMM();}])], blas)
if test "$blas_ok" != "yes"; then
enable_blas=no
fi
fi
AC_MSG_RESULT($enable_blas)
if test "$enable_blas" != no; then
AC_MSG_NOTICE(* BLAS support enabled)
AC_MSG_NOTICE(* BLAS libs = $with_blas)
AC_DEFINE(USE_BLAS, 1)
else
AC_MSG_NOTICE(* BLAS is disabled)
AC_DEFINE(USE_BLAS, 0)
fi
else
AC_MSG_ERROR(* BLAS is not found)
fi
#--------------------------------------- LAPACK
AC_LANG(C)
AC_ARG_ENABLE(lapack,
[ --enable-lapack enable LAPACK support (default)
--disable-lapack disable LAPACK support
--with-lapack=lapack LAPACK lib],,enable_lapack=yes)
if test "$enable_lapack" != no; then
AC_MSG_CHECKING([whether we have LAPACK ])
if test "$enable_lapack" != no -a "$with_lapack" == ""; then
for d in /usr/local/lib /usr/local/lib64 /usr/local/lapack/lib /usr/local/lapack*/lib \
/usr/lib /usr/lib64 /opt/lapack/lib /opt/lapack*/lib; do
if test -r ${d}/liblapack.*; then
with_lapack_libdir="$d"
with_lapack="-L$d -llapack"
break
fi
done
fi
AC_ADD_LIBS(LIBS, $with_lapack)
if test "$enable_lapack" != no; then
AC_CHECK_FORTRAN([AC_LANG_SOURCE([main(){$DGELS();}])], lapack)
if test "$lapack_ok" != "yes"; then
enable_lapack=no
fi
fi
AC_MSG_RESULT($enable_lapack)
if test "$enable_lapack" != no; then
AC_MSG_NOTICE(* LAPACK support enabled)
AC_MSG_NOTICE(* LAPACK libs = $with_lapack)
AC_DEFINE(USE_LAPACK, 1)
else
AC_MSG_NOTICE(* LAPACK is disabled)
AC_DEFINE(USE_LAPACK, 0)
fi
else
AC_MSG_ERROR(* LAPACK is not found)
fi
#--------------------------------------- the end
if test -z "$LINKER"; then
LINKER="$CC"
fi
LIBS="-litsol $LIBS"
AC_OUTPUT