-
Notifications
You must be signed in to change notification settings - Fork 227
/
configure.ac
2150 lines (1939 loc) · 80.5 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
AC_INIT([Macaulay2],[m4_esyscmd_s([cat VERSION])],[https://github.com/Macaulay2/M2/issues],[Macaulay2],[https://macaulay2.com/])
AC_MSG_NOTICE([configuring Macaulay2 version $PACKAGE_VERSION])
AC_CONFIG_SRCDIR(INSTALL)
AC_CONFIG_HEADERS(include/M2/config.h)
AC_CONFIG_FILES(m4_include(config/files))
AC_SUBST(CONFIGURED_FILES,"$ac_config_files")
AC_SUBST(CONFIG_ARGS,"$ac_configure_args")
echo "'$0' $ac_configure_args" > config.args
C_CONFIG_ARGS=` echo "$ac_configure_args" | sed -e 's=\\\\=\\\\\\\\=g' -e 's=\\"=\\\\"=g' `
AC_DEFINE_UNQUOTED(CONFIG_ARGS,"$C_CONFIG_ARGS",arguments used for configure)
AC_SUBST(CONFIG_CMD,"'$0' $ac_configure_args")
AC_CONFIG_MACRO_DIR([config]) dnl can't get this to work
m4_include(config/ax_compare_version.m4)
m4_include(config/ax_prog_cc_for_build.m4)
m4_include(config/ax_func_accept_argtypes.m4)
m4_include(config/relpaths.m4)
m4_include(config/gtest.m4)
m4_include(config/openmp.m4)
m4_include(config/search-libraries.m4)
m4_include(config/ax_boost_base.m4)
m4_include(config/ax_boost_regex.m4)
dnl define(TO_UPPER,[translit($1, [a-z], [A-Z])])
echo "relevant environment variable values, if any:"
for x in CC FC CXX AR CPPFLAGS CFLAGS FCFLAGS CXXFLAGS LDFLAGS LIBS ISSUE DISTRIBUTION PKG_CONFIG_PATH GFTABLESDIR
do eval v=\$$x
test "$v" && echo " $x = $v"
done
AC_SUBST(DISTRIBUTION) # use this starting number to sequentially number the downstream distributions
test "$DISTRIBUTION" || DISTRIBUTION=1
for i in $CFLAGS
do case $i in
-I*) AC_MSG_ERROR(preprocessor flag $i found in CFLAGS instead of in CPPFLAGS) ;;
-L*) AC_MSG_ERROR(link flag $i found in CFLAGS instead of in LDFLAGS);;
esac
done
for i in $CXXFLAGS
do case $i in
-I*) AC_MSG_ERROR(preprocessor flag $i found in CXXFLAGS instead of in CPPFLAGS);;
-L*) AC_MSG_ERROR(link flag $i found in CXXFLAGS instead of in LDFLAGS);;
esac
done
for i in $CPPFLAGS
do case $i in
-L*) AC_MSG_ERROR(link flag $i found in CPPFLAGS instead of in LDFLAGS);;
esac
done
for i in $LDFLAGS
do case $i in
-I*) AC_MSG_ERROR(preprocessor flag $i found in LDFLAGS instead of in CPPFLAGS);;
esac
done
dnl AC_MSG_CHECKING(whether $FIND is GNU find)
dnl if "$FIND" --version | head -1 | grep "GNU find" >/dev/null 2>&1
dnl then AC_MSG_RESULT(yes)
dnl else AC_MSG_ERROR($FIND: GNU find is required")
dnl fi
dnl interesting behavior: $A expansion happens after statement separation!
dnl $ A="echo hi 2>/dev/null "
dnl $ echo "`$A`"
dnl hi 2>/dev/null
dnl $ $A
dnl hi 2>/dev/null
dnl $ eval $A
dnl hi
AC_SUBST(NODENAME,"`uname -n`")
AC_DEFINE_UNQUOTED(NODENAME,"$NODENAME",hostname used for compilation)
AC_SUBST(ISSUE) # no initial value
AC_ARG_WITH(issue, AS_HELP_STRING([--with-issue=...,specify the OS issue (e.g., Ubuntu-7.10)]),ISSUE=$withval)
AC_SUBST(OS,"` uname -s | sed s=/=-=g `")
AC_SUBST(REL,"` uname -r | sed -e s=/=-=g -e 's= =+=' -e 's=[()]==g' `")
AC_SUBST(UNAME_INFO_COMMAND," uname -pmso 2>/dev/null || uname -pms ")
AC_SUBST(UNAME_INFO,"` eval $UNAME_INFO_COMMAND `")
case $OS in
# Here we normalize the name of the OS for windows for startup.m2, which
# needs to know that C:/FOO/BAR is an absolute path.
CYGWIN*) OS=MicrosoftWindows ; ISSUE=${ISSUE:-Cygwin} ;;
esac
if test ! "$ISSUE"
then if test -f /usr/bin/sw_vers
then ISSUE_FLAVOR=`/usr/bin/sw_vers -productName`
ISSUE_RELEASE=`/usr/bin/sw_vers -productVersion`
elif test -f /usr/bin/lsb_release
then ISSUE_FLAVOR=`lsb_release -s --id`
ISSUE_RELEASE=`lsb_release -s --release`
if test $ISSUE_RELEASE = n/a
then ISSUE_RELEASE=`lsb_release -s --codename`
fi
elif test -f /etc/os-release
then ISSUE_FLAVOR=`. /etc/os-release ; echo $ID`
ISSUE_RELEASE=`. /etc/os-release ; echo $VERSION_ID`
elif test -f /usr/lib/os-release
then ISSUE_FLAVOR=`. /usr/lib/os-release ; echo $ID`
ISSUE_RELEASE=`. /usr/lib/os-release ; echo $VERSION_ID`
elif test -f /bin/freebsd-version
then ISSUE_FLAVOR=FreeBSD
ISSUE_RELEASE=`freebsd-version`
elif test -f /etc/system-release
then ISSUE_FLAVOR=[`</etc/system-release head -1 | sed 's/^\([A-Za-z ]*\).*/\1/' | sed 's/ //g' `]
ISSUE_RELEASE=[`</etc/system-release head -1 | sed 's/[^0-9]*\([0-9.]*\).*/\1/'`]
elif test -f /etc/issue
then ISSUE_FLAVOR=[`</etc/issue head -1 | sed 's/^\([A-Za-z ]*\).*/\1/' | sed 's/ //g' `]
ISSUE_RELEASE=[`</etc/issue head -1 | sed 's/[^0-9]*\([0-9.]*\).*/\1/'`]
fi
# translate to something standard (for us), and verify :
case $ISSUE_FLAVOR in
"Mac OS X") ISSUE_FLAVOR=MacOS ;;
"debian"|"Debian"*) ISSUE_FLAVOR=Debian ;;
"ubuntu"|"Ubuntu") ISSUE_FLAVOR=Ubuntu ;;
"FedoraCore"*) ISSUE_FLAVOR=FedoraCore ;;
"Fedora"*) ISSUE_FLAVOR=Fedora ;;
"RedHatEnterprise"*) ISSUE_FLAVOR=RedHatEnterprise ;;
"RedHat"*) ISSUE_FLAVOR=RedHat ;;
"Scientific"*) ISSUE_FLAVOR="ScientificLinux" ;;
"Raspbian"*) ISSUE_FLAVOR=Raspbian ;;
*"openSUSE") ISSUE_FLAVOR=openSUSE ;;
"SUSE LINUX") ISSUE_FLAVOR=SuseLinux ;;
"arch") ISSUE_FLAVOR=ArchLinux ; ISSUE_RELEASE=none ;;
"") AC_MSG_ERROR([issue not found]) ;;
*) AC_MSG_NOTICE([unrecognized issue: $ISSUE_FLAVOR]) ;;
esac
ISSUE_FLAVOR=`echo $ISSUE_FLAVOR | sed 's/ /-/g'`
case $ISSUE_RELEASE in
none) ISSUE=$ISSUE_FLAVOR ;;
"") AC_MSG_NOTICE([release number not found])
ISSUE_RELEASE=unknown
ISSUE=$ISSUE_FLAVOR-unknown ;;
*) ISSUE=$ISSUE_FLAVOR-$ISSUE_RELEASE
esac
fi
# some operating systems have no ISSUE_FLAVOR, e.g., MacOS
test "$ISSUE" || ISSUE=$REL
AC_DEFINE_UNQUOTED(ISSUE,"$ISSUE",[issue (flavor) of operating system, if any])
AC_DEFINE_UNQUOTED(OS,"$OS",[operating system name, obtained with uname -s, perhaps modified])
AC_DEFINE_UNQUOTED(REL,"$REL",[operating system release, obtained with uname -r])
AC_MSG_NOTICE([operating system information:
OS = $OS
ISSUE = $ISSUE])
AC_CONFIG_AUX_DIR(config)
AC_CHECK_PROGS(MAKE,gmake make,false)
AC_CHECK_PROGS(PKG_CONFIG,pkg-config,false)
if test $PKG_CONFIG = false; then AC_MSG_ERROR(pkg-config is required); fi
AC_CHECK_PROGS(ETAGS,etags ctags,false)
if test "$ETAGS" = false; then AC_MSG_WARN(without etags no TAGS files will be made); fi
AC_CHECK_PROGS(LINTIAN,lintian,false)
AC_CHECK_PROGS(OTOOL,otool,false)
AC_CHECK_PROGS(RPMLINT,rpmlint,false)
AC_CHECK_PROGS(TAR,gtar gnutar tar,false)
AC_CHECK_PROGS(FIND,gfind find,false)
AC_CHECK_PROGS(OBJDUMP,objdump,false)
AC_CHECK_PROGS(OBJCOPY,objcopy,false)
AC_CHECK_PROGS(LDD,ldd,false)
AC_CHECK_PROGS(GIT,git,false)
AC_CHECK_TOOL(AR,ar,false)
AC_CHECK_TOOL(AS,as,false)
AC_CHECK_TOOL(DLLTOOL,dlltool,false)
AC_CHECK_TOOL(LD,ld,false)
AC_CHECK_TOOL(STRIP,strip,false)
if test "$STRIP" != "false"
then AC_MSG_CHECKING(whether $STRIP accepts the remove-section option)
if "$STRIP" --help 2>&1 | grep remove-section >/dev/null
then val=yes
else val=no
fi
AC_MSG_RESULT($val)
AC_SUBST(STRIP_REMOVE_SECTION,$val)
fi
AC_MSG_CHECKING(whether $MAKE is GNU make)
if "$MAKE" --version | head -1 | grep GNU >/dev/null 2>&1
then AC_MSG_RESULT(yes)
else AC_MSG_RESULT(no)
AC_MSG_ERROR($MAKE: GNU make is required)
fi
AC_MSG_CHECKING(whether GNU make is recent enough)
dnl Note: run our makefiles with GNU make, version 4 or larger.
dnl Version 3.81, provided on Mac OS X, has a bug, but you can
dnl use "homebrew" to install a modern version under the name "gmake"
if "$MAKE" --version | head -1 | grep "GNU Make 3.81" >/dev/null 2>&1
then AC_MSG_RESULT(no)
AC_MSG_ERROR([$MAKE: GNU make 3.81 found, too old; install a more recent version])
else AC_MSG_RESULT(yes)
fi
AC_MSG_CHECKING(whether $TAR is GNU tar)
if "$TAR" --version | head -1 | grep "GNU tar" >/dev/null 2>&1
then AC_MSG_RESULT(yes)
else AC_MSG_ERROR($TAR: GNU tar is required)
fi
AC_ARG_ENABLE([documentation],
[AS_HELP_STRING([--enable-documentation=...],
[space-delimited list of types of documentation to build; available
options are "html", "info", and "pdf"; default value is "html info"])],
[DOCUMENTATION=$enableval],
[DOCUMENTATION="html info"])
if test "$DOCUMENTATION" = no
then DOCUMENTATION=""
elif test "$DOCUMENTATION" = yes
then DOCUMENTATION="html info"
else for DOCTYPE in $DOCUMENTATION
do case $DOCTYPE in
html|info|pdf)
;;
*)
AC_MSG_ERROR([unknown documentation type ($DOCTYPE); expected html, info, or pdf])
;;
esac
done
fi
AC_SUBST(DOCUMENTATION)
AC_CANONICAL_HOST()
AC_SUBST(ARCH,$build_cpu)
AC_DEFINE_UNQUOTED(ARCH,"$ARCH",[machine hardware type])
dnl AC_ARG_VAR(CC,C compiler to use)
dnl AC_ARG_VAR(CXX,C++ compiler to use)
AC_SUBST(OPTIMIZE,yes) AC_ARG_ENABLE(optimize, AS_HELP_STRING(--disable-optimize,disable optimization), OPTIMIZE=$enableval)
AC_SUBST(NTL_WIZARD,no) AC_ARG_ENABLE(ntl-wizard, AS_HELP_STRING(--enable-ntl-wizard,enable running the NTL wizard), NTL_WIZARD=$enableval)
AC_SUBST(M2_CPPFLAGS)
AC_SUBST(M2_CFLAGS)
AC_SUBST(M2_CXXFLAGS)
dnl Fix standards, apply everywhere
CXXFLAGS="-std=gnu++14 $CXXFLAGS"
CFLAGS="-std=gnu11 $CFLAGS"
AC_PROG_CC() # set CFLAGS before this
AC_SUBST(GCC) # gets set to yes or no by AC_PROG_CC
AC_PROG_CXX() # set CXXFLAGS before this
AC_SUBST(GXX) # gets set to yes or no by AC_PROG_CXX
AC_PROG_YACC()
if test "$YACC" = byacc
then AC_MSG_ERROR([byacc found, but leads to a crash in scc1: install bison instead])
fi
AC_PROG_RANLIB()
AC_PROG_INSTALL()
AC_PROG_AWK()
dnl always compile with "-g", so we can debug even optimized versions
if test "$GCC" = yes
then CFLAGS="$CFLAGS -g3"
CXXFLAGS="$CXXFLAGS -g3"
LDFLAGS="$LDFLAGS -g3"
else CFLAGS="$CFLAGS -g"
CXXFLAGS="$CXXFLAGS -g"
LDFLAGS="$LDFLAGS -g"
fi
AC_SUBST(DEBUG,no) AC_ARG_ENABLE(debug, AS_HELP_STRING(--enable-debug,enable debugging (and disable stripping)), DEBUG=$enableval)
if test "$DEBUG" = yes
then # It is a mistake to add "-DDEBUG" to CPPFLAGS, because it is nonstandard and may confusing libraries, such as "flint".
# Instead, NDEBUG being *not* defined as a C macro is what indicates debug mode. This is standard practice.
# gc.h obeys the GC_DEBUG flag:
M2_CPPFLAGS="$M2_CPPFLAGS -DGC_DEBUG"
CPPFLAGS="$CPPFLAGS -DGC_DEBUG"
else M2_CPPFLAGS="$M2_CPPFLAGS -DNDEBUG"
CPPFLAGS="$CPPFLAGS -DNDEBUG"
fi
[
CFLAGS=` echo $CFLAGS | sed -e 's/-O[0-9]//g' -e 's/ */ /g' -e 's/^ *//' -e 's/ * $//' `
CXXFLAGS=` echo $CXXFLAGS | sed -e 's/-O[0-9]//g' -e 's/ */ /g' -e 's/^ *//' -e 's/ * $//' `
FCFLAGS=` echo $FCFLAGS | sed -e 's/-O[0-9]//g' -e 's/ */ /g' -e 's/^ *//' -e 's/ * $//' `
]
if test "$OPTIMIZE" = yes
then CFLAGS="$CFLAGS -O2"
CXXFLAGS="$CXXFLAGS -O2"
FCFLAGS="$FCFLAGS -O2"
else CFLAGS="$CFLAGS -O0"
CXXFLAGS="$CXXFLAGS -O0"
FCFLAGS="$FCFLAGS -O0"
fi
AC_SUBST(GCCVERSION)
if test $GCC = yes
then AC_MSG_CHECKING(for $CC version)
GCCVERSION=`$CC -dumpversion 2>&1 | sed 's/.*-\(.*\):.*/\1/'`
AC_MSG_RESULT($GCCVERSION)
fi
dnl this macro is available only in autoconf 2.60, but most systems have 2.59 as the default:
dnl AC_PROG_MKDIR_P()
AC_MSG_CHECKING(whether exceptions are caught)
AC_LANG(C++)
AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <stdexcept>
#include <string>
int main () {
const std::string s("caught");
try { throw(std::runtime_error(s)); }
catch (std::runtime_error e) { }
return 0;
}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT([no, use a different C++ compiler])]; exit 1
)
AC_CHECK_SIZEOF([int *])
AC_SUBST(SIZEOF_INT_P,$ac_cv_sizeof_int_p)
AC_CHECK_SIZEOF([long])
AC_SUBST(SIZEOF_LONG,$ac_cv_sizeof_long)
dnl Now we make the 32 bit / 64 bit choice explicit, because config.guess may guess it's a 32 bit system even though gcc compiles
dnl 64 bit object code by default, and then mpir's configure script (versions 1.2.1 and 1.3.0-rc1) gets confused.
dnl if test "$GCC" = yes
dnl then if test "$SIZEOF_INT_P" = 4
dnl then case " $CC $CFLAGS " in
dnl *" -m32 "*) ;;
dnl *) CC="$CC -m32" ;;
dnl esac
dnl fi
dnl if test "$SIZEOF_INT_P" = 8
dnl then case " $CC $CFLAGS " in
dnl *" -m64 "*) ;;
dnl *) CC="$CC -m64" ;;
dnl esac
dnl fi
dnl fi
dnl if test "$GXX" = yes
dnl then if test "$SIZEOF_INT_P" = 4
dnl then case " $CXX $CFLAGS " in
dnl *" -m32 "*) ;;
dnl *) CXX="$CXX -m32" ;;
dnl esac
dnl fi
dnl if test "$SIZEOF_INT_P" = 8
dnl then case " $CXX $CFLAGS " in
dnl *" -m64 "*) ;;
dnl *) CXX="$CXX -m64" ;;
dnl esac
dnl fi
dnl fi
AC_CHECK_HEADERS_ONCE([sys/time.h])
AC_CHECK_HEADERS(sys/ioctl.h termios.h sys/mman.h sys/socket.h netdb.h netinet/in.h arpa/inet.h sys/time.h time.h sys/wait.h sys/resource.h io.h linux/personality.h stddef.h stdint.h inttypes.h elf.h execinfo.h stdlib.h syscall.h sys/types.h sys/stat.h unistd.h math.h pthread.h assert.h alloca.h malloc.h dlfcn.h)
AC_CHECK_HEADERS(winsock2.h) dnl used with ws2_32.dll under mingw64
dnl winsock2.h should be included before including windows.h
dnl pthread.h includes windows.h
dnl therefore winsock2.h should be included before pthread
AC_SEARCH_LIBS(clock_gettime,rt)
dnl winsock2.h should be used with ws2_32.lib; it defines:
dnl accept bind closesocket connect freeaddrinfo getaddrinfo gethostbyaddr
dnl gethostbyname gethostname getnameinfo getpeername getprotobyname
dnl getprotobynumber getservbyname getservbyport getsockname getsockopt htonl htons
dnl inet_addr inet_ntoa inet_ntop inet_pton ioctlsocket listen ntohl ntohs recv
dnl recvfrom select send sendto setsockopt shutdown socket
AC_SEARCH_LIBS(socket,socket ws2_32) dnl ws2_32 is used under mingw64
AC_SEARCH_LIBS(hstrerror,resolv)
AC_SEARCH_LIBS(dlopen,dl)
AC_SEARCH_LIBS(gethostbyname,nsl)
AC_SUBST(ENABLE_TBB,yes) AC_ARG_ENABLE(tbb, AS_HELP_STRING(--disable-tbb,disable use of the tbb (threaded building blocks) library), ENABLE_TBB=$enableval)
if test $ENABLE_TBB = yes
then AC_DEFINE(WITH_TBB,1,[whether the tbb library has been enabled by the builder])
AC_SUBST(LIBTBB) dnl LIBTBB is usually set to -ltbb
AC_LANG(C++)
AC_CHECK_HEADER(tbb/tbb.h,
[AC_SEARCH_LIBS(TBB_runtime_interface_version,"tbb",
LIBTBB=$ac_cv_search_TBB_runtime_interface_version,
[AC_MSG_ERROR([tbb library not found])])],
[AC_MSG_ERROR([tbb include file (tbb.h) not found])])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
#include <tbb/tbb.h>
int main () {
printf("tbb version %d.%d found\n", TBB_VERSION_MAJOR, TBB_VERSION_MINOR);
return 0;
}
]])])
fi
AC_CHECK_FUNCS([herror error clock_gettime getaddrinfo hstrerror sync getpgrp setpgid fchmod pipe waitpid setrlimit alarm fork sigprocmask kill longjmp siglongjmp sigaction wait4 readlink lstat realpath mkdir link symlink socket accept fcntl personality ioctl])
AC_SUBST(HAVE_PERSONALITY,$ac_cv_func_personality)
AC_DEFINE_UNQUOTED(SOCKLEN_T,[`echo "$ac_cv_func_accept_arg3" | sed 's/ \*$//'`],[socket length type used by accept()])
if test $host_os = mingw32
then CPPFLAGS="$CPPFLAGS -D_POSIX" # arrange for SIGPIPE to get defined
CPPFLAGS="$CPPFLAGS -D__USE_MINGW_ALARM" # for SIGALRM to get defined
fi
AC_SUBST(__INTEL_COMPILER,no)
AC_CHECK_DECL(__INTEL_COMPILER,__INTEL_COMPILER=yes)
dnl this macro is available only in autoconf 2.60, but most systems have 2.59 as the default:
dnl AC_TYPE_INT64_T()
AC_FUNC_ALLOCA()
dnl AC_SUBST(PTHREADS,yes) AC_ARG_ENABLE(pthreads, AS_HELP_STRING(--disable-pthreads,[disable pthreads (for gc)]), PTHREADS=$enableval)
AC_SUBST(ENABLE_STRIP,no) AC_ARG_ENABLE(strip, AS_HELP_STRING(--enable-strip,strip the symbol table from the Macaulay2 binary), ENABLE_STRIP=$enableval)
test "$DEBUG" = "yes" && ENABLE_STRIP=no
# note: we build many programs for inclusion in the distribution -- stripping them saves 9MB of 70
AC_SUBST(MEMDEBUG,no) AC_ARG_ENABLE(memdebug, AS_HELP_STRING(--enable-memdebug,enable memory allocation debugging), MEMDEBUG=$enableval)
AC_SUBST(ENCAP,no) AC_ARG_ENABLE(encap, AS_HELP_STRING(--enable-encap,encapsulate all files in a subdirectory at installation time), ENCAP=$enableval)
AC_SUBST(XCODE,no) AC_ARG_ENABLE(xcode, AS_HELP_STRING(--enable-xcode,create Macaulay2/d/interpret.a for use with xcode), XCODE=$enableval)
AC_SUBST(CC_THREAD_SUPPORT)
AC_MSG_CHECKING(whether the C compiler accepts the __thread storage attribute)
AC_LANG(C)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([__thread int x;])],
CC_THREAD_SUPPORT=yes; [AC_MSG_RESULT(yes)],
CC_THREAD_SUPPORT=no ; [AC_MSG_RESULT(no)])
AC_SUBST(XML,yes)
AC_ARG_ENABLE(xml, AS_HELP_STRING(--disable-xml,[do not link with xml library]), XML=$enableval)
if test "$XML" = yes
then AC_DEFINE(WITH_XML,1,[whether we are linking with the xml library])
fi
AC_SUBST(MYSQL,no)
AC_ARG_WITH(mysql, AS_HELP_STRING(--with-mysql,[link with mysql]), MYSQL=$withval)
if test "$MYSQL" = yes
then AC_DEFINE(WITH_MYSQL,1,[whether we are linking with the mysql library])
fi
AC_ARG_ENABLE(altivec, AS_HELP_STRING(--enable-altivec,compile with "-faltivec" option))
if test "$enable_altivec" = yes
then LDFLAGS="$LDFLAGS -faltivec"
CFLAGS="CFLAGS -faltivec"
CXXFLAGS="$CXXFLAGS -faltivec"
fi
AC_PROG_FC() dnl check for Fortran compiler presence
USE_FCLIBS=unspecified
AC_ARG_ENABLE(fc-lib-ldflags,
AS_HELP_STRING(--disable-fc-lib-ldflags,[do not use extra libraries for linking with Fortran (the default under Cygwin)]),
USE_FCLIBS=$enableval)
if test "$USE_FCLIBS" = unspecified
then if test "$ISSUE" = Cygwin
then USE_FCLIBS=no
AC_MSG_NOTICE([by default under Cygwin, not adding linker flags to link with Fortran libraries])
else USE_FCLIBS=yes
AC_MSG_NOTICE([by default, adding linker flags to link with Fortran libraries])
fi
fi
if test "$FC"
then AC_FC_DUMMY_MAIN()
AC_FC_WRAPPERS()
AC_FC_LIBRARY_LDFLAGS()
fi
dnl if test "$PTHREADS" = yes
dnl then
AC_SEARCH_LIBS(pthread_mutex_trylock,pthread)
dnl fi
AC_SUBST(PROFILING,no)
AC_ARG_ENABLE(profile, AS_HELP_STRING(--enable-profile,enable profiling (and disable stripping)), PROFILING=$enableval)
test "$PROFILING" = no; val=$?; AC_DEFINE_UNQUOTED(PROFILING, $val,whether profiling has been enabled)
AC_SUBST(COMPRESS,gz) AC_ARG_ENABLE(compress, AS_HELP_STRING([--enable-compress=[gz|bz2]],compression method for tarball), COMPRESS=$enableval)
AC_SUBST(EXPERIMENT,no)
AC_ARG_ENABLE(experimental-code, AS_HELP_STRING(--enable-experimental-code,enable experimental code), EXPERIMENT=$enableval)
test "$EXPERIMENT" = no; val=$?; AC_DEFINE_UNQUOTED(EXPERIMENT,$val,whether experimental code has been enabled)
AC_SUBST(M2TARFILE,no) AC_ARG_ENABLE(tarfile, AS_HELP_STRING(--enable-tarfile,prepare binary and source packages as compressed tar files), M2TARFILE=$enableval)
AC_SUBST(TARLIBS,no) AC_ARG_ENABLE(tarlibs, AS_HELP_STRING(--enable-tarlibs,include symbolic links to needed shared libraries for tar), TARLIBS=$enableval)
AC_SUBST(SHARED,yes) AC_ARG_ENABLE(shared, AS_HELP_STRING(--disable-shared,disable building of shared libraries), SHARED=$enableval)
dnl Under Mac OS X 10.15 the Gatekeeper makes it impossible for us to distribute shared libraries with our program to end users in disk image (*.dmg) format:
dnl ... but we've given up on trying to satisfy the gatekeeper. There is a strange error message when we try to link with libgmp.a:
dnl ld: illegal text-relocation to '___gmp_binvert_limb_table' in /Users/runner/runners/2.263.0/work/M2/M2/M2/BUILD/cicd/usr-host/lib/libgmp.a(mp_minv_tab.o) from '___gmpn_divexact_1' in /Users/runner/runners/2.263.0/work/M2/M2/M2/BUILD/cicd/usr-host/lib/libgmp.a(dive_1.o) for architecture x86_64
dnl if test "$ISSUE_FLAVOR" = "MacOS"
dnl then SHARED=no
dnl AC_MSG_NOTICE([disabling the building of shared libraries under Mac OS X])
dnl fi
test "$MEMDEBUG" = "yes" && DEBUG=yes
test "$PROFILING" = "yes" && CFLAGS="$CFLAGS -pg" CXXFLAGS="$CXXFLAGS -pg" LDFLAGS="$LDFLAGS -pg" ENABLE_STRIP=no
if <$srcdir/Macaulay2/packages/=distributed-packages sort|uniq -c|grep -v -q ' 1 '
then echo "error: some packages are listed more than once in Macaulay2/packages/=distributed-packages:"
<$srcdir/Macaulay2/packages/=distributed-packages sort|uniq -c|grep -v ' 1 '
exit 1
fi
AC_SUBST(PACKAGES,`cat $srcdir/Macaulay2/packages/=distributed-packages`)
[if [ $? != 0 ] ; then exit 1 ; fi]
# convert the newlines to spaces
PACKAGES=`echo $PACKAGES`
AC_DEFINE_UNQUOTED(PACKAGES,"$PACKAGES",the list of packages included with the release of Macaulay2)
AC_DEFINE_UNQUOTED(buildsystemtype,"$build",the type of system on which the package was built)
AC_DEFINE_UNQUOTED(hostsystemtype,"$host",the type of system on which the package runs)
case $host in
i586-*|i686-*)
newhost=`echo $host | sed s/i.86-/i486-/`
AC_MSG_NOTICE([warning: building for host $host might not be compatible enough, consider using option "--build=$newhost"]) ;;
esac
AC_SUBST(AUTOINST,no)
AC_ARG_ENABLE(
auto-instantiation,
AS_HELP_STRING([--enable-auto-instantiation,enable automatic instantiation of C++ templates (it uses -frepo option to g++)]),
AUTOINST=$enableval)
test "$AUTOINST" = no; val=$?; AC_DEFINE_UNQUOTED(AUTOINST,$val,whether to instantiate templates automatically)
AC_SUBST(IMPLINST,yes)
AC_ARG_ENABLE(
implicit-templates,
AS_HELP_STRING([--disable-implicit-templates,disable implicit instantiation of C++ templates (it uses -fno-implicit-templates option to g++)]),
IMPLINST=$enableval)
test "$IMPLINST" = no; val=$?; AC_DEFINE_UNQUOTED(IMPLINST,$val,whether to instantiate templates implicitly)
AC_SUBST(DEVELOPMENT,no)
AC_ARG_ENABLE(development, AS_HELP_STRING(--enable-development,build a development version), DEVELOPMENT=$enableval)
if test "$DEVELOPMENT" = yes
then AC_DEFINE_UNQUOTED(DEVELOPMENT,1,whether to build a development version)
fi
AC_SUBST(DEVELOPER)
AC_ARG_WITH(developer, AS_HELP_STRING(--with-developer=...,specify the name of the developer ($USER)),DEVELOPER=$withval)
AC_SUBST(TAR_COMPRESS_OPTION,)
case $COMPRESS in
gz) TAR_COMPRESS_OPTION=--gzip ;;
bz2) TAR_COMPRESS_OPTION=--bzip ;;
*) AC_MSG_ERROR(unrecognized option for enable-compress) ;;
esac
AC_SUBST(GIT_DESCRIPTION)
# TODO: currently finds the last commit that changed the VERSION file
# but ideally it should get the last release commit instead
NEW_COMMITS=`$GIT rev-list $($GIT rev-list -1 HEAD $srcdir/VERSION)..HEAD --count`
GIT_COMMIT=`$GIT describe --dirty --always --match HEAD`
if test "$NEW_COMMITS-$GIT_COMMIT" = "-"
then GIT_DESCRIPTION=version-$PACKAGE_VERSION-unknown
else GIT_DESCRIPTION=version-$PACKAGE_VERSION-$NEW_COMMITS-$GIT_COMMIT
fi
AC_DEFINE_UNQUOTED(GIT_DESCRIPTION,"$GIT_DESCRIPTION",[summary of git status])
AC_SUBST(DEB,no)
AC_ARG_ENABLE(deb, AS_HELP_STRING(--enable-deb,prepare a *.deb package (for debian, ubuntu, ...)), DEB=$enableval)
if test "$DEB" = yes
then if test "$OPTIMIZE" = no
then AC_MSG_ERROR([--disable-optimize and --enable-deb both specified])
fi
if test "$DEBUG" = yes
then AC_MSG_ERROR([--enable-debug and --enable-deb both specified])
fi
fi
AC_SUBST(FREEBSD,no)
AC_ARG_ENABLE(freebsd, AS_HELP_STRING(--enable-freebsd,prepare a package file for freebsd), FREEBSD=$enableval)
if test "$FREEBSD" = yes
then if test "$OPTIMIZE" = no
then AC_MSG_ERROR([--disable-optimize and --enable-freebsd both specified])
fi
if test "$DEBUG" = yes
then AC_MSG_ERROR([--enable-debug and --enable-freebsd both specified])
fi
fi
AC_SUBST(RPM,no)
AC_ARG_ENABLE(rpm, AS_HELP_STRING(--enable-rpm,prepare a *.rpm package (for red hat based systems)), RPM=$enableval)
if test "$RPM" = yes
then if test "$OPTIMIZE" = no
then AC_MSG_ERROR([--disable-optimize and --enable-rpm both specified])
fi
if test "$DEBUG" = yes
then AC_MSG_ERROR([--enable-debug and --enable-rpm both specified])
fi
fi
AC_SUBST(DMG,no)
AC_ARG_ENABLE(dmg, AS_HELP_STRING(--enable-dmg,prepare a *.dmg package (for Mac OS)), DMG=$enableval)
if test "$DMG" = yes
then if test "$OPTIMIZE" = no
then AC_MSG_ERROR([--disable-optimize and --enable-dmg both specified])
fi
if test "$DEBUG" = yes
then AC_MSG_ERROR([--enable-debug and --enable-dmg both specified])
fi
if test $SHARED = yes
then SHARED=no
AC_MSG_WARN([--enable-dmg specified, so disabling the building of shared libraries])
fi
fi
AC_SUBST(M2SUFFIX)
test "$program_suffix" != NONE && M2SUFFIX=$program_suffix
AC_ARG_ENABLE(dummy, AS_HELP_STRING(--program-suffix=...,suffix to append to executable name M2))
AC_DEFINE(M2_CONFIG_H,1,a macro definition to ensure our config.h was the one loaded)
AC_DEFINE_UNQUOTED(M2SUFFIX,"$M2SUFFIX",[suffix to append to executable name M2])
WITH_NEWLINE_CR=0
WITH_NEWLINE_CRLF=0
AC_ARG_WITH(newline, AS_HELP_STRING([--with-newline=...], [crlf, cr, or lf (the default)]),
[ case $withval in
crlf) WITH_NEWLINE_CRLF=1 WITH_NEWLINE_CR=0 ;;
cr) WITH_NEWLINE_CR=1 WITH_NEWLINE_CRLF=0 ;;
lf) WITH_NEWLINE_CR=0 WITH_NEWLINE_CRLF=0 ;;
*) AC_MSG_ERROR([--with-newline expected crlf, cr, or lf]) ;;
esac ])
AC_DEFINE_UNQUOTED(WITH_NEWLINE_CRLF,$WITH_NEWLINE_CRLF,[whether newline is cr lf])
AC_DEFINE_UNQUOTED(WITH_NEWLINE_CR, $WITH_NEWLINE_CR, [whether newline is cr])
AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[suffix the compiler appends to executable filenames])
AC_SUBST(ISYSTEM,no)
AC_MSG_CHECKING(whether g++ gets confused about C linkage in system library files)
AC_LANG(C++)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
# 1 "foo" 1 3 4
template <class T> struct A { };])],AC_MSG_RESULT(no);ISYSTEM=yes,AC_MSG_RESULT(yes))
dnl Check for openmp and fail if it cannot be found.
dnl This is required for building the library csdp and good for building the library normaliz
AC_LANG(C++)
AC_OPENMP
if test "$ac_cv_prog_cxx_openmp" = unsupported
then AC_MSG_ERROR([OpenMP does not work, use a compiler that supports OpenMP])
fi
TMP=$OPENMP_CXXFLAGS
OPENMP_CXXFLAGS=
for i in $TMP
do case $i in
-l*) OPENMP_LIBS="$OPENMP_LIBS $i" ;;
*) OPENMP_CXXFLAGS="$OPENMP_CXXFLAGS $i" ;;
esac
done
AC_SUBST(OPENMP_CXXFLAGS,"$OPENMP_CXXFLAGS")
AC_SUBST(OPENMP_LIBS,"$OPENMP_LIBS")
#############################################################################
AC_SUBST(BUILTLIBS)
# The list BUILTLIBS is the list of link options for the libraries we have decided to build,
# of the form "-lFOO", which will be used to link Macaulay2 later on. These libraries are not
# available at the time this configure script is run, which is why we can't add "-lFOO" to LIBS.
# (Programs linked by this configure script are linked with the options in LIBS. This allows libraries
# dependent on previously detected libraries to be detected by tests that involve linking.
AC_SUBST(LIBLIST, " gc gdbm gmp mpir mpfr mpfi readline ntl flint factory lapack mpsolve frobby glpk cddlib fplll linbox gtest ")
# The list LIBLIST is the list of libraries that might be used and linked into M2.
AC_SUBST(PROGLIST, "4ti2 gfan normaliz csdp nauty cddplus lrslib gftables topcom cohomcalg")
# The list PROGLIST is the list of programs and libraries for them that are distributed with M2.
# Initially, we offer no option for not compiling some of them.
AC_SUBST(SUBLIST, " memtailor mathic mathicgb fflas_ffpack givaro ")
# The list SUBLIST is the list of submodules that might be used and linked into M2.
# These three lists reflect dependencies, with prerequisites listed first, including the following dependencies:
# mathicgb needs mathic and memtailor
# mathic needs memtailor
# factory needs flint, ntl and gmp; it includes and installs gftables, so doesn't need it separately
# libfac has been replaced by code in factory
# lapack includes blas, makes both libblas and liblapack
# mpir is a plug-in replacement for gmp and can provide libgmp and libgmpxx, too.
# mpfr needs gmp (or mpir
# mpfr puts pointers to gmp numbers in thread local variables, unless
# specially configured, so we shouldn't tell gmp to use libgc (we used to do that)
# ntl needs gmp (or mpir)
# 4ti2 needs glpk
# glpk needs gmp (or mpir)
# topcom depends on cddlib
# gfan needs cddlib
# cddlib uses gmp
# polymake cannot be included in Macaulay2 because its compile/build/install procedure is flawed:
# it uses a dynamic readline library that can only be provided by fink and probably will not be copied into the install location
# it offers no way to provide a directory tree containing a readline library we've compiled
# it writes a file into the user's home directory called ".polymake"
# it asks questions
# normaliz needs libgmp, libgmpxx, boost
# Greg Smith requested cddplus and lrslib for future use
# nauty is used by the package Nauty
# normaliz is used by the package Normaliz
# gfan is used by the packages gfanInterface and StatePolytope
# 4ti2 is used by the package FourTiTwo
# linbox is provided as an option for experimentation
# linbox needs fflas_ffpack and givaro
# givaro uses gmp
# fflas_ffpack needs givaro and lapack, but fflas_ffpack is just source code, so we don't *have* to build it
# mpir is used by givaro
# mpir and mpfr are used by fplll
# flint depends on gmp (or mpir) and mpfr
# frobby depends on gmp
# mpfi needs mpfr
AC_SUBST(FILE_PREREQS)
# This is the list of files found in the system that we need to be there for the user who
# installs a binary distribution.
# a library is listed in BUILD_ALWAYS if and only if we *always* build it,
# even if the option "--disable-building" is specified:
BUILD_ALWAYS=""
for i in $LIBLIST $SUBLIST $PROGLIST
do eval BUILD_$i=no
done
# Convert package identifiers used here to package names as known by the package.
# The point is that BUILD_fflas_ffpack is a valid shell identifier, but
# the name of the package is fflas-ffpack and BUILD_fflas-ffpack is not valid as
# a shell identifier. We may need the name of the package, for example, as an
# argument to pkg-config.
for i in $LIBLIST
do eval PKGNAME_$i=$i
done
PKGNAME_fflas_ffpack=fflas-ffpack
#############################################################################
LIBLIST=" $LIBLIST "
AC_ARG_ENABLE(build-libraries, AS_HELP_STRING(--enable-build-libraries=...,[list of libraries, submodules, and programs to build from downloaded source code (e.g., gc gdbm mpir mpfr mpfi readline ntl gftables factory lapack mpsolve frobby glpk cddlib givaro fflas_ffpack linbox 4ti2 gfan normaliz csdp nauty cddplus lrslib)]),
[for i in $enableval
do case " $LIBLIST $SUBLIST $PROGLIST " in
*" $i "*)
eval BUILD_$i=yes
BUILD_ALWAYS="$BUILD_ALWAYS $i"
;;
*) AC_MSG_ERROR(--enable-build-libraries option: unrecognized library name: $i) ;;
esac
done])
#############################################################################
dnl We disable something temporarily that didn't work out, because if we put a static library, such
dnl as libflint.a, into LIBS, then mathicgb, mathic, and memtailor get confused and include a copy
dnl of the file in their *.a file.
TRY_STATIC=no
AC_SUBST(LIBS_GDBM)
AC_LANG(C)
AC_CHECK_HEADER(gdbm.h,
test $BUILD_gdbm = yes && AC_MSG_WARN([[library gdbm exists, but we are asked to build it]]),
BUILD_gdbm=yes)
if test $BUILD_gdbm = yes
then LIBS_GDBM="-lgdbm"
BUILTLIBS="$LIBS_GDBM $BUILTLIBS"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(gdbm_close,"/usr/lib/libgdbm.a" "/usr/local/lib/libgdbm.a",,[AC_MSG_ERROR([libgdbm.a not found])])
else AC_SEARCH_LIBS(gdbm_close,"gdbm",,[AC_MSG_ERROR([libgdbm not found])])
fi
if test "none required" != "$ac_cv_search_gdbm_close"
then LIBS_GDBM=$ac_cv_search_gdbm_close
fi
fi
## we build gc by default so we can configure it for large memory spaces
## see issue #2445
AC_ARG_WITH([system-gc],
[AS_HELP_STRING([--with-system-gc],
[use system gc instead of building it])],
[],
[with_system_gc=no])
AS_IF([test "x$with_system_gc" = xyes],
[AC_MSG_CHECKING(whether package bdw-gc is provided)
dnl Note: we don't include -lgccpp below, because linking with that library is what replaces ::new and friends with GC_MALLOC_UNCOLLECTABLE and friends:
if [ pkg-config --exists bdw-gc ]
then AC_MSG_RESULT(yes)
CPPFLAGS="`pkg-config --cflags-only-I bdw-gc | sed -e 's=^-I/=-isystem /=g' -e 's= -I/= -isystem /=g'` $CPPFLAGS"
dnl should probably use `pkg-config --libs bdw-gc` here instead
FOUND_gc=yes
else AC_MSG_RESULT(no)
BUILD_gc=yes
fi],
[BUILD_gc=yes])
if test $BUILD_gc = yes
then BUILTLIBS="-lgc -lpthread $BUILTLIBS"
BUILD_ALWAYS="$BUILD_ALWAYS gc"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(GC_malloc,"/usr/lib/libgc.a" "/usr/local/lib/libgc.a",,
[AC_MSG_ERROR([libgc.a not found])])
else AC_SEARCH_LIBS(GC_malloc,"gc",,[AC_MSG_ERROR([libgc not found])])
fi
fi
# mpir and gmp serve the same purpose
AC_SUBST(LIBS_GMP)
AC_LANG(C)
AC_CHECK_HEADER(gmp.h, FOUND_gmp=yes ,FOUND_gmp=no )
AC_CHECK_HEADER(mpir.h,FOUND_mpir=yes,FOUND_mpir=no)
dnl Remark: both gmp.h and mpir.h are surrounded by
dnl #ifndef __GMP_H__
dnl #endif
dnl , so only one can be loaded. Similarly for gmpxx.h and mpirxx.h. However, the contents of
dnl the files differ. For example, mpf_cmp_z is defined only in gmp.h.
AC_SUBST(PREFERRED_INTEGER_PACKAGE,gmp)
AC_ARG_WITH(integer-package,
AS_HELP_STRING(--with-integer-package=[mpir|gmp],specify the big integer package to use (mpir or gmp)),
if ! test $withval = mpir -o $withval = gmp
then AC_MSG_ERROR([big integer package option: invalid value: $withval])
fi
PREFERRED_INTEGER_PACKAGE=$withval)
if test $BUILD_gmp = yes -a $BUILD_mpir = yes
then AC_MSG_ERROR([refusing to build both mpir and gmp, since the are interchangeable])
fi
AC_MSG_CHECKING([whether to use gmp or mpir])
if test "$PREFERRED_INTEGER_PACKAGE" = mpir
then USING_MPIR=1
AC_MSG_RESULT([using mpir])
AC_DEFINE(USING_MPIR,1,[Whether we use MPIR (instead of GMP)])
if test "$FOUND_mpir" = no
then BUILD_mpir=yes
LIBS_GMP="-lmpirxx -lmpir"
BUILTLIBS="$LIBS_GMP $BUILTLIBS"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(__gmpz_init,"/usr/lib/libmpirxx.a /usr/lib/libmpir.a" "/usr/local/lib/libmpirxx.a /usr/local/lib/libmpir.a",,
[AC_MSG_ERROR([libmpir.a not found])])
else SEARCH_LIBRARIES(__gmpz_init,"-lmpirxx -lmpir",,[AC_MSG_ERROR([libmpir not found])])
fi
if test "none required" != "$ac_cv_search___gmpz_init"
then LIBS_GMP=$ac_cv_search___gmpz_init
fi
fi
else USING_MPIR=0 # i.e., using gmp
AC_MSG_RESULT([using gmp])
AC_DEFINE(USING_MPIR,0,[Whether we use MPIR (instead of GMP)])
if test "$FOUND_gmp" = no
then BUILD_gmp=yes
LIBS_GMP="-lgmpxx -lgmp"
BUILTLIBS="$LIBS_GMP $BUILTLIBS"
else AC_LANG(C)
if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(__gmpz_init,"/usr/lib/libgmpxx.a /usr/lib/libgmp.a" "/usr/local/lib/libgmpxx.a /usr/local/lib/libgmp.a",,
[AC_MSG_ERROR([libgmp.a not found])])
else SEARCH_LIBRARIES(__gmpz_init,"-lgmpxx -lgmp",,[AC_MSG_ERROR([libgmp not found])])
fi
if test "none required" != "$ac_cv_search___gmpz_init"
then LIBS_GMP=$ac_cv_search___gmpz_init
fi
dnl By the way: with Hombebrew on the Mac gmp comes with package configuration:
dnl $ pkg-config gmp --cflags
dnl -I/usr/local/Cellar/gmp/6.2.0/include
dnl $ pkg-config gmp --libs
dnl -L/usr/local/Cellar/gmp/6.2.0/lib -lgmp
fi
fi
AC_SUBST(USING_MPIR)
AC_LANG(C)
AC_CHECK_HEADER(mpfr.h,,BUILD_mpfr=yes)
if test $BUILD_mpfr = yes
then BUILTLIBS="-lmpfr $BUILTLIBS"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(mpfr_digamma,"/usr/lib/libmpfr.a" "/usr/local/lib/libmpfr.a",,
[AC_MSG_ERROR([libmpfr.a not found])])
else AC_SEARCH_LIBS(mpfr_digamma,"mpfr",,[AC_MSG_ERROR([libmpfr not found])])
fi
fi
AC_LANG(C)
AC_CHECK_HEADER(mpfi.h,,BUILD_mpfi=yes)
if test $BUILD_mpfi = yes
then BUILTLIBS="-lmpfi $BUILTLIBS"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(mpfi_set_prec,"/usr/lib/libmpfi.a" "/usr/local/lib/libmpfi.a",,
[AC_MSG_ERROR([libmpfi.a not found])])
else AC_SEARCH_LIBS(mpfi_set_prec,"mpfi",,[AC_MSG_ERROR([libmpfi not found])])
fi
fi
# including mpsolve (requires gmp or mpir)
AC_LANG(C)
AC_CHECK_HEADER(mps/mps.h,LIBS="-lmps $LIBS",BUILD_mpsolve=yes)
if test $BUILD_mpsolve = yes
then BUILTLIBS="-lmps $BUILTLIBS"
fi
AC_SUBST(LIBS_GLPK)
AC_LANG(C)
AC_CHECK_HEADER(glpk.h,,BUILD_glpk=yes)
if test $BUILD_glpk = yes
then BUILTLIBS="-lglpk $BUILTLIBS"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(glp_free,"/usr/lib/libglpk.a" "/usr/local/lib/libglpk.a",,[AC_MSG_ERROR([libglpk.a not found])])
else AC_SEARCH_LIBS(glp_free,"glpk",,[AC_MSG_ERROR([libglpk not found])])
fi
if test "none required" != "$ac_cv_search_glp_free"
then LIBS_GLPK=$ac_cv_search_glp_free
fi
fi
AC_MSG_CHECKING([whether givaro library is installed])
AC_SUBST(BUILD_givaro)
if $PKG_CONFIG --exists givaro
then AC_MSG_RESULT(yes)
LIBS="`$PKG_CONFIG --libs givaro` $LIBS"
CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags-only-I givaro`"
AC_MSG_CHECKING([whether givaro has isUnit or isunit])
AC_LANG([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [ #include <givaro/gfq.h>
],
[ class Givaro::GFqDom<long int> foo; foo.isunit(0) ])],
[AC_MSG_RESULT([isunit]); AC_DEFINE([HAVE_GIVARO_isunit], [1],[whether givaro has isunit])],
[AC_MSG_RESULT([isUnit]); AC_DEFINE([HAVE_GIVARO_isunit], [0],[whether givaro has isunit])])
else AC_MSG_RESULT(no)
AC_DEFINE([HAVE_GIVARO_isunit], [0],[whether givaro has isunit])
BUILD_givaro=yes
fi
if test $BUILD_givaro = yes
then BUILTLIBS="-lgivaro $BUILTLIBS"
fi
# We add these directories to the end, so the user can override this by setting CPPFLAGS.
# /cddlib/ is more modern than /cdd/
if test -d /usr/local/include/cddlib
then CPPFLAGS="$CPPFLAGS -I/usr/local/include/cddlib"
fi
if test -d /usr/local/include/cdd
then CPPFLAGS="$CPPFLAGS -I/usr/local/include/cdd"
fi
if test -d /usr/include/cddlib
then CPPFLAGS="$CPPFLAGS -I/usr/include/cddlib"
fi
if test -d /usr/include/cdd
then CPPFLAGS="$CPPFLAGS -I/usr/include/cdd"
fi
AC_LANG(C)
AC_CHECK_HEADER(cdd.h,,[ AC_MSG_RESULT([[cddlib not found, will build]])
BUILD_cddlib=yes],
[
#include <setoper.h>
])
if test $BUILD_cddlib = yes
then BUILTLIBS="-lcdd $BUILTLIBS"
else if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(dd_Equal,"/usr/lib/libcdd.a" "/usr/local/lib/libcdd.a",,
[AC_MSG_ERROR([cdd.h found but libcdd.a not found])])
else AC_SEARCH_LIBS(dd_Equal,"cdd",,[AC_MSG_ERROR([cdd.h found but libcdd not found])])
fi
fi
dnl factory needs to know:
AC_SUBST(BUILD_flint)
if test $BUILD_flint = no
then AC_LANG(C)
AC_MSG_CHECKING([for flint >= 2.6.3])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <flint/flint.h>
],
[
/* version == __FLINT_VERSION . __FLINT_VERSION_MINOR . __FLINT_VERSION_PATCHLEVEL */
#if (__FLINT_VERSION < 2) \
|| (__FLINT_VERSION == 2 && __FLINT_VERSION_MINOR < 6) \
|| (__FLINT_VERSION == 2 && __FLINT_VERSION_MINOR == 6 && __FLINT_VERSION_PATCHLEVEL < 3)
#error old flint
#endif
])],
AC_MSG_RESULT([yes])
if test $SHARED = no -a $TRY_STATIC = yes
then SEARCH_LIBRARIES(_fmpz_mod_mul1,/usr/lib/libflint.a /usr/local/lib/libflint.a,,
[AC_MSG_ERROR([libflint.a not found])])
else AC_SEARCH_LIBS(_fmpz_mod_mul1,"flint",,[AC_MSG_ERROR([libflint not found])])
fi,
AC_MSG_RESULT([no])
BUILD_flint=yes)
AC_CHECK_HEADERS([flint/nmod.h]) dnl only present in flint >= 2.9.0