-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
3213 lines (2688 loc) · 96.3 KB
/
acinclude.m4
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
# -----------------------------------------------------------------
# $Revision: 1.58 $
# $Date: 2010/12/15 22:28:17 $
# -----------------------------------------------------------------
# Programmer(s): Radu Serban and Aaron Collier @ LLNL
# -----------------------------------------------------------------
# Copyright (c) 2002, The Regents of the University of California.
# Produced at the Lawrence Livermore National Laboratory.
# All rights reserved.
# For details, see the LICENSE file.
# -----------------------------------------------------------------
#
# SUNDIALS autoconf macros
#
# The functions defined here fall into the following categories:
#
# (1) Initializations:
# SUNDIALS_GREETING
# SUNDIALS_INITIALIZE
# SUNDIALS_ENABLES
#
# (2) C compiler tests
# SUNDIALS_SET_CC
# SUNDIALS_CC_CHECK
# SUNDIALS_CPLUSPLUS_CHECK
#
# (3) Fortran support
# SUNDIALS_F77_SUPPORT
# SUNDIALS_F77_CHECK
# SUNDIALS_F77_LNKR_CHECK
# SUNDIALS_F77_NAME_MANGLING
# SUNDIALS_F77_LAPACK_SET
#
# (4) Parallel support
# SUNDIALS_SET_MPICC
# SUNDIALS_CHECK_MPICC
# SUNDIALS_CC_WITH_MPI_CHECK
# SUNDIALS_SET_MPIF77
# SUNDIALS_CHECK_MPIF77
# SUNDIALS_MPIF77_LNKR_CHECK
# SUNDIALS_F77_WITH_MPI_CHECK
# SUNDIALS_CHECK_MPI2
#
# (5) Finalizations:
# SUNDIALS_MORE_HELP
# SUNDIALS_SET_EXAMPLES
# SUNDIALS_BUILD_MODULES_LIST
# SUNDIALS_POST_PROCESSING
# SUNDIALS_REPORT
#
# -----------------------------------------------------------------
#=================================================================#
# #
# #
# I N I T I A L I Z A T I O N S #
# #
# #
#==================================================================
#------------------------------------------------------------------
# GREETING
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_GREETING],
[
# Say Hi!
echo "
---------------------------------
Running SUNDIALS Configure Script
---------------------------------
"
]) dnl END SUNDIALS_GREETING
#------------------------------------------------------------------
# PERFORM INITIALIZATIONS
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_INITIALIZE],
[
# Reference custom macros
m4_include([config/mod_fortran.m4])
m4_include([config/mod_c.m4])
m4_include([config/cust_general.m4])
# Make input filename DOS compatible (change config.h.in to config.hin)
AC_CONFIG_HEADERS([config.h:config.hin])
# Make user aware of copyright notice (input COPYRIGHT information)
AC_COPYRIGHT(
[
Copyright (c) 2002, The Regents of the University of California.
Produced at the Lawrence Livermore National Laboratory.
All rights reserved.
For details, see the LICENSE file.
])
# Specify root of source tree
# Given file is guaranteed to exist in all SUNDIALS packages
AC_CONFIG_SRCDIR([/src/sundials/sundials_nvector.c])
# Get host information
# AC_CANONICAL_BUILD defines the following variables: build, build_cpu,
# build_vendor, and build_os
AC_CANONICAL_BUILD
# AC_CANONICAL_HOST defines the following variables: host, host_cpu,
# host_vendor, and host_os
AC_CANONICAL_HOST
# Set MAKE if necessary
# Must include @SET_MAKE@ in each Makefile.in file
# AC_SUBST is called automatically for SET_MAKE
AC_PROG_MAKE_SET
# Defines INSTALL (sets to path of "install" program)
# Also sets INSTALL_PROGRAM and INSTALL_SCRIPT
AC_PROG_INSTALL
# Set defaults for config/sundials_config.in file
F77_MANGLE_MACRO1=""
F77_MANGLE_MACRO2=""
PRECISION_LEVEL=""
GENERIC_MATH_LIB=""
BLAS_LAPACK_MACRO=""
F77_MPI_COMM_F2C=""
SUNDIALS_EXPORT="#define SUNDIALS_EXPORT"
# Initialize enable status of various modules, options, and features
# to their default values
#
# NOTE: when CPODES is released, change its default to enabled.
#
CVODE_ENABLED="yes"
CVODES_ENABLED="yes"
IDA_ENABLED="yes"
IDAS_ENABLED="yes"
KINSOL_ENABLED="yes"
LAPACK_ENABLED="yes"
FCMIX_ENABLED="yes"
MPI_ENABLED="yes"
#
CPODES_ENABLED="no"
#
EXAMPLES_ENABLED="no"
F77_EXAMPLES_ENABLED="no"
# Initialize variables that may NOT necessarily be initialized
# during normal execution. Should NOT use uninitialized variables
F77_OK="no"
LAPACK_OK="no"
MPI_C_COMP_OK="no"
MPI_F77_COMP_OK="no"
# This variable is set to "yes" if an AC_MSG_WARN statement
# was executed
SUNDIALS_WARN_FLAG="no"
]) dnl END SUNDIALS_INITIALIZE
#------------------------------------------------------------------
# TEST ENABLES
#
# The following variables may be changed here (default value in []):
#
# CVODE_ENABLED - enable CVODE module [yes]
# CVODES_ENABLED - enable CVODES module [yes]
# IDA_ENABLED - enable IDA module [yes]
# IDAS_ENABLED - enable IDAS module [yes]
# KINSOL_ENABLED - enable KINSOL module [yes]
# FCMIX_ENABLED - enable Fortran-C interfaces [yes]
# LAPACK_ENABLED - enable Lapack support [yes]
# MPI_ENABLED - enable parallel support [yes]
# EXAMPLES_ENABLED - enable example programs [no]
# F77_EXAMPLES_ENABLED - enable Fortran example programs [no]
#
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_ENABLES],
[
# Check if user wants to disable CVODE module
# If not, then make certain source directory actually exists
AC_ARG_ENABLE(cvode,
[AC_HELP_STRING([--disable-cvode],[disable configuration of CVODE])],
[
if test "X${enableval}" = "Xno"; then
CVODE_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/cvode ; then
CVODE_ENABLED="yes"
else
CVODE_ENABLED="no"
fi
])
# Check if user wants to disable CVODES module
# If not, then make certain source directory actually exists
AC_ARG_ENABLE(cvodes,
[AC_HELP_STRING([--disable-cvodes],[disable configuration of CVODES])],
[
if test "X${enableval}" = "Xno"; then
CVODES_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/cvodes ; then
CVODES_ENABLED="yes"
else
CVODES_ENABLED="no"
fi
])
# Check if user wants to disable IDA module
# If not, then make certain source directory actually exists
AC_ARG_ENABLE(ida,
[AC_HELP_STRING([--disable-ida],[disable configuration of IDA])],
[
if test "X${enableval}" = "Xno"; then
IDA_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/ida ; then
IDA_ENABLED="yes"
else
IDA_ENABLED="no"
fi
])
# Check if user wants to disable IDAS module
# If not, then make certain source directory actually exists
AC_ARG_ENABLE(idas,
[AC_HELP_STRING([--disable-idas],[disable configuration of IDAS])],
[
if test "X${enableval}" = "Xno"; then
IDAS_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/idas ; then
IDAS_ENABLED="yes"
else
IDAS_ENABLED="no"
fi
])
# Check if user wants to disable KINSOL MODULE
# If not, then make certain source directory actually exists
AC_ARG_ENABLE(kinsol,
[AC_HELP_STRING([--disable-kinsol],[disable configuration of KINSOL])],
[
if test "X${enableval}" = "Xno"; then
KINSOL_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/kinsol ; then
KINSOL_ENABLED="yes"
else
KINSOL_ENABLED="no"
fi
])
# Check if user wants to disable CPODES module
# If not, then make certain source directory actually exists
AC_ARG_ENABLE(cpodes,
[AC_HELP_STRING([--disable-cpodes],[disable configuration of CPODES])],
[
if test "X${enableval}" = "Xno"; then
CPODES_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/cpodes ; then
CPODES_ENABLED="yes"
else
CPODES_ENABLED="no"
fi
])
# Check if user wants to disable Fortran support (FCMIX components).
AC_ARG_ENABLE([fcmix],
[AC_HELP_STRING([--disable-fcmix], [disable Fortran-C support])],
[
if test "X${enableval}" = "Xno"; then
FCMIX_ENABLED="no"
fi
],
[
if test "X${CVODE_ENABLED}" = "Xno" && test "X${KINSOL_ENABLED}" = "Xno" && test "X${IDA_ENABLED}" = "Xno"; then
FCMIX_ENABLED="no"
fi
])
# Check if user wants to disable Lapack support.
AC_ARG_ENABLE([lapack],
[AC_HELP_STRING([--disable-lapack], [disable Lapack support])],
[
if test "X${enableval}" = "Xno"; then
LAPACK_ENABLED="no"
fi
])
# Check if user wants to disable support for MPI.
# If not, set the default based on whetehr certain source directories exist
AC_ARG_ENABLE([mpi],
[AC_HELP_STRING([--disable-mpi],[disable MPI support])],
[
if test "X${enableval}" = "Xno"; then
MPI_ENABLED="no"
fi
],
[
if test -d ${srcdir}/src/nvec_par || test -d ${srcdir}/src/nvec_spcpar; then
MPI_ENABLED="yes"
else
MPI_ENABLED="no"
fi
])
# Check if user wants to enable all examples.
# Examples are NOT built by default
AC_ARG_ENABLE(examples,
[AC_HELP_STRING([--enable-examples],[enable configuration of examples])],
[
if test "X${enableval}" = "Xno"; then
EXAMPLES_ENABLED="no"
else
EXAMPLES_ENABLED="yes"
fi
])
# Fortran examples are enabled only if both FCMIX and EXAMPLES are enabled
if test "X${FCMIX_ENABLED}" = "Xyes" && test "X${EXAMPLES_ENABLED}" = "Xyes"; then
F77_EXAMPLES_ENABLED="yes"
fi
]) dnl END SUNDIALS_ENABLES
#=================================================================#
# #
# #
# C C O M P I L E R T E S T S #
# #
# #
#==================================================================
#------------------------------------------------------------------
# CHECK C COMPILER
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_SET_CC],
[
if test "X${CC}" = "X"; then
echo ""
echo " Unable to find a working C compiler"
echo ""
echo " Try using CC to explicitly specify a C compiler"
echo ""
AC_MSG_ERROR([cannot find a C compiler])
else
SUNDIALS_CC_CHECK
fi
]) dnl END SUNDIALS_SET_CC
AC_DEFUN([SUNDIALS_CC_CHECK],
[
# Default is C programming language (initialize language stack)
AC_LANG([C])
AC_ARG_WITH([],[],[])
# Set floating-point precision: single [C type 'float']
# double [C type 'double'] (default)
# extended [C type 'long double']
# Provide variable description templates for config.hin and config.h files
# Required by autoheader utility
AH_TEMPLATE([SUNDIALS_SINGLE_PRECISION],
[Define SUNDIALS data type 'realtype' as 'float'])
AH_TEMPLATE([SUNDIALS_DOUBLE_PRECISION],
[Define SUNDIALS data type 'realtype' as 'double'])
AH_TEMPLATE([SUNDIALS_EXTENDED_PRECISION],
[Define SUNDIALS data type 'realtype' as 'long double'])
AC_MSG_CHECKING([floating-point data type to use])
AC_ARG_WITH(precision,
[AC_HELP_STRING([--with-precision=ARG],
[specify floating-point precision (single/double/extended) [double]])],
[
if test "X${withval}" = "Xsingle"; then
AC_MSG_RESULT([float])
AC_DEFINE([SUNDIALS_SINGLE_PRECISION],[1],[])
FLOAT_TYPE="single"
PRECISION_LEVEL="#define SUNDIALS_SINGLE_PRECISION 1"
elif test "X${withval}" = "Xdouble"; then
AC_MSG_RESULT([double])
AC_DEFINE([SUNDIALS_DOUBLE_PRECISION],[1],[])
FLOAT_TYPE="double"
PRECISION_LEVEL="#define SUNDIALS_DOUBLE_PRECISION 1"
elif test "X${withval}" = "Xextended"; then
AC_MSG_RESULT([long double])
AC_DEFINE([SUNDIALS_EXTENDED_PRECISION],[1],[])
FLOAT_TYPE="extended"
PRECISION_LEVEL="#define SUNDIALS_EXTENDED_PRECISION 1"
else
AC_MSG_ERROR([invalid input])
fi
],
[
# Use 'double' by default
AC_MSG_RESULT([double])
AC_DEFINE([SUNDIALS_DOUBLE_PRECISION],[1],[])
FLOAT_TYPE="double"
PRECISION_LEVEL="#define SUNDIALS_DOUBLE_PRECISION 1"
])
AC_ARG_WITH([],[ ],[])
# Overwrite CFLAGS
AC_MSG_CHECKING([for C compiler flags])
AC_ARG_WITH(cflags,
[AC_HELP_STRING([--with-cflags=ARG],[specify C compiler flags (CFLAGS will be overridden)])],
[
AC_MSG_RESULT([${withval}])
CFLAGS="${withval}"
],
[
AC_MSG_RESULT([none])
])
# Set CPP to command that runs C preprocessor
AC_PROG_CPP
# Overwrite CPPFLAGS
AC_MSG_CHECKING([for C/C++ preprocessor flags])
AC_ARG_WITH(cppflags,
[AC_HELP_STRING([--with-cppflags=ARG],[specify C/C++ preprocessor flags (CPPFLAGS will be overridden)])],
[
AC_MSG_RESULT([${withval}])
CPPFLAGS="${withval}"
],
[
AC_MSG_RESULT([none])
])
# Overwrite LDFLAGS
AC_MSG_CHECKING([for linker flags])
AC_ARG_WITH(ldflags,
[AC_HELP_STRING([--with-ldflags=ARG],[specify linker flags (LDFLAGS will be overridden)])],
[
AC_MSG_RESULT([${withval}])
LDFLAGS="${withval}"
],
[
AC_MSG_RESULT([none])
])
# Add any additional libraries
AC_MSG_CHECKING([for extra libraries])
AC_ARG_WITH(libs,
[AC_HELP_STRING([--with-libs=ARG],[add extra libraries])],
[
AC_MSG_RESULT([${withval}])
if test "X${LIBS}" = "X"; then
LIBS="${withval}"
else
LIBS="${LIBS} ${withval}"
fi
],
[
AC_MSG_RESULT([none])
])
# Defines STDC_HEADERS if the following header files are found: stdlib.h,
# stdarg.h, string.h, and float.h
# We really only need stdlib.h and float.h
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h float.h math.h])
# Set flag indicating if generic function names should be used
# Provide variable description template for config.hin and config.h files
# Required by autoheader utility
AH_TEMPLATE([SUNDIALS_USE_GENERIC_MATH],
[Use generic math functions])
# Check if math library contains abs(), fabs(), pow(), and sqrt() functions (required)
# May update LIBS (meaning add additional library, namely libm)
MATH_FABS_OK="yes"
MATH_POW_OK="yes"
MATH_SQRT_OK="yes"
# Save copy of LIBS variable and unset LIBS
SAVED_LIBS="${LIBS}"
LIBS=""
# The abs routine is defined for an integer argument, so check for it regardless of
# the level of precision chosen
AC_CHECK_LIB([m],abs,[],[AC_MSG_ERROR([cannot find abs function])])
TEMP_MATH_LIB="${LIBS}"
LIBS=""
# Check for single-precision math routines
if test "X${FLOAT_TYPE}" = "Xsingle"; then
AC_CHECK_LIB([m],fabsf,[],[MATH_FABS_OK="no"])
AC_CHECK_LIB([m],powf,[],[MATH_POW_OK="no"])
AC_CHECK_LIB([m],sqrtf,[],[MATH_SQRT_OK="no"])
# Check for extended-precision math routines
elif test "X${FLOAT_TYPE}" = "Xextended"; then
AC_CHECK_LIB([m],fabsl,[],[MATH_FABS_OK="no"])
AC_CHECK_LIB([m],powl,[],[MATH_POW_OK="no"])
AC_CHECK_LIB([m],sqrtl,[],[MATH_SQRT_OK="no"])
# Check for (generic) double-precision math routines
elif test "X${FLOAT_TYPE}" = "Xdouble"; then
AC_CHECK_LIB([m],fabs,[],[AC_MSG_ERROR([cannot find fabs function])])
AC_CHECK_LIB([m],pow,[],[AC_MSG_ERROR([cannot find pow function])])
AC_CHECK_LIB([m],sqrt,[],[AC_MSG_ERROR([cannot find sqrt function])])
fi
# If cannot find precision-specific implementations, then check for generic versions
if test "X${MATH_FABS_OK}" = "Xno" || test "X${MATH_POW_OK}" = "Xno" || test "X${MATH_SQRT_OK}" = "Xno"; then
AC_CHECK_LIB([m],fabs,[],[AC_MSG_ERROR([cannot find fabs function])])
AC_CHECK_LIB([m],pow,[],[AC_MSG_ERROR([cannot find pow function])])
AC_CHECK_LIB([m],sqrt,[],[AC_MSG_ERROR([cannot find sqrt function])])
# If all generic math routines are available, then set SUNDIALS_USE_GENERIC_MATH flag
# for use by sundials_math.c file (preprocessor macros)
AC_DEFINE([SUNDIALS_USE_GENERIC_MATH],[1],[])
GENERIC_MATH_LIB="#define SUNDIALS_USE_GENERIC_MATH"
# If found all precision-specific routines, then set SUNDIALS_USE_GENERIC_MATH only if
# building SUNDIALS libraries with double-precision
else
if test "X${FLOAT_TYPE}" = "Xdouble"; then
AC_DEFINE([SUNDIALS_USE_GENERIC_MATH],[1],[])
GENERIC_MATH_LIB="#define SUNDIALS_USE_GENERIC_MATH"
else
AC_DEFINE([SUNDIALS_USE_GENERIC_MATH],[0],[])
fi
fi
# Add math library to LIBS environment variable
LIBS="${TEMP_MATH_LIB}"
AC_MSG_CHECKING([for additional required C libraries])
if test "X${LIBS}" = "X"; then
if test "X${SAVED_LIBS}" = "X"; then
LIBS=""
else
LIBS="${SAVED_LIBS}"
fi
AC_MSG_RESULT([none])
else
AC_MSG_RESULT([${LIBS}])
if test "X${SAVED_LIBS}" = "X"; then
LIBS="${LIBS}"
else
LIBS="${LIBS} ${SAVED_LIBS}"
fi
fi
# Check sizeof(int) - used to modify Fortran examples
AC_CHECK_SIZEOF(int)
# Check sizeof(long int) - used to modify Fortran examples
AC_CHECK_SIZEOF(long int)
# Check sizeof(realtype), where realtype is either float, double
# or long double - used to modify Fortran examples
if test "X${FLOAT_TYPE}" = "Xsingle"; then
AC_CHECK_SIZEOF(float)
elif test "X${FLOAT_TYPE}" = "Xdouble"; then
AC_CHECK_SIZEOF(double)
elif test "X${FLOAT_TYPE}" = "Xextended"; then
AC_CHECK_SIZEOF(long double)
fi
# Defines EGREP and exports via AC_SUBST - used by FCMIX Makefile's
AC_PROG_EGREP
# Defines FGREP and exports via AC_SUBST - used by FCMIX Makefile's
AC_PROG_FGREP
# Check if CC is a C++ compiler
# Note: If CC is a C++ compiler and MPI is enabled, then we will
# check for "mpiCC" instead of "mpicc" if an MPI compiler was NOT specified
SUNDIALS_CPLUSPLUS_CHECK([${CC}])
]) dnl END SUNDIALS_SET_CC
#------------------------------------------------------------------
# CHECK IF COMPILER IS A C++ COMPILER
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_CPLUSPLUS_CHECK],
[
# Rename argument
COMP_NAME="$1"
# Update the language stack
AC_LANG_PUSH([C])
# Check if using a C++ compiler
AC_MSG_CHECKING([if ${COMP_NAME} is a C++ compiler])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[]],
[[
#ifdef __cplusplus
return(0);
#else
return(1);
#endif
]])],
[
AC_MSG_RESULT([yes])
# COMP_NAME is a C++ compiler
USING_CPLUSPLUS_COMP="yes"
],
[
AC_MSG_RESULT([no])
# COMP_NAMPE is NOT a C++ compiler
USING_CPLUSPLUS_COMP="no"
])
# Revert back to previous language
AC_LANG_POP([C])
]) dnl END SUNDIALS_CPLUSPLUS_CHECK
#=================================================================#
# #
# #
# F O R T R A N S U P P O R T #
# #
# #
#==================================================================
#------------------------------------------------------------------
# FORTRAN SUPPORT
#
# Fortran support is required if FCMIX is enabled OR if LAPACK
# is enabled. In either case, we need a working F77 compiler in
# order to determine the Fortran name-mangling scheme.
#
# If we do need Fortran support, we first find and test a F77
# compiler, determine the mangling scheme, then we find the
# libraries required to link C and Fortran.
#
# Throughout this function we use the control variable F77_OK
# which was initialized to "no".
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_F77_SUPPORT],
[
F77_OK="yes"
# Look for a F77 compiler
# If unsuccessful, disable all Fortran support
AC_PROG_F77(f77 g77)
if test "X${F77}" = "X"; then
F77_OK="no"
SUNDIALS_WARN_FLAG="yes"
echo ""
echo " Unable to find a working Fortran compiler"
echo ""
echo " Try using F77 to explicitly specify a C compiler"
echo ""
if test "X${FCMIX_ENABLED}" = "Xyes"; then
echo " Disabling compilation of Fortran-C interfaces..."
fi
if test "X${LAPACK_ENABLED}" = "Xyes"; then
echo " Disabling compilation of Blas/Lapack interfaces..."
fi
echo ""
FCMIX_ENABLED="no"
LAPACK_ENABLED="no"
F77_EXAMPLES_ENABLED="no"
fi
# Check Fortran compiler
# If unsuccessful, disable all Fortran support
if test "X${F77_OK}" = "Xyes"; then
SUNDIALS_F77_CHECK
if test "X${F77_OK}" = "Xno"; then
SUNDIALS_WARN_FLAG="yes"
echo ""
echo " Unable to compile test program using given Fortran compiler."
echo ""
if test "X${FCMIX_ENABLED}" = "Xyes"; then
echo " Disabling compilation of Fortran-C interfaces..."
fi
if test "X${LAPACK_ENABLED}" = "Xyes"; then
echo " Disabling compilation of Blas/Lapack interfaces..."
fi
echo ""
FCMIX_ENABLED="no"
LAPACK_ENABLED="no"
F77_EXAMPLES_ENABLED="no"
fi
fi
# Determine the Fortran name-mangling scheme
# If successfull, provide variable description templates for config.hin
# and config.h files required by autoheader utility
# Otherwise, disable all Fortran support.
if test "X${F77_OK}" = "Xyes"; then
SUNDIALS_F77_NAME_MANGLING
AH_TEMPLATE([SUNDIALS_F77_FUNC], [FCMIX: Define name-mangling macro for C identifiers])
AH_TEMPLATE([SUNDIALS_F77_FUNC_], [FCMIX: Define name-mangling macro for C identifiers with underscores])
if test "X${F77_OK}" = "Xno"; then
SUNDIALS_WARN_FLAG="yes"
echo ""
echo " Unable to determine Fortran name-mangling scheme."
echo ""
if test "X${FCMIX_ENABLED}" = "Xyes"; then
echo " Disabling compilation of Fortran-C interfaces..."
fi
if test "X${LAPACK_ENABLED}" = "Xyes"; then
echo " Disabling compilation of Blas/Lapack interfaces..."
fi
echo ""
F77_EXAMPLES_ENABLED="no"
FCMIX_ENABLED="no"
LAPACK_ENABLED="no"
fi
fi
# If LAPACK is enabled, determine the proper library linkage
# If successful, set the libaries
# Otherwise, disable all Blas/Lapack support.
if test "X${LAPACK_ENABLED}" = "Xyes" && test "X${F77_OK}" = "Xyes"; then
SUNDIALS_F77_LAPACK_SET
if test "X${LAPACK_OK}" = "Xyes"; then
AC_MSG_CHECKING([for Blas/Lapack library linkage])
BLAS_LAPACK_LIBS="${LAPACK_LIBS} ${BLAS_LIBS} ${LIBS} ${FLIBS}"
AC_MSG_RESULT([${LAPACK_LIBS} ${BLAS_LIBS}])
else
SUNDIALS_WARN_FLAG="yes"
AC_MSG_CHECKING([for Blas/Lapack library linkage])
AC_MSG_RESULT("no")
echo ""
echo " Unable to determine Blas/Lapack library linkage."
echo ""
echo " Try using --with-blas and --with-lapack."
echo ""
echo " Disabling compilation of Blas/Lapack interfaces..."
LAPACK_ENABLED="no"
fi
fi
# Set the macro BLAS_LAPACK_MACRO for expansion in sundials_config.h
AH_TEMPLATE([SUNDIALS_BLAS_LAPACK], [Availability of Blas/Lapack libraries])
if test "X${LAPACK_ENABLED}" = "Xyes"; then
AC_DEFINE([SUNDIALS_BLAS_LAPACK],[1],[])
BLAS_LAPACK_MACRO="#define SUNDIALS_BLAS_LAPACK 1"
else
AC_DEFINE([SUNDIALS_BLAS_LAPACK],[0],[])
BLAS_LAPACK_MACRO="#define SUNDIALS_BLAS_LAPACK 0"
fi
]) dnl SUNDIALS_F77_SUPPORT
#------------------------------------------------------------------
# CHECK FORTRAN COMPILER
#
# Test the Fortran compiler by attempting to compile and link a
# simple Fortran program. If the test succeeds, set F77_OK=yes.
# If the test fails, set F77_OK="no"
#
# Finally, check if we must use a Fortran compiler to link the
# Fortran codes (default is to use CC).
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_F77_CHECK],
[
AC_LANG_PUSH([Fortran 77])
# Add any additional FFLAGS
AC_MSG_CHECKING([for extra Fortran compiler flags])
AC_ARG_WITH(fflags,
[AC_HELP_STRING([--with-fflags=ARG],[add extra Fortran compiler flags])],
[
AC_MSG_RESULT([${withval}])
FFLAGS="${FFLAGS} ${withval}"
],
[
AC_MSG_RESULT([none])
])
# Add any required linker flags to FLIBS
# Note: if FLIBS is defined, it is left unchanged
AC_F77_LIBRARY_LDFLAGS
# Try to compile a simple Fortran program (no linking)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[
SUBROUTINE SUNDIALS()
RETURN
END
]])],
[F77_OK="yes"],
[F77_OK="no"])
# If CC is a C++ compiler (decided in SUNDIALS_CPLUSPLUS_CHECK), we must use
# it to link the Fortran examples. In this case, test if that is successful.
# Otherwise, simply use F77 as the linker
if test "X${F77_OK}" = "Xyes"; then
AC_MSG_CHECKING([which linker to use])
if test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
SUNDIALS_F77_LNKR_CHECK
else
F77_LNKR="${F77}"
fi
AC_MSG_RESULT([${F77_LNKR}])
fi
# Reset language (remove 'Fortran 77' from stack)
AC_LANG_POP([Fortran 77])
]) dnl END SUNDIALS_SET_F77
#------------------------------------------------------------------
# F77 LINKER CHECK
# Check if the C++ compiler CC can be used to link a Fortran program.
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_F77_LNKR_CHECK],
[
F77_LNKR_CHECK_OK="no"
# Compile simple Fortran example, but do NOT link
# Note: result stored as conftest.${ac_objext}
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[
PROGRAM SUNDIALS
WRITE(*,*)'TEST'
END
]])],
[
# Temporarily reset LIBS environment variable to perform test
SAVED_LIBS="${LIBS}"
LIBS="${LIBS} ${FLIBS}"
# Switch working language to C for next test
AC_LANG_PUSH([C])
# Check if CC can link Fortran example
# Note: AC_LINKONLY_IFELSE is a custom macro (modifications made to
# general.m4 and c.m4) (see config/cust_general.m4 and config/mod_c.m4)
AC_LINKONLY_IFELSE([],[F77_LNKR_CHECK_OK="yes"],[F77_LNKR_CHECK_OK="no"])
# Revert back to previous language (Fortran 77)
AC_LANG_POP([C])
# Set LIBS environment variable back to original value
LIBS="${SAVED_LIBS}"
])
# If either the compilation or the linking failed, we should
# disable building the Fortran examples
# For now, use F77 as the linker...
if test "X${F77_LNKR_CHECK_OK}" = "Xyes"; then
F77_LNKR="${CC}"
else
F77_LNKR="${F77}"
fi
]) dnl SUNDIALS_F77_LNKR_CHECK
#------------------------------------------------------------------
# DETERMINE FORTRAN NAME-MANGLING SCHEME
#
# Compiling a simple Fortran example and link it using a C compiler.
# Interpret results to infer name-mangling scheme.
#------------------------------------------------------------------
AC_DEFUN([SUNDIALS_F77_NAME_MANGLING],
[
AC_LANG_PUSH([Fortran 77])
# (1) Compile a dummy Fortran subroutine named SUNDIALS
FNAME_STATUS="none"
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[
SUBROUTINE SUNDIALS()
RETURN
END
]])],
[
mv conftest.${ac_objext} f77_wrapper_check.${ac_objext}
# Temporarily reset LIBS environment variable to perform test
SAVED_LIBS="${LIBS}"
LIBS="f77_wrapper_check.${ac_objext} ${LIBS} ${FLIBS}"
AC_LANG_PUSH([C])
for i in "sundials" "SUNDIALS"
do
for j in "" "_" "__"
do
F77_MANGLED_NAME="${i}${j}"
AC_LINK_IFELSE([AC_LANG_CALL([],[${F77_MANGLED_NAME}])],[FNAME_STATUS="set" ; break 2])
done
done
AC_LANG_POP([C])
# If test succeeded, then set the F77_MANGLE_MACRO1 macro
if test "X${FNAME_STATUS}" = "Xset"; then
if test "X${i}" = "Xsundials"; then
FNAME_MSG="lower case "
if test "X${j}" = "X"; then
FNAME_MSG="${FNAME_MSG} + no underscore"
AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name],[])
F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name"
dgemm="dgemm"
dgetrf="dgetrf"
elif test "X${j}" = "X_"; then
FNAME_MSG="${FNAME_MSG} + one underscore"
AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name ## _],[])
F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name ## _"
dgemm="dgemm_"
dgetrf="dgetrf_"
else
FNAME_MSG="${FNAME_MSG} + two underscores"