-
Notifications
You must be signed in to change notification settings - Fork 245
/
configure.ac
1259 lines (1074 loc) · 35.8 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
################################################################################
# preamble
################################################################################
define(FLINT_COPYRIGHT,[[
Copyright (C) 2023, 2024 Albin Ahlbäck
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
]])
define(FLINT_COPYRIGHT_C,[[/*
Copyright (C) 2023, 2024 Albin Ahlbäck
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/]])
dnl TODO
dnl * Move more stuff to acinclude.m4 to debloat this file.
AC_COPYRIGHT(FLINT_COPYRIGHT)
AH_TOP(FLINT_COPYRIGHT_C)
AC_PREREQ(2.62)
m4_define(FLINT_VERSION,m4_include([VERSION]))
AC_INIT(FLINT, FLINT_VERSION, [https://github.com/flintlib/flint/issues/], flint, [https://flintlib.org/])
AC_CONFIG_AUX_DIR([config])
AC_LANG(C)
# Every major version of Flint (1.0, 1.1, 1.2, etc.) gets
# a new major soname number.
# Every time a release happens where interfaces are added
# to Flint, the minor soname number gets incremented.
# Every patch that is made that doesn't change the Flint
# interface updates the patch number.
# However, if backwards incompatible changes are made, both
# the minor and patch numbers are set to 0. (Hopefully this
# doesn't happen in practice.)
# flint => soname
# 2.5.0 => 13.5.0
# 2.5.1 => 13.5.1
# 2.5.2 => 13.5.2
# 2.6.0 => 14.0.0
# 2.6.1 => 14.0.1
# 2.6.2 => 14.0.2
# 2.6.3 => 14.0.3
# 2.7.0 => 15.0.0
# 2.7.1 => 15.0.1
# 2.8.0 => 16.1.0
# 2.8.1 => 16.1.1
# 2.8.2 => 16.1.2
# 2.8.3 => 16.1.3
# 2.8.4 => 16.1.4
# 2.8.5 => 16.1.5
# 2.9.0 => 17.0.0
# 3.0.0 => 18.0.0
# 3.1.0 => 19.0.0
# NOTE: This must be after AC_INIT
FLINT_MAJOR_SO=19
FLINT_MINOR_SO=0
FLINT_PATCH_SO=0
# Make sure that we are in the right directory
AC_CONFIG_SRCDIR(src/fmpz/link/fmpz_reentrant.c)
################################################################################
# initialize libtool
################################################################################
# Later we want to overwrite the default CFLAGS. Check now whether they are set
# or not as Libtool overwrites CFLAGS.
if test -n "${CFLAGS+x}";
then
cflags_set="yes"
else
cflags_set="no"
fi
if test -n "${TESTCFLAGS+x}";
then
testcflags_set="yes"
else
testcflags_set="no"
fi
if test -n "${CXXFLAGS+x}";
then
cxxflags_set="yes"
else
cxxflags_set="no"
fi
LT_INIT
if test "$cflags_set" = "no";
then
CFLAGS=
fi
if test "$cxxflags_set" = "no";
then
CXXFLAGS=
fi
################################################################################
# build system
################################################################################
if test -n "$target_alias";
then
AC_MSG_ERROR([FLINT does not support the use of specifying --target.])
fi
dnl Get system triplet
dnl NOTE: This is already invoked from LT_INIT
dnl AC_CANONICAL_HOST
################################################################################
# configure headers
################################################################################
AC_CONFIG_HEADERS(src/config.h src/flint-config.h)
################################################################################
# features
################################################################################
AC_ARG_ENABLE(pthread,
[AS_HELP_STRING([--enable-pthread],[Enable pthread [default=yes]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-pthread. Need yes or no.])
;;
esac],
enable_pthread="yes")
AC_ARG_ENABLE(reentrant,
[AS_HELP_STRING([--enable-reentrant],[Build reentrant version of library [default=no]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-reentrant. Need yes or no.])
;;
esac],
enable_reentrant="no")
# Synonym for thread-safe. Only here for say to users that it is deprecated.
AC_ARG_ENABLE(tls)
AC_ARG_ENABLE(thread-safe,
[AS_HELP_STRING([--enable-thread-safe],[Enable thread-local storage [default=yes]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-tls. Need yes or no.])
;;
esac],
enable_thread_safe="yes")
if test -n "$enable_tls";
then
AC_MSG_ERROR([--enable-tls is an old feature. Please use --enable-thread-safe instead.])
fi
AC_ARG_ENABLE(assert,
[AS_HELP_STRING([--enable-assert],[Enable use of asserts [default=no]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-assert. Need yes or no.])
;;
esac],
enable_assert="no")
AC_ARG_ENABLE(coverage,
[AS_HELP_STRING([--enable-coverage],[Enable test coverage [default=no]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-coverage. Need yes or no.])
;;
esac],
enable_coverage="no")
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],[Compile FLINT with debug information [default=yes]])],
[case $enableval in
yes|no)
if test "$enableval" = "no" && test "$enable_coverage" = "yes";
then
AC_MSG_ERROR([Debug information is required by coverage.])
fi
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-debug. Need yes or no.])
;;
esac],
enable_debug="yes")
AC_ARG_ENABLE(dependency-tracking,
[AS_HELP_STRING([--enable-dependency-tracking],[Enable GCC automated dependency tracking [default=yes]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-dependency-tracking. Need yes or no.])
;;
esac],
enable_dependency_tracking="yes")
AC_ARG_ENABLE(pretty-tests,
[AS_HELP_STRING([--enable-pretty-tests],[Enable pretty printing for tests [default=yes]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-pretty-tests. Need yes or no.])
;;
esac],
enable_pretty_tests="yes")
AC_ARG_ENABLE(gmp-internals,
[AS_HELP_STRING([--enable-gmp-internals],[Enable calling GMP internals directly [default=yes]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-gmp-internals. Need yes or no.])
;;
esac],
enable_gmp_internals="yes")
AC_ARG_ENABLE(assembly,
[AS_HELP_STRING([--enable-assembly],[Enable assembly routines (if available) [default=yes]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-assembly. Need yes or no.])
;;
esac],
enable_assembly="yes")
AC_ARG_ENABLE(avx2,
[AS_HELP_STRING([--enable-avx2],[Enable AVX2 instructions [default=no]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-avx2. Need yes or no.])
;;
esac],
enable_avx2="no")
AC_ARG_ENABLE(avx512,
[AS_HELP_STRING([--enable-avx512],[Enable AVX512 instructions [default=no]])],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-avx512. Need yes or no.])
;;
esac],
enable_avx512="no")
AC_ARG_ENABLE(arch,
[AS_HELP_STRING([--enable-arch[[=ARCH]]],[Enable and push -march=ARCH option to C compiler [default=native]])],
[],
enable_arch="native")
# Note: This is maintainer level only. Currently only used for Nemo CI.
AC_ARG_ENABLE(mpfr-check,[],
[case $enableval in
yes|no)
;;
*)
AC_MSG_ERROR([Bad value $enableval for --enable-mpfr-check. Need yes or no.])
;;
esac],
enable_mpfr_check="yes")
################################################################################
# packages
################################################################################
AC_ARG_WITH(gmp_include,
[AS_HELP_STRING([--with-gmp-include=DIR],[GMP include directory])],
CPPFLAGS="$CPPFLAGS -I$withval"
gmp_include_path="$withval"
)
AC_ARG_WITH(gmp_lib,
[AS_HELP_STRING([--with-gmp-lib=DIR],[GMP library directory])],
LDFLAGS="$LDFLAGS -L$withval"
gmp_lib_path="$withval"
)
AC_ARG_WITH(gmp,
[AS_HELP_STRING([--with-gmp[[=DIR]]],[GMP install directory])],
if test "$with_gmp" = "no";
then
AC_MSG_FAILURE([The use of GMP is mandatory.])
elif test "$with_gmp" = "yes";
then
:
elif test -z "$gmp_include_path" && test -z "$gmp_lib_path";
then
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
gmp_include_path="$withval/include"
gmp_lib_path="$withval/lib"
with_gmp="yes"
else
AC_MSG_FAILURE([Cannot use --with-gmp along with --with-gmp-include or --with-gmp-lib.])
fi,
with_gmp="yes"
)
AC_ARG_WITH(mpfr_include,
[AS_HELP_STRING([--with-mpfr-include=DIR],[MPFR include directory])],
CPPFLAGS="$CPPFLAGS -I$withval"
mpfr_include_path="$withval"
)
AC_ARG_WITH(mpfr_lib,
[AS_HELP_STRING([--with-mpfr-lib=DIR],[MPFR library directory])],
LDFLAGS="$LDFLAGS -L$withval"
mpfr_lib_path="$withval"
)
AC_ARG_WITH(mpfr,
[AS_HELP_STRING([--with-mpfr[[=DIR]]],[MPFR install directory])],
if test "$with_mpfr" = "no";
then
AC_MSG_FAILURE([The use of MPFR is mandatory.])
elif test "$with_mpfr" = "yes";
then
:
elif test -z "$mpfr_include_path" && test -z "$mpfr_lib_path";
then
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
mpfr_include_path="$withval/include"
mpfr_lib_path="$withval/lib"
with_mpfr="yes"
else
AC_MSG_FAILURE([Cannot use --with-mpfr along with --with-mpfr-include or --with-mpfr-lib.])
fi,
with_mpfr="yes"
)
AC_ARG_WITH(blas_include,
[AS_HELP_STRING([--with-blas-include=DIR],[Use BLAS and specify its include directory])],
CPPFLAGS="$CPPFLAGS -I$withval"
blas_include_path="$withval"
)
AC_ARG_WITH(blas_lib,
[AS_HELP_STRING([--with-blas-lib=DIR],[Use BLAS and specify its library directory])],
LDFLAGS="$LDFLAGS -L$withval"
blas_lib_path="$withval"
)
AC_ARG_WITH(blas,
[AS_HELP_STRING([--with-blas[[=DIR]]],[Use BLAS and specify its install directory])],
if test "$with_blas" = "yes";
then
:
elif test "$with_blas" = "no";
then
if test -n "$blas_include_path" || test -n "$blas_lib_path";
then
AC_MSG_FAILURE([--with-blas-include or --with-blas-lib was specified but --with-blas=no.])
fi
elif test -z "$blas_include_path" && test -z "$blas_lib_path";
then
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
blas_include_path="$withval/include"
blas_lib_path="$withval/lib"
with_blas="yes"
else
AC_MSG_FAILURE([Cannot use --with-blas along with --with-blas-include or --with-blas-lib.])
fi,
with_blas="no"
)
if test "$with_blas" != "no" || test -n "$blas_include_path" || test -n "$blas_lib_path";
then
with_blas="yes"
fi
AC_ARG_WITH(gc_include,
[AS_HELP_STRING([--with-gc-include=DIR],[Use GC and specify its include directory])],
CPPFLAGS="$CPPFLAGS -I$withval"
gc_include_path="$withval",
with_gc_include="no"
)
AC_ARG_WITH(gc_lib,
[AS_HELP_STRING([--with-gc-lib=DIR],[Use GC and specify its library directory])],
LDFLAGS="$LDFLAGS -L$withval"
gc_lib_path="$withval",
with_gc_lib="no"
)
AC_ARG_WITH(gc,
[AS_HELP_STRING([--with-gc[[=DIR]]],[Use GC and optionally specify its install directory])],
if test "$with_gc" = "yes";
then
:
elif test "$with_gc" = "no";
then
if test -n "$gc_include_path" || test -n "$gc_lib_path";
then
AC_MSG_FAILURE([--with-gc-include or --with-gc-lib was specified but --with-gc=no.])
fi
elif test -z "$gc_include_path" && test -z "$gc_lib_path";
then
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
gc_include_path="$withval/include"
gc_lib_path="$withval/lib"
with_gc="yes"
else
AC_MSG_FAILURE([Cannot use --with-gc along with --with-gc-include or --with-gc-lib.])
fi,
with_gc="no"
)
if test "$with_gc" != "no" || test -n "$gc_include_path" || test -n "$gc_lib_path";
then
with_gc="yes"
fi
AC_ARG_WITH(ntl_include,
[AS_HELP_STRING([--with-ntl-include=DIR],[Use NTL (in tests) and specify its include directory])],
CPPFLAGS="$CPPFLAGS -I$withval"
ntl_include_path="$withval"
)
AC_ARG_WITH(ntl_lib,
[AS_HELP_STRING([--with-ntl-lib=DIR],[Use NTL (in tests) and specify its library directory])],
LDFLAGS="$LDFLAGS -L$withval"
ntl_lib_path="$withval"
)
AC_ARG_WITH(ntl,
[AS_HELP_STRING([--with-ntl[[=DIR]]],[Use NTL (in tests) and optionally specify its install directory])],
if test "$with_ntl" = "yes";
then
:
elif test "$with_ntl" = "no";
then
if test -n "$ntl_include_path" || test -n "$ntl_lib_path";
then
AC_MSG_FAILURE([--with-ntl-include or --with-ntl-lib was specified but --with-ntl=no.])
fi
elif test -z "$ntl_include_path" && test -z "$ntl_lib_path";
then
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
ntl_include_path="$withval/include"
ntl_lib_path="$withval/lib"
with_ntl="yes"
else
AC_MSG_FAILURE([Cannot use --with-ntl along with --with-ntl-include or --with-ntl-lib.])
fi,
with_ntl="no"
)
if test "$with_ntl" != "no" || test -n "$ntl_include_path" || test -n "$ntl_lib_path";
then
with_ntl="yes"
fi
################################################################################
# programs
################################################################################
dnl NOTE: The following line is invoked from LT_INIT
dnl AC_PROG_CC
if test "$with_ntl" = "yes";
then
AC_PROG_CXX
AC_LANG_PUSH(C++)
if test "$cxxflags_set" = "no";
then
AX_CXX_CHECK_COMPILE_FLAG([-Wall],[CXXFLAGS="-Wall $CXXFLAGS"])
AX_CXX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration],[CXXFLAGS="-Werror=implicit-function-declaration $CXXFLAGS"])
AX_CXX_CHECK_COMPILE_FLAG([-O2],[CXXFLAGS="-O2 $CXXFLAGS"])
if test "$enable_arch" != "no";
then
AX_CXX_CHECK_COMPILE_FLAG([-march=$enable_arch],[CXXFLAGS="-march=$enable_arch $CXXFLAGS"])
fi
AX_CXX_CHECK_COMPILE_FLAG([-std=c++11],[CXXFLAGS="-std=c++11 $CXXFLAGS"],
AC_MSG_ERROR([Couldn't compile with the C++11 standard needed by the NTL interface.])
)
if test "$enable_debug" = "yes";
then
if "$ac_cv_prog_cxx_g" = "yes";
then
CXXFLAGS="-g $CXXFLAGS"
else
AC_MSG_ERROR([$CXX does not support the flag -g needed to generate debug information])
fi
fi
fi
AC_LANG_POP
fi
AC_PROG_MKDIR_P
################################################################################
# environment variables
################################################################################
AC_ARG_VAR([TESTCFLAGS], [Choose different C compiler flags for tests [default=CFLAGS]. Can be useful to compile library at a specific optimization level while compiling tests fast.])
################################################################################
# check programs and system
################################################################################
AC_C_INLINE
if test "$compiler_c_o" = "no";
then
AC_MSG_ERROR([Compiler must support both -c and -o simultaneously!])
fi
AC_C_BIGENDIAN(flint_big_endian=yes)
case "$host_os" in
darwin*)
flint_lib="libflint.dylib"
flint_lib_major="libflint.$FLINT_MAJOR_SO.dylib"
flint_lib_full="libflint.$FLINT_MAJOR_SO.$FLINT_MINOR_SO.dylib"
extra_shared_flags="-install_name '`pwd`/$flint_lib_full' -compatibility_version $FLINT_MAJOR_SO.$FLINT_MINOR_SO -current_version $FLINT_MAJOR_SO.$FLINT_MINOR_SO.$FLINT_PATCH_SO"
flint_dylib="yes"
;;
cygwin|mingw*|msys)
flint_lib="libflint.dll"
flint_lib_major="libflint.$FLINT_MAJOR_SO.dll"
flint_lib_full="libflint.$FLINT_MAJOR_SO.$FLINT_MINOR_SO.$FLINT_PATCH_SO.dll"
flint_implib="$flint_lib.$libext"
extra_shared_flags="-static-libgcc $wl--export-all-symbols,--out-implib,$flint_implib"
flint_dlllib="yes"
;;
*)
flint_lib="libflint.so"
flint_lib_major="libflint.so.$FLINT_MAJOR_SO"
flint_lib_full="libflint.so.$FLINT_MAJOR_SO.$FLINT_MINOR_SO.$FLINT_PATCH_SO"
extra_shared_flags="$wl-soname,$flint_lib_major"
flint_solib="yes"
;;
esac
flint_lib_static="libflint.$libext"
if test "`uname -s`" = "android";
then
extra_shared_flags="$wl-soname,$flint_lib"
fi
AC_SUBST(WL,$wl)
AC_SUBST(FLINT_LIB,$flint_lib)
AC_SUBST(FLINT_LIB_MAJOR,$flint_lib_major)
AC_SUBST(FLINT_LIB_FULL,$flint_lib_full)
AC_SUBST(FLINT_IMPLIB,$flint_implib)
AC_SUBST(FLINT_LIB_STATIC,$flint_lib_static)
AC_SUBST(EXTRA_SHARED_FLAGS,$extra_shared_flags)
if test "$flint_dlllib" = "yes";
then
AC_SUBST(FLINT_DLLLIB,1)
else
AC_SUBST(FLINT_DLLLIB,0)
fi
if test "$flint_dylib" = "yes";
then
AC_SUBST(FLINT_DYLIB,1)
else
AC_SUBST(FLINT_DYLIB,0)
fi
if test "$flint_solib" = "yes";
then
AC_SUBST(FLINT_SOLIB,1)
else
AC_SUBST(FLINT_SOLIB,0)
fi
case "$host_os" in
cygwin|mingw*|msys)
if test "$DLLTOOL" = "false";
then
AC_MSG_ERROR(["Couldn't find any dlltool that is required to create import libraries for Windows-type systems."])
fi
;;
esac
dnl FIXME: Improve this check to include more processors.
AC_MSG_CHECKING([if memory is strongly-ordered])
case "$host" in
X86_PATTERN | X86_64_PATTERN)
flint_know_strong_order="yes"
AC_MSG_RESULT([yes])
;;
*)
flint_know_strong_order="no"
AC_MSG_RESULT([unsure])
;;
esac
if test "$flint_know_strong_order" = "yes";
then
AC_DEFINE(FLINT_KNOW_STRONG_ORDER,1,[Define if system is strongly ordered])
fi
################################################################################
# check GMP
################################################################################
FLINT_CHECK_GMP_H(6,2,1)
FLINT_GMP_LONG_LONG_LIMB([gmpcompat_h_in="gmpcompat-longlong.h.in"],
[gmpcompat_h_in="gmpcompat.h.in"])
AC_CONFIG_FILES([src/gmpcompat.h:src/$gmpcompat_h_in],[],[gmpcompat_h_in="$gmpcompat_h_in"])
AC_SUBST(GMPCOMPAT_H_IN, $gmpcompat_h_in)
################################################################################
# check MPFR
################################################################################
FLINT_CHECK_MPFR_H(4,1,0)
################################################################################
# check ABI
################################################################################
FLINT_ABI
case "$flint_cv_abi" in
32)
fft_tuning_in="src/fft_tuning32.in"
;;
64)
fft_tuning_in="src/fft_tuning64.in"
;;
esac
AC_CONFIG_FILES([src/fft_tuning.h:$fft_tuning_in],[],[fft_tuning_in="$fft_tuning_in"])
AC_SUBST(FFT_TUNING_IN, $fft_tuning_in)
################################################################################
# check headers
################################################################################
# Mandatory headers
# The following headers are checked previously:
# stdio.h stdlib.h stdint.h string.h
AC_CHECK_HEADERS([stdarg.h math.h float.h errno.h],,
AC_MSG_ERROR([Could not find a mandatory header!]))
# Optional headers
# The following headers are checked previously:
# unistd.h
AC_CHECK_HEADERS([fenv.h alloca.h malloc.h sys/param.h windows.h pthread_np.h])
if test "$enable_pthread" = "yes";
then
AC_CHECK_HEADER([pthread.h],,
AC_MSG_ERROR([Could not find pthread.h!]))
fi
if test "$enable_assert" = "yes";
then
AC_CHECK_HEADER([assert.h],,
AC_MSG_ERROR([Could not find assert.h!]))
fi
if test "$with_blas" = "yes";
then
AC_CHECK_HEADER([cblas.h],,
AC_MSG_ERROR([Could not find cblas.h!]))
fi
if test "$with_gc" = "yes";
then
AC_CHECK_HEADER([gc.h],,
AC_MSG_ERROR([Could not find gc.h!]))
fi
if test "$with_ntl" = "yes";
then
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([NTL/ZZ.h],,
AC_MSG_ERROR([Could not find NTL/ZZ.h!]))
AC_LANG_POP([C++])
fi
################################################################################
# check libraries
################################################################################
AC_SEARCH_LIBS([atan2],[m],
[],
[AC_MSG_ERROR(["The C math library was not found!"])])
AC_SEARCH_LIBS([__gmpz_init],[gmp],
[],
[AC_MSG_ERROR(["GMP library was not found. If you indeed have GMP installed, please
submit a bug report to <https://github.com/flintlib/flint/issues/> so
that we can either fix the issue or give a more proper error message."])])
if test "$enable_gmp_internals" = "yes";
then
AC_SEARCH_LIBS([__gmpn_gcd_11],[gmp],
[],
[AC_MSG_ERROR(["`mpn_gcd_11' was not found in the GMP library. It is needed to enable GMP
internals."])])
AC_SEARCH_LIBS([__gmpn_div_q],[gmp],
[],
[AC_MSG_ERROR([`mpn_div_q' was not found in the GMP library. It is needed to enable GMP
internals.])])
AC_SEARCH_LIBS([__gmpn_mul_basecase],[gmp],
[],
[AC_MSG_ERROR([`mpn_mul_basecase' was not found in the GMP library. It is needed to enable GMP
internals.])])
AC_SEARCH_LIBS([__gmpn_modexact_1_odd],[gmp],
[AC_DEFINE(FLINT_HAVE_MPN_MODEXACT_1_ODD,1,Define if system has mpn_modexact_1_odd)])
AC_SEARCH_LIBS([__gmpn_addmul_2],[gmp],
[AC_DEFINE(FLINT_HAVE_MPN_ADDMUL_2,1,Define if GMP has mpn_addmul_2)])
fi
if test "$enable_mpfr_check" = "yes";
then
AC_SEARCH_LIBS([mpfr_init],[mpfr],
[],
[AC_MSG_ERROR([MPFR library was not found. If you indeed have MPFR installed, please
submit a bug report to <https://github.com/flintlib/flint/issues/> so
that we can either fix the issue or give a more proper error message.])])
AC_SEARCH_LIBS([mpfr_round_p],[mpfr],
[],
[AC_MSG_ERROR(["`mpfr_round_p' was not found in the MPFR library. It is required for FLINT."])])
AC_SEARCH_LIBS([mpfr_mulhigh_n],[mpfr],
[],
[AC_MSG_ERROR(["`mpfr_mulhigh_n' was not found in the MPFR library. It is required for FLINT."])])
AC_SEARCH_LIBS([mpfr_sqrhigh_n],[mpfr],
[],
[AC_MSG_ERROR(["`mpfr_sqrhigh_n' was not found in the MPFR library. It is required for FLINT."])])
else
LIBS="$LIBS -lmpfr"
fi
if test "$enable_pthread" = "yes";
then
# check if compiler accepts the preferred -pthread
AX_CHECK_COMPILE_FLAG([-pthread],
[LIBS="-pthread $LIBS"],
# check if the compiler can do -lpthread
AC_SEARCH_LIBS([pthread_create],[pthread],
[],
AC_MSG_ERROR([Couldn't link against POSIX threads via -pthread or -lpthread while
--enable-pthread was specified.])
)
)
fi
if test "$with_blas" = "yes";
then
AC_SEARCH_LIBS([cblas_dgemm],[cblas openblas blas],[],
[AC_MSG_ERROR([BLAS library was not found. If you indeed have BLAS installed, please
submit a bug report to <https://github.com/flintlib/flint/issues/> so
that we can either fix the issue or give a more proper error message.])]
)
fi
if test "$with_ntl" = "yes";
then
AC_MSG_CHECKING([if linking simple code snippet of NTL works])
SAVE_libs="$LIBS"
LIBS="-lntl $LIBS"
AC_LANG_PUSH([C++])
dnl The following code snippet was taken from NTL's documentation
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <NTL/ZZ.h>]],
[NTL::ZZ a, b, c;
std::cin >> a;
std::cin >> b;
c = (a+1)*(b+1);
std::cout << c << "\n";])],
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
[AC_MSG_ERROR([NTL library was not found. If you indeed have NTL installed, please
submit a bug report to <https://github.com/flintlib/flint/issues/> so
that we can either fix the issue or give a more proper error message.])]
)
AC_LANG_POP
LIBS="$SAVE_libs"
fi
################################################################################
# check settings and environment
################################################################################
AC_SUBST(PIC_FLAG,$pic_flag)
AC_MSG_CHECKING([if cpu_set_t is supported])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#define _GNU_SOURCE
#include <sched.h>
#include <pthread.h>],
[cpu_set_t s;CPU_ZERO(&s); pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), 0);])],
[AC_DEFINE(FLINT_USES_CPUSET,1,Define if system has cpu_set_t)
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
# ensure alloca works
AC_MSG_CHECKING([if alloca works])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[#ifndef alloca
# ifdef __GNUC__
# define alloca __builtin_alloca
# else
# ifdef _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# include <alloca.h> /* We assume then that you have alloca.h */
# endif
# endif
#endif],
[char * p = alloca(128);])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Couldn't find alloca, which is required for FLINT. Please submit a bug
report to <https://github.com/flintlib/flint/issues/> and specify your
operating system.])])
AC_CHECK_FUNCS([aligned_alloc _aligned_malloc])
################################################################################
# CFLAGS
################################################################################
save_CFLAGS="$CFLAGS"
CFLAGS=""
# The following is needed for Clang to check for unknown options.
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option], [CFLAGS="-Werror=unknown-warning-option"])
if test "$enable_coverage" = "yes";
then
AX_CHECK_COMPILE_FLAG([--coverage],
[save_CFLAGS="--coverage $save_CFLAGS"],
[AC_MSG_ERROR([$CC does not to support test coverage flags])])
LDFLAGS="--coverage $LDFLAGS"
if test "$enable_pthread" = "yes";
then
AX_CHECK_COMPILE_FLAG([-fprofile-update=atomic],
[save_CFLAGS="-fprofile-update=atomic $save_CFLAGS"],
[AC_MSG_ERROR([$CC does not to support multi-threaded test coverage flags])])
fi
fi
if test "$enable_debug" = "yes";
then
if test "$ac_cv_prog_cc_g" = "yes";
then
save_CFLAGS="-g $save_CFLAGS"
else
AC_MSG_ERROR([$CC does not support the flag -g needed to generate debug information])
fi
fi
if test -n "$ABI";
then
AX_CHECK_COMPILE_FLAG([-m$ABI],
[save_CFLAGS="-m$ABI $save_CFLAGS"],
[AC_MSG_ERROR([$CC does not support the ABI flag -m$ABI])]
)
fi
if test "$enable_avx2" = "yes";
then
AX_CHECK_COMPILE_FLAG([-mavx2],
[save_CFLAGS="-mavx2 $save_CFLAGS"
AC_DEFINE(FLINT_HAVE_AVX2,1,[Define if system has AVX2])],
[AC_MSG_ERROR([$CC does not support the flag -mavx2 needed for AVX2 instructions])])
AX_CHECK_COMPILE_FLAG([-mfma], [save_CFLAGS="-mfma $save_CFLAGS"])
fi
if test "$enable_avx512" = "yes";
then
AX_CHECK_COMPILE_FLAG([-mavx512f],
[save_CFLAGS="-mavx512f $save_CFLAGS"
AC_DEFINE(FLINT_HAVE_AVX512,1,[Define if system has AVX512])],
[AC_MSG_ERROR([$CC does not support the flag -mavx512f needed for AVX512 instructions])])
fi
case $host_cpu in
sparc*)
AX_CHECK_COMPILE_FLAG(-mno-relax,[DEFAULT_CFLAGS="-mno-relax $DEFAULT_CFLAGS"])
;;
*)
;;
esac
AX_CHECK_COMPILE_FLAG([-Wall],[DEFAULT_CFLAGS="-Wall $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overread],[DEFAULT_CFLAGS="-Wno-stringop-overread $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overflow],[DEFAULT_CFLAGS="-Wno-stringop-overflow $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration],[DEFAULT_CFLAGS="-Werror=implicit-function-declaration $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-O3],[DEFAULT_CFLAGS="-O3 $DEFAULT_CFLAGS"])
if test "$enable_arch" != "no";
then
AX_CHECK_COMPILE_FLAG([-march=$enable_arch],[DEFAULT_CFLAGS="-march=$enable_arch $DEFAULT_CFLAGS"])
fi
AX_CHECK_COMPILE_FLAG([-std=c11],[DEFAULT_CFLAGS="-std=c11 $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-pedantic],[DEFAULT_CFLAGS="-pedantic $DEFAULT_CFLAGS"])
if test "$cflags_set" = "no";
then
CFLAGS="$save_CFLAGS $DEFAULT_CFLAGS"
AC_SUBST(UNROLL_LOOPS,1)
AC_DEFINE(FLINT_UNROLL_LOOPS, 1, [Define to locally unroll some loops])
else
CFLAGS="$save_CFLAGS"
AX_CHECK_COMPILE_FLAG([$CFLAGS],[],AC_MSG_ERROR(["Couldn't compile with given CFLAGS!"]))
AC_SUBST(UNROLL_LOOPS,0)
fi
if test "$testcflags_set" = "no";
then
TESTCFLAGS="$CFLAGS"
else
TESTCFLAGS="$TESTCFLAGS $save_CFLAGS"
fi
CPPFLAGS="-I./src $CPPFLAGS"
################################################################################
# Architecture
################################################################################
FLINT_ARCH
################################################################################
# fft_small module
################################################################################
FLINT_CHECK_FFT_SMALL(
[AC_SUBST(FFT_SMALL, [fft_small\ \ \ ])
AC_DEFINE(FLINT_HAVE_FFT_SMALL, 1, [Define to use the fft_small module])
case $flint_cv_arch in
FAST_VROUNDPD_PATTERN)
fft_small_threshold="400"
;;
SLOW_VROUNDPD_PATTERN)
fft_small_threshold="1540"
;;
*)
fft_small_threshold="500"
;;
esac
AC_DEFINE_UNQUOTED(FLINT_FFT_SMALL_THRESHOLD,[$fft_small_threshold],[Define to set threshold for when to use fft_small module])],
[AC_SUBST(FFT_SMALL, [\ \ \ \ \ \ \ \ \ \ \ \ ])])
################################################################################