-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathconfigure.ac
918 lines (826 loc) · 24.6 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
dnl========================================================================
dnl The Yices SMT Solver. Copyright 2017 SRI International.
dnl
dnl Yices is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl Yices is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Yices. If not, see <http://www.gnu.org/licenses/>.
dnl
dnl========================================================================
dnl
dnl Configure for Yices
dnl
dnl This builds a platform-dependent configuration
dnl file stored in configs/Makefile.$ARCH
dnl
AC_PREREQ(2.60)
AC_INIT([Yices],[2])
dnl
dnl Our public repository (used if ./configure fails)
dnl
repo_url="https://github.com/SRI-CSL/yices2"
dnl
dnl Save CFLAGS (AC_PROC_CC modifies it)
dnl
saved_cflags=$CFLAGS
dnl
dnl Build platform
dnl --------------
dnl
dnl Changed this (07/12/2012) to allow cross-compilation (patch from
dnl Dave Vitek, from Grammatch).
dnl build = platform on which we run the build
dnl host = platform for which we build
dnl
dnl Also changed AC_CHECK_PROG(LD, ..) to AC_CHECK_TOOL(LD, ...) etc.
dnl
AC_CANONICAL_BUILD
AC_SUBST(ARCH)
AC_SUBST(POSIXOS)
POSIXOS=$host_os
ARCH=$host
if test "$POSIXOS" = unknown ; then
AC_MSG_ERROR([Unknown operating system])
fi
dnl
dnl define SET_MAKE if needed
dnl -------------------------
dnl
AC_PROG_MAKE_SET
dnl
dnl Tools for building Yices
dnl ------------------------
dnl
AC_PROG_SED
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_EGREP
AC_CHECK_TOOL(LD,ld,ld)
AC_CHECK_TOOL(AR,ar,ar)
AC_CHECK_TOOL(STRIP,strip,strip)
#
# gperf generates source files. Better
# to keep AC_CHECK_PROG rather than AC_CHECK_TOOL
#
AC_CHECK_PROG(GPERF,gperf,gperf,nogperf)
#
# CHECK GPERF
# -----------
# the src/Makefile uses command-line options that appeared in version 3.0
# of gperf
#
if test "$GPERF" = nogperf; then
AC_MSG_ERROR([*** gperf not found. gperf version 3.0 or higher is required to build Yices ***])
else
AC_MSG_CHECKING([gperf version])
gperfversion=`"$GPERF" --version 2>&1 | awk '/^GNU/ { print $3 }'`
case $gperfversion in
0.* | 1.* | 2.* )
AC_MSG_RESULT([${gperfversion}])
AC_MSG_ERROR([*** found $GPERF version $gperfversion but version 3.0 or higher is required ***])
;;
3.*)
AC_MSG_RESULT([${gperfversion}])
;;
*)
AC_MSG_RESULT([${gperfversion}])
AC_MSG_WARN([*** Unexpected $GPERF output. Cannot determine version. Continuing anyway ***]);;
esac
fi
dnl
dnl Check whether the C compiler accepts the flag -fno-stack-protector
dnl -------------------------------------------------------------------
dnl
dnl Several Linux distributions (also Darwin) come with GCC that has
dnl -fstack-protector enabled by default. This may cause problems at
dnl link time on the user machine (if the user doesn't have the right
dnl runtime libraries). The symptom is:
dnl undefined reference to '__stack_chk_fail'
dnl To avoid this, we try to give flag -fno-stack-protector when
dnl compiling Yices in release mode. However, this flag is not supported
dnl by older versions of GCC (e.g., gcc-4.0.x don't seem to have it)
dnl
dnl The following test attempts to determine whether the C compiler
dnl supports -fno-stack-protector. If it does, we set variable
dnl NO_STACK_PROTECTOR to -fno-stack-protector. Otherwise, we leave
dnl NO_STACK_PROTECTOR empty
dnl
NO_STACK_PROTECTOR=""
AC_MSG_CHECKING([whether $CC accepts option -fno-stack-protector])
if $CC -fno-stack-protector -c -xc - -o /dev/null < /dev/null > /dev/null 2>&1 ; then
NO_STACK_PROTECTOR="-fno-stack-protector"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi;
AC_SUBST(NO_STACK_PROTECTOR)
dnl
dnl Check for endianness
dnl --------------------
dnl
WORDS_BIGENDIAN=""
AC_C_BIGENDIAN([WORDS_BIGENDIAN=yes],[WORDS_BIGENDIAN=no],[WORDS_BIGENDIAN=yes])
AC_SUBST(WORDS_BIGENDIAN)
dnl
dnl CHECK_THREAD_LOCAL
dnl ------------------
dnl check whether we can declare variables with the __thread
dnl attribute. If not we assume the platform doesn't support
dnl thread-local storage.
dnl
dnl result: $has_tls is "yes" if the __thread attribute is supported
dnl $has_tls is "no" otherwise
dnl
AC_DEFUN([CSL_CHECK_THREAD_LOCAL],
[
save_cppflags=$CPPFLAGS
save_libs=$LIBS
AC_MSG_CHECKING([for thread-local storage support])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[__thread int test;]],
[[]])],
has_tls=yes,has_tls=no,has_tls=no)
AC_MSG_RESULT([$has_tls])
#
# restore CPPFLAGS and LIBS
#
CPPFLAGS=$save_cppflags
LIBS=$save_libs
])
dnl
dnl GMP Libraries
dnl -------------
dnl
dnl We need as many as three different versions of GMP:
dnl
dnl To build static executables and libraries, we link with the
dnl default libgmp.a (usually /usr/local/lib/libgmp.a).
dnl
dnl To construct the yices library (libyices.so) with GMP included,
dnl we need a version of libgmp.a that's position independent code.
dnl On systems where -fPIC is not the default, we must build
dnl a specific version of GMP from the source, using option CFLAG=-fPIC.
dnl
dnl To build dynamic executables and libraries without GMP included,
dnl we need a a dynamic version of the GMP library (e.g., /usr/local/lib/libgmp.so).
dnl
dnl On mingw and cygwin, dynamic and static GMP libraries do not coexist well.
dnl They must be installed in different locations and use different gmp.h files.
dnl
dnl To deal with this, the build Makefiles use the following variables:
dnl STATIC_GMP = full path to a static version of gmp (e.g., /usr/local/lib/libgmp.a)
dnl STATIC_GMP_INCLUDE_DIR = directory where a 'gmp.h' compatible with STATIC_GMP is located
dnl (or empty if 'gmp.h' is in a standard place)
dnl
dnl PIC_GMP = full path to a libgmp.a that's PIC code
dnl PIC_GMP_INCLUDE_DIR = directory where a 'gmp.h' header file compatible with PIC_GMP
dnl is located
dnl
dnl By default, the configure script searches for a usable STATIC_GMP in default
dnl locations and sets PIC_GMP to the same thing as STATIC_GMP.
dnl
dnl If the configure script does not find STATIC_GMP or if the defaults are
dnl incorrect, the right libraries can be given as options to ./configure:
dnl
dnl --with-static-gmp=full-path-to-libgmp.a for static linking
dnl --with-static-gmp-include-dir=corresponding directory for gmp.h
dnl
dnl --with-pic-gmp=full-path-to-relocatable-libgmp.a
dnl --with-pic-gmp-include-dir=directory where the corresponding gmp.h resides
dnl
static_libgmp=""
AC_ARG_WITH([static-gmp],
[AS_HELP_STRING([--with-static-gmp=<path>],[Full path to a static GMP library (e.g., libgmp.a)])],
[if test "x$withval" = x; then
AC_MSG_WARN([--with-static-gmp was used but no path was given. Using defaults])
else
static_libgmp=$withval
fi
],
[])
static_includegmp=""
AC_ARG_WITH([static-gmp-include-dir],
[AS_HELP_STRING([--with-static-gmp-include-dir=<directory>],
[Directory of include file "gmp.h" compatible with static GMP library])],
[if test "x$withval" = x; then
AC_MSG_WARN([--with-static-gmp-include-dir was used but no directory was given. Using defaults])
else
static_includegmp=$withval
fi
],
[])
pic_libgmp=""
AC_ARG_WITH([pic-gmp],
[AS_HELP_STRING([--with-pic-gmp=<path>],[Full path to a relocatable GMP library (e.g., libgmp.a)])],
[if test "x$withval" = x; then
AC_MSG_WARN([--with-pic-gmp was used but no path was given. Using defaults])
else
pic_libgmp=$withval
fi
],
[])
pic_includegmp=""
AC_ARG_WITH([pic-gmp-include-dir],
[AS_HELP_STRING([--with-pic-gmp-include-dir=<directory>],
[Directory of include file "gmp.h" compatible with relocatable GMP library])],
[if test "x$withval" = x; then
AC_MSG_WARN([--with-pic-gmp-include-dir was used but no directory was given. Using defaults])
else
pic_includegmp=$withval
fi
],
[])
dnl
dnl Options for mcsat and the libpoly library
dnl -----------------------------------------
dnl --enable-mcsat: add support for MCSAT
dnl
dnl If mcsat is emabled, we provide options to specify
dnl the static libraries, using the same conventions as for GMP.
dnl
use_mcsat="no"
AC_ARG_ENABLE([mcsat],
[AS_HELP_STRING([--enable-mcsat],[Enable support for MCSAT. This requires the LibPoly library and the CUDD library.])],
[if test "$enableval" = yes ; then
use_mcsat="yes"
AC_MSG_NOTICE([Enabling support for MCSAT])
fi],
[])
static_lpoly=""
AC_ARG_WITH([static-libpoly],
[AS_HELP_STRING([--with-static-libpoly=<path>],[Full path to libpoly.a])],
[if test $use_mcsat = "no" ; then
AC_MSG_WARN([Ignoring option --with-static-libpoly since MCSAT support is disabled])
else
if test "x$withval" = x; then
AC_MSG_WARN([--with-static-poly was used but no path was given. Using defaults])
else
static_lpoly=$withval
fi
fi
],
[])
static_includelpoly=""
AC_ARG_WITH([static-libpoly-include-dir],
[AS_HELP_STRING([--with-static-libpoly-include-dir=<directory>],
[Path to include files compatible with libpoly.a (e.g., /usr/local/include)])],
[if test $use_mcsat = "no" ; then
AC_MSG_WARN([Ignoring option --with-static-libpoly-include-dir since MCSAT support is disabled])
else
if test "x$withval" = x; then
AC_MSG_WARN([--with-static-libpoly-include-dir was used but no directory was given. Using defaults])
else
static_includelpoly=$withval
fi
fi
],
[])
pic_lpoly=""
AC_ARG_WITH([pic-libpoly],
[AS_HELP_STRING([--with-pic-libpoly=<path>],[Full path to a relocatable libpoly.a])],
[if test $use_mcsat = "no" ; then
AC_MSG_WARN([Ignoring option --with-pic-libpoly since MCSAT support is disabled])
else
if test "x$withval" = x; then
AC_MSG_WARN([--with-pic-libpoly was used but no path was given. Using defaults])
else
pic_lpoly=$withval
fi
fi
],
[])
pic_includelpoly=""
AC_ARG_WITH([pic-libpoly-include-dir],
[AS_HELP_STRING([--with-pic-libpoly-include-dir=<directory>],
[Path to include files compatible with the relocatable libpoly.a])],
[if test $use_mcsat = "no" ; then
AC_MSG_WARN([Ignoring option --with-pic-libpoly-include-dir since MCSAT support is disabled])
else
if test "x$withval" = x; then
AC_MSG_WARN([--with-pic-libpoly-include-dir was used but no directory was given. Using defaults])
else
pic_includelpoly=$withval
fi
fi
],
[])
dnl
dnl Option to enable thread-safety
dnl ------------------------------
dnl --enable-thread-safety
dnl
dnl The default is don't build thread safe. If the --enable-thread-safety
dnl is given, we check whether thread-local storage is supported.
dnl
thread_safe="no"
AC_ARG_ENABLE([thread-safety],
[AS_HELP_STRING([--enable-thread-safety],[Build in thread-safe mode.])],
[if test "$enableval" = yes ; then
thread_safe="yes"
AC_MSG_NOTICE([Enabling thread-safe build])
fi],
[])
dnl
dnl CSL_COLLECT_LIBRARY_PATHS
dnl -------------------------
dnl Sets variable search_libs to a default list of directories in which to search for libraries.
dnl The list include /usr/local/lib /usr/lib /lib + directories found by
dnl ld --verbose + LD_LIBRARY_PATH + DYLD_LIBRARY_PATH + LDFLAGS if non-empty.
dnl
AC_DEFUN([CSL_COLLECT_LIBRARY_PATHS],
[
#
# Some (non-GNU) versions of ld do not recognize --verbose
#
# Also, some versions of GNU ld have things like SEARCH_DIR(=/usr/local/lib32)
# and the '=' causes us trouble.
#
# man ld says
# If searchdir begins with "=", then the "=" will be replaced by the
# sysroot prefix, a path specified when the linker is configured.
#
# We ignore this here. If the search dir starts with =, we remove =
#
# NOTE: this sed command uses \? which, is a GNU extension.
#
if ld --verbose > /dev/null 2>&1; then
base_libs=`ld --verbose | grep SEARCH_DIR | sed -e 's,SEARCH_DIR(\"\?=\?,,g' -e 's,\"\?);,,g' | sed -e 's,SEARCH_DIR(\",,g' -e 's,\");,,g' `
else
base_libs=""
fi
#
# Add LD_LIBRARY_PATH or DYLD_LIBRARY_PATH if they are defined
#
if test "x$LD_LIBRARY_PATH" != x; then
aux_libs=`echo $LD_LIBRARY_PATH | sed -e 's,:, ,g'`
else
if test "x$DYLD_LIBRARY_PATH" != x; then
aux_libs=`echo $DYLD_LIBRARY_PATH | sed -e 's,:, ,g'`
else
aux_libs=""
fi
fi
search_libs="$aux_libs $base_libs /usr/local/lib /usr/lib /lib"
#
# Add other libraries from $LDFLAGS
#
prev_l_opt=false
for ld_arg in $LDFLAGS; do
if test "$prev_l_opt" = "true"; then
search_libs=" $ld_arg $search_libs"
else
if test "$ld_arg" = "-L"; then
prev_l_opt=true
else
libprefix=`echo $ld_arg | cut -c -2`
body=`echo $ld_arg | cut -c 3-`
if test "$libprefix" = "-L"; then
search_libs=" $body $search_libs"
else
libprefix=`echo $ld_arg | cut -c -15`
body=`echo $ld_arg | cut -c 16-`
if test "$libprefix" = "--library-path"; then
search_libs=" $body $search_libs"
fi
fi
fi
fi
done
])
dnl
dnl CSL_CHECK_LIB_PATH(path,option)
dnl ----------------------------------
dnl path should be the full path to a static library.
dnl this checks whether the given file exists. Prints an
dnl error and exit otherwise.
dnl
dnl If the test succeeds, set variable testlib to path.
dnl
AC_DEFUN([CSL_CHECK_LIB_PATH],
[
testlib=""
AC_MSG_CHECKING([for $1])
if test -f $1; then
AC_MSG_RESULT(found)
testlib=$1
else
AC_MSG_RESULT(no)
AC_MSG_ERROR([*** $1 was not found: Check option $2 ***])
fi
])
dnl
dnl CSL_CHECK_HEADER(header,includedir,option)
dnl ----------------------------------------
dnl check whether a header file like 'gmp.h' is present in includedir
dnl set variable $testincludedir to includedir if so
dnl exit otherwise.
dnl if includedir is empty, just set testincludedir to empty string too
dnl
dnl option must be the '--with-...-include-dir from which includedir was given
dnl it's used to print the error message.
dnl
AC_DEFUN([CSL_CHECK_HEADER],
[
testincludedir=""
if test "x$2" != x; then
if test -d "$2" ; then
if test -f "$2/$1" ; then
testincludedir="$2"
else
AC_MSG_ERROR([*** $1 not found in $2. Check option $3 ***])
fi
else
AC_MSG_ERROR([*** directory $2 not found. Check option $3 ***])
fi
fi
])
dnl
dnl CSL_CHECK_GMP(libgmp,includedir)
dnl --------------------------------
dnl attempt to compile a test program that calls a gmp function
dnl set run_ok to "yes" if the program executes and exits with 0
dnl set run_ok to "no" otherwise
dnl
dnl libgmp must be the full-path name to the library to test
dnl includedir must be the directory where the corresponding 'gmp.h'
dnl can be found
dnl
AC_DEFUN([CSL_CHECK_GMP],
[
save_cppflags=$CPPFLAGS
save_libs=$LIBS
#
# Add -I option to CPPFLAGS (it must be first)
# Add $1 to LIBS
#
if test "x$2" != x ; then
CPPFLAGS="-I$2 $CPPFLAGS"
fi
LIBS="$1 -lm"
AC_MSG_CHECKING([whether $1 is usable])
#
# Test program: check whether the GMP version is recent enough
#
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <gmp.h>
mpz_t tst;
]],
[[
mpz_init(tst);
mpz_clear(tst);
if ((__GNU_MP_VERSION < 4) ||
((__GNU_MP_VERSION == 4) && (__GNU_MP_VERSION_MINOR < 1))) {
return 1;
}
]])
],run_ok=yes,run_ok=no,run_ok=yes)
AC_MSG_RESULT([$run_ok])
#
# restore CPPFLAGS and LIBS
#
CPPFLAGS=$save_cppflags
LIBS=$save_libs
])
dnl
dnl CSL_CHECK_STATIC_GMP(libgmp,includedir)
dnl ------------------------------------
dnl try to find the full path to a usable libgmp.a, use $1 if not empty.
dnl if $2 is not empty, then the checks are compiled with -I$2
dnl if everything works, then set STATIC_GMP to the fullpath for libgmp.a
dnl and set STATIC_GMP_INCLUDE_DIR to $2
dnl
dnl
AC_DEFUN([CSL_CHECK_STATIC_GMP],
[
AC_MSG_NOTICE([Trying to find a usable libgmp.a])
CSL_CHECK_HEADER([gmp.h],$2,--with-static-gmp-include-dir)
#
# if $1 is not given, search for it in library paths
#
if test -z "$1"; then
CSL_COLLECT_LIBRARY_PATHS
#
# now $search_libs contains all the directories to search
#
AC_MSG_NOTICE([Searching in $search_libs])
for ldir in $search_libs; do
AC_MSG_CHECKING([for libgmp.a in $ldir])
if test -f $ldir/libgmp.a; then
AC_MSG_RESULT(found)
testlib=$ldir/libgmp.a
CSL_CHECK_GMP($testlib,$testincludedir)
if test $run_ok = yes; then
STATIC_GMP=$testlib
STATIC_GMP_INCLUDE_DIR=$testincludedir
break
fi
else
AC_MSG_RESULT(no)
fi
done
#
#
else
#
# User gave option --with-static-gmp=xxx
# Check whether the specified xxx actually works
#
CSL_CHECK_LIB_PATH($1,--with-static-gmp)
CSL_CHECK_GMP($testlib,$testincludedir)
if test $run_ok = yes; then
STATIC_GMP=$testlib
STATIC_GMP_INCLUDE_DIR=$testincludedir
else
AC_MSG_ERROR([*** $1 does not appear to be usable: check option --with-static-gmp ***])
fi
fi
if test "x$STATIC_GMP" = x; then
AC_MSG_WARN([*** No usable libgmp.a library was found ***])
fi
])
dnl
dnl CSL_CHECK_LIBPOLY(libpoly,includedir,libs)
dnl ------------------------------------------
dnl attempt to compile and run a test program that calls libpoly
dnl set run_ok to "yes" if the program executes and exits with 0.
dnl set run_ok to "no" otherwise.
dnl
dnl libpoly must be the full-path name to the library to test.
dnl includedir must be a directory with 'poly/polyn.h' can be found.
dnl libs may contain GMP libraries to use
dnl
AC_DEFUN([CSL_CHECK_LIBPOLY],
[
save_cppflags=$CPPFLAGS
save_libs=$LIBS
#
# Add the -I option to CPPFLAGS
# Add $1 then $3 to LIBS
#
if test "x$2" != x ; then
CPPFLAGS="-I$2 $CPPFLAGS"
fi
LIBS="$1"
if test "x$3" != x ; then
LIBS="$LIBS $3"
fi
AC_MSG_CHECKING([whether $1 is usable])
#
# Test program
#
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <poly/variable_db.h>
#include <poly/variable_order.h>
#include <poly/polynomial_context.h>
#include <poly/polynomial.h>
]],
[[
lp_variable_db_t* var_db = lp_variable_db_new();
lp_variable_order_t* var_order = lp_variable_order_new();
lp_polynomial_context_t* ctx = lp_polynomial_context_new(lp_Z, var_db, var_order);
lp_polynomial_t* p = lp_polynomial_new(ctx);
lp_polynomial_delete(p);
lp_polynomial_context_detach(ctx);
lp_variable_order_detach(var_order);
lp_variable_db_detach(var_db);
]])
],run_ok=yes,run_ok=no,run_ok=no)
AC_MSG_RESULT([$run_ok])
#
# restore CPPFLAGS and LIBS
#
CPPFLAGS=$save_cppflags
LIBS=$save_libs
])
dnl
dnl CSL_CHECK_STATIC_LIBPOLY(libpoly,includedir)
dnl --------------------------------------------
dnl Try to find a usable libpoly.a.
dnl If $1 is not empty, it's assumed to be the full path to libpoly.a
dnl If $2 is not empty, it's assumed to be the path to the
dnl corresponding include directory (i.e., the relevant headers are
dnl assumed to be in $2/poly/...
dnl If $3 is not empty, it's the GMP library to use
dnl
dnl If the test succeeds. then this macro sets STATIC_LIBPOLY to
dnl the full path for libpoly.a and STATIC_LIBPOLY_INCLUDE_DIR to $2.
dnl
AC_DEFUN([CSL_CHECK_STATIC_LIBPOLY],
[
AC_MSG_NOTICE([Searching for a usable libpoly.a])
CSL_CHECK_HEADER([poly/polynomial.h],$2,--with-static-libpoly-include-dir)
#
# If $1 is empty search for it in the
#
if test -z "$1" ; then
CSL_COLLECT_LIBRARY_PATHS
#
# $search_libs contains the directories to search
#
AC_MSG_NOTICE([Searching in $search_libs])
for ldir in $search_libs ; do
AC_MSG_CHECKING([for libpoly.a in $ldir])
if test -f $ldir/libpoly.a ; then
AC_MSG_RESULT(found)
testlib=$ldir/libpoly.a
CSL_CHECK_LIBPOLY($testlib,$testincludedir,$3)
if test $run_ok = yes ; then
STATIC_LIBPOLY=$testlib
STATIC_LIBPOLY_INCLUDE_DIR=$testincludedir
break
fi
else
AC_MSG_RESULT(no)
fi
done
#
else
# got --with-static-libpoly=xxxx
CSL_CHECK_LIB_PATH($1,--with-static-libpoly)
CSL_CHECK_LIBPOLY($testlib,$testincludedir,$3)
if test $run_ok = yes; then
STATIC_LIBPOLY=$testlib
STATIC_LIBPOLY_INCLUDE_DIR=$testincludedir
else
AC_MSG_ERROR([*** $1 does not appear to be usable: check option --with-static-libpoly ***])
fi
fi
if test "x$STATIC_LIBPOLY" = x; then
AC_MSG_WARN([*** No usable libpoly.a library was found ***])
fi
])
#
# CHECK LIBRARIES
# ---------------
#
AC_LANG([C])
#
# We must search for the static versions first
# since other tests may modify $LIBS and $CPPFLAGS
#
STATIC_GMP=""
STATIC_GMP_INCLUDE_DIR=""
AC_SUBST(STATIC_GMP)
AC_SUBST(STATIC_GMP_INCLUDE_DIR)
CSL_CHECK_STATIC_GMP($static_libgmp,$static_includegmp)
#
# Position-independent static version of GMP
#
PIC_GMP="$STATIC_GMP"
PIC_GMP_INCLUDE_DIR="$STATIC_GMP_INCLUDE_DIR"
AC_SUBST(PIC_GMP)
AC_SUBST(PIC_GMP_INCLUDE_DIR)
if test "x$pic_libgmp" != x ; then
#
# --with-pic-gmp was given on the command line
#
CSL_CHECK_HEADER([gmp.h],$pic_includegmp,--with-pic-gmp-include-dir)
CSL_CHECK_LIB_PATH($pic_libgmp,--with-pic-gmp)
CSL_CHECK_GMP($testlib,$testincludedir)
if test $run_ok = yes; then
PIC_GMP=$testlib
PIC_GMP_INCLUDE_DIR=$testincludedir
else
AC_MSG_ERROR([*** $testlib does not appear to be usable: check option --with-pic-gmp ***])
fi
fi
#
# We need -lm (for fclassify)
#
AC_CHECK_LIB([m], [main], [], [])
#
# MCSAT SUPPORT
# -------------
ENABLE_MCSAT="$use_mcsat"
AC_SUBST(ENABLE_MCSAT)
#
# libpoly.a
#
STATIC_LIBPOLY=""
STATIC_LIBPOLY_INCLUDE_DIR=""
AC_SUBST(STATIC_LIBPOLY)
AC_SUBST(STATIC_LIBPOLY_INCLUDE_DIR)
if test $use_mcsat = yes ; then
if test "x$STATIC_GMP" = x ; then
auxlibs="-lgmp"
else
auxlibs="$STATIC_GMP"
fi
CSL_CHECK_STATIC_LIBPOLY($static_lpoly,$static_includelpoly,$auxlibs)
fi
#
# Position-independent static version of LIBPOLY
#
PIC_LIBPOLY="$STATIC_LIBPOLY"
PIB_LIBPOLY_INCLUDE_DIR="$STATIC_LIBPOLY_INCLUDE_DIR"
AC_SUBST(PIC_LIBPOLY)
AC_SUBST(PIC_LIBPOLY_INCLUDE_DIR)
if test $use_mcsat = yes ; then
if test "x$pic_lpoly" != x ; then
CSL_CHECK_HEADER([poly/polynomial.h],$pic_includelpoly,--with-pic-libpoly-include-dir)
CSL_CHECK_LIB_PATH($pic_lpoly,--with-pic-lpoly)
if test "x$PIC_GMP" != x ; then
auxlibs="$PIC_GMP"
else
if test "x$STATIC_GMP" != x ; then
auxlibs="$STATIC_GMP"
else
auxlibs="-lgmp"
fi
fi
CSL_CHECK_STATIC_LIBPOLY($pic_lpoly,$pic_includelpoly,$auxlibs)
if test $run_ok = yes; then
PIC_LIBPOLY=$testlib
PIC_LIBPOLY_INCLUDE_DIR=$testincludedir
else
AC_MSG_ERROR([*** $testlib does not appear to be usable: check option --with-pic-libpoly ***])
fi
fi
fi
#
# Default GMP
#
AC_CHECK_LIB(gmp, __gmpz_cmp, [],
[AC_MSG_ERROR([*** GMP library not found. Try to set LDFLAGS ***])])
#
# Default libpoly
#
if test $use_mcsat = yes ; then
AC_CHECK_LIB([poly],[lp_polynomial_new], [], [AC_MSG_ERROR([*** libpoly library not found. Try to set LDFLAGS ***])])
fi
#
# Default CUDD
#
if test $use_mcsat = yes ; then
AC_CHECK_LIB([cudd],[Cudd_Init], [], [AC_MSG_ERROR([*** CUDD library not found. Try to set LDFLAGS ***])])
fi
#
# Fix MKDIR_P to an absolute path if it's set to './install-sh -c -d'
# because the Makefiles import its definition via ./configs/make.include.
# This may be unreliable (it won't handle spaces in directory names).
#
# case "$MKDIR_P" in
# ./install-sh*)
# curdir=`pwd`
# new_mkdir_p="$curdir/$MKDIR_P"
# AC_MSG_WARN([*** MKDIR_P is relative: converting $MKDIR_P to $new_mkdir_p ***])
# MKDIR_P=$new_mkdir_p
# ;;
# esac
#
#
# THREAD-SAFE OPTION
# ------------------
#
AC_SUBST(THREAD_SAFE)
if test "x$thread_safe" = xyes ; then
THREAD_SAFE=1
fi
dnl
dnl Test support for thread-local storage
dnl -------------------------------------
dnl
AC_SUBST(HAVE_TLS)
if test "x$thread_safe" = xyes ; then
has_tls=""
CSL_CHECK_THREAD_LOCAL
if test "x$has_tls" = xyes; then
HAVE_TLS=1
else
AC_MSG_ERROR([Building with --enable-thread-safety requires thread-local storage])
fi
fi
dnl AC_CHECK_HEADERS([poly/poly.h], [], [AC_MSG_ERROR([*** libpoly headers not found. Try to set CPPFLAGS ***])])
#
# Restore CFLAGS
#
CFLAGS=$saved_cflags
#
# Store config data in ./configs/make.include.$(ARCH)
#
AC_CONFIG_FILES([make.include])
AC_OUTPUT
if test ! -d configs ; then
AC_MSG_NOTICE([Creating the configs directory])
AS_MKDIR_P([configs])
fi
if test "x$host" = x ; then
AC_MSG_NOTICE([Moving make.include to configs/make.include.$build])
mv make.include "configs/make.include.$build"
else
AC_MSG_NOTICE([Moving make.include to configs/make.include.$host])
mv make.include "configs/make.include.$host"
fi