forked from igraph/igraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
410 lines (371 loc) · 13.7 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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
AC_INIT(igraph, esyscmd([tr -d '\n' < IGRAPH_VERSION]), [email protected])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/games.c)
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_HEADERS([config.h])
m4_include(tools/autoconf/ax_tls.m4)
m4_include(tools/autoconf/as-version.m4)
AS_VERSION
# Define list of additional libraries that have to be linked to igraph when
# another app tries to link to the static library of igraph. This is substituted
# into igraph.pc later on.
PKGCONFIG_LIBS_PRIVATE="-lxml2 -lz -lm"
AC_SUBST(PKGCONFIG_LIBS_PRIVATE)
# Test suite
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
# Don't allow AC_PROG_CC to set a default CFLAGS or CXXFLAGS
: ${CFLAGS=""}
: ${CXXFLAGS=""}
AC_LANG(C)
AC_PROG_CC
# Tricky check for C++ compiler, because Autoconf has a weird bug:
# http://lists.gnu.org/archive/html/autoconf/2006-03/msg00067.html
AC_PROG_CXX
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <iostream>
const char hw[] = "Hello, World\n";]],
[[std::cout << hw;]])],
[AC_PROG_CXXCPP
cxx_error=no],
[AC_MSG_ERROR([no C++ compiler found or it cannot create executables])])
AC_LANG_POP([C++])
AM_PROG_LEX
AC_PROG_YACC
AC_CHECK_HEADER([sys/times.h],
[AC_DEFINE([HAVE_TIMES_H], [1], [Define to 1 if you have the sys/times.h header])],
[CPPFLAGS="$CPPFLAGS -DMSDOS"],
)
AC_LIBTOOL_WIN32_DLL
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_HEADER_STDC
AC_CHECK_HEADERS([stdarg.h stdlib.h string.h time.h unistd.h stdint.h sys/int_types.h])
LIBS_SAVE=$LIBS
LIBS="$LIBS -lm"
AC_CHECK_FUNCS([expm1 rint rintf finite log2 snprintf log1p round fabsl fmin strcasecmp isnan strdup _strdup ftruncate stpcpy])
AC_CHECK_DECLS(isfinite,,,[#include <math.h>])
AC_CHECK_DECL([stpcpy],
[AC_DEFINE([HAVE_STPCPY_SIGNATURE], [1], [Define to 1 if the stpcpy function has a signature])])
LIBS=$LIBS_SAVE
AC_DEFUN([IGRAPH_WARNING],
[AC_MSG_CHECKING(whether compiler accepts $1)
AC_SUBST(WARNING_CFLAGS)
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_TRY_COMPILE(,
[int x;],
WARNING_CFLAGS="$WARNING_CFLAGS $1"
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$ac_save_CFLAGS"])
AC_DEFUN([IGRAPH_CC_SWITCH],
[AC_MSG_CHECKING(whether compiler supports $1)
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_TRY_COMPILE(,
[int x;],
AC_MSG_RESULT(yes)
$2,
AC_MSG_RESULT(no)
$3)
CFLAGS="$ac_save_CFLAGS"])
## Solaris cc does not support -ffloat-store.
FLOATSTORE=
IGRAPH_CC_SWITCH([-ffloat-store], [FLOATSTORE="-ffloat-store"], [])
IGRAPH_CC_SWITCH([-fstore], [FLOATSTORE="$FLOATSTORE -fstore"], [])
AC_SUBST(FLOATSTORE)
AC_ARG_ENABLE(gcc-warnings,
AC_HELP_STRING([--enable-gcc-warnings],
[turn on lots of GCC warnings (not recommended)]),
[case "${enableval}" in
yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for gcc-warnings option]) ;;
esac],
[enableval=no])
if test "${enableval}" = yes; then
IGRAPH_WARNING(-Werror)
AC_SUBST([WERROR_CFLAGS], [$WARNING_CFLAGS])
WARNING_CFLAGS=
IGRAPH_WARNING(-Wall)
IGRAPH_WARNING(-W)
IGRAPH_WARNING(-Wbad-function-cast)
IGRAPH_WARNING(-Wcast-align)
IGRAPH_WARNING(-Wcast-qual)
IGRAPH_WARNING(-Wformat)
IGRAPH_WARNING(-Wmissing-declarations)
IGRAPH_WARNING(-Wmissing-prototypes)
IGRAPH_WARNING(-Wnested-externs)
IGRAPH_WARNING(-Wshadow)
IGRAPH_WARNING(-Wstrict-prototypes)
IGRAPH_WARNING(-Wwrite-strings)
else
WARNING_CFLAGS=
IGRAPH_WARNING(-Wall)
fi
use_gprof=no
AC_ARG_ENABLE(profiling,
AC_HELP_STRING([--enable-profiling], [Enable gprof profiling]),
[use_gprof=$enableval], [use_gprof=no])
use_asan=no
AC_ARG_ENABLE(asan,
AC_HELP_STRING([--enable-asan], [Enable Clang address sanitizer]),
[use_asan=$enableval], [use_asan=no])
debug=no
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [Enable debug build]),
[debug=$enableval])
graphml_support=yes
AC_ARG_ENABLE(graphml,
AC_HELP_STRING([--disable-graphml], [Disable support for GraphML format]),
[graphml_support=$enableval], [graphml_support=yes])
HAVE_LIBXML=0
if test $graphml_support = yes; then
AC_PATH_PROG([XML2CONFIG], [xml2-config], [none])
if test "$XML2CONFIG" = "none"; then
# Hmmm, no xml2-config. Older versions of OS X do not have it while still
# having libxml2, so let's try an educated guess if
# /usr/include/libxml2/libxml/parser.h exists.
AC_CHECK_FILE([/usr/include/libxml2/libxml/parser.h], [
XML2_LIBS="-lxml2 -lz -lm"
XML2_CFLAGS="-I/usr/include/libxml2"
], [
graphml_support=no
])
else
XML2_LIBS=`$XML2CONFIG --libs`
XML2_CFLAGS=`$XML2CONFIG --cflags`
if test -f /usr/bin/sw_vers -a `sw_vers -productVersion | grep -c "^10\.11\."` -gt 0 -a `echo $XML2_LIBS | grep -c '/Developer/'` -gt 0; then
# We are on OS X 10.11, which has a known bug with xml2-config; see
# https://github.com/igraph/igraph/issues/973 . We work around it
# here
XML2_LIBS=`$XML2CONFIG --exec-prefix=/usr --libs`
fi
fi
AC_CHECK_LIB([xml2], [xmlSAXUserParseFile], [
ac_save_CFLAGS="$CFLAGS"
ac_save_CPPFLAGS="$CPPFLAGS"
CFLAGS=${XML2_CFLAGS}
CPPFLAGS=${XML2_CFLAGS}
AC_CHECK_HEADER([libxml/parser.h], [
HAVE_LIBXML=1
AC_DEFINE([HAVE_LIBXML], [1], [Define to 1 if you have the libxml2 libraries installed])
CFLAGS="$ac_save_CFLAGS ${XML2_CFLAGS}"
CPPFLAGS="$ac_save_CPPFLAGS"
AC_SUBST(XML2_LIBS)
AC_SUBST(XML2_CFLAGS)
], [
graphml_support=no
CFLAGS="$ac_save_CFLAGS"
CPPFLAGS="$ac_save_CPPFLAGS"
])
], [
graphml_support=no
])
fi
AC_LANG_PUSH([C++])
gmp_support=no
AC_ARG_ENABLE(gmp, AC_HELP_STRING([--disable-gmp], [Compile without the GMP library]))
if test "x$enable_gmp" != "xno"; then
AC_CHECK_LIB([gmp], [__gmpz_add], [
AC_CHECK_HEADER([gmp.h], [
AC_DEFINE([HAVE_GMP], [1], [Define to 1 if you have the GMP library])
gmp_support=yes
LDFLAGS="${LDFLAGS} -lgmp"
PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} -lgmp"
])
])
fi
AC_LANG_POP([C++])
tls_support=no
HAVE_TLS=0
THREAD_LOCAL=
AC_ARG_ENABLE(tls, AC_HELP_STRING([--enable-tls], [Compile with thread-local storage]))
if test "x$enable_tls" = "xyes"; then
keywords="__thread __declspec(thread)"
for kw in $keywords ; do
AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw)
AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw ; break ;)
done
AX_TLS([
AC_DEFINE([HAVE_TLS], [1], [Define to 1 if you want to use thread-local storage for global igraph structures])
tls_support=yes
HAVE_TLS=1
THREAD_LOCAL=$ac_cv_tls
], [])
fi
AC_SUBST(HAVE_TLS)
AC_DEFINE_UNQUOTED([IGRAPH_THREAD_LOCAL], $THREAD_LOCAL,
[Keyword for thread local storage, or empty if not available])
AC_DEFINE_UNQUOTED([IGRAPH_F77_SAVE], [static IGRAPH_THREAD_LOCAL],
[Keyword for thread local storage, or just static if not available])
AC_ARG_WITH([external-f2c], [AS_HELP_STRING([--with-external-f2c],
[Use external F2C library [default=no]])],
[internal_f2c=no],
[internal_f2c=yes])
AC_ARG_WITH([external-blas], [AS_HELP_STRING([--with-external-blas],
[Use external BLAS library [default=no]])],
[internal_blas=no],
[internal_blas=yes])
AC_ARG_WITH([external-lapack], [AS_HELP_STRING([--with-external-lapack],
[Use external LAPACK library [default=no]])],
[internal_lapack=no],
[internal_lapack=yes])
AC_ARG_WITH([external-arpack], [AS_HELP_STRING([--with-external-arpack],
[Use external ARPACK library [default=no]])],
[internal_arpack=no],
[internal_arpack=yes])
AC_ARG_WITH([external-glpk], [AS_HELP_STRING([--with-external-glpk],
[Use external GLPK library [default=no]])],
[internal_glpk=no],
[internal_glpk=yes])
needs_f2c="no"
if test "$internal_blas" = "yes" -o "$internal_lapack" = "yes" -o "$internal_arpack" = "yes"; then
needs_f2c="yes"
fi
if test "$needs_f2c" = "yes"; then
if test "$internal_f2c" = "no"; then
AC_CHECK_LIB([f2c], [f77_alloc_], [],
AC_CHECK_LIB([f2c], [f77_alloc], [],
AC_CHECK_LIB([f2c], [F77_ALLOC_], [],
AC_CHECK_LIB([f2c], [F77_ALLOC], [],
[AC_MSG_RESULT(not found, trying to use -lf2c anyway.)]))))
LDFLAGS="${LDFLAGS} -lf2c"
else
AC_DEFINE([INTERNAL_F2C], [1], [Define to 1 if you use the internal F2C library])
fi
else
internal_f2c=no
fi
if test "$internal_blas" = "no"; then
AC_CHECK_LIB([blas], [daxpy_], [],
AC_CHECK_LIB([blas], [daxpy], [],
AC_CHECK_LIB([blas], [DAXPY_], [],
AC_CHECK_LIB([blas], [DAXPY], [],
[AC_MSG_RESULT(not found, trying to use -lblas anyway.)]))))
LDFLAGS="${LDFLAGS} -lblas"
PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} -lblas"
else
AC_DEFINE([INTERNAL_BLAS], [1], [Define to 1 if you use the internal BLAS library])
fi
if test "$internal_lapack" = "no"; then
AC_CHECK_LIB([lapack], [dlarnv_], [],
AC_CHECK_LIB([lapack], [dlarnv], [],
AC_CHECK_LIB([lapack], [DLARNV_], [],
AC_CHECK_LIB([lapack], [DLARNV], [],
[AC_MSG_RESULT(not found, trying to use -llapack anyway.)]))))
LDFLAGS="${LDFLAGS} -llapack"
PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} -llapack"
else
AC_DEFINE([INTERNAL_LAPACK], [1], [Define to 1 if you use the internal LAPACK library])
fi
if test "$internal_arpack" = "no"; then
if test "$tls_support" = "yes"; then
AC_MSG_ERROR([Thread-local storage only supported with internal ARPACK library])
fi
AC_CHECK_LIB([arpack], [dsaupd_], [],
AC_CHECK_LIB([arpack], [dsaupd], [],
AC_CHECK_LIB([arpack], [DSAUPD_], [],
AC_CHECK_LIB([arpack], [DSAUPD], [],
[AC_MSG_RESULT(not found, trying to use -larpack anyway.)]))))
LDFLAGS="${LDFLAGS} -larpack"
PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} -larpack"
else
AC_DEFINE([INTERNAL_ARPACK], [1], [Define to 1 if you use the internal ARPACK library])
fi
glpk_support=no
AC_ARG_ENABLE(glpk, AC_HELP_STRING([--disable-glpk], [Compile without the GLPK library]))
if test "x$enable_glpk" != "xno"; then
if test "$internal_glpk" = "no"; then
AC_CHECK_LIB([glpk], [glp_read_mps], [
AC_CHECK_HEADER([glpk.h], [
AC_EGREP_CPP(yes, [
#include <glpk.h>
#if GLP_MAJOR_VERSION > 4 || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION >= 38)
yes
#endif
], [
AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have the GLPK library])
glpk_support=yes
LDFLAGS="${LDFLAGS} -lglpk"
PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} -lglpk"
])
])
])
else
AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have the GLPK library])
AC_DEFINE([INTERNAL_GLPK], [1], [Define to 1 if you use the internal GLPK library])
glpk_support=yes
fi
else
internal_glpk=no
fi
# Link time optimization feature in newer gcc/g++
# based on http://svn.r-project.org/R/trunk/configure.ac
AC_ARG_ENABLE([lto],
[AS_HELP_STRING([--enable-lto],[enable link-time optimization @<:@default=no@:>@])],
[if test "x${enableval}" = xyes -o "x${enableval}" = x; then
want_lto=yes
elif test "x${enableval}" = xno; then
want_lto=no
else
AC_MSG_ERROR([Invalid response to --enable-lto (got ${enableval})])
fi],
[want_lto=no]
)
use_lto=no
if test "x${want_lto}" = xyes; then
AX_CHECK_COMPILE_FLAG([-flto],
[use_lto=yes; CFLAGS="$CFLAGS -flto"; CXXFLAGS="$CXXFLAGS -flto"],
[AC_MSG_ERROR([Compiler doesn't support -flto, requested by link-time optimization (--enable-lto)])])
LTO=-flto
fi
AC_SUBST(LTO)
AM_CONDITIONAL(BUILD_LTO, [test "x${want_lto}" != xno])
AM_CONDITIONAL(INTERNAL_GLPK, test x$internal_glpk = xyes)
AM_CONDITIONAL(INTERNAL_ARPACK, test x$internal_arpack = xyes)
AM_CONDITIONAL(INTERNAL_LAPACK, test x$internal_lapack = xyes)
AM_CONDITIONAL(INTERNAL_BLAS, test x$internal_blas = xyes)
AM_CONDITIONAL(INTERNAL_F2C, test x$internal_f2c = xyes)
if test "$debug" = "yes"; then
CFLAGS="${CFLAGS} -ggdb -O0"
CPPFLAGS="${CPPFLAGS} -DRC_DEBUG"
CXXFLAGS="${CXXFLAGS} -ggdb -O0"
fi
if test "$use_gprof" = "yes"; then
CFLAGS="${CFLAGS} -pg"
CXXFLAGS="${CXXFLAGS} -pg"
fi
if test "$use_asan" = "yes"; then
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
CXXFLAGS="${CXXFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
fi
if test "$use_asan" != "yes" -a "$use_gprof" != "yes" -a "$debug" != "yes"; then
CFLAGS="${CFLAGS} -O3"
CPPFLAGS="${CPPFLAGS} -O3"
CXXFLAGS="${CXXFLAGS} -O3"
fi
AC_CONFIG_FILES([Makefile src/Makefile igraph.pc igraph_Info.plist doc/Makefile include/igraph_version.h include/igraph_threading.h])
AC_OUTPUT
AC_MSG_RESULT([igraph successfully configured.])
AC_MSG_RESULT([ GraphML format support -- $graphml_support])
AC_MSG_RESULT([ GMP library support -- $gmp_support])
AC_MSG_RESULT([ GLPK library support -- $glpk_support])
AC_MSG_RESULT([ Thread-local storage -- $tls_support])
AC_MSG_RESULT([ Use internal ARPACK -- $internal_arpack])
AC_MSG_RESULT([ Use internal LAPACK -- $internal_lapack])
AC_MSG_RESULT([ Use internal BLAS -- $internal_blas])
if test "$needs_f2c" != "yes"; then
AC_MSG_RESULT([ Use internal F2C -- f2c not needed])
else
AC_MSG_RESULT([ Use internal F2C -- $internal_f2c])
fi
if test "$glpk_support" != "no"; then
AC_MSG_RESULT([ Use internal GLPK -- $internal_glpk])
fi
AC_MSG_RESULT([ Debug build -- $debug])
AC_MSG_RESULT([ Clang AddressSanitizer -- $use_asan])
AC_MSG_RESULT([ Profiling -- $use_gprof])
AC_MSG_RESULT([ Link time optimization -- $use_lto])