forked from boutproject/BOUT-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1499 lines (1292 loc) · 50.1 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
# Copyright 2010 B D Dudson, S Farley
#
# Contact Ben Dudson, [email protected]
#
# This file is part of BOUT++.
#
# BOUT++ is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BOUT++ is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOUT++. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################
#
# Process this file with autoreconf to produce a configure script.
#
# $ autoreconf -if
#
# Changelog:
#
# 2010-03-09 Ben Dudson <[email protected]>
# * Changing to always require FFTW (removing NR routines)
# 2015-08-08 David Schwörer <[email protected]>
# * Searching for libs in lib and lib64
#
AC_PREREQ([2.69])
AC_INIT([BOUT++],[5.1.0],[[email protected]])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_MSG_WARN([./configure is deprecated and will be removed in a future version, please use CMake instead])
AC_ARG_WITH(netcdf, [AS_HELP_STRING([--with-netcdf],
[Enable support for netCDF files])],,[])
AC_ARG_WITH(pnetcdf, [AS_HELP_STRING([--with-pnetcdf],
[Set path to Parallel NetCDF library])],,[])
AC_ARG_WITH(ida, [AS_HELP_STRING([--with-ida=/path/to/ida],
[Use the SUNDIALS IDA solver])],,[])
AC_ARG_WITH(cvode, [AS_HELP_STRING([--with-cvode],
[Use the SUNDIALS CVODE solver])],,[])
AC_ARG_WITH(sundials, [AS_HELP_STRING([--with-sundials],
[Use CVODE and IDA])],,[])
AC_ARG_WITH(fftw, [AS_HELP_STRING([--with-fftw],
[Set directory of FFTW3 library])],,[])
AC_ARG_WITH(lapack, [AS_HELP_STRING([--with-lapack],
[Use the LAPACK library])],,[with_lapack=guess])
AC_ARG_WITH(petsc, [AS_HELP_STRING([--with-petsc],
[Enable PETSc interface])],,[with_petsc=no])
AC_ARG_WITH(slepc, [AS_HELP_STRING([--with-slepc],
[Enable SLEPc interface])],,[with_slepc=no])
AC_ARG_WITH(pvode, [AS_HELP_STRING([--with-pvode],
[Build and enable PVODE 98 (DEFAULT)])],,[])
AC_ARG_WITH(arkode, [AS_HELP_STRING([--with-arkode],
[Use the SUNDIALS ARKODE solver])],,[])
AC_ARG_WITH(scorep, [AS_HELP_STRING([--with-scorep],
[Enable support for scorep based instrumentation])],,[with_scorep=no])
AC_ARG_WITH(hypre, [AS_HELP_STRING([--with-hypre],
[Enable support for HYPRE])],,[with_hypre=no])
dnl --with-hdf5 flags are set in AX_LIB_{PARALLEL}HDF5
AC_ARG_WITH(system_mpark, [AS_HELP_STRING([--with-system-mpark],
[Use mpark.variant already installed rather then the bundled one])],,[with_system_mpark=auto])
AC_ARG_WITH(system_uuid, [AS_HELP_STRING([--with-system-uuid],
[Use libuuid to generate UUIDs])],,[with_system_uuid=auto])
AC_ARG_ENABLE(warnings, [AS_HELP_STRING([--disable-warnings],
[Disable compiler warnings])],,[])
AC_ARG_ENABLE(checks, [AS_HELP_STRING([--enable-checks=no/1/2/3],
[Set run-time checking level])],,[enable_checks=default])
AC_ARG_ENABLE(msgstack, [AS_HELP_STRING([--enable-msgstack=no/yes],
[Enable MstStack for backtrace. Default based on check level.])],,[enable_msgstack=maybe])
AC_ARG_ENABLE(signal, [AS_HELP_STRING([--disable-signal],
[Disable SEGFAULT handling])],,[])
AC_ARG_ENABLE(color, [AS_HELP_STRING([--disable-color],
[Disable -c option to color output])],,[])
AC_ARG_ENABLE(track, [AS_HELP_STRING([--enable-track],
[Enable variable tracking])],,[])
AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug],
[Enable all debugging flags])],,[])
AC_ARG_ENABLE(output_debug, [AS_HELP_STRING([--enable-output-debug],
[Enable some extra debugging output])],,[])
AC_ARG_ENABLE(optimize, [AS_HELP_STRING([--enable-optimize=no/1/2/3/4],
[Enable optimization])],,[])
AC_ARG_ENABLE(sigfpe, [AS_HELP_STRING([--enable-sigfpe],
[Enable FloatingPointExceptions])],,[])
AC_ARG_ENABLE(backtrace, [AS_HELP_STRING([--disable-backtrace],
[Disable function backtrace])],,[enable_backtrace=maybe])
AC_ARG_ENABLE(shared, [AS_HELP_STRING([--enable-shared],
[Enable building bout++ into an shared object])],,[enable_shared=no])
AC_ARG_ENABLE(static, [AS_HELP_STRING([--enable-static],
[Enable building bout++ into an static library])],,[enable_static=auto])
AC_ARG_ENABLE(openmp, [AS_HELP_STRING([--enable-openmp],
[Enable building with OpenMP support])],,[enable_openmp=no])
AC_ARG_WITH(openmp_schedule,[AS_HELP_STRING([--with-openmp-schedule=static/dynamic/guided/auto],
[Set OpenMP schedule (default: static)])],,[with_openmp_schedule=static])
AC_ARG_ENABLE(pvode_openmp, [AS_HELP_STRING([--enable-pvode-openmp],
[Enable building PVODE with OpenMP support])],,[enable_pvode_openmp=no])
AC_ARG_ENABLE(metric_3d, [AS_HELP_STRING([--enable-metric-3d],
[Use Field3D to store coordinates metric data])],,[enable_metric_3d=no])
AC_ARG_VAR(EXTRA_INCS,[Extra compile flags])
AC_ARG_VAR(EXTRA_LIBS,[Extra linking flags])
file_formats="" # Record which file formats are being supported
# Delete the build log from last time
rm -f config-build.log
# only keep BOUT related undefs
if ! grep -q 'NOTE TO DEVEL' autoconf_build_defines.hxx.in ; then
grep 'undef BOUT' -B 4 -A 1 autoconf_build_defines.hxx.in > autoconf_build_defines.hxx.in.tmp
echo '// NOTE TO DEVELOPERS: PLEASE KEEP THIS LINE AND DELETE AUTOGENERATED CONTENT BELOW!' >> autoconf_build_defines.hxx.in.tmp
mv autoconf_build_defines.hxx.in.tmp autoconf_build_defines.hxx.in
fi
AC_ARG_VAR(CXXFLAGS,[Extra compile flags])
AC_ARG_VAR(LDFLAGS,[Extra linking flags])
AC_ARG_VAR(LIBS,[Extra linking libraries])
LIBS="$LIBS $LDLIBS"
AC_SUBST(MKDIR_P)
AC_SUBST(EXTRA_INCS)
AC_SUBST(EXTRA_LIBS)
# Adding variables for additional sources
AC_SUBST(PRECON_SOURCE)
# We're using C++
AC_LANG(C++)
#############################################################
# Checks for programs
#############################################################
# Autoconf inserts "-g -O2" into flags by default
# Set them to be just "-g", but only if the user hasn't already set CXXFLAGS
# We then put "-O2" back in later, assuming optimisations aren't explicitly disabled
: ${CXXFLAGS="-g"}
# Search for MPI compiler; fail if not found
AX_PROG_CXX_MPI([], [], [
AC_MSG_ERROR([*** An MPI compiler is required. You might need to set MPICXX correctly.])
])
# Utility programs
AC_PROG_MKDIR_P
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
# Set MAKE to gmake if possible, otherwise make
AC_CHECK_PROG(MAKE, gmake, gmake, make)
AC_PROG_RANLIB
AC_SUBST(ARFLAGS)
ARFLAGS=''
for flag in cruU cru
do
echo 1 > artest1
ar $flag artest artest1 &&ar $flag artest artest1
arexit=$?
rm -f artest1 artest
if test $arexit -eq 0
then
ARFLAGS="$flag"
break;
fi
done
test -z $ARFLAGS && AC_MSG_ERROR([Failed to find suitable flags for ar])
# Check for and enable C++14 support
# Error if not supported
AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory])
#############################################################
# STD Library functions
#############################################################
# Checks for libraries.
AC_CHECK_LIB([m], [sqrt])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_VPRINTF
# Check for OpenMP support
: ${enable_openmp=no} # Disable by default
AC_OPENMP
BOUT_USE_OPENMP=$enable_openmp
BOUT_OPENMP_SCHEDULE=$with_openmp_schedule
# Check if we have access to __PRETTY_FUNCTION__
BOUT_CHECK_PRETTYFUNCTION
#############################################################
# Code coverage using gcov
#
# Mutally exclusive with optimisation, therefore needs to come first
# so we can turn off optimisation if coverage is enabled
#############################################################
AX_CODE_COVERAGE()
AS_IF([test "x$enable_code_coverage" = "xyes"],
[
AS_IF([test "x$enable_optimize"], [
AC_MSG_WARN([Code coverage clashes with optimisations, disabling optimisations])
enable_optimize="no"
])
COVERAGE_FLAGS="--coverage --no-inline"
LDFLAGS="$LDFLAGS --coverage"
], [
COVERAGE_FLAGS=
])
AC_SUBST([COVERAGE_FLAGS])
#############################################################
# General Options
#############################################################
# Always pass -Werror=unknown-warning-option to get Clang to fail on bad
# flags, otherwise they are always appended to the warn_cxxflags variable,
# and Clang warns on them for every compilation unit.
# If this is passed to GCC, it will explode, so the flag must be enabled
# conditionally.
# This check taken from AX_COMPILER_FLAGS_CXXFLAGS
extra_compiler_flags_test=""
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
extra_compiler_flags_test="-Werror=unknown-warning-option"
])
# A similar check to above, but for Intel. -we is undocumented, but
# the equivalent (?) -diag-error gets accepted by GCC. 10006 is
# "unknown option", and 10148 is the more recent "unknown warning
# option"
AX_CHECK_COMPILE_FLAG([-we10006,10148],[
extra_compiler_flags_test="-we10006,10148"
])
AS_IF([test "x$enable_warnings" != "xno"], [
# Some hopefully sensible default compiler warning flags
AX_APPEND_COMPILE_FLAGS([ dnl
-Wall dnl
-Wextra dnl
-Wnull-dereference dnl
], [CXXFLAGS], [$extra_compiler_flags_test])
# Note we explicitly turn off -Wcast-function-type as PETSc *requires*
# we cast a function to the wrong type in MatFDColoringSetFunction
# Also note that gcc ignores unknown flags of the form "-Wno-warning"
# for backwards compatibility. Therefore we need to add the positive
# form as an additional flag which it will choke on (if it doesn't
# exist). See: https://gcc.gnu.org/wiki/FAQ#wnowarning
AX_APPEND_COMPILE_FLAGS([ dnl
-Wno-cast-function-type dnl
], [CXXFLAGS], [$extra_compiler_flags_test "-Wcast-function-type"])
], [
AC_MSG_NOTICE([Compiler warnings disabled])
])
OPT_FLAGS=""
enable_checks_def=2
AS_IF([test "$enable_debug" != ""], [
AC_MSG_NOTICE([Enabling all debug options])
enable_checks_def=3
# use -Og with available, otherwise fall back to -O0
OPT_FLAGS="-g -O0 -Og -fno-inline -hipa1"
], [
AS_IF([test "x$enable_optimize" != "xno"], [
AS_CASE(["$enable_optimize"],
["default" | "yes" | ""],
[AC_MSG_NOTICE([Enabling default optimisations])
OPT_FLAGS="-O2"],
["fast" | "4"],
[AC_MSG_NOTICE([Enabling level 4 optimisations])
OPT_FLAGS="-Ofast -fno-finite-math-only -march=native -funroll-loops"
enable_checks_def=0],
["3"],
[AC_MSG_NOTICE([Enabling level 3 optimisations])
OPT_FLAGS="-O3 -march=native -funroll-loops"
enable_checks_def=0],
["2"],
[AC_MSG_NOTICE([Enabling level 2 optimisations])
OPT_FLAGS="-O2 -march=native"
enable_checks_def=1],
["1" | "0"],
[AC_MSG_NOTICE([Enabling level $enable_optimize optimisations])
OPT_FLAGS="-O$enable_optimize"],
[
AC_MSG_ERROR([unrecognized option: --enable-optimize=$enable_optimize])
])
], [OPT_FLAGS=""])
])
# Append optimisation/debug flags if they work with this compiler
AX_APPEND_COMPILE_FLAGS([ dnl
$OPT_FLAGS dnl
], [CXXFLAGS], [$extra_compiler_flags_test])
# Disable checks if optimization > 2 is used
AS_IF([test "x$enable_checks" = "xdefault" ], [
enable_checks=$enable_checks_def
])
BOUT_CHECK_LEVEL=0
AS_IF([test "x$enable_checks" != "xno" && test "x$enable_checks" != "x0"], [
AC_MSG_NOTICE([Run-time checking enabled])
AS_CASE([$enable_checks],
[1], [AC_MSG_NOTICE([ -> Level 1 (Basic checking)])
CXXFLAGS="$CXXFLAGS -DCHECK=1"
BOUT_CHECK_LEVEL=1],
[3], [AC_MSG_NOTICE([ -> Level 3 (Full checking)])
enable_output_debug=yes
CXXFLAGS="$CXXFLAGS -DCHECK=3"
BOUT_CHECK_LEVEL=3],
[AC_MSG_NOTICE([ -> Level 2 (Enhanced checking)])
CXXFLAGS="$CXXFLAGS -DCHECK=2"
BOUT_CHECK_LEVEL=2])
], [
AC_MSG_NOTICE([Run-time checking disabled])
])
BOUT_USE_MSGSTACK=$(test $BOUT_CHECK_LEVEL -gt 1 && echo yes || echo no)
AS_IF([test "x$enable_msgstack" = "xyes" ], [
BOUT_USE_MSGSTACK=yes
], [
AS_IF([test "x$enable_msgstack" = "xno" ], [
BOUT_USE_MSGSTACK=no
], [])
])
AS_IF([test $BOUT_USE_MSGSTACK = no ], [
AC_MSG_NOTICE([Stack tracing disabled])
], [
AC_MSG_NOTICE([Stack tracing enabled])
])
BOUT_USE_SIGNAL=no
AS_IF([test "x$enable_signal" != "xno"], [
AC_MSG_NOTICE([Segmentation fault handling enabled])
BOUT_USE_SIGNAL=yes
], [
AC_MSG_NOTICE([Segmentation fault handling disabled])
])
BOUT_USE_COLOR=no
AS_IF([test "x$enable_color" != "xno"], [
AC_MSG_NOTICE([Output coloring enabled])
BOUT_USE_COLOR=yes
], [
AC_MSG_NOTICE([Output coloring disabled])
])
BOUT_USE_TRACK=no
AS_IF([test "x$enable_track" = "xyes"], [
AC_MSG_NOTICE([Field name tracking enabled])
BOUT_USE_TRACK=yes
], [
AC_MSG_NOTICE([Field name tracking disabled])
])
BOUT_USE_SIGFPE=no
AS_IF([test "x$enable_sigfpe" = "xyes"], [
AC_MSG_NOTICE([Signaling floating point exceptions enabled])
BOUT_USE_SIGFPE=yes
], [
AC_MSG_NOTICE([Signaling floating point exceptions disabled])
])
BOUT_USE_OUTPUT_DEBUG=no
AS_IF([test "x$enable_output_debug" = "xyes"], [
AC_MSG_NOTICE([Extra debug output enabled])
BOUT_USE_OUTPUT_DEBUG=yes
], [
AC_MSG_NOTICE([Extra debug output disabled])
])
BOUT_VERSION=$PACKAGE_VERSION
BOUT_VERSION_MAJOR=$(echo $PACKAGE_VERSION | cut -d. -f1)
BOUT_VERSION_MINOR=$(echo $PACKAGE_VERSION | cut -d. -f2)
BOUT_VERSION_PATCH=$(echo ${PACKAGE_VERSION%-*} | cut -d. -f3)
BOUT_VERSION_TAG=$(echo $PACKAGE_VERSION | cut -d- -f2)
#############################################################
# Enable Backtrace if possible
#############################################################
BOUT_USE_BACKTRACE=no
AS_IF([test "x$enable_backtrace" = "xyes" || test "x$enable_backtrace" = "xmaybe"], [
AC_CHECK_PROG([works], [addr2line], [yes], [no])
AS_IF([test $works = yes], [
AC_CHECK_FUNCS([popen backtrace], [works=yes], [works=no; break])
])
AS_IF([test $works = yes], [
AC_CHECK_HEADERS([execinfo.h dlfcn.h], [works=yes], [works=no; break])
])
AS_IF([test $works = yes], [
AC_SEARCH_LIBS([dladdr], [dl], [works=yes], [works=no; break])
])
AS_IF([test $works = yes], [
AC_MSG_NOTICE([Native backtrace enabled])
BOUT_USE_BACKTRACE=yes
], [
AS_IF([test "x$enable_backtrace" = "xyes"], [
AC_MSG_ERROR([backtrace requested, but cannot be enabled])
], [
AC_MSG_WARN([Native backtrace disabled])
])
])
])
AS_IF([test "x$enable_metric_3d" != "xno"], [
AC_MSG_WARN([Using Field3D to store coordinates data, this is experimental.])
BOUT_METRIC_TYPE="3D"
], [
AC_MSG_NOTICE([Using Field2D to store coordinates data])
BOUT_METRIC_TYPE="2D"
])
#############################################################
# Build into shared object (pic)
#############################################################
LIB_TO_BUILD=''
AS_IF([test "x$enable_shared" = "xyes"], [
# compile as position independent code.
# -fpic is apparently faster then -fPIC, but -fPIC works always.
# From a SO comment (https://stackoverflow.com/a/3544211/3384414):
# What's more: I did a little experiment here (on x86_64
# platform), -fPIC and -fpic appears to have generated the same
# code. It seems they generate a different code only on m68k,
# PowerPC and SPARC.
# Therfore use -fPIC for now
CXXFLAGS="$CXXFLAGS -fPIC"
LIB_TO_BUILD="$LIB_TO_BUILD"' $(BOUT_LIB_PATH)/libbout++.so'
AS_IF([test "x$enable_static" = "xauto"], [
enable_static=no
])
SHARED_EXTRA=':'
AS_IF([test "x$enable_static" = "xno"], [
SHARED_EXTRA='$(RM) -f $(BOUT_LIB_PATH)/libbout++.a'
])
], [
AS_IF([test "x$enable_static" = "xauto"], [
enable_static=yes
])
])
AS_IF([test "x$enable_static" = "xyes"], [
LIB_TO_BUILD="$LIB_TO_BUILD"' $(BOUT_LIB_PATH)/libbout++.a'
STATIC_EXTRA=':'
# In case we only build static, make sure shared libs are removed
AS_IF([! test "x$enable_shared" = "xyes"], [
STATIC_EXTRA='$(RM) -f $(BOUT_LIB_PATH)/*.so*'
])
])
AS_IF([test "x$LIB_TO_BUILD" = x ], [
AC_MSG_ERROR([Need to enable at least one of static or shared!])
])
#############################################################
# Git revision number
#############################################################
rev=`git rev-parse HEAD`
AS_IF([test $? = 0], [
AC_MSG_NOTICE([Git revision: $rev])
BOUT_REVISION=$rev
], [
BOUT_REVISION=
])
#############################################################
# FFT routines
#############################################################
AS_IF([test "x$with_fftw" != "xno"], [
AC_PATH_PROG([fftw_path], [fftw-wisdom], [no], [$with_fftw$PATH_SEPARATOR$PATH])
AS_IF([test "x$fftw_path" != "xno"], [
fftw_wisdom0=`AS_DIRNAME(["$fftw_path"])`
fftw_wisdom=`AS_DIRNAME(["$fftw_wisdom0"])`
with_fftw="$with_fftw $fftw_wisdom"
], AC_MSG_NOTICE([FFTW3 requested but fftw-wisdom not found]))
BOUT_ADDPATH_CHECK_HEADER(fftw3.h, ,AC_MSG_ERROR([FFTW3 requested but header not found]), $with_fftw)
BOUT_ADDPATH_CHECK_LIB(fftw3, fftw_plan_dft_r2c_1d, ,AC_MSG_ERROR([FFTW3 requested but library not found]), $with_fftw)
BOUT_HAS_FFTW="yes"
],
[
AC_MSG_NOTICE([Configuring without FFTW3 is not recommended])
BOUT_HAS_FFTW="no"
])
#############################################################
# netCDF support
#############################################################
NCCONF="" # Configuration script
BOUT_HAS_NETCDF=no
BOUT_HAS_LEGACY_NETCDF=no
AS_IF([test "x$with_netcdf" != "xno"],
[
##########################################
# Try to find a valid NetCDF configuration
#
# at first, try to find ncconf script
# Search for NetCDF config scripts, prefer ncxx4-config over nc-config
# Check if the path to the config script has been supplied directly, otherwise
# check the path provided by --with-netcdf, appending "/bin" if need
# be, then check system path
# Set NCCONF to the full path of the found scropt
AS_CASE([`basename $with_netcdf 2> /dev/null`],
["ncxx4-config"], [NCCONF=$with_netcdf],
["nc-config"], [NCCONF=$with_netcdf],
[AC_PATH_PROGS([NCCONF], [ncxx4-config nc-config], [],
[$with_netcdf$PATH_SEPARATOR$with_netcdf/bin$PATH_SEPARATOR$PATH])])
##########################################
# Get configuration
AS_IF([test "x$NCCONF" != "x" ],
[
# If we found nc-config rather than ncxx4-config, we need to check if it supports C++
AS_IF([test `basename $NCCONF` = 'nc-config'],
[AC_MSG_CHECKING([if $NCCONF has C++4 support])
nc_has_cpp4=`$NCCONF --has-c++4`
AC_MSG_RESULT([$nc_has_cpp4])
AC_MSG_CHECKING([if $NCCONF has C++ support])
nc_has_cpp=`$NCCONF --has-c++`
AC_MSG_RESULT([$nc_has_cpp])
], [
nc_has_cpp4="yes"
])
NCINC=`$NCCONF --cflags`
EXTRA_INCS="$EXTRA_INCS $NCINC"
AS_IF([test "x$nc_has_cpp4" = "xyes"],
[
NCLIB=`$NCCONF --libs`
BOUT_HAS_NETCDF=yes
AC_MSG_NOTICE([ -> NetCDF-4 support enabled])
], [
# nc-config might not *say* it has C++ support, but we can try anyway
AC_MSG_CHECKING([if we can compile NetCDF with C++])
# Note netcdf_c++ needed
NCLIB=`$NCCONF --libs | sed s/-lnetcdf/-lnetcdf_c++\ -lnetcdf/`
save_LIBS=$LIBS
save_LDFLAGS=$LDFLAGS
save_CXXFLAGS=$CXXFLAGS
AC_LANG_PUSH([C++])
LIBS="$save_LIBS $NCLIB"
LDFLAGS="$save_LDFLAGS $NCLIB"
CXXFLAGS="$save_CXXFLAGS $NCINC"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([
#include <netcdfcpp.h>
], [NcFile file("foo.nc");])],
[AC_MSG_RESULT([yes])
AC_MSG_NOTICE([ -> Legacy NetCDF support enabled])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([*** Could not compile NetCDF C++ program!])])
AC_LANG_POP([C++])
LIBS=$save_LIBS
LDFLAGS=$save_LDFLAGS
CXXFLAGS="$save_CXXFLAGS"
BOUT_HAS_NETCDF=yes
BOUT_HAS_LEGACY_NETCDF=yes
])
EXTRA_LIBS="$EXTRA_LIBS $NCLIB"
file_formats="$file_formats netCDF"
NCPATH="found"
NCFOUND=yes
], [
# if nc-config / ncxx4-config is not found, try to find library directly
BOUT_MSG_DEBUG([calling bout addpath])
BOUT_ADDPATH_CHECK_HEADER(netcdfcpp.h,
BOUT_ADDPATH_CHECK_LIB(netcdf, nc_get_att,
BOUT_ADDPATH_CHECK_LIB(netcdf_c++, nc_close, NCFOUND=yes, NCFOUND=no, [$with_netcdf]),
NCFOUND=no, [$with_netcdf]),
NCFOUND=no, [$with_netcdf])
AS_IF([test "x$NCFOUND" = "xyes"],
[
file_formats="$file_formats netCDF"
AC_MSG_NOTICE([ -> Legacy NetCDF support enabled])
NCPATH="found"
BOUT_HAS_NETCDF=yes
BOUT_HAS_LEGACY_NETCDF=yes
], [])
])
AS_IF([test $with_netcdf && test "x$NCFOUND" != "xyes" ], AC_MSG_ERROR([NetCDF requested but not found]), [])
AS_IF([test "x$NCFOUND" != "xyes"], [AC_MSG_NOTICE([ -> NetCDF support disabled])], [])
], [])
#############################################################
# Parallel NetCDF support
#############################################################
PNCPATH=""
AS_IF([test "$with_pnetcdf" != "no" && test "x$with_pnetcdf" != "x" ], [
AC_MSG_NOTICE([Searching for Parallel-NetCDF library])
AS_IF([test "x$with_pnetcdf" != "xyes"], [
# Given a path to the library
AC_CHECK_FILES([$with_pnetcdf/include/pnetcdf.h], [PNCPATH=$with_pnetcdf],
AC_MSG_NOTICE([parallel-netcdf not found in given directory])
)
])
# Find the utilities included with pnetcdf
AS_IF([test "x$PNCPATH" = "x"], [
AS_IF([test "x$with_pnetcdf" = "xyes"], [
AC_PATH_PROG([NCMPIDUMP_PATH], [ncmpidump])
], [
AC_PATH_PROG([NCMPIDUMP_PATH], [ncmpidump], [$with_pnetcdf$PATH_SEPARATOR$PATH])
])
AS_IF([test "$NCMPIDUMP_PATH" != ""], [
AC_CHECK_FILES([$NCMPIDUMP_PATH/../include/pnetcdf.h], [PNCPATH=$NCMPIDUMP_PATH/../])
])
])
AS_IF([test "x$PNCPATH" != "x"], [
AC_CHECK_FILES($path/lib/libpnetcdf.a, PNCPATHLIB='lib',
AC_CHECK_FILES($path/lib64/libpnetcdf.a, PNCPATHLIB='lib64', PNCPATH=''))
])
AS_IF([test "x$PNCPATH" = "x" && test "x$with_pnetcdf" != "x"], [
AC_MSG_FAILURE([*** Parallel-NetCDF requested but not found])
])
])
AS_IF([test "x$PNCPATH" = "x"], [
AC_MSG_NOTICE([Parallel-NetCDF support disabled])
], [
# Set a compile-time flag
CXXFLAGS="$CXXFLAGS -DPNCDF"
EXTRA_INCS="$EXTRA_INCS -I$PNCPATH/include"
EXTRA_LIBS="$EXTRA_LIBS -L$PNCPATH/$PNCPATHLIB -lpnetcdf"
file_formats="$file_formats Parallel-NetCDF"
AC_MSG_NOTICE([Parallel-NetCDF support enabled])
])
#############################################################
# Check file formats
#############################################################
AS_IF([test "x$file_formats" = "x"], [
AC_MSG_ERROR([*** At least one file format must be supported])
], [
AC_MSG_NOTICE([Supported file formats:$file_formats])
])
#############################################################
# LAPACK routines (Used for tri- and band-diagonal solvers)
#############################################################
BOUT_HAS_LAPACK="no"
AS_IF([test "x$with_lapack" != "xno"], [
AS_IF([test "x$with_lapack" = "xguess" || test "x$with_lapack" = "x" ],
[lapack_path=""],
[AS_IF([test "x$with_lapack" != xyes],
[lapack_path=$with_lapack
with_lapack=yes],
[lapack_path=""])
])
BOUT_ADDPATH_CHECK_LIB(blas, zgemm_,
[BOUT_HAS_BLAS=yes],
[AS_IF([test "x$with_lapack" = "xyes"],
AC_MSG_ERROR([LAPACK requested but couldn't find BLAS]))],
$lapack_path)
BOUT_ADDPATH_CHECK_LIB(lapack, zgbsv_,
[BOUT_HAS_LAPACK=yes
AC_MSG_NOTICE([Using LAPACK])
],
[AS_IF([test "x$with_lapack" = "xyes"],
AC_MSG_ERROR([LAPACK requested but not found]))],
$lapack_path)
])
#############################################################
# PETSc library
#############################################################
AS_IF([test "x$with_petsc" != "x" && test "$with_petsc" != "no"], [
# Supplying an argument to "--with-petsc" only works if PETSC_ARCH
# *should* be empty. If it should be non-empty, THIS WILL NOT WORK
AS_IF([test "$with_petsc" != "yes"], [
PETSC_DIR="$with_petsc"
PETSC_ARCH=
])
AC_MSG_NOTICE([Using PETSC_DIR=$PETSC_DIR, PETSC_ARCH=$PETSC_ARCH])
# Define a macro for a nice error message that preserves the
# formatting. Use like:
#
# PETSC_ERROR_MESSAGE
#
# with no identation
m4_define(PETSC_ERROR_MESSAGE,
[ You may need to specify PETSC_DIR and PETSC_ARCH like so:
--with-petsc PETSC_DIR=\$PETSC_DIR PETSC_ARCH=\$PETSC_ARCH
Also see the help online:
http://bout-dev.readthedocs.io/en/latest/user_docs/advanced_install.html#petsc
])
# PETSc changed the location of the conf directory in 3.5, so we
# need to check both locations
# If we find nether, try to fall back to pkg-conf
PETSC_PKGCONF=no
AC_CHECK_FILE($PETSC_DIR/$PETSC_ARCH/conf, [
PETSC_CONFDIR=${PETSC_DIR}/conf
], [
AC_CHECK_FILE($PETSC_DIR/$PETSC_ARCH/lib/petsc/conf, [
PETSC_CONFDIR=${PETSC_DIR}/lib/petsc/conf
], [
PKG_CHECK_MODULES(PETSC, PETSc >= 3.4.0 ,
PETSC_PKGCONF=yes, [
PKG_CHECK_MODULES(PETSC, petsc >= 3.4.0 ,
PETSC_PKGCONF=yes, [
AC_MSG_ERROR([--with-petsc was specified but could not find PETSc distribution.
PETSC_ERROR_MESSAGE])
])
])
])
])
AS_IF([test $PETSC_PKGCONF = no] ,
[
# We've found an installation, need to check we can use it. First we
# need to be able to check the version number, for which we need
# petscverion.h
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$PETSC_DIR/include"
AC_CHECK_HEADER([petscversion.h],
[FOUND_PETSC_HEADER=yes],
[FOUND_PETSC_HEADER=no]
)
# This is a terrible hack for some Linux distributions (Fedora) that
# install PETSc in a non-supported fashion. This is really the fault
# of PETSc for their weird method of installation
AS_IF([test $FOUND_PETSC_HEADER = no], [
AC_CHECK_FILE([${PETSC_CONFDIR}/petscvariables], [], [
AC_MSG_ERROR([Unable to find either petscversion.h or petscvariables
PETSC_ERROR_MESSAGE])
])
# This relies on the assumption that PETSC_ARCH is empty
PETSC_CC_INCLUDES=$(grep ^PETSC_CC_INCLUDES ${PETSC_CONFDIR}/petscvariables | cut -d= -f 2-)
AC_MSG_NOTICE([Looking for petscverion.h using $PETSC_CC_INCLUDES from ${PETSC_CONFDIR}/petscvariables])
# This is the cache variable set by the previous call to
# AC_CHECK_HEADER. We need to unset it so we can call the macro
# again, but now with different CPPFLAGS
AS_UNSET([ac_cv_header_petscversion_h])
CPPFLAGS="$CPPFLAGS $PETSC_CC_INCLUDES"
AC_CHECK_HEADER([petscversion.h], [], [
AC_MSG_ERROR([Couldn't find or include petscversion.h.
PETSC_ERROR_MESSAGE])
])
], [])
# Now we have the header we want, we can check the version number
AC_MSG_CHECKING([PETSc is at least 3.4.0])
AC_EGREP_CPP([yes], [
#include <petscversion.h>
#if PETSC_VERSION_GE(3, 4, 0)
yes
#endif
], [PETSC_VERSION_OK="yes"],
[PETSC_VERSION_OK="no"])
AC_MSG_RESULT([$PETSC_VERSION_OK])
CPPFLAGS="$save_CPPFLAGS"
AS_IF([test $PETSC_VERSION_OK = no], [
AC_MSG_ERROR([PETSc version must be at least 3.4.0])
])
# Check if PETSc was compiled with SUNDIALS
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$PETSC_DIR/$PETSC_ARCH/include"
AC_MSG_CHECKING([PETSc has SUNDIALS support])
AC_EGREP_CPP([yes], [
#include <petscconf.h>
#ifdef PETSC_HAVE_SUNDIALS
yes
#endif
], [PETSC_HAS_SUNDIALS="yes"],
[PETSC_HAS_SUNDIALS="no"])
AC_MSG_RESULT([$PETSC_HAS_SUNDIALS])
CPPFLAGS="$save_CPPFLAGS"
AS_IF([test "$PETSC_HAS_SUNDIALS" = "yes"], [
CXXFLAGS="$CXXFLAGS -DPETSC_HAS_SUNDIALS "
])
# Set the line to be included in the make.conf file
PETSC_MAKE_INCLUDE="include ${PETSC_CONFDIR}/variables"
BOUT_HAS_PETSC="yes"
EXTRA_INCS="$EXTRA_INCS \$(PETSC_CC_INCLUDES)"
EXTRA_LIBS="$EXTRA_LIBS \$(PETSC_LIB)"
], [ dnl pkg-config version
# Check if PETSc was compiled with SUNDIALS
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PETSC_CFLAGS"
AC_MSG_CHECKING([PETSc has SUNDIALS support])
AC_EGREP_CPP([yes], [
#include <petscconf.h>
#ifdef PETSC_HAVE_SUNDIALS
yes
#endif
], [PETSC_HAS_SUNDIALS="yes"],
[PETSC_HAS_SUNDIALS="no"])
AC_MSG_RESULT([$PETSC_HAS_SUNDIALS])
CPPFLAGS="$save_CPPFLAGS"
AS_IF([test "$PETSC_HAS_SUNDIALS" = "yes"], [
CXXFLAGS="$CXXFLAGS -DPETSC_HAS_SUNDIALS "
])
PETSC_MAKE_INCLUDE=
BOUT_HAS_PETSC="yes"
EXTRA_INCS="$EXTRA_INCS $PETSC_CFLAGS"
EXTRA_LIBS="$PETSC_LIBS $EXTRA_LIBS"
])
], [
PETSC_MAKE_INCLUDE=
BOUT_HAS_PETSC="no"
PETSC_HAS_SUNDIALS="no"
])
#############################################################
# SLEPc library
#############################################################
AS_IF([test "x$with_slepc" != "x" && test "$with_slepc" != "no"], [
AS_IF([test $BOUT_HAS_PETSC = "no"], [
AC_MSG_ERROR([--with-slepc specified, but no PETSc detected. Please reconfigure and specify --with-petsc
PETSC_ERROR_MESSAGE])
])
# Supplying an argument to "--with-slepc" only works if SLEPC_ARCH
# *should* be empty. If it should be non-empty, THIS WILL NOT WORK
AS_IF([test "$with_slepc" != "yes"], [
SLEPC_DIR="$with_slepc"
SLEPC_ARCH=
])
AC_MSG_NOTICE([Using SLEPC_DIR=$SLEPC_DIR, SLEPC_ARCH=$SLEPC_ARCH])
# Define a macro for a nice error message that preserves the
# formatting. Use like:
#
# SLEPC_ERROR_MESSAGE
#
# with no identation
m4_define(SLEPC_ERROR_MESSAGE,
[ You may need to specify SLEPC_DIR and SLEPC_ARCH like so:
--with-slepc SLEPC_DIR=\$SLEPC_DIR SLEPC_ARCH=\$SLEPC_ARCH
Also see the help online:
http://bout-dev.readthedocs.io/en/latest/user_docs/advanced_install.html#slepc
])
# Slepc changed the location of the conf directory in 3.5, so we
# need to check both locations
AC_CHECK_FILE($SLEPC_DIR/$SLEPC_ARCH/conf, [
SLEPC_CONFDIR=${SLEPC_DIR}/conf
], [
AC_CHECK_FILE($SLEPC_DIR/$SLEPC_ARCH/lib/slepc/conf, [
SLEPC_CONFDIR=${SLEPC_DIR}/lib/slepc/conf
], [
AC_MSG_ERROR([--with-slepc was specified but could not find Slepc distribution.
SLEPC_ERROR_MESSAGE])
])
])
# We've found an installation, need to check we can use it. First we
# need to be able to check the version number, for which we need
# slepcverion.h
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$SLEPC_DIR/include"
AC_CHECK_HEADER([slepcversion.h],
[FOUND_SLEPC_HEADER=yes],
[FOUND_SLEPC_HEADER=no]
)
# This is a terrible hack for some Linux distributions (Fedora) that
# install Slepc in a non-supported fashion. This is really the fault
# of Slepc for their weird method of installation
AS_IF([test $FOUND_SLEPC_HEADER = no], [
AC_CHECK_FILE([${SLEPC_CONFDIR}/slepc_variables], [], [
AC_MSG_ERROR([Unable to find either slepcversion.h or slepc_variables
SLEPC_ERROR_MESSAGE])
])
# This relies on the assumption that SLEPC_ARCH is empty
SLEPC_CC_INCLUDES=$(grep ^SLEPC_CC_INCLUDES ${SLEPC_CONFDIR}/slepc_variables | cut -d= -f 2-)
AC_MSG_NOTICE([Looking for slepcverion.h using $SLEPC_CC_INCLUDES from ${SLEPC_CONFDIR}/slepc_variables])
# This is the cache variable set by the previous call to
# AC_CHECK_HEADER. We need to unset it so we can call the macro
# again, but now with different CPPFLAGS
AS_UNSET([ac_cv_header_slepcversion_h])
CPPFLAGS="$CPPFLAGS $SLEPC_CC_INCLUDES"
AC_CHECK_HEADER([slepcversion.h], [], [
AC_MSG_ERROR([Couldn't find or include slepcversion.h.
SLEPC_ERROR_MESSAGE])
])
], [])
# Now we have the header we want, we can check the version number
AC_MSG_CHECKING([Slepc is at least 3.4.0])
AC_EGREP_CPP([yes], [
#include <slepcversion.h>
#if SLEPC_VERSION_GE(3, 4, 0)
yes
#endif
], [SLEPC_VERSION_OK="yes"],
[SLEPC_VERSION_OK="no"])
AC_MSG_RESULT([$SLEPC_VERSION_OK])
CPPFLAGS="$save_CPPFLAGS"
AS_IF([test $SLEPC_VERSION_OK = no], [
AC_MSG_ERROR([Slepc version must be at least 3.4.0])
])
# Check if Slepc was compiled with SUNDIALS
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$SLEPC_DIR/$SLEPC_ARCH/include"
# Set the line to be included in the make.conf file
SLEPC_MAKE_INCLUDE="include ${SLEPC_CONFDIR}/slepc_variables"
BOUT_HAS_SLEPC="yes"
EXTRA_INCS="$EXTRA_INCS \$(SLEPC_INCLUDE)"
EXTRA_LIBS="$EXTRA_LIBS \$(SLEPC_LIB)"
], [
SLEPC_MAKE_INCLUDE=
BOUT_HAS_SLEPC="no"
])
#############################################################
# Solver choice: SUNDIALS' IDA, SUNDIALS' CVODE, PVODE
#############################################################
BOUT_HAS_SUNDIALS=no
AS_IF([test "x$with_sundials" != "x" && test "x$with_sundials" != "xno"], [
# Now follows a few different checks for the version of SUNDIALS.
# We need the sundials_config.h header, which comes with all the
# versions we care about
# If we've been given a path, look in there first
AS_IF([test "x$with_sundials" != "xyes"], [
AC_CHECK_FILE([$with_sundials/include/sundials/sundials_config.h],
[SUNDIALS_INC=$with_sundials/include], [SUNDIALS_INC=""])
])