-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconfigure.ac
457 lines (400 loc) · 16.1 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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([nauty-h.in])
# ======================================================================
# First we define some functions
dnl AC_TRY_CFLAGS(CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl Check if $CC supports a given set of cflags
AC_DEFUN([AC_TRY_CFLAGS],
[AC_MSG_CHECKING([if $CC supports $1 flags])
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], \
[[]])],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no])
CFLAGS="$SAVE_CFLAGS"
AC_MSG_RESULT([$ac_cv_try_cflags_ok])
if test "x$ac_cv_try_cflags_ok" = xyes; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi])
dnl CVT_YESNO([YES-NO VARIABLE],[0-1 VARIABLE])
dnl Make a 0-1 output variable from a yes/no shell variable
AC_DEFUN([CVT_YESNO],[if test "x$$1" = xyes; then
$2=1
else
$2=0
fi
AC_SUBST($2)])
dnl Check for thread-local attribute
AC_DEFUN([AX_TLS], [
AC_MSG_CHECKING([for thread local storage (TLS) class])
AC_CACHE_VAL([ac_cv_tls],
[for ax_tls_keyword in thread_local _Thread_local __thread '__declspec(thread)' none; do
AS_CASE([$ax_tls_keyword],
[none], [ac_cv_tls=none ; break],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include <stdlib.h>],
[static $ax_tls_keyword int bar;]
)],
[ac_cv_tls=$ax_tls_keyword ; break],
[ac_cv_tls=none]
)]
)
done ]
)
AC_MSG_RESULT([$ac_cv_tls])
AS_IF([test "$ac_cv_tls" != "none"],
[AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class, define it to that here])
m4_ifnblank([$1],[$1],[[:]])],
[m4_ifnblank([$2],[$2],[[:]])])
])
# ======================================================================
# First we check for configuration switches
dnl --disable-popcnt disallows popcount instruction, otherwise they are tested for
AC_ARG_ENABLE([popcnt],
AS_HELP_STRING([--disable-popcnt], [Disable popcnt extensions]),
[enablearg=given], [enablearg=notgiven])
AS_IF([test $enablearg = notgiven || test "x$enable_popcnt" = xyes],[allow_popcnt=1],[allow_popcnt=0])
dnl --disable-clz disallows clz instructions, otherwise they are tested for
AC_ARG_ENABLE([clz],
AS_HELP_STRING([--disable-clz], [Disable clz extensions]),
[enablearg=given], [enablearg=notgiven])
AS_IF([test $enablearg = notgiven || test "x$enable_clz" = xyes],[allow_clz=1],[allow_clz=0])
dnl --enable-generic disallows -march=native, otherwise it is tested for
AC_ARG_ENABLE([generic],
AS_HELP_STRING([--enable-generic], [Disable -march=native switch]),
[enablearg=given], [enablearg=notgiven])
AS_IF([test $enablearg = notgiven || test "x$enable_generic" = xno],[allow_native=1],[allow_native=0])
dnl --enable-tls specifies thread-local storage, if possible
AC_ARG_ENABLE([tls],
AS_HELP_STRING([--enable-tls], [Enable thread-local storage]),
[use_tls="#define USE_TLS"], [use_tls=])
dnl --enable-ansi specifies ANSI controls are allowed in output
AC_ARG_ENABLE([ansi],
AS_HELP_STRING([--enable-ansi], [Enable ANSI controls in output]),
[enablearg=given], [enablearg=notgiven])
AS_IF([test $enablearg = notgiven || test "x$enable_ansi" = xno],[allow_ansi=0],[allow_ansi=1])
dnl --disable-interrupt prevents nauty or traces catching control-C, otherwise allow it
AC_ARG_ENABLE([interrupt],
AS_HELP_STRING([--disable-interrupt], [Disable interrupt catching in nauty&traces]),
[enablearg=given], [enablearg=notgiven])
AS_IF([test $enablearg = notgiven || test "x$enable_interrupt" = xyes],[allow_interrupt=1],[allow_interrupt=0])
dnl --enable-wordsize=value overrides default rule for choosing WORDSIZE
AC_ARG_ENABLE([wordsize],
AS_HELP_STRING([--enable-wordsize=value], [Override default WORDSIZE choice]))
AS_IF([test "x$enable_wordsize" = x16],[default_wordsize=16],[default_wordsize=0])
AS_IF([test "x$enable_wordsize" = x32],[default_wordsize=32])
AS_IF([test "x$enable_wordsize" = x64],[default_wordsize=64])
# ======================================================================
# Next we get to work
dnl Checks for system features
AC_CANONICAL_HOST
case "$host" in
*powerpc*)
is_powerpc=1 ;;
*)
is_powerpc=0 ;;
esac
case "$build" in
*cygwin*)
is_cygwin=1 ;;
*)
is_cygwin=0 ;;
esac
dnl Checks for C compiler and sets CFLAGS if not set by user
user_cflags="$CFLAGS"
AC_PROG_CC
CFLAGS=$user_cflags
MORECFLAGS=""
dnl we need AC_SYS_LARGEFILE and AC_FUNC_FSEEKO
AC_SYS_LARGEFILE
AS_IF([test "x$ac_cv_sys_file_offset_bits" = xno],[ac_cv_sys_file_offset_bits=0])
AC_SUBST(ac_cv_sys_file_offset_bits)
AS_IF([test "x$user_cflags" = x || test "x$user_cflags" = x-m32],
[
AS_IF([test "$CC" = "icc"],
[AC_TRY_CFLAGS([-O3],[CFLAGS="$CFLAGS -O3"]);
AS_IF([test "x$ac_cv_try_cflags_ok" = xno],
[AC_TRY_CFLAGS([-O2],[CFLAGS="$CFLAGS -O2"],[CFLAGS="$CFLAGS -O"])])],
[AC_TRY_CFLAGS([-O4 -Werror],[CFLAGS="$CFLAGS -O4"]);
AS_IF([test "x$ac_cv_try_cflags_ok" = xno],
[AC_TRY_CFLAGS([-O3],[CFLAGS="$CFLAGS -O3"])
AS_IF([test "x$ac_cv_try_cflags_ok" = xno],
[AC_TRY_CFLAGS([-O2],[CFLAGS="$CFLAGS -O2"],[CFLAGS="$CFLAGS -O"])])
])
])
])
case "$CC" in
gcc*)
gccver=`"$CC" -dumpversion` ;;
*)
gccver=0.0.0 ;;
esac
dnl Checks relevant to Cygwin and other Windows things
AC_EXEEXT
dnl Checks for header files.
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(signal.h stddef.h unistd.h sys/types.h sys/wait.h stdlib.h string.h errno.h limits.h stdint.h)
CVT_YESNO(ac_cv_header_stddef_h,header_stddef_h)
CVT_YESNO(ac_cv_header_unistd_h,header_unistd_h)
CVT_YESNO(ac_cv_header_stdlib_h,header_stdlib_h)
CVT_YESNO(ac_cv_header_string_h,header_string_h)
CVT_YESNO(ac_cv_header_sys_wait_h,header_sys_wait_h)
CVT_YESNO(ac_cv_header_sys_types_h,header_sys_types_h)
CVT_YESNO(ac_cv_header_errno_h,header_errno_h)
CVT_YESNO(ac_cv_header_signal_h,header_signal_h)
CVT_YESNO(ac_cv_header_limits_h,header_limits_h)
CVT_YESNO(ac_cv_header_stdint_h,header_stdint_h)
AC_TYPE_PID_T
CVT_YESNO(ac_cv_type_pid_t,have_pid_t)
AC_CHECK_DECL([ftell],ftell_dec=1,ftell_dec=0)
AC_SUBST(ftell_dec)
AC_CHECK_DECL([popen],popen_dec=1,popen_dec=0)
AC_SUBST(popen_dec)
AC_CHECK_DECL([fdopen],fdopen_dec=1,fdopen_dec=0)
AC_SUBST(fdopen_dec)
AC_CHECK_DECL([putenv],putenv_dec=1,putenv_dec=0)
AC_SUBST(putenv_dec)
AC_CHECK_DECL([setenv],setenv_dec=1,setenv_dec=0)
AC_SUBST(setenv_dec)
AC_CHECK_DECL([malloc],malloc_dec=1,malloc_dec=0)
AS_IF([test $malloc_dec -eq 0],
[AC_EGREP_HEADER([(^|[^a-zA-Z_0-9])malloc[^a-zA-Z_0-9]],malloc.h,
malloc_dec=2,malloc_dec=0)])
AC_SUBST(malloc_dec)
AC_MSG_CHECKING(if compiler accepts flexible array members)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], \
[[void foo(void*);struct { int a; int b[]; } ab; foo(&ab); ]])],
[flex_array_ok=1],[flex_array_ok=0])
AC_SUBST(flex_array_ok)
AC_MSG_RESULT($flex_array_ok)
AC_MSG_CHECKING(if INFINITY is declared in math.h)
AC_EGREP_CPP(yes,
[#include <stdio.h>
#include <math.h>
#ifdef INFINITY
yes
#endif
], has_math_inf=1, has_math_inf=0)
AC_SUBST(has_math_inf)
AC_MSG_RESULT($has_math_inf)
dnl Checks for sizes of integer types; avoid 64-bit if necessary
AC_CHECK_SIZEOF([int])
AC_SUBST(ac_cv_sizeof_int)
AC_CHECK_SIZEOF([long])
AC_SUBST(ac_cv_sizeof_long)
AC_CHECK_SIZEOF([long long])
AC_SUBST(ac_cv_sizeof_long_long)
AC_CHECK_SIZEOF([void*])
AC_SUBST(ac_cv_sizeof_voidp)
AC_CHECK_SIZEOF([__int128])
AC_SUBST(ac_cv_sizeof___int128)
AC_CHECK_SIZEOF([__int128_t])
AC_SUBST(ac_cv_sizeof___int128_t)
lok=0
testprogs="dreadtest dreadtestS dreadtestS1 dreadtest4K"
testprogs="$testprogs dreadtest1 dreadtestW dreadtestW1"
AS_IF([test $ac_cv_sizeof_long_long -eq 8],
[lok=1
testprogs="$testprogs dreadtestL1 dreadtestL"],
[AS_IF([test $ac_cv_sizeof_long -eq 8],
[lok=1])
])
AC_SUBST(lok)
AC_SUBST(testprogs)
dnl Checks for library functions.
AC_CHECK_FUNC(isatty,have_isatty=1,have_isatty=0)
AC_SUBST(have_isatty)
AC_CHECK_FUNC(time,have_time=1,have_time=0)
AC_SUBST(have_time)
AC_CHECK_FUNC(gettimeofday,have_gettimeofday=1,have_gettimeofday=0)
AC_SUBST(have_gettimeofday)
AC_CHECK_FUNC(times,have_times=1,have_times=0)
AC_SUBST(have_times)
AC_CHECK_FUNC(getrusage,have_getrusage=1,have_getrusage=0)
AC_SUBST(have_getrusage)
AC_CHECK_FUNC(perror,have_perror=1,have_perror=0)
AC_SUBST(have_perror)
AC_CHECK_FUNC(pipe,have_pipe=1,have_pipe=0)
AC_SUBST(have_pipe)
AC_CHECK_FUNC(wait,have_wait=1,have_wait=0)
AC_SUBST(have_wait)
AC_CHECK_FUNC(popen,have_popen=1,have_popen=0)
AC_SUBST(have_popen)
AC_CHECK_FUNC(putenv,have_putenv=1,have_putenv=0)
AC_SUBST(have_putenv)
AC_CHECK_FUNC(setenv,have_setenv=1,have_setenv=0)
AC_SUBST(have_setenv)
AC_FUNC_FORK
CVT_YESNO(ac_cv_func_fork,have_fork)
AC_SUBST(have_fork)
AC_CHECK_FUNC(fseeko,have_fseeko=1,have_fseeko=0)
AC_SUBST(have_fseeko)
AC_CHECK_FUNC(sigaction,have_sigaction=1,have_sigaction=0)
AC_SUBST(have_sigaction)
AC_CHECK_FUNC(sigprocmask,have_sigprocmask=1,have_sigprocmask=0)
AC_SUBST(have_sigprocmask)
dnl --check if popcnt instruction is available and desired
AC_MSG_CHECKING(if popcnt instruction is available and requested)
AC_RUN_IFELSE([AC_LANG_PROGRAM([],[[if (__builtin_cpu_supports("popcnt")) return 0; else return 1;]])],
popsup=1,popsup=0)
AS_IF([test "$allow_popcnt" -eq 1],
[have_hwpopcnt=$popsup
test -f /proc/cpuinfo && grep -i popcnt /proc/cpuinfo >/dev/null && have_hwpopcnt=1
test $have_hwpopcnt -eq 0 && sysctl machdep.cpu.features 2>/dev/null | grep -i popcnt >/dev/null && have_hwpopcnt=1
test $have_hwpopcnt -eq 0 && isainfo -x -v 2>/dev/null | grep -i popc >/dev/null && have_hwpopcnt=1 ],
[have_hwpopcnt=0
])
# Some problems with popcnt on powerpc are not resolved yet
test $is_powerpc -eq 1 && have_hwpopcnt=0
AC_MSG_RESULT($have_hwpopcnt)
AC_SUBST(have_hwpopcnt)
SAVE_CFLAGS="$CFLAGS"
have_popcnt=0
have_popcntl=0
have_popcntll=0
have_mmpop32=0
have_mmpop64=0
AS_IF([test $have_hwpopcnt -eq 1],
[AS_IF([test "$CC" = "icc"],
[AC_MSG_CHECKING(if _mm_popcnt_u32() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([#include <nmmintrin.h>
int main(){unsigned int x; x = _mm_popcnt_u32(x);}])],
[have_mmpop32=1], [have_mmpop32=0])
AC_MSG_RESULT($have_mmpop32)
AC_MSG_CHECKING(if _mm_popcnt_u64() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([#include <nmmintrin.h>
int main(){unsigned int x; x = _mm_popcnt_u64(x);}])],
[have_mmpop64=1], [have_mmpop64=0])
AC_MSG_RESULT($have_mmpop64)],
[CFLAGS="$CFLAGS -mpopcnt"
AC_MSG_CHECKING(if __builtin_popcount() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){unsigned int x; x = __builtin_popcount(x);}])],
[have_popcnt=1], [have_popcnt=0])
AC_MSG_RESULT($have_popcnt)
AC_MSG_CHECKING(if __builtin_popcountl() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){unsigned long x; x = __builtin_popcountl(x);}])],
[have_popcntl=1], [have_popcntl=0])
AC_MSG_RESULT($have_popcntl)
AC_MSG_CHECKING(if __builtin_popcountll() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){unsigned long long x; x = __builtin_popcountll(x);}])],
[have_popcntll=1], [have_popcntll=0])
AC_MSG_RESULT($have_popcntll)
AS_IF([test $have_popcnt -eq 1 || test $have_popcntl -eq 1 || test $have_popcntll -eq 1],
[MORECFLAGS="$MORECFLAGS -mpopcnt"])
])])
CFLAGS="$SAVE_CFLAGS"
AC_SUBST(have_popcnt)
AC_SUBST(have_popcntl)
AC_SUBST(have_popcntll)
AC_SUBST(have_mmpop32)
AC_SUBST(have_mmpop64)
# Unless --enable-generic is given to configure, we try to use the -march=native compiler
# switch. However, it breaks some versions of gcc on MacOSX due to a compiler bug, so
# we will also add --mno-avx if that is necessary.
# But don't add -march-native if the user provided an architecture via CFLAGS or CC
case "$CFLAGS" in
*-march=* ) allow_native=0 ;;
esac
case "$CC" in
*-march=* ) allow_native=0 ;;
esac
AS_IF([test "$allow_native" -eq 1],
[
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -march=native"
AC_MSG_CHECKING([if $CC supports -march=native])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
int main() { double t; long int q; scanf("%ld",&q);
t = q; printf("t = %f\n",t); return 0; }]]
)
],
[ac_cv_native_ok=yes], [ac_cv_native_ok=no])
AC_MSG_RESULT([$ac_cv_native_ok])
CFLAGS="$SAVE_CFLAGS"
AS_IF([test "x$ac_cv_native_ok" = xyes],
[MORECFLAGS="$MORECFLAGS -march=native"],
[AC_TRY_CFLAGS([-march=native -mno-avx],
[MORECFLAGS="$MORECFLAGS -march=native -mno-avx"])]
)
])
AC_SUBST(MORECFLAGS)
echo CC="$CC"
echo CFLAGS="$CFLAGS"
echo MORECFLAGS="$MORECFLAGS"
dnl --check if lzcnt instruction is available and requested
AC_MSG_CHECKING(if lzcnt instruction is available and requested)
AS_IF([test "$allow_clz" -eq 1],
[have_hwlzcnt=0
test -f /proc/cpuinfo && egrep -i "abm|bmi1" /proc/cpuinfo >/dev/null && have_hwlzcnt=1
test $have_hwlzcnt -eq 0 && sysctl machdep.cpu.features 2>/dev/null | egrep -i "bmi1|abm" >/dev/null && have_hwlzcnt=1
test $have_hwlzcnt -eq 0 && sysctl machdep.cpu.extfeatures 2>/dev/null | egrep -i "lzcnt" >/dev/null && have_hwlzcnt=1
test $have_hwlzcnt -eq 0 && isainfo -x -v 2>/dev/null | egrep -i "bmi1|abm" >/dev/null && have_hwlzcnt=1 ],
[have_hwlzcnt=0
])
AC_MSG_RESULT($have_hwlzcnt)
AC_SUBST(have_hwlzcnt)
dnl Check for existence of gcc clz extensions
AS_IF([test "$allow_clz" -eq 1],
[ AC_MSG_CHECKING(if __builtin_clz() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){unsigned int x; x = __builtin_clz(x);}])],
[have_clz=1], [have_clz=0])
AC_MSG_RESULT($have_clz)
AC_MSG_CHECKING(if __builtin_clzl() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){unsigned long x; x = __builtin_clzl(x);}])],
[have_clzl=1], [have_clzl=0])
AC_MSG_RESULT($have_clzl)
AC_MSG_CHECKING(if __builtin_clzll() is supported)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){unsigned long long x; x = __builtin_clzll(x);}])],
[have_clzll=1], [have_clzll=0])
AC_MSG_RESULT($have_clzll) ],
[
have_clz=0
have_clzl=0
have_clzll=0
])
AC_SUBST(have_clz)
AC_SUBST(have_clzl)
AC_SUBST(have_clzll)
AC_SUBST(default_wordsize)
AS_IF([test $have_pipe -eq 1 && test $have_wait -eq 1 && test $have_fork -eq 1],
[shortg=1
shortg_or_null=shortg],
[shortg=0
shortg_or_null=])
AC_SUBST(shortg_or_null)
AC_CHECK_FUNC(getc_unlocked,have_getc_unlocked=1,have_getc_unlocked=0)
AC_CHECK_FUNC(flockfile,have_flockfile=1,have_flockfile=0)
AS_IF([test $have_getc_unlocked -eq 1 && test $have_flockfile -eq 1],
[stdio_nolock=1],[stdio_nolock=0])
AC_SUBST(stdio_nolock)
dnl Set thread-local variables
AX_TLS([tls_supported=1],[tls_supported=0])
AS_IF([test "$tls_supported" -eq 0],[ac_cv_tls=])
AC_SUBST(ac_cv_tls)
AC_SUBST(tls_supported)
AC_SUBST(use_tls)
dnl ANSI terminal control sequences
have_ansicontrols=$allow_ansi
AC_SUBST(have_ansicontrols)
dnl SIGINT catching in dreadnaut
AC_SUBST(allow_interrupt)
dnl Existence and attributes of sort program
AS_IF([test $is_cygwin -eq 1],
[ AC_PATH_PROGS(sort_prog,[gsort sort],no_sort_found,
[/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR$PATH])],
[ AC_CHECK_PROGS(sort_prog,[gsort sort],no_sort_found)])
AC_MSG_CHECKING(if sort supports the -k switch)
AS_IF([{ $sort_prog -k "2,3" </dev/null >/dev/null 2>&1 ; }],
[sort_newparams_ok=1], [sort_newparams_ok=0])
AC_SUBST(sort_newparams_ok)
AC_MSG_RESULT($sort_newparams_ok)
edit_msg="++++++ This file is automatically generated, don't edit it by hand! ++++++"
AC_SUBST(edit_msg)
AC_PROG_MKDIR_P
AC_PROG_INSTALL
AC_CONFIG_FILES([makefile:makefile.in nauty.h:nauty-h.in
naututil.h:naututil-h.in gtools.h:gtools-h.in
nauty.pc:nauty.pc.in])
AC_OUTPUT