-
Notifications
You must be signed in to change notification settings - Fork 9
/
configure
executable file
·1992 lines (1859 loc) · 61.5 KB
/
configure
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
#! /bin/sh
sysname='Sundials/ML'
version=6.1.1
versionp=1
contact='[email protected]'
unset prefix
unset libdir
unset stubdir
unset docdir
unset install_docs
unset os_distribution
enable_mpi=1
enable_openmp=1
enable_klu=1
enable_superlumt=1
unset enable_debug
unset mathjax
opt_compiler=1
cflags_openmp=
unset mpi_lib_path
unset Lmpi_lib_path
ocaml_tweaks=
other_tweaks=
unset EXAMPLESROOT
debug_configure=false
logfile=/dev/null
bounds_checking=1
ocaml_warnings='+a-4-9-30-41-42-70'
configure_command="$0"
for option in "$@"
do
case "$option" in
--ignore-envs)
OCAMLROOT=
SUNDIALS_DIR=
SUNDIALS_LIBRARY_DIR=
SUNDIALS_INCLUDE_DIR=
SUPERLUMT_DIR=
SUPERLUMT_INCLUDE_DIR=
SUPERLUMT_LIBRARY_DIR=
KLU_INCLUDE_DIR=
KLU_LIBRARY_DIR=
LAPACKLIB=
SUNDIALS_EXAMPLES_DIR=
OCAMLMPI=
MPICC=
MPIRUN=
MPI_LIBRARY_DIR=
MATHJAX=
CFLAGS_OPENMP=
CC=
CPP=
;;
esac
done
for option in "$@"
do
# Try to quote configure_command so that it can be cut-and-pasted to the
# command line. Not a perfect solution, but works for common cases.
configure_command="${configure_command} '$option'"
name=`expr "$option" : "\([^=]*\).*"`
value=`expr "$option" : "[^=]*=\(.*\)"`
case "$name" in
--prefix)
prefix="${value%/}/";;
--libdir)
libdir="${value%/}/";;
--stubdir)
stubdir="${value%/}/";;
--docdir)
docdir="${value%/}/";;
--os-distribution)
os_distribution="${value}";;
--disable-doc)
install_docs=0;;
--disable-mpi)
enable_mpi=0;;
--disable-openmp)
enable_openmp=0;;
--disable-klu)
enable_klu=0;;
--disable-superlumt)
enable_superlumt=0;;
--enable-debug)
ocaml_tweaks="${ocaml_tweaks} debug"
enable_debug=1;;
--unsafe)
ocaml_tweaks="${ocaml_tweaks} unsafe"
bounds_checking=0;;
--no-opt-compiler) # not meant for users (under normal circumstances)
opt_compiler=0;;
--debug-configure)
debug_configure=true
logfile="config.debug"
echo >${logfile};;
-h|--help)
cat <<-END_HELP_TEXT
'configure' configures $sysname ${version}p${versionp} to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Those variables can be set in the shell to affect all future invocations
of $0.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--ignore-envs ignore variables set in the shell
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
For better control, use the options below.
Fine tuning of the installation directories:
--libdir=DIR installation directory [OCAML]
--stubdir=DIR stub installation directory [OCAML/stublibs]
--docdir=DIR documentation [PREFIX/share/doc/sundialsml]
Optional Features:
--disable-doc do not install html documentation
--disable-mpi build without parallel features
--disable-openmp build without OpenMP features
--disable-klu build without KLU features
--disable-superlumt build without SuperLU/MT features
--no-lib-path do not record paths in the OCaml library
--enable-debug enable assertions and debug symbols
--unsafe no bounds or other runtime checks
Influential environment variables:
OCAMLROOT Path to OCaml installation
SUNDIALS_DIR Path to Sundials installation
SUNDIALS_LIBRARY_DIR Path to Sundials libraries (for linking)
(default: \$SUNDIALS_DIR/lib)
SUNDIALS_INCLUDE_DIR Path to Sundials header files (for compiling)
(default: \$SUNDIALS_DIR/include)
SUPERLUMT_DIR Path to SuperLU_MT build files
SUPERLUMT_INCLUDE_DIR Path to SuperLU_MT header files
(default: \$SUPERLUMT_DIR/SRC)
SUPERLUMT_LIBRARY_DIR Path to SuperLU_MT libraries
(default: \$SUPERLUMT_DIR/lib)
KLU_INCLUDE_DIR Path to KLU (SuiteSparse) header files
KLU_LIBRARY_DIR Path to KLU (SuiteSparse) libraries
LAPACKLIB Command for linking with Lapack (default: -llapack)
(sometimes also: -lSimTKlapack)
SUNDIALS_EXAMPLES_DIR Path to installed examples (for comparison with Sundials)
(default: \$SUNDIALS_DIR/examples)
OCAMLMPI Path to OCamlMPI installation
CFLAGS_OPENMP Compiler flag to enable OpenMP compilation
MPICC Name of the MPI compiler (default: mpicc)
MPIRUN Name of MPI program launcher (default: mpirun)
MPI_LIBRARY_DIR Path to include for MPI libraries (optional)
MATHJAX Local or remote directory containing MathJax.js
(e.g., MATHJAX=/usr/share/javascript/mathjax)
OCAML_GRAPHICS Path to OCaml graphics library (for some examples)
Set these options by passing arguments of the form FOO=value to help
configure find libraries and programs with nonstandard names/locations.
Report bugs to <$contact>.
END_HELP_TEXT
exit 0
;;
--ignore-envs)
: # Handled above.
;;
OCAMLROOT)
OCAMLROOT="${value}";;
SUNDIALS_DIR)
SUNDIALS_DIR="${value}";;
SUNDIALS_LIBRARY_DIR)
SUNDIALS_LIBRARY_DIR="${value}";;
SUNDIALS_INCLUDE_DIR)
SUNDIALS_INCLUDE_DIR="${value}";;
SUPERLUMT_DIR)
SUPERLUMT_DIR="${value}";;
SUPERLUMT_LIBRARY_DIR)
SUPERLUMT_LIBRARY_DIR="${value}";;
SUPERLUMT_INCLUDE_DIR)
SUPERLUMT_INCLUDE_DIR="${value}";;
KLU_LIBRARY_DIR)
KLU_LIBRARY_DIR="${value}";;
KLU_INCLUDE_DIR)
KLU_INCLUDE_DIR="${value}";;
CFLAGS_OPENMP)
CFLAGS_OPENMP="${value}";;
LAPACKLIB)
LAPACKLIB="${value}";;
SUNDIALS_EXAMPLES_DIR)
SUNDIALS_EXAMPLES_DIR="${value}";;
CC)
CC="${value}";;
CPPFLAGS)
CPPFLAGS="${value}";;
CFLAGS)
CFLAGS="${value}";;
LDFLAGS)
LDFLAGS="${value}";;
OCAMLMPI)
OCAMLMPI="${value}";;
OCAMLFLAGS)
OCAMLFLAGS="${value}";;
OCAMLOPTFLAGS)
OCAMLOPTFLAGS="${value}";;
OCAMLMKLIBFLAGS)
OCAMLMKLIBFLAGS="${value}";;
MPICC)
MPICC="${value}";;
MPIRUN)
MPIRUN="${value}";;
MPI_LIBRARY_DIR)
MPI_LIBRARY_DIR="${value}";;
MATHJAX)
MATHJAX="${value}";;
OCAML_GRAPHICS)
OCAML_GRAPHICS="${value%/}";;
*)
printf "illegal option \"%s\".\n" "$option" 1>&2; exit 2;;
esac
done
if [ -f /etc/debian_version ]; then
distribution=debian
elif [ -f /etc/centos-release ]; then
distribution=centos
elif [ -f /etc/gentoo-release ]; then
distribution=gentoo
elif [ -f /etc/fedora-release ]; then
distribution=fedora
KLU_INCLUDE_DIR="${KLU_INCLUDE_DIR:-/usr/include/suitesparse/}"
elif [ -f /etc/arch-release ]; then
distribution=arch
elif [ -f /etc/alpine-release ]; then
distribution=alpine
else
case $(uname -s) in
Darwin) distribution=macos ;;
*) distribution=unknown ;;
esac
fi
case "${os_distribution}" in
macports)
prefix="${prefix:-/opt/local/}"
SUNDIALS_DIR="${SUNDIALS_DIR:-/opt/local/}"
KLU_LIBRARY_DIR="${KLU_LIBRARY_DIR:-/opt/local/lib/}"
KLU_INCLUDE_DIR="${KLU_INCLUDE_DIR:-/opt/local/include/}"
;;
*)
esac
if [ x"${OCAMLROOT}" != x ]; then
OCAMLBIN="${OCAMLROOT%/}/bin/"
fi
if [ x"${SUNDIALS_LIBRARY_DIR}" != x ]; then
sundials_lib_path="${SUNDIALS_LIBRARY_DIR%/}"
Lsundials_lib_path="-L${sundials_lib_path}"
fi
if [ x"${SUNDIALS_INCLUDE_DIR}" != x ]; then
sundials_inc_path="${SUNDIALS_INCLUDE_DIR%/}"
Isundials_inc_path="-isystem ${sundials_inc_path}"
fi
if [ x"${SUNDIALS_DIR}" != x ]; then
if [ "x${sundials_lib_path}" = x ]; then
sundials_lib_path="${SUNDIALS_DIR%/}/lib/"
Lsundials_lib_path="-L${sundials_lib_path}"
fi
if [ "x${sundials_inc_path}" = x ]; then
sundials_inc_path="${SUNDIALS_DIR%/}/include/"
Isundials_inc_path="-isystem ${sundials_inc_path}"
fi
if [ x"${SUNDIALS_EXAMPLES_DIR}" = x ]; then
SUNDIALS_EXAMPLES_DIR="${SUNDIALS_DIR%/}/examples/"
fi
fi
if [ x"${SUNDIALS_EXAMPLES_DIR}" != x ]; then
if [ ! -d "${SUNDIALS_EXAMPLES_DIR%/}/cvode/serial" ]; then
msg="ignoring invalid examples directory (${SUNDIALS_EXAMPLES_DIR%})"
warning="${warning}\n\t${msg}"
SUNDIALS_EXAMPLES_DIR=
else
EXAMPLESROOT="${SUNDIALS_EXAMPLES_DIR%/}"
fi
fi
if [ x"${SUNDIALS_EXAMPLES_DIR}" = x -a "${distribution}" = debian ]; then
if [ -d "/usr/share/doc/libsundials-serial-dev/examples/cvode/serial" ]; then
EXAMPLESROOT=/usr/share/doc/libsundials-serial-dev/examples
elif [ -d "/usr/share/doc/libsundials-dev/examples/cvode/serial" ]; then
EXAMPLESROOT=/usr/share/doc/libsundials-dev/examples
fi
fi
if [ x"${SUPERLUMT_DIR}" != x ]; then
if [ x"${SUPERLUMT_INCLUDE_DIR}" = x ]; then
SUPERLUMT_INCLUDE_DIR="${SUPERLUMT_DIR%/}/SRC"
fi
if [ x"${SUPERLUMT_LIBRARY_DIR}" = x ]; then
SUPERLUMT_LIBRARY_DIR="${SUPERLUMT_DIR%/}/lib"
fi
fi
if [ x"${SUPERLUMT_INCLUDE_DIR}" != x ]; then
superlumt_inc_path="${SUPERLUMT_INCLUDE_DIR%/}"
Isuperlumt_inc_path="-isystem ${superlumt_inc_path}"
elif [ "${distribution}" = centos ]; then
superlumt_inc_path="/usr/include/SuperLUMT/"
Isuperlumt_inc_path="-isystem ${superlumt_inc_path}"
fi
if [ x"${SUPERLUMT_LIBRARY_DIR}" != x ]; then
superlumt_lib_path="${SUPERLUMT_LIBRARY_DIR%/}"
Lsuperlumt_lib_path="-L${superlumt_lib_path}"
fi
if [ x"${KLU_INCLUDE_DIR}" != x ]; then
klu_inc_path="${KLU_INCLUDE_DIR%/}"
Iklu_inc_path="-isystem ${klu_inc_path}"
elif [ "${distribution}" = debian ] || [ "${distribution}" = centos ]; then
klu_inc_path="/usr/include/suitesparse/"
Iklu_inc_path="-isystem ${klu_inc_path}"
elif [ "${distribution}" = macos ]; then
klu_inc_path="/usr/local/include/"
Iklu_inc_path="-isystem ${klu_inc_path}"
fi
if [ x"${KLU_LIBRARY_DIR}" != x ]; then
klu_lib_path="${KLU_LIBRARY_DIR%/}"
Lklu_lib_path="-L${klu_lib_path}"
fi
if [ x"${CFLAGS_OPENMP}" != x ]; then
cflags_openmp="${CFLAGS_OPENMP}"
fi
if [ x"${CPPFLAGS}" != x ]; then
cppflags="${CPPFLAGS}"
fi
if [ x"${CFLAGS}" != x ]; then
cflags="${CFLAGS}"
fi
if [ x"${LDFLAGS}" != x ]; then
ldflags="${LDFLAGS}"
fi
if [ x"${OCAMLFLAGS}" != x ]; then
ocamlflags="${OCAMLFLAGS}"
fi
if [ x"${OCAMLOPTFLAGS}" != x ]; then
ocamloptflags="${OCAMLOPTFLAGS}"
fi
if [ x"${OCAMLMKLIBFLAGS}" != x ]; then
ocamlmklibflags="${OCAMLMKLIBFLAGS}"
fi
if [ x"${MPICC}" != x ]; then
mpicc="${MPICC}"
fi
if [ x"${MPIRUN}" != x ]; then
mpirun="${MPIRUN}"
fi
if [ x"${MPI_LIBRARY_DIR}" != x ]; then
mpi_lib_path="${MPI_LIBRARY_DIR%/}"
Lmpi_lib_path="-L${MPI_LIBRARY_DIR%/}"
fi
if [ x"${MATHJAX}" != x ]; then
mathjax="${MATHJAX}"
fi
CC=${CC:-cc}
CPP=${CPP:-${CC} -E}
LAPACKLIB=${LAPACKLIB:-"-llapack"}
error=""
if [ "x${prefix}" = x ]; then
case "${os_distribution}" in
macports)
prefix=/opt/local/ ;;
*)
prefix=/usr/local/ ;;
esac
case `uname -s` in
Darwin)
# OS X does not search /usr/local by default.
if [ "x${sundials_lib_path}" = x ]; then
sundials_lib_path="${prefix}lib/"
Lsundials_lib_path="-L${sundials_lib_path}"
fi
if [ "x${sundials_inc_path}" = x ]; then
sundials_inc_path="${prefix}include/"
Isundials_inc_path="-isystem ${sundials_inc_path}"
fi
if [ "x${superlumt_lib_path}" = x ]; then
superlumt_lib_path="${prefix}lib/"
Lsuperlumt_lib_path="-L${superlumt_lib_path}"
fi
if [ "x${klu_lib_path}" = x ]; then
klu_lib_path="${prefix}lib/"
Lklu_lib_path="-L${klu_lib_path}"
fi
esac
fi
if [ ${bounds_checking} -eq 0 ]; then
ocamloptflags="-unsafe ${ocamloptflags}"
ocamlflags="-unsafe ${ocamlflags}"
fi
# C compiler's output file names
if uname -s | grep -q MINGW; then
XA=.lib
XO=.obj
XS=.dll
XX=.exe
else
XA=.a
XO=.o
XS=.so
XX=
fi
# Check C compiler: detect gcc and add a default optimization level.
test_stem=__configure_test_file__gcc
test_cmd="$CC -c $test_stem.c"
echo "/* $test_cmd */" > $test_stem.c
echo "#ifndef __GNUC__" >> $test_stem.c
echo "#error not gcc" >> $test_stem.c
echo "#endif" >> $test_stem.c
using_gcc=false
${test_cmd} >>${logfile} 2>&1 && using_gcc=true
${debug_configure} || rm -f ./$test_stem.*
if [ $using_gcc = true ]; then
c_suppress_warnings=-w
else
c_suppress_warnings=
fi
if [ "x${cflags}" = x ]; then # Don't touch CFLAGS if explicitly given.
if [ $using_gcc = true ]; then
optflags="-O3"
# Compiling with -O2 and clang-602.0.49 (Apple LLVM version 6.1.0)
# Results in a segfault in examples like
# cvode/serial/cvKrylovDemo_proc (in denseAddIdentity)
# due to a miscompilation of sundials_ml.c:c_sundials_realarray2_wrap
# (The code generated for the loop:
# table[0] = (realtype *)(ba->data);
# for (j = 1; j < nc; ++j) {
# table[j] = table[j - 1] + nr;
# }
# is incorrect. To see, add this loop afterward:
# for (j = 0; j < nc; ++j)
# printf("table[%d] = %p\n", j, table[j]);
# TPB was unable to extract a minimum example.)
if $CC -v 2>&1 | grep -q 'LLVM version 6.1'; then
optflags="-O1"
fi
if [ "x$enable_debug" = x1 ]; then
cflags="-O0 -Wall -Werror -g3"
else
cflags="$optflags -Wall -Werror -Wno-error=deprecated-declarations"
fi
else
echo "<info> Your C compiler seems to be different from gcc. Make"
echo "<info> sure you set optimization flags explicitly with CFLAGS."
fi
fi
if [ "x$enable_debug" = x1 ]; then
ocamloptflags="${ocamloptflags} -g"
ocamlflags="${ocamlflags} -g"
if [ $using_gcc = true ]; then
# This case is handled above.
:
else
cflags="${cflags} -g"
fi
cppflags="${cppflags}"
else
cflags="${cflags} -DNDEBUG=1"
cppflags="${cppflags} -DNDEBUG=1"
fi
arch=`uname -m`
case ${arch} in
x86_64)
cflags="${cflags} -fPIC"
;;
aarch64)
cflags="${cflags} -fPIC"
;;
*)
:
;;
esac
ml_cppflags="-P -traditional-cpp"
case `uname -s` in
Darwin*)
ml_cppflags="${ml_cppflags} -x c -Wno-invalid-pp-token"
;;
*)
ml_cppflags="${ml_cppflags} -x c"
;;
esac
# Check for Sundials installation (and version)
test_stem=__configure_test_file_sundialsversion0
cat > $test_stem.c <<EOF
// ${CPP} ${cppflags} ${Isundials_inc_path} -P $test_stem.c
#include "sundials/sundials_config.h"
SUNDIALS_PACKAGE_VERSION
EOF
sundials_version=$(${CPP} ${cppflags} ${Isundials_inc_path} \
-P $test_stem.c 2>>${logfile} \
| tail -1 | sed -e 's/ //g' -e 's/"//g')
${debug_configure} || rm -f ./$test_stem.c
Lsundials_arkode=
arkode_mlobj_main=
arkode_cobj_main=
arkode_mlobj_bbd=
arkode_cobj_bbd=
arkode_cobj_sens=
arkode_subdir=
arkode_enabled=
if [ "${sundials_version}" = "SUNDIALS_PACKAGE_VERSION" ] \
|| [ "x${sundials_version}" = x ]
then
test_stem=__configure_test_file_sundialsversion1
cat > $test_stem.c <<EOF
// ${CPP} ${cppflags} ${Isundials_inc_path} -P $test_stem.c
#include "sundials/sundials_config.h"
SUNDIALS_VERSION
EOF
sundials_version=$(${CPP} ${cppflags} ${Isundials_inc_path} \
-P $test_stem.c 2>>${logfile} \
| tail -1 | sed -e 's/ //g' -e 's/"//g')
${debug_configure} || rm -f ./$test_stem.c
fi
if [ "${sundials_version}" = "SUNDIALS_VERSION" ] \
|| [ "x${sundials_version}" = x ]
then
error="${error}\n\tcould not find sundials_config.h"
sundials=0
sundials_version="UNKNOWN"
else
case "${sundials_version}" in
[0-1].*.* | 2.[0-4].*)
sundials=0
error="${error}\n\tsundials >= 2.5.0 required" ;;
2.5.*) sundials=250;;
*) sundials=260
Lsundials_arkode=-lsundials_arkode
arkode_mlobj_main='arkode/arkode_impl.cmo arkode/arkode.cmo'
arkode_cobj_main=arkode/arkode_ml${XO}
arkode_mlobj_bbd=arkode/arkode_bbd.cmo
arkode_cobj_bbd=arkode/arkode_bbd_ml${XO}
arkode_cobj_sens="arkode/arkode_klu_ml${XO} arkode/arkode_superlumt_ml${XO}"
arkode_subdir=arkode
arkode_enabled=1
;;
esac
case "${sundials_version}" in
2.6.0) sundials=260 ;;
2.6.1) sundials=261 ;;
2.6.2) sundials=262 ;;
2.7.*) sundials=270 ;;
3.0.*) sundials=300 ;;
3.1.0) sundials=310 ;;
3.1.1) sundials=311 ;;
3.1.*) sundials=312 ;;
3.2.*) sundials=320 ;;
4.0.0) sundials=400 ;;
4.0.1) sundials=401 ;;
4.0.2) sundials=402 ;;
4.*) sundials=410 ;;
5.0.*) sundials=500 ;;
5.1.*) sundials=510 ;;
5.2.*) sundials=520 ;;
5.3.*) sundials=530 ;;
5.4.*) sundials=540 ;;
5.5.*) sundials=550 ;;
5.6.0) sundials=560 ;;
5.6.*) sundials=561 ;;
5.7.*) sundials=570 ;;
5.*) sundials=580 ;;
6.0.*) sundials=600 ;;
6.*) sundials=610 ;;
7.*) sundials=700 ;;
8.*) sundials=800 ;;
9.*) sundials=900 ;;
*) sundials=1000 ;;
esac
# Make sure realtype has the right size.
test_stem=__configure_test_file__realtype
test_cmd="$CC ${Isundials_inc_path} -o ${test_stem}${XX} $test_stem.c"
if [ ${sundials} -ge 600 ]; then
cat > $test_stem.c <<EOF
/* ${test_cmd} */
#include <sundials/sundials_types.h>
int main (int argc, char *argv[])
{
return sizeof (sunrealtype) != sizeof (double);
}
EOF
else
cat > $test_stem.c <<EOF
/* ${test_cmd} */
#include <sundials/sundials_types.h>
int main (int argc, char *argv[])
{
return sizeof (realtype) != sizeof (double);
}
EOF
fi
if ! eval "${test_cmd}" >>${logfile} 2>&1
then
error="${error}\n\tCan't link C code to sundials. Is sundials installed properly?"
error="${error}\n\tSaved test code as ${test_stem}.c"
error="${error}\n\tCompilation command was:"
error="${error}\n\t${test_cmd}"
elif ! ./$test_stem$XX
then
error="${error}\n\trealtype not defined as double. Recompile sundials with -DSUNDIALS_PRECISION=double."
else
${debug_configure} || rm -f ./$test_stem*
fi
fi
if [ ${sundials} -ge 600 ]; then
sundials_at_least_6_0_0=1
sundials_at_least_5_8_0=1
sundials_at_least_5_4_0=1
sundials_at_least_5_3_0=1
sundials_at_least_5_1_0=1
sundials_at_least_5_0_0=1
sundials_at_least_4_0_0=1
sundials_at_least_3_2_0=1
sundials_at_least_3_1_2=1
sundials_at_least_3_0=1
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 500 ]; then
if [ ${sundials} -ge 510 ]; then
sundials_at_least_5_1_0=1
fi
if [ ${sundials} -ge 530 ]; then
sundials_at_least_5_3_0=1
fi
if [ ${sundials} -ge 540 ]; then
sundials_at_least_5_4_0=1
fi
if [ ${sundials} -ge 580 ]; then
sundials_at_least_5_8_0=1
fi
sundials_at_least_5_0_0=1
sundials_at_least_4_0_0=1
sundials_at_least_3_2_0=1
sundials_at_least_3_1_2=1
sundials_at_least_3_0=1
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 400 ]; then
sundials_at_least_4_0_0=1
sundials_at_least_3_2_0=1
sundials_at_least_3_1_2=1
sundials_at_least_3_0=1
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 320 ]; then
sundials_at_least_3_2_0=1
sundials_at_least_3_1_2=1
sundials_at_least_3_0=1
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 312 ]; then
sundials_at_least_3_1_2=1
sundials_at_least_3_0=1
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 300 ]; then
sundials_at_least_3_0=1
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 270 ]; then
sundials_at_least_2_7=1
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 260 ]; then
sundials_at_least_2_6=1
sundials_at_least_2_5=1
elif [ ${sundials} -ge 250 ]; then
sundials_at_least_2_6=
sundials_at_least_2_5=1
else
sundials_at_least_2_6=
sundials_at_least_2_5=
fi
sundials_indextype=
if [ ${sundials} -ge 300 ]; then
include="\"sundials/sundials_config.h\""
test_stem=__configure_test_file_indextype
cat > $test_stem.c <<EOF
// ${CPP} ${cppflags} ${Isundials_inc_path} -P $test_stem.c
#include "sundials/sundials_config.h"
SUNDIALS_INT64_T
EOF
sundials_int64_t=$(${CPP} ${cppflags} ${Isundials_inc_path} \
-P $test_stem.c 2>>${logfile} \
| tail -1 | sed -e 's/ //g' -e 's/"//g')
${debug_configure} || rm -f ./$test_stem.c
if [ "${sundials_int64_t}" = SUNDIALS_INT64_T ]; then
sundials_indextype=32
other_tweaks="${other_tweaks} index-int32"
else
sundials_indextype=64
fi
printf "Sundials index_type=%s\n" "${sundials_indextype}" >>${logfile}
else
sundials_indextype=64
fi
set_ocaml_version () {
# expr may be antiquated but it can handle leading zeros, e.g.,
# for OCaml 4.08.00 -> 10000 * 4 + 100 * 08 + 0.
# shellcheck disable=SC2003
ocaml_version="$(expr 10000 '*' "$1" + 100 '*' "$2" + "$3")"
}
# Check for OCaml installation (and version)
ocaml_path=$("${OCAMLBIN}ocamlc" -where)
ocaml_version_string=$("${OCAMLBIN}ocamlc" -version)
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
error="${error}\n\tcould not find ocamlc"
ocaml_path='NOT FOUND'
ocaml_version=0
ocaml_version_string=''
ocaml_version_info=''
Iocaml_inc_path=''
ocaml_libpath=''
else
# shellcheck disable=SC2046
set_ocaml_version $(ocamlc -version | cut -d "~" -f 1 | cut -d + -f 1 | tr '.' ' ')
if [ $ocaml_version -le 40203 ]; then
error="${error}\\n\\tocaml >= 4.03.0 required"
fi
if [ $ocaml_version -lt 40600 ]; then
ocaml_warnings="${ocaml_warnings}-40"
fi
Iocaml_inc_path="-isystem ${ocaml_path}"
ocaml_libpath="${ocaml_path%/}/"
ocaml_version_info=" (${ocaml_version_string})"
fi
ocamlflags="${ocamlflags} -w ${ocaml_warnings} -bin-annot"
ocamloptflags="${ocamloptflags} -w ${ocaml_warnings} -bin-annot"
# Check if .opt variants are available.
if [ "x$opt_compiler" = x1 ] && \
([ -x "${OCAMLBIN}ocamlc.opt" ] \
|| which "${OCAMLBIN}ocamlc.opt" >>${logfile} 2>&1)
then
ocamlc="${OCAMLBIN}ocamlc.opt"
else
ocamlc="${OCAMLBIN}ocamlc"
fi
if [ "x$opt_compiler" = x1 ] && \
([ -x "${OCAMLBIN}ocamlopt.opt" ] \
|| which "${OCAMLBIN}ocamlopt.opt" >>${logfile} 2>&1)
then
ocamlopt="${OCAMLBIN}ocamlopt.opt"
else
ocamlopt="${OCAMLBIN}ocamlopt"
fi
if [ "x$opt_compiler" = x1 ] && \
([ -x "${OCAMLBIN}ocamldoc.opt" ] \
|| which "${OCAMLBIN}ocamldoc.opt" >>${logfile} 2>&1)
then
ocamldoc="${OCAMLBIN}ocamldoc.opt"
ocamldoc_plugin=".cmxs"
else
ocamldoc="${OCAMLBIN}ocamldoc"
ocamldoc_plugin=".cma"
fi
if [ "x$opt_compiler" = x1 ] && \
([ -x "${OCAMLBIN}ocamldep.opt" ] \
|| which "${OCAMLBIN}ocamldep.opt" >>${logfile} 2>&1)
then
ocamldep="${OCAMLBIN}ocamldep.opt"
else
ocamldep="${OCAMLBIN}ocamldep"
fi
cppflags="${cppflags} ${Isundials_inc_path} ${Iocaml_inc_path}"
cflags="${cflags} ${Iocaml_inc_path}"
test_stem=__configure_test_file__intsizes
cat > $test_stem.c <<EOF
// ${CPP} ${cppflags} -P $test_stem.c
#include <caml/mlvalues.h>
SIZEOF_INT,SIZEOF_LONG,SIZEOF_PTR
EOF
ilp_size=$(${CPP} ${cppflags} -P $test_stem.c 2>>${logfile} | tail -1)
int_size=`expr "$ilp_size" : "^\([^,]*\),*"`
long_size=`expr "$ilp_size" : "^[^,]*,\([^,]*\),*"`
ptr_size=`expr "$ilp_size" : "^[^,]*,[^,]*,\([^,]*\)"`
${debug_configure} || rm -f ./$test_stem.c
if echo ${int_size:-not_found} | grep -q '[^0-9]'; then
printf "Failed to detect size of \`int'. This might be a problem\n"
printf "with detecting your system's C preprocessor.\n\n"
exit 1
fi
if echo ${long_size:-not_found} | grep -q '[^0-9]'; then
printf "Failed to detect size of \`long'. This might be a problem\n"
printf "with detecting your system's C preprocessor.\n\n"
exit 1
fi
if echo ${ptr_size:-not found} | grep -q '[^0-9]'; then
printf "Failed to detect size of pointers. This might be a problem\n"
printf "with detecting your system's C preprocessor.\n\n"
exit 1
fi
if [ "${long_size}" -ne "${ptr_size}" ]; then
error="${error}\nsizeof (long) does not match sizeof (void*)."
error="${error}\nStarting with SUNDIALS version 2.5.0, DenseGETRF() and"
error="${error}\nsimilar functions require arrays of longs as input,"
error="${error}\nso this binding needs to map C's long * type to some OCaml"
error="${error}\ntype. We chose to map it to bigarray with int entries,"
error="${error}\nwhich gives an overhead-free mapping and a convenient API"
error="${error}\nfor the user. As a downside, this requires C's long type"
error="${error}\nto have the same size as OCaml values, i.e. the same size"
error="${error}\nas pointers. The only platform known to violate this"
error="${error}\nrequirement is Microsoft Visual C on 64-bit Windows"
error="${error}\n(Win64). If you must use this binding on 64-bit Windows,"
error="${error}\ntry compiling SUNDIALS and the binding with Cygwin. If"
error="${error}\nusing Cygwin is not an option, write to us and we may"
error="${error}\nbe able to hack together a workaround for Win64, albeit"
error="${error}\nwith a slight performance hit."
fi
if [ "${int_size}" -ne 4 ]; then
error="${error}\nint is not 32 bits on this platform."
error="${error}\nSome SUNDIALS functions require arrays of ints as input,"
error="${error}\nso this binding needs to map C's int * type to some OCaml"
error="${error}\ntype. We chose to map it to bigarray with int32 entries"
error="${error}\nwhich gives an overhead-free mapping and a convenient API"
error="${error}\nfor the user, provided that C's int type is 32 bits. This"
error="${error}\nis the case with most, if not all, 32-bit and 64-bit"
error="${error}\nsystems, and we were not aware of any platforms that are "
error="${error}\nstill in use which violate this requirement. However, it"
error="${error}\nlooks like you have such a platform. Please inform us"
error="${error}\nabout your platform and we may be able to hack together a"
error="${error}\nworkaround, albeit with a slight performance hit."
fi
# Check for opam
if command -v opam >>${logfile} 2>&1; then
opam_libpath="$(opam var lib)/"
# if the opam path is a prefix of the ocaml path, use the former
case "${ocaml_libpath}" in
"${opam_libpath}"*)
ocaml_libpath="${opam_libpath}";;
esac
# install the docs with opam
if [ "x${docdir}" = x ]; then
docdir="$(dirname "${opam_libpath}")/doc/sundialsml/"
fi
else
opam_libpath=''
fi
# Check if we can compile a direct call to caml_weak_get from C. Usually we
# can, but it doesn't seem to be supported officially. Note that a .c + .ml
# pair is infinitely easier to compile portably than a standalone .c file.
test_stem=__configure_test_file__weakget
test_ml_stem=configure_test_ml_file__weakget
cat > $test_stem.c <<EOF
/* This file tests if we can call caml_weak_get() directly from C. */
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>
CAMLprim value caml_weak_get (value ar, value n);
CAMLprim value caml_weak_set (value ar, value n, value el);
CAMLprim value caml_weak_create (value len);
#define None_val (Val_int(0))
#define Some_tag 0
CAMLprim value f ()
{
CAMLparam0 ();
CAMLlocal3 (table, x, y);
table = caml_weak_create (Val_int (1));
x = caml_weak_get (table, Val_int (0));
if (x != None_val)
CAMLreturn (Val_int (1));
y = caml_alloc_small (1, Some_tag);
Field (y, 0) = Val_int (42);
caml_weak_set (table, Val_int (0), y);
x = caml_weak_get (table, Val_int (0));
if (!Is_block (x) || Tag_val(x) != Some_tag || Field (x,0) != Field(y,0))
CAMLreturn (Val_int (2));
caml_weak_set (table, Val_int (0), None_val);
x = caml_weak_get (table, Val_int (0));
if (x != None_val)
CAMLreturn (Val_int (3));
CAMLreturn (Val_int (0));
}
EOF
test_cmd="${ocamlc} ${test_stem}.c ${test_ml_stem}.ml \
-o ${test_ml_stem}$XX -custom"
cat > ${test_ml_stem}.ml <<EOF
(* ${test_cmd} *)
external f : unit -> int = "f"
let _ = exit (f ())
EOF
if eval "${test_cmd}" >>${logfile} 2>&1 && ./${test_ml_stem}$XX; then
have_weak=1
else
have_weak=0
warning="${warning}\n\tCould not compile caml_weak_get; using workaround."
fi
${debug_configure} || \
rm -f ./${test_stem}.* ./${test_ml_stem}.* ${test_ml_stem}
# Check whether compiler-libs is available
test_ml_stem=configure_test_ml_file__
cat > ${test_ml_stem}.ml <<EOF
Toploop.execute_phrase false Format.err_formatter
(!Toploop.parse_toplevel_phrase (Lexing.from_string ""))
EOF
# FIXME: is it ever possible that compiler-libs is installed somewhere else?
if ${ocamlc} -I +compiler-libs -c ${test_ml_stem}.ml \
-o ${test_ml_stem}.cmo >>${logfile} 2>&1; then
have_compiler_libs=1
compiler_libs_path=+compiler-libs
else
# have_compiler_libs should be empty, not 0.
have_compiler_libs=
compiler_libs_path=
warning="${warning}\n\tCould not find compiler-libs; printers will not be"
warning="${warning}\n\tinstalled by default in the OCaml toplevel."
fi
${debug_configure} || rm -f ./${test_ml_stem}.* ${test_ml_stem}
# Check whether using generic math library (-lm) or not
libm=-lm
if [ $sundials -ge 260 ]; then
test_stem=__configure_test_file__generic_math
cat > $test_stem.c <<EOF
// ${CPP} ${cppflags} ${Isundials_inc_path} -P 2>>${logfile} $test_stem.c
#include "sundials/sundials_config.h"
#ifdef SUNDIALS_USE_GENERIC_MATH
1
#else
0
#endif
EOF
sundials_info=$(${CPP} ${cppflags} ${Isundials_inc_path} \
-P 2>>${logfile} $test_stem.c \
| grep -v ^$)
${debug_configure} || rm -f ./${test_stem}.c
printf "Sundials uses -lm?: %s\n" "${sundials_info}" >>${logfile}
case "${sundials_info}" in
1) ;;
0) unset libm ;;
*) error="${error}\n\terror interpreting sundials_config.h"