forked from vermaseren/form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1314 lines (1258 loc) · 39.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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# m4_esyscmd_s implementation for autoconf < 2.64.
# (Taken from m4sugar.m4 in autoconf 2.69.)
m4_ifndef([m4_esyscmd_s], [m4_define([m4_esyscmd_s],
[m4_chomp_all(m4_esyscmd([$1]))])])
m4_ifndef([m4_chomp_all], [m4_define([m4_chomp_all],
[m4_format([[%.*s]], m4_bregexp(m4_translit([[$1]], [
/], [/ ]), [/*$]), [$1])])])
# Get the version from
# (1) .version file available in a tarball, or
# (2) the latest tag in the repository.
m4_define([FORM_VERSION], m4_esyscmd_s([
if test -f .version; then
cat .version
else
scripts/git-version-gen.sh -C . -v || {
# As a fallback, try for form3.h.
major_version=`grep MAJORVERSION sources/form3.h | sed -e 's/ *#define *MAJORVERSION *//'`
minor_version=`grep MINORVERSION sources/form3.h | sed -e 's/ *#define *MINORVERSION *//'`
if test "x$major_version" != x && test "x$minor_version" != x; then
# Make the version files.
echo "$major_version.$minor_version" >.version
echo "#define REPO_MAJOR_VERSION $major_version" >sources/version.h.in
echo "#define REPO_MINOR_VERSION $minor_version" >>sources/version.h.in
echo '\\def\\repomajorversion'"{$major_version}" >doc/manual/version.tex.in
echo '\\def\\repominorversion'"{$minor_version}" >>doc/manual/version.tex.in
cp doc/manual/version.tex.in doc/devref/version.tex.in
touch doc/doxygen/version.sh.in
fi
cat <<END >&2
========================================================================
Failed to determine the revision of the source code.
The reason may be
- this is neither a source distribution (containing the configure
script) nor a cloned Git repository,
- this is a shallow clone and no version tags are reachable,
- some required utilities (e.g., git) are missing.
Source distributions and some binaries can be found in:
http://www.nikhef.nl/~form/maindir/binaries/binaries.html
https://github.com/vermaseren/form/releases
The latest source code can be cloned by:
git clone https://github.com/vermaseren/form.git
END
test -f .version && cat <<END >&2
You can continue the build, but binaries will not contain the revision
information.
END
cat <<END >&2
========================================================================
END
test -f .version && cat .version
}
fi
]))
# Use the serial-tests option of AM_INIT_AUTOMAKE if automake >= 1.13.
# Assume the automake command is ${AUTOMAKE:-automake} as autoreconf does.
# It may not work if "make" re-runs a different version of automake.
m4_define([serial_tests], [m4_esyscmd_s([
${AUTOMAKE:-automake} --version | head -1 |
awk '{split ($NF,a,"."); if (a[1] >= 2 || (a[1] == 1 && a[2] >= 13)) { print "serial-tests" }}'
])])
AC_PREREQ([2.59])
AC_INIT([FORM], [FORM_VERSION], [https://github.com/vermaseren/form/issues])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([sources/form3.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.7 foreign -Wall dist-bzip2] serial_tests)
# Check for .version file
AM_CONDITIONAL([FIXED_VERSION], [test -f $srcdir/.version])
# Check for automake >= 1.10
flag=false
case $am__api_version in
1.6|1.7|1.8|1.9)
;;
*)
flag=:
;;
esac
AM_CONDITIONAL([AUTOMAKE_GE_110], [$flag])
# Check for programs
: ${CFLAGS=''} # avoid autoconf's default CFLAGS/CXXFLAGS
: ${CXXFLAGS=''}
AC_PROG_CC([gcc cc icc])
AM_PROG_CC_C_O
AC_PROG_CXX([g++ c++ icpc])
AC_PROG_LN_S
# Checks for header files
# NOTE: autoconf>=2.70 has started to warn obsolete macros.
# We check if AC_CHECK_INCLUDES_DEFAULT (introduced in 2.70) is available
# and switch to the new code if possible.
m4_ifdef([AC_CHECK_INCLUDES_DEFAULT],
[AC_CHECK_INCLUDES_DEFAULT
AC_PROG_EGREP
AC_CHECK_HEADERS_ONCE([sys/time.h])
AC_DEFINE([TIME_WITH_SYS_TIME],
[1],
[Define to 1 if you can safely include both <sys/time.h> and <time.h>. This macro is obsolete.])],
[AC_HEADER_STDC
AC_HEADER_TIME])
AC_CHECK_HEADERS([fcntl.h limits.h sys/file.h])
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([unordered_map tr1/unordered_map boost/unordered_map.hpp])
AC_CHECK_HEADERS([unordered_set tr1/unordered_set boost/unordered_set.hpp])
AC_LANG_POP([C++])
# Checks for builtin functions
ok=no
AS_IF([test $ok != yes],
[AC_MSG_CHECKING([__builtin_popcount])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [
int x = __builtin_popcount((unsigned int)(-1));
])],
[ok=yes;
AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Define to 1 if you have __builtin_popcount function.])])
AC_MSG_RESULT($ok)])
AS_IF([test $ok != yes],
[AC_MSG_CHECKING([__popcnt])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <intrin.h>], [
unsigned int x = __popcnt((unsigned int)(-1));
])],
[ok=yes;
AC_DEFINE([HAVE_POPCNT], [1], [Define to 1 if you have __popcnt function.])])
AC_MSG_RESULT($ok)])
# Check for inline
AC_C_INLINE
# Sets _FILE_OFFSET_BITS if possible
AC_SYS_LARGEFILE
# Check for architecture and OS
AC_CANONICAL_HOST
case $host_os in
darwin* )
print_os="OSX"
;;
linux* )
print_os="Linux"
# "LINUX" is still used in mallocprotect.h. (TU 16 Oct 2011)
AC_DEFINE(LINUX, , [Compiling for a Linux system.])
;;
cygwin* )
print_os="Cygwin"
;;
freebsd* )
print_os="FreeBSD"
;;
netbsd* )
print_os="NetBSD"
;;
openbsd* )
print_os="OpenBSD"
;;
* )
print_os="UNKNOWN OS ($host_os)"
;;
esac
case $host_cpu in
i586 )
print_cpu="Pentium"
;;
i686 )
print_cpu="Pentium Pro"
;;
x86_64 )
print_cpu="Opteron"
;;
alpha* )
print_cpu="Alpha"
;;
* )
print_cpu="UNKNOWN CPU ($host_cpu)"
;;
esac
# Check for C compiler vendor. We assume that all compilers (CC, CXX, MPICC and
# MPICXX) have the same vendor and the same version. Clang most likely works
# as GCC.
vendors="
intel: __ICC,__ECC,__INTEL_COMPILER
gnu: __GNUC__
microsoft: _MSC_VER
unknown: UNKNOWN
"
for ventest in $vendors; do
case $ventest in
*:)
vendor=$ventest
continue
;;
*)
vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")"
;;
esac
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#if !($vencpp)
choke me
#endif
])], [break])
done
vendor=`echo $vendor | cut -d: -f1`
# POSIX or Windows API
AC_ARG_WITH([api],
[AS_HELP_STRING([--with-api=API],
[use POSIX (posix) or Windows (windows) API @<:@default=posix@:>@])],
[AS_IF([test "x$withval" != xposix && test "x$withval" != xwindows],
[AC_MSG_FAILURE([Invalid argument for API. Use --with-api=posix or --with-api=windows])])],
[with_api=posix])
AS_IF([test "x$with_api" = xposix],
[print_api=POSIX
AC_CHECK_HEADERS([unistd.h], [], [AC_MSG_FAILURE([unistd.h is not found])])
AC_DEFINE(UNIX, , [Compiling for UNIX system])])
AS_IF([test "x$with_api" = xwindows],
[print_api=Windows
AC_CHECK_HEADERS([windows.h], [],[AC_MSG_FAILURE([windows.h is not found])] )
AC_DEFINE(WINDOWS, , [Compiling for WINDOWS system])])
AM_CONDITIONAL([ONUNIX], [test "x$with_api" = xposix])
AM_CONDITIONAL([ONWINDOWS], [test "x$with_api" = xwindows])
# Check for data model
AC_CHECK_SIZEOF([char])
AC_CHECK_SIZEOF([short])
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([void *])
AC_CHECK_SIZEOF([off_t])
case $ac_cv_sizeof_char-$ac_cv_sizeof_short-$ac_cv_sizeof_int-$ac_cv_sizeof_long-$ac_cv_sizeof_long_long-$ac_cv_sizeof_void_p-$ac_cv_sizeof_off_t in
1-2-4-4-*-4-*)
# Most of today's 32 bit systems.
print_data_model="ILP32"
ac_cv_sizeof_WORD=$ac_cv_sizeof_short
ac_cv_sizeof_LONG=$ac_cv_sizeof_long
AC_DEFINE(ILP32, , [Compiling for ILP32 data model])
# We need INT64.
AS_IF([test $ac_cv_sizeof_long_long -ne 8],
[AC_MSG_FAILURE([64-bit integers are not available])])
;;
1-2-4-4-8-8-*)
# Microsoft Windows (X64/IA-64).
print_data_model="LLP64"
ac_cv_sizeof_WORD=$ac_cv_sizeof_int
ac_cv_sizeof_LONG=$ac_cv_sizeof_long_long
AC_DEFINE(LLP64, , [Compiling for LLP64 data model])
;;
1-2-4-8-*-8-*)
# Most Unix and Unix-like systems, e.g., Solaris, Linux and Mac OS X.
print_data_model="LP64"
ac_cv_sizeof_WORD=$ac_cv_sizeof_int
ac_cv_sizeof_LONG=$ac_cv_sizeof_long
AC_DEFINE(LP64, , [Compiling for LP64 data model])
;;
*)
AC_MSG_FAILURE([Cannot recognize the data model used in the compiler])
;;
esac
# Our basic assumption:
# sizeof(off_t) >= sizeof(LONG) >= sizeof(void *) >= sizeof(int)
# >= sizeof(WORD) >= sizeof(char) == 1.
flag=:
$flag && test $ac_cv_sizeof_off_t -lt $ac_cv_sizeof_LONG && flag=false
$flag && test $ac_cv_sizeof_LONG -lt $ac_cv_sizeof_void_p && flag=false
$flag && test $ac_cv_sizeof_void_p -lt $ac_cv_sizeof_int && flag=false
$flag && test $ac_cv_sizeof_int -lt $ac_cv_sizeof_WORD && flag=false
$flag && test $ac_cv_sizeof_WORD -lt $ac_cv_sizeof_char && flag=false
$flag && test $ac_cv_sizeof_char -ne 1 && flag=false
AS_IF([$flag], [], [AC_MSG_FAILURE([Basic assumption sizeof(off_t) >= sizeof(LONG) >= sizeof(void *) >= sizeof(int) >= sizeof(WORD) >= sizeof(char) == 1 does not hold.])])
# sizeof(off_t) <= 4 means files must <= 2 GB.
AS_IF([test $ac_cv_sizeof_off_t -le 4], [AC_MSG_WARN([Large files more than 2 GB are not supported])])
AC_MSG_NOTICE([The data model is $print_data_model])
# Check for gmp
AC_ARG_WITH([gmp],
[AS_HELP_STRING([--with-gmp@<:@=DIR@:>@],
[use GMP for long integer arithmetic (installed in prefix DIR) @<:@default=check@:>@])],
[AS_IF([test "x$withval" != xyes && test "x$withval" != xno && test "x$withval" != xcheck],
[with_gmp=yes
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"])],
[with_gmp=check])
AS_IF([test "x$with_gmp" != xno],
[flag=:
AS_IF([$flag], [AC_CHECK_HEADER([gmp.h], [], [flag=false])])
AS_IF([$flag], [AC_CHECK_LIB([gmp], [__gmpz_init], [LIBS="-lgmp $LIBS"], [flag=false])])
AS_IF([$flag],
[AC_DEFINE(WITHGMP, [], [Define to use GMP for long integer arithmetic.])
with_gmp=yes],
[AS_IF([test "x$with_gmp" = xyes],
[AC_MSG_FAILURE([test for GMP failed. Give --without-gmp if you want to compile without GMP])])
AC_MSG_NOTICE([GMP is not available])
with_gmp=no])])
# Check for mpfr
AC_ARG_WITH([mpfr],
[AS_HELP_STRING([--with-mpfr@<:@=DIR@:>@],
[use MPFR for long float arithmetic (installed in prefix DIR) @<:@default=check@:>@])],
[AS_IF([test "x$withval" != xyes && test "x$withval" != xno && test "x$withval" != xcheck],
[with_mpfr=yes
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"])],
[with_mpfr=check])
AS_IF([test "x$with_mpfr" != xno],
[flag=:
AS_IF([$flag], [AC_CHECK_HEADER([mpfr.h], [], [flag=false])])
AS_IF([$flag], [AC_CHECK_LIB([mpfr], [mpfr_init2], [LIBS="-lmpfr $LIBS"], [flag=false])])
AS_IF([$flag],
[AC_DEFINE(WITHMPFR, [], [Define to use MPFR for long float arithmetic.])
with_mpfr=yes],
[AS_IF([test "x$with_mpfr" = xyes],
[AC_MSG_FAILURE([test for MPFR failed. Give --without-mpfr if you want to compile without MPFR])])
AC_MSG_NOTICE([MPFR is not available])
with_mpfr=no])])
# Check for zlib
AC_ARG_WITH([zlib],
[AS_HELP_STRING([--with-zlib@<:@=DIR@:>@],
[use zlib for compression (installed in prefix DIR) @<:@default=check@:>@])],
[AS_IF([test "x$withval" != xyes && test "x$withval" != xno && test "x$withval" != xcheck],
[with_zlib=yes
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"])],
[with_zlib=check])
AS_IF([test "x$with_zlib" != xno],
[flag=:
AS_IF([$flag], [AC_CHECK_HEADER([zlib.h], [], [flag=false])])
AS_IF([$flag], [AC_CHECK_LIB([z], [get_crc_table], [LIBS="-lz $LIBS"], [flag=false])])
AS_IF([$flag],
[AC_DEFINE(WITHZLIB, [], [Define to use zlib for compression.])
with_zlib=yes],
[AS_IF([test "x$with_zlib" = xyes],
[AC_MSG_FAILURE([test for zlib failed. Give --without-zlib if you want to compile without zlib])])
AC_MSG_NOTICE([zlib is not available])
with_zlib=no])])
# enable-scalar/threaded/parform/debug/float
AC_ARG_ENABLE([scalar],
[AS_HELP_STRING([--enable-scalar],
[build scalar version (form) @<:@default=yes@:>@])],
[AS_IF([test "x$enableval" != xno], [enable_scalar=yes])],
[enable_scalar=yes])
AC_ARG_ENABLE([threaded],
[AS_HELP_STRING([--enable-threaded],
[build multi-threaded version (tform) @<:@default=check@:>@])],
[AS_IF([test "x$enableval" != xno && test "x$enableval" != xcheck], [enable_threaded=yes])],
[enable_threaded=check])
AC_ARG_ENABLE([parform],
[AS_HELP_STRING([--enable-parform],
[build parallel version using MPI (parform) @<:@default=no@:>@])],
[AS_IF([test "x$enableval" != xno && test "x$enableval" != xcheck], [enable_parform=yes])],
[enable_parform=no])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[build debugging versions (vorm/tvorm/parvorm) @<:@default=no@:>@])],
[AS_IF([test "x$enableval" != xno], [enable_debug=yes])],
[enable_debug=no])
AC_ARG_ENABLE([float],
[AS_HELP_STRING([--enable-float],
[build with the float feature @<:@default=yes@:>@])],
[AS_IF([test "x$enableval" != xno && test "x$enableval" != xcheck], [enable_float=yes])],
[enable_float=yes])
# Check for scalar version
build_form=$enable_scalar
AS_IF([test "x$enable_scalar" = xyes && test "x$enable_debug" = xyes], [build_vorm=yes], [build_vorm=no])
AM_CONDITIONAL([BUILD_FORM], [test "x$build_form" = xyes])
AM_CONDITIONAL([BUILD_VORM], [test "x$build_vorm" = xyes])
# Check for threaded version
PTHREAD_CFLAGS=
PTHREAD_CPPFLAGS=
PTHREAD_LIBS=
AH_VERBATIM([WITHPOSIXCLOCK],
[/* Define to use POSIX thread clock. */
#ifdef WITHPTHREADS
#undef WITHPOSIXCLOCK
#endif])
thread_clock_ok=no
AS_IF([test "x$enable_threaded" != xno],
[flag=:
# Check the flag/library for pthreads
AS_IF([$flag],
[ok=no
# none : Cygwin
# -pthread : Linux/gcc (kernel threads), BSD/gcc (userland threads)
# pthread : Linux, OSX
for a in none -pthread pthread; do
case $a in
none)
AC_MSG_CHECKING([whether pthreads works without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads works with $a])
PTHREAD_CFLAGS="$a"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$a])
PTHREAD_LIBS="-l$a"
;;
esac
save_CFLAGS=$CFLAGS
save_LIBS=$LIBS
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <pthread.h>
static void *start_routine(void *a) { return a; }
], [
pthread_t th;
pthread_condattr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE);
])],
[ok=yes],
[])
CFLAGS=$save_CFLAGS
LIBS=$save_LIBS
AC_MSG_RESULT($ok)
test "x$ok" = xyes && break
PTHREAD_CFLAGS=
PTHREAD_LIBS=
done
test "x$ok" = xno && flag=false])
# Check pthread_rwlock_t
AS_IF([$flag],
[ok=no
# -D_XOPEN_SOURCE=500: Scientific Linux 4.8
for a in none -D_XOPEN_SOURCE=500; do
case $a in
none)
AC_MSG_CHECKING([for pthread_rwlock_t])
;;
-D*)
AC_MSG_CHECKING([for pthread_rwlock_t with $a])
PTHREAD_CPPFLAGS="$a"
;;
esac
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$PTHREAD_CPPFLAGS $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <errno.h>
#include <pthread.h>
pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
], [
while (pthread_rwlock_tryrdlock(&rwlock) == EBUSY) {}
pthread_rwlock_unlock(&rwlock);
])],
[ok=yes],
[])
CPPFLAGS=$save_CPPFLAGS
AC_MSG_RESULT($ok)
test "x$ok" = xyes && break
PTHREAD_CPPFLAGS=
done
test "x$ok" = xno && flag=false])
# Check clock_gettime with CLOCK_THREAD_CPUTIME_ID
AS_IF([$flag && test "x$with_api" = xposix],
[ok=yes
AS_IF([test "x$ok" = xyes],
[AC_MSG_CHECKING([for the POSIX thread clock])
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$PTHREAD_CPPFLAGS $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <time.h>
], [
struct timespec t;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t);
])],
[],
[ok=no])
CPPFLAGS=$save_CPPFLAGS
AC_MSG_RESULT($ok)])
AS_IF([test "x$ok" = xyes],
[save_LIBS=$LIBS
AC_SEARCH_LIBS([clock_gettime], [rt], [], [ok=no])
LIBS=$save_LIBS
if test "x$ac_cv_search_clock_gettime" != "xnone required" && test "x$ac_cv_search_clock_gettime" != "xno"; then
PTHREAD_LIBS="$ac_cv_search_clock_gettime $PTHREAD_LIBS"
fi])
AS_IF([test "x$ok" = xyes],
[cat >>confdefs.h <<END
#ifdef WITHPTHREADS
#define WITHPOSIXCLOCK /**/
#endif
END
thread_clock_ok=yes],
[AC_MSG_WARN([POSIX thread clock is not available.])])])
# Windows has GetThreadTimes().
$flag && test "x$with_api" = xwindows && thread_clock_ok=yes
AS_IF([$flag],
[enable_threaded=yes],
[AS_IF([test "x$enable_threaded" = xyes],
[AC_MSG_FAILURE([test for tform failed. Give --disable-threaded if you do not need to build tform])])
AC_MSG_NOTICE([building tform has been disabled])
AS_IF([test "x$enable_debug" = xyes],
[AC_MSG_NOTICE([building tvorm has been disabled])])
enable_threaded=no])])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CPPFLAGS])
AC_SUBST([PTHREAD_LIBS])
build_tform=$enable_threaded
AS_IF([test "x$enable_threaded" = xyes && test "x$enable_debug" = xyes], [build_tvorm=yes], [build_tvorm=no])
AM_CONDITIONAL([BUILD_TFORM], [test "x$build_tform" = xyes])
AM_CONDITIONAL([BUILD_TVORM], [test "x$build_tvorm" = xyes])
# AX_PROG_MPICC
# -------------
AC_DEFUN([AX_PROG_MPICC], [
AC_REQUIRE([AC_PROG_CC])
AC_ARG_VAR([MPICC], [C compiler with MPI support])
AS_IF([test "x$MPICC" != x], [
AC_CHECK_PROGS([MPICC], [$MPICC])
], [
AC_CHECK_PROGS([MPICC], [mpicc hcc mpxlc_r mpxlc mpcc cmpicc], $CC)
])
AC_LANG_PUSH([C])
save_CC=$CC
CC=$MPICC
_AX_CHECK_MPI([MPICC], [C])
CC=$save_CC
AC_LANG_POP([C])
])
# AX_PROG_MPICXX
# --------------
AC_DEFUN([AX_PROG_MPICXX], [
AC_REQUIRE([AC_PROG_CXX])
AC_ARG_VAR([MPICXX], [C++ compiler with MPI support])
AS_IF([test "x$MPICXX" != x], [
AC_CHECK_PROGS([MPICXX], [$MPICXX])
], [
AC_CHECK_PROGS([MPICXX], [mpic++ mpicxx mpiCC hcp mpxlC_r mpxlC mpCC cmpic++], $CXX)
])
AC_LANG_PUSH([C++])
save_CXX=$CXX
CXX=$MPICXX
_AX_CHECK_MPI([MPICXX], [CXX])
CXX=$save_CXX
AC_LANG_POP([C++])
])
# _AX_CHECK_MPI(compiler, output-var-prefix)
# ------------------------------------------
AC_DEFUN([_AX_CHECK_MPI], [
# Check whether MPI works or not.
AC_MSG_CHECKING([whether MPI works with $$1])
AC_LINK_IFELSE([AC_LANG_SOURCE([_AX_CHECK_MPI_SOURCE])], [
AC_MSG_RESULT([yes])
# Find a flag for showing the compile and link lines.
ax_ok=false
for ax_show in -show -showme -compile-info; do
AC_MSG_CHECKING([whether $$1 accepts $ax_show])
ax_mpi_cmdline=`$$1 $ax_show 2>/dev/null`
AS_IF([test $? -eq 0], [
AC_MSG_RESULT([yes])
ax_ok=:
break
], [
AC_MSG_RESULT([no])
])
done
AS_IF([$ax_ok], [], [AC_MSG_WARN([Cannot extract compiler and linker flags from $$1])])
# Extract the compile and link flags.
ax_mpi_cflags=
ax_mpi_cppflags=
ax_mpi_ldflags=
ax_mpi_libs=
ax_first=:
for ax_opt in $ax_mpi_cmdline; do
case $ax_opt in
-I*|-D*)
ax_mpi_cppflags="$ax_mpi_cppflags $ax_opt"
;;
-L*|-Wl,*)
ax_mpi_ldflags="$ax_mpi_ldflags $ax_opt"
;;
-l*)
ax_mpi_libs="$ax_mpi_libs $ax_opt"
;;
*)
$ax_first || ax_mpi_cflags="$ax_mpi_cflags $ax_opt"
;;
esac
ax_first=false
done
MPI_$2FLAGS=` echo "$ax_mpi_cflags" | sed 's/^ *//;s/ *$//;s/ */ /g'`
MPI_$2PPFLAGS=`echo "$ax_mpi_cppflags" | sed 's/^ *//;s/ *$//;s/ */ /g'`
MPI_$2LDFLAGS=`echo "$ax_mpi_ldflags" | sed 's/^ *//;s/ *$//;s/ */ /g'`
MPI_$2LIBS=` echo "$ax_mpi_libs" | sed 's/^ *//;s/ *$//;s/ */ /g'`
], [
AC_MSG_RESULT([no])
$1=
MPI_$2FLAGS=
MPI_$2LDFLAGS=
MPI_$2LIBS=
])
])
AC_DEFUN([_AX_CHECK_MPI_SOURCE], [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
m4_define([_AX_CHECK_MPI_SOURCE(C)],
[#include <mpi.h>
int main(int argc, char **argv) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Finalize();
return 0;
}])
m4_copy([_AX_CHECK_MPI_SOURCE(C)], [_AX_CHECK_MPI_SOURCE(C++)])
# Check for MPI version
AS_IF([test "x$enable_parform" != xno],
[flag=:
AS_IF([$flag], [AX_PROG_MPICC
AS_IF([test "x$MPICC" = x], [flag=false])])
AS_IF([$flag], [AX_PROG_MPICXX
AS_IF([test "x$MPICXX" = x], [flag=false])])
AS_IF([$flag],
[enable_parform=yes
AC_SUBST([MPI_CFLAGS])
AC_SUBST([MPI_CXXFLAGS])
AC_SUBST([MPI_CPPFLAGS])],
[AS_IF([test "x$enable_parform" = xyes],
[AC_MSG_FAILURE([test for parform failed. Give --disable-parform if you do not need to build parform])])
AC_MSG_NOTICE([building parform has been disabled])
AS_IF([test "x$enable_debug" = xyes],
[AC_MSG_NOTICE([building parvorm has been disabled])])
enable_parform=no])])
build_parform=$enable_parform
AS_IF([test "x$enable_parform" = xyes && test "x$enable_debug" = xyes], [build_parvorm=yes], [build_parvorm=no])
AM_CONDITIONAL([BUILD_PARFORM], [test "x$build_parform" = xyes])
AM_CONDITIONAL([BUILD_PARVORM], [test "x$build_parvorm" = xyes])
AS_IF([test "x$build_form" = xyes || test "x$build_tform" = xyes || test "x$build_parform" = xyes ||
test "x$build_vorm" = xyes || test "x$build_tvorm" = xyes || test "x$build_parvorm" = xyes], [build_any=yes], [build_any=no])
# Check for float
AS_IF([test "x$enable_float" != xno],
[AS_IF([test "x$with_gmp" = xyes && test "x$with_mpfr" = xyes],
[enable_float=yes],
[AS_IF([test "x$enable_float" = xyes && test "x$build_any" = xyes],
[AC_MSG_FAILURE([test for the float feature failed. It requires both GMP and MPFR. Give --disable-float if you want to build without the float feature.])])
enable_float=no
])])
AS_IF([test "x$enable_float" = xyes],
[AC_DEFINE(WITHFLOAT, [], [Define to enable the float feature.])],
[AS_IF([test "x$with_mpfr" = xyes],
[AC_MSG_WARN([mpfr is not required without the float feature.])])])
AM_CONDITIONAL([WITHFLOAT], [test "x$enable_float" = xyes])
# Check for wall-clock time
ok=no
AS_IF([test $ok != yes],
[AC_SEARCH_LIBS([clock_gettime], [rt],
[AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define to 1 if you have clock_gettime.])
ok=yes])])
AS_IF([test $ok != yes],
# TODO: gettimeofday is also deprecated.
[AC_SEARCH_LIBS([gettimeofday], [],
[AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define to 1 if you have gettimeofday.])
ok=yes])])
AS_IF([test $ok != yes],
# Fallback: ftime. Available also on Windows. Some BSDs require -lcompat.
[AC_SEARCH_LIBS([ftime], [compat],
[AC_DEFINE([HAVE_FTIME], [1], [Define to 1 if you have ftime.])
ok=yes])])
AS_IF([test $ok != yes],
[AC_MSG_FAILURE([Wall-clock time not available])])
# Check for static linking
STATIC_LDFLAGS=
MPI_STATIC_LDFLAGS=
AC_ARG_ENABLE([static-link],
[AS_HELP_STRING([--enable-static-link],
[link with static libraries (release versions) @<:@default=no@:>@])],
[AS_IF([test "x$enableval" != xno && test "x$enableval" != xcheck], [enable_static_link=yes])],
[enable_static_link=no])
AS_IF([test "x$enable_static_link" != xno],
[flag=:
if test "x$vendor" = xgnu; then
static_list='-static -static-libgcc,-static-libstdc++ -static-libgcc'
elif test "x$vendor" = xintel; then
static_list='-static -static-libgcc,-static-intel -static-intel -static-libgcc'
else
static_list='-static -static-libgcc'
fi
for a in $static_list; do
a=`echo $a | sed 's/,/ /g'`
AC_MSG_CHECKING([for static linking with $CXX $a])
AC_LANG_PUSH([C++])
save_CFLAGS=$CFLAGS
save_LDFLAGS=$LDFLAGS
save_LIBS=$LIBS
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LDFLAGS="$LDFLAGS $a"
LIBS="$PTHREAD_LIBS $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
[AC_MSG_RESULT([yes]); STATIC_LDFLAGS=$a],
[AC_MSG_RESULT([no]); flag=false])
CFLAGS=$save_CFLAGS
LDFLAGS=$save_LDFLAGS
LIBS=$save_LIBS
AC_LANG_POP([C++])
test "x$STATIC_LDFLAGS" != x && break
done
AS_IF([test "x$enable_parform" = xyes],
[for a in $static_list; do
a=`echo $a | sed 's/,/ /g'`
AC_MSG_CHECKING([for static linking with $MPICXX $a])
AC_LANG_PUSH([C++])
save_CXX=$CXX
save_LDFLAGS=$LDFLAGS
CXX=$MPICXX
LDFLAGS="$LDFLAGS $a"
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
[AC_MSG_RESULT([yes]); MPI_STATIC_LDFLAGS=$a],
[AC_MSG_RESULT([no]); flag=false])
CXX=$save_CXX
LDFLAGS=$save_LDFLAGS
AC_LANG_POP([C++])
test "x$MPI_STATIC_LDFLAGS" != x && break
done])
AS_IF([$flag],
[enable_static_link=yes],
[AS_IF([test "x$enable_static_link" = xyes],
[AC_MSG_FAILURE([test for static linking failed. Give --disable-static-link if you want to build without static libraries.])])
AS_IF([test "x$STATIC_LDFLAGS" = x && test "x$MPI_STATIC_LDFLAGS" = x],
[AC_MSG_NOTICE([static linking has been disabled])],
[AC_MSG_NOTICE([static linking has been partially disabled])])
enable_static_link=no])])
AC_SUBST([STATIC_LDFLAGS])
AC_SUBST([MPI_STATIC_LDFLAGS])
# Check for native/universal build
AC_ARG_ENABLE([native],
[AS_HELP_STRING([--enable-native],
[tune for the compiling machine (release versions) @<:@default=yes@:>@])],
[AS_IF([test "x$enableval" = xno || test "x$cross_compiling" = xyes],
[enable_native=no], [enable_native=yes])],
[enable_native=yes])
# Check for profiling option
AC_ARG_ENABLE([profile],
[AS_HELP_STRING([--enable-profile@<:@=PROFILER@:>@],
[build with profiling (release versions) @<:@default=no@:>@ PROFILER: gprof (default) or gperftools])],
[AS_IF([test "x$enableval" = xyes],
[enable_profile=gprof],
[AS_IF([test "x$enableval" = xgprof || test "x$enableval" = xgperftools],
[enable_profile=$enableval],
[enable_profile=no])])],
[enable_profile=no])
# Check for coverage option
AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],
[generate coverage files (debugging versions) @<:@default=no@:>@])],
[AS_IF([test "x$enableval" = xyes && test "x$enable_debug" = xyes],
[enable_coverage=yes], [enable_coverage=no])],
[enable_coverage=no])
# Check for sanitizers
AC_ARG_ENABLE([sanitize],
[AS_HELP_STRING([--enable-sanitize@<:@=CHECKS@:>@],
[enable sanitizers (debugging versions) @<:@default=no@:>@ Optionally CHECKS will be passed via the compiler sanitizer option])],
[AS_IF([test "x$enable_debug" != xyes],
[enable_sanitize=no])],
[enable_sanitize=no])
# Check for extra compiler warnings
AC_ARG_ENABLE([extra-warning],
[AS_HELP_STRING([--enable-extra-warning],
[enable extra compiler warnings @<:@default=no@:>@])],
[],
[enable_extra_warning=no])
# Optimization/debugging flags
AC_ARG_VAR([COMPILEFLAGS], [Compiler flags for release versions])
AC_ARG_VAR([LINKFLAGS], [Linker flags for release versions])
AC_ARG_VAR([DEBUGCOMPILEFLAGS], [Compiler flags for debugging versions])
AC_ARG_VAR([DEBUGLINKFLAGS], [Linker flags for debugging versions])
TOOL_LIBS=
DEBUGTOOL_LIBS=
# AX_HANDLE_EXTRA_WARNING(COMPILEFLAGS)
# -------------------------------------
AC_DEFUN([AX_HANDLE_EXTRA_WARNING],
[if test "x$enable_extra_warning" != xyes; then
# Too many misleading indentation in the FORM source code.
AX_CHECK_COMPILE_FLAG([-Wno-misleading-indentation],
[$1="$$1 -Wno-misleading-indentation"],
[],
[-Werror])
# Too many false positives.
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overflow],
[$1="$$1 -Wno-stringop-overflow"],
[],
[-Werror])
fi[]dnl
])
my_test_COMPILEFLAGS=${COMPILEFLAGS+set}
if test "$my_test_COMPILEFLAGS" != set; then
if test "x$vendor" = xgnu; then
# We don't use -pedantic option because of horrible warnings.
COMPILEFLAGS="-Wall -Wextra"
AX_HANDLE_EXTRA_WARNING([COMPILEFLAGS])
# Enable optimizations.
COMPILEFLAGS="$COMPILEFLAGS -O3"
if test "x$enable_profile" != xgprof; then
# -pg conflicts with -fomit-frame-pointer.
COMPILEFLAGS="$COMPILEFLAGS -fomit-frame-pointer"
fi
if test "x$enable_native" = xyes; then
# Use -march=native if available.
AX_CHECK_COMPILE_FLAG([-march=native],
[COMPILEFLAGS="$COMPILEFLAGS -march=native"],
[if test "x$print_data_model" = xILP32; then
if test "x$print_cpu" = xPentium; then
COMPILEFLAGS="$COMPILEFLAGS -march=i586"
elif test "x$print_cpu" = 'xPentium Pro'; then
COMPILEFLAGS="$COMPILEFLAGS -march=i686"
elif test "x$print_cpu" = xOpteron; then
COMPILEFLAGS="$COMPILEFLAGS -march=opteron"
fi
fi],
[-Werror])
fi
# Profiling option.
if test "x$enable_profile" = xgprof; then
COMPILEFLAGS="$COMPILEFLAGS -g -pg"
elif test "x$enable_profile" = xgperftools; then
COMPILEFLAGS="$COMPILEFLAGS -g"
TOOL_LIBS="$TOOL_LIBS -lprofiler"
fi
elif test "x$vendor" = xintel; then
# NOTE: -fast option includes -static and may cause an error in linking.
COMPILEFLAGS="-Wall -ipo -O3 -no-prec-div"
if test "x$enable_native" = xyes; then
COMPILEFLAGS="$COMPILEFLAGS -xHost"
fi
if test "x$enable_profile" != xno; then
enable_profile=unavailable
fi
else
COMPILEFLAGS=-O2
if test "x$enable_profile" != xno; then
enable_profile=unavailable
fi
fi
fi
my_test_LINKFLAGS=${LINKFLAGS+set}
if test "$my_test_LINKFLAGS" != set; then
if test "x$vendor" = xgnu && test "x$print_os" = xOSX; then
# On OS X Mavericks, -s option has a funny effect: though the linker
# warns the option is obsolete and being ignored, it causes an internal
# error "atom not found in symbolIndex...".
LINKFLAGS=
elif test "x$enable_profile" != xno && test "x$enable_profile" != xunavailable; then
# Profilers needs symbol tables.
LINKFLAGS=
else
LINKFLAGS=-s
fi
fi
my_test_DEBUGCOMPILEFLAGS=${DEBUGCOMPILEFLAGS+set}
if test "$my_test_DEBUGCOMPILEFLAGS" != set && test "x$enable_debug" = xyes; then
if test "x$vendor" = xgnu; then
DEBUGCOMPILEFLAGS='-Wall -Wextra'
if test "x$enable_sanitize" = xno; then
# UBSan puts many paddings (at least in gcc 5.3).
#
# Unfortunately gmp.h and mpfr.h give padding warnings.
# We leave those out. (JV 5-apr-2023)
#
# DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -Wpadded"
DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS"
fi
AX_HANDLE_EXTRA_WARNING([DEBUGCOMPILEFLAGS])
# Check for -Og. If it doesn't work then use -O0.
AX_CHECK_COMPILE_FLAG([-Og],
[DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -Og"],
[DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -O0"],
[-Werror])
# Debugging information.
DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -g3"
# Coverage option.
if test "x$enable_coverage" = xyes; then
DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -coverage"
fi
# Sanitizer option.
if test "x$enable_sanitize" = xyes; then
enable_sanitize=
for san in address undefined; do
if test "x$enable_sanitize" = x; then
tmp_sanitize=$san
else
tmp_sanitize=$enable_sanitize,$san
fi
AX_CHECK_COMPILE_FLAG([-fsanitize=$tmp_sanitize], [enable_sanitize=$tmp_sanitize], [], [-Werror])
done
if test "x$enable_sanitize" = x; then
enable_sanitize=failed
fi
elif test "x$enable_sanitize" != xno; then
AX_CHECK_COMPILE_FLAG([-fsanitize=$enable_sanitize], [], [enable_sanitize=failed], [-Werror])
fi
if test "x$enable_sanitize" = xfailed; then
AC_MSG_FAILURE([test for sanitizer failed. Give --disable-sanitize if you want to compile without sanitizer])
fi
if test "x$enable_sanitize" != xno; then
DEBUGCOMPILEFLAGS="$DEBUGCOMPILEFLAGS -fsanitize=$enable_sanitize"
fi
elif test "x$vendor" = xintel; then
DEBUGCOMPILEFLAGS='-g3 -Wall -O0'
if test "x$enable_coverage" != xno; then
enable_coverage=unavailable
fi
if test "x$enable_sanitize" != xno; then
enable_sanitize=unavailable
fi
else
DEBUGCOMPILEFLAGS=-g
if test "x$enable_coverage" != xno; then
enable_coverage=unavailable
fi
if test "x$enable_sanitize" != xno; then
enable_sanitize=unavailable
fi
fi
fi
my_test_DEBUGLINKFLAGS=${DEBUGLINKFLAGS+set}
if test "$my_test_DEBUGLINKFLAGS" != set && test "x$enable_debug" = xyes; then
DEBUGLINKFLAGS=
if test "x$vendor" = xgnu; then
# Coverage option.
if test "x$enable_coverage" = xyes; then
DEBUGLINKFLAGS="$DEBUGLINKFLAGS -coverage"
fi
# Sanitizer option.
if test "x$enable_sanitize" != xno; then
# Workaround for https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1650186
ok=no
save_CFLAGS=$CFLAGS
save_LDFLAGS=$LDFLAGS
CFLAGS="$CFLAGS -fsanitize=$enable_sanitize"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], [ok=yes])
if test "x$ok" != xyes; then
LDFLAGS="$LDFLAGS -fuse-ld=gold"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], [ok=yes])
if test "x$ok" = xyes; then
DEBUGLINKFLAGS="$DEBUGLINKFLAGS -fuse-ld=gold"
fi
fi
CFLAGS=$save_CFLAGS
LDFLAGS=$save_LDFLAGS
fi
fi
fi
AC_SUBST([TOOL_LIBS])
AC_SUBST([DEBUGTOOL_LIBS])
# Check for doxygen
AC_PATH_PROG(DOXYGEN, doxygen, "")
AM_CONDITIONAL(CONFIG_DOXYGEN, [test "x$DOXYGEN" != x])
# Check for LaTeX programs
AC_PATH_PROG(LATEX, latex, "")
AC_PATH_PROG(PDFLATEX, pdflatex, "")
AC_PATH_PROG(DVIPS, dvips, "")
AC_PATH_PROG(MAKEINDEX, makeindex, "")
AC_PATH_PROG(HTLATEX, htlatex, "")
AC_PATH_PROG(LATEX2HTML, latex2html, "")
AM_CONDITIONAL(CONFIG_TEX, [test "x$LATEX" != x])
AM_CONDITIONAL(CONFIG_PS, [test "x$LATEX" != x && test "x$DVIPS" != x])
AM_CONDITIONAL(CONFIG_PDF, [test "x$PDFLATEX" != x])
AM_CONDITIONAL(CONFIG_MAKEINDEX, [test "x$MAKEINDEX" != x])
AM_CONDITIONAL(CONFIG_HTLATEX, [test "x$HTLATEX" != x])