-
Notifications
You must be signed in to change notification settings - Fork 9
/
configure1
1843 lines (1653 loc) · 59.5 KB
/
configure1
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
# Initial information about the package
AC_INIT([Agate],[1.4.1],[[email protected]])
# Check source directory
AC_CONFIG_SRCDIR([bin/agate.cpp])
AC_CONFIG_SRCDIR([src/base/exception.cpp])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([m4])
# Check include directory
AC_CONFIG_HEADER([agate.h])
#AC_CONFIG_HEADER(config.h)
# Check for c++ preprocessor and compiler
CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/lib"
if test -d "/usr/local/lib"; then
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi
if test -d "/usr/lib64"; then
LDFLAGS="$LDFLAGS -L/usr/lib64"
fi
OLD_CXXFLAGS=$CXXFLAGS
OLD_CPPFLAGS=$CPPFLAGS
AC_PROG_CXXCPP
#---# Precheck for NetCDF compiler #---#
AC_MSG_CHECKING([for user defined NetCDF library prefix])
AC_ARG_WITH([netcdf],
[AS_HELP_STRING([--with-netcdf],
[prefix used for include and lib directories]
)
],
[netcdf_prefix="$with_netcdf";resultnetcdf=yes],
[netcdf_prefix="";resultnetcdf=no]
)
AC_MSG_RESULT([$resultnetcdf])
OLDPATH=$PATH
PATH="$PATH:$netcdf_prefix/bin"
AC_PATH_PROGS([NCCONFIG],[nc-config],[no])
PATH=$OLDPATH
if test x"$NCCONFIG" != x"no"
then
NC_CC=$($NCCONFIG --cc)
else
NC_CC=$CXX
fi
#---# END #---#
AC_PROG_CXX([$NC_CC $CXX])
CXXFLAGS=$OLD_CXXFLAGS
CPPFLAGS=$OLD_CPPFLAGS
# Check for automak >= v1.9
AM_INIT_AUTOMAKE([1.14])
AM_SILENT_RULES([yes])
# Set main langage to c++
AC_LANG([C++])
AC_GNU_SOURCE
echo
echo "================================================================================"
echo "=== Tools "
echo "================================================================================"
# Tools
AC_PROG_GREP
AC_PROG_SED
AC_PROG_LN_S
AC_PATH_PROG([GIT],[git],[no])
includedir='${prefix}/include/agate'
AC_SUBST(includedir)
# To build libraries
AM_PROG_AR
LT_INIT([disable-static])
AC_CANONICAL_HOST
case $host in
*linux*)
default_prefix=/usr
GL_PREFIX=GL
AC_DEFINE([HAVE_LINUX],[1],[Define to 1 if we are on linux])
;;
*bsd*|*apple*)
default_prefix=/usr/local
GL_PREFIX=OpenGL
;;
*mingw32*)
AC_DEFINE([HAVE_MINGW],[1],[Define to 1 if we are running on WINGW])
GL_PREFIX=GL
;;
*)
default_prefix=/usr
GL_PREFIX=GL
esac
AC_DEFINE_UNQUOTED([COMPILE_HOST],"$host", [Host on which the code was compile])
AC_DEFINE_UNQUOTED([COMPILE_BUILD],"$build", [Build target : on which target should run the code])
if test x"$GIT" != x"n"
then
HASH=$(${GIT} rev-parse --short HEAD)
AC_DEFINE_UNQUOTED([HASH_VERSION],"$HASH", [git short SHA1 of the current version])
else
HASH="unknown"
fi
##########################################################################
# C++ support
##########################################################################
echo
echo "================================================================================"
echo "=== C/C++ functions "
echo "================================================================================"
AC_CHECK_HEADER([getopt.h],[AC_DEFINE([HAVE_GETOPT_H],[1],[Define to 1 if we have getopt.])],[])
AC_CHECK_HEADER([cmath],[LIBS="$LIBS -lm"],[
AC_MSG_ERROR([--> Need mathematical library])])
##########################################################################
# C++11 support
##########################################################################
echo
echo "================================================================================"
echo "=== C++11 compilers requirements "
echo "================================================================================"
##########################
# Check for C++11
##########################
AX_CXX_COMPILE_STDCXX_11([noext],[mandatory])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
##########################
# Use -lm library
##########################
#AC_MSG_CHECKING([wheaher to use -lm])
#AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<cmath>]],[[float a = std::floor((float)2.555);a+=1.0;]])],
# [
# AC_MSG_RESULT([no])
# ],
# [
# OLD_LIBS=$LIBS
# LIBS="$LIBS -lm"
# AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<cmath>]],[[float a = std::floor((float)2.555);a+=1.0;]])],
# [
# AC_MSG_RESULT([yes])
# ],
# [
# AC_MSG_RESULT([broken])
# AC_MSG_ERROR([Can not link with libm (cmath).])
# ]
# )
# ]
# )
##########################
# use -lstdc++
##########################
AC_MSG_CHECKING([whether to use -lstdc++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<exception>
#include<vector>
#include<iostream>]],[[
try
{
std::vector<int> vec;
for ( auto it = vec.begin() ; it != vec.end() ; ++it){}
throw std::exception();
}
catch(std::exception& e)
{std::cout << e.what();}]])],
[
AC_MSG_RESULT([no])
],
[
OLD_LIBS=$LISB
LIBS="$LIBS -lstdc++"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include<exception>
#include<vector>
#include<iostream>]],
[[
try
{
std::vector<int> vec;
for ( auto it = vec.begin() ; it != vec.end() ; ++it){}
throw std::exception();
}
catch(std::exception& e)
{std::cout << e.what();}]])],
[
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([broken])
AC_MSG_ERROR([Can not use exception.])
]
)
]
)
##########################
# Accept shrink_to_fit
##########################
AC_MSG_CHECKING([whether we have shrink_to_fit])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include<vector>
]],[[
std::vector<int> vec;
vec.push_back(1);
vec.shrink_to_fit();
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_SHRINK_TO_FIT],[1],[Define to 1 if shrink_to_fit can be used])
],
[
AC_MSG_RESULT([no])
]
)
##########################
# Accept noexcept
##########################
AC_MSG_CHECKING([whether we have noexcept])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
void function(void) noexcept {}]],[[
function();
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([_NOEXCEPT],[noexcept],[define to noexcept if noexcept can be used])
],
[
AC_MSG_RESULT([no])
AC_DEFINE([_NOEXCEPT],[],[Define to nothing if noexcept cannot be used])
]
)
##########################
# Accept long long
##########################
AC_MSG_CHECKING([whether we have long long])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[
long long val = 0;
unsigned long long uval = 1;
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_LONG_LONG],[1],[Define to nothing if we have (unsigned) long long type])
],
[
AC_MSG_RESULT([no])
]
)
##########################
# Accept long double
##########################
AC_MSG_CHECKING([whether we have long double])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[
long double val = 0.0;
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_LONG_LONG],[1],[Define to nothing if we have (unsigned) long long type])
],
[
AC_MSG_RESULT([no])
]
)
##########################
# Accept std::to_string
##########################
AC_MSG_CHECKING([whether we have to_string])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <string>
]],[[
int ival = 0;
unsigned uval = 0;
long lval = 0;
std::string test = std::to_string(ival) + std::to_string(uval) + std::to_string(lval);
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_TO_STRING],[1],[Define to nothing if we have std::to_string])
],
[
AC_MSG_RESULT([no])
]
)
##########################
# Accept std::stoi
##########################
AC_MSG_CHECKING([whether we have stoi])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <string>
]],[[
std::string test("42");
std::stoi(test);
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_STOI],[1],[Define to nothing if we have std::stoi])
],
[
AC_MSG_RESULT([no])
]
)
##########################
# Accept std::stod
##########################
AC_MSG_CHECKING([whether we have stod])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <string>
]],[[
std::string test("42.666");
std::stod(test);
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_STOD],[1],[Define to nothing if we have std::stod])
],
[
AC_MSG_RESULT([no])
]
)
###########################
## Accept find_first_not_of
###########################
#AC_MSG_CHECKING([whether we have find_first_not_of])
#AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
##include <string>
#]],[[
#std::string foo("abcdef");
#foo.find_first_not_of("abc");
#]])],
# [
# AC_MSG_RESULT([yes])
# AC_DEFINE([HAVE_FIND_FIRST_NOT_OF],[1],[Define to nothing if we have std::string::find_first_not_of])
# ],
# [
# AC_MSG_RESULT([no])
# ]
# )
#
###########################
## Accept find_last_not_of
###########################
#AC_MSG_CHECKING([whether we have find_last_not_of])
#AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
##include <string>
#]],[[
#std::string foo("abcdef");
#foo.find_last_not_of("def");
#]])],
# [
# AC_MSG_RESULT([yes])
# AC_DEFINE([HAVE_FIND_LAST_NOT_OF],[1],[Define to nothing if we have std::string::find_last_not_of])
# ],
# [
# AC_MSG_RESULT([no])
# ]
# )
##########################
# Accept std::accumulate
##########################
AC_MSG_CHECKING([whether we have std::accumulate])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include<numeric>
]],[[
double data[10] ={0};
std::accumulate(&data[0],&data[10],0.);
]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_ACCUMULATE],[1],[Define to 1 if ACCUMULATE can be used])
],
[
AC_MSG_RESULT([no])
]
)
##########################################################################
# C++11 threads
##########################################################################
OLD_LIBS=$LIBS;
#CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
# Default option
#CXXFLAGS="$CXXFLAGS -pthread"
PTHREAD_BUGFIX="-Wl,--no-as-needed"
# check for pthread
AC_MSG_CHECKING([whether we have threads])
# try to compile a file that includes a header of the library libjpeg
PTHREADH_TRYME="#include<thread>
void thread_func() {
int a=0;
++a;
}
"
PTHREADC_TRYME=" std::thread pt(thread_func);
pt.join();
"
TRY_PTHREAD_FIX=0
PTHREAD_WORK=0
AC_RUN_IFELSE([AC_LANG_PROGRAM([[$PTHREADH_TRYME]],[[$PTHREADC_TRYME]])],
[
AC_MSG_RESULT([yes]);
PTHREAD_WORK=1;
],
[
LIBS="$LIBS -pthread";
AC_RUN_IFELSE([AC_LANG_PROGRAM([[$PTHREADH_TRYME]],[[$PTHREADC_TRYME]])],
[
AC_MSG_RESULT([yes]);
TRY_PTHREAD_FIX=0;
PTHREAD_WORK=1;
],
[
AC_MSG_RESULT([[might need a fix]]);
TRY_PTHREAD_FIX=1
]
)
]
)
if test $TRY_PTHREAD_FIX != 0;
then
LIBS="$LIBS $PTHREAD_BUGFIX"
AC_MSG_CHECKING([whether running threads with fix works])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[$PTHREADH_TRYME]],[[$PTHREADC_TRYME]])],
[AC_MSG_RESULT([yes])]
PTHREAD_WORK=1,
[AC_MSG_RESULT([no])],
[]
)
fi
have_pthread="no"
# handle check results
if test $PTHREAD_WORK != 1;
then
AC_MSG_NOTICE([]);
AC_MSG_WARN([Threads do not seem to be working.]);
HAVE_PTHREAD=0
#try_audio="no"
# reset original *FLAGS
LIBS=$OLD_LIBS
else
#try_audio="yes"
have_pthread="yes"
AC_MSG_CHECKING([whether we have std::this_thread::yield])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <thread>]],[[std::this_thread::yield();]])],
[
AC_MSG_RESULT([yes]);
AC_DEFINE(HAVE_CPPTHREAD_YIELD,1,[Define to 1 if std::this_thread::yield is available])
],
[
AC_MSG_RESULT([no]);
]
)
AC_DEFINE(HAVE_CPPTHREAD,1,[Define if the threads are usable])
fi
AC_SUBST(HAVE_CPPTHREAD)
echo
echo "================================================================================"
echo "=== Compilation options (optimization/debugging) "
echo "================================================================================"
#=========================================================================
# debug compilation support
#=========================================================================
AC_MSG_CHECKING([whether to build with debug information])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[enable debug data generation (default=no)])
],
[case "${enableval}" in
yes) debugit="yes"; debugcustom="no" ;;
no) debugit="no"; debugcustom="no";;
thread) debugit="yes"; debugcustom="thread";;
proof) debugit="yes"; debugcustom="proof";;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac
],
[debugit="no"]
)
AC_MSG_RESULT([$debugit])
AC_MSG_CHECKING([whether to build with aggressive optimizations])
AC_ARG_ENABLE([optim],
[AS_HELP_STRING([--enable-optim],
[enable cpu-dependant optimizations (default=no)])
],
[case "${enableval}" in
yes) optimit="yes"; optimcustom="no" ;;
no) optimit="no"; optimcustom="no";;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-optim]) ;;
esac
],
[optimit="no"]
)
AC_MSG_RESULT([$optimit])
EXFLAGS=""
#AX_CHECK_COMPILE_FLAG([-Werror],[EXFLAGS="-Werror"])
AX_CHECK_COMPILE_FLAG([-rpath],\
[CPPFLAGS="$CPPFLAGS"],[],[$EXFLAGS])
if test x"$debugit" = x"yes"; then
AC_DEFINE([DEBUG],[],[Debug Mode])
DEBUGLDFLAGS=""
DEBUGFLAGS=$EXFLAGS
AX_CHECK_COMPILE_FLAG([-g],\
[DEBUGFLAGS="$DEBUGFLAGS -g"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-O0],\
[DEBUGFLAGS="$DEBUGFLAGS -O0"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-Wall],\
[DEBUGFLAGS="$DEBUGFLAGS -Wall"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-Wno-uninitialized],\
[DEBUGFLAGS="$DEBUGFLAGS -Wno-uninitialized"],[],[$EXFLAGS]) AX_CHECK_COMPILE_FLAG([-Wextra],\
[DEBUGFLAGS="$DEBUGFLAGS -Wextra"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-Weffc++],\
[DEBUGFLAGS="$DEBUGFLAGS -Weffc++"],[],[$EXFLAGS])
if test x"$debugcustom" = x"thread"; then
AX_CHECK_COMPILE_FLAG([-fsanitize=thread -fPIE],\
[DEBUGFLAGS="$DEBUGFLAGS -fsanitize=thread -fPIE";DEBUGLDFLAGS="-pie"],[],[$EXFLAGS])
fi
if test x"$debugcustom" = x"proof"; then
AX_CHECK_COMPILE_FLAG([-pg],\
[DEBUGFLAGS="$DEBUGFLAGS -pg"])
fi
CXXFLAGS="$CXXFLAGS $DEBUGFLAGS"
LDFLAGS="$LDFLAGS $DEBUGLDFLAGS"
else
if test x"$optimit" = x"yes"; then
AC_DEFINE([NDEBUG],[],[No-debug Mode])
AX_CHECK_COMPILE_FLAG([-O3],[FASTFLAGS="$FASTFLAGS -O3"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-ffast-math],[FASTFLAGS="$FASTFLAGS -ffast-math"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-fast],[FASTFLAGS="$FASTFLAGS -fast"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-march=native],[FASTFLAGS="$FASTFLAGS -march=native"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-mtune=native],[FASTFLAGS="$FASTFLAGS -mtune=native"],[],[$EXFLAGS])
AX_CHECK_COMPILE_FLAG([-xHOST],[FASTFLAGS="$FASTFLAGS -xHOST"],[],[$EXFLAGS])
CXXFLAGS="$CXXFLAGS $FASTFLAGS"
fi
fi
AC_MSG_CHECKING([whether to build with OpenMP support])
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--enable-openmp],
[enable OpenMP for big loops (default=yes)])
],
[case "${enableval}" in
yes) useomp="yes";;
no) useomp="no";;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-openmp]) ;;
esac
],
[useomp="yes"]
)
AC_MSG_RESULT([$useomp])
if test x"$useomp" = x"yes"; then
have_omp=yes
OMPFLAGS=''
omp_input="int a = omp_get_num_threads();
#pragma omp for private(a)
for ( int i = 0 ; i < 2 ; ++i)
a+=i;"
AC_MSG_CHECKING([whether C++ compiler need a flag for OpenMP])
AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <omp.h>],[$omp_input])],
[ompneedsflag=no;have_omp=yes;],
[ompneedsflag=yes;]
)
AC_MSG_RESULT([$ompneedsflag])
if test x"$ompneedsflag" = x"yes"; then
AX_CHECK_COMPILE_FLAG([-fopenmp],
[OMPFLAGS=" -fopenmp";have_omp=yes;
],
[have_omp=no],
[],
[AC_LANG_PROGRAM([#include <omp.h>],[$omp_input])]
)
CXXFLAGS="$CXXFLAGS$OMPFLAGS"
fi
if test x"$ompneedsflag" = x"yes" && test x"$have_omp" = x"no"; then
AX_CHECK_COMPILE_FLAG([-openmp],
[OMPFLAGS=" -openmp";have_omp=yes;
],
[have_omp=no],
[],
[AC_LANG_PROGRAM([#include <omp.h>],[$omp_input])]
)
CXXFLAGS="$CXXFLAGS$OMPFLAGS"
fi
if test x"$have_omp" = x"yes"; then
AC_DEFINE([HAVE_OMP],[1],[Define to 1 if OpenMP is usable.])
AC_MSG_CHECKING([whether OpenMP 4.0 is supported])
omp_input="std::vector<double> a;
#pragma omp declare reduction(+: std::vector<double> : \
std::transform(omp_out.begin(), omp_out.end(), omp_in.begin(), omp_out.begin(), std::plus<double>())) \
initializer(omp_priv = omp_orig)
#pragma omp parallel for reduction(+:a)
for ( int i = 0 ; i < 42 ; ++ i )
a.at(i) += i;
"
omp_header="#include<vector>
#include<algorithm>
#include<functional>"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$omp_header],[$omp_input])],
[have_omp4=yes;],
[have_omp4=no;]
)
AC_MSG_RESULT([$have_omp4])
if test x"$have_omp4" = x"yes"; then
AC_DEFINE([HAVE_OMP4],[1],[Define to 1 if OpenMP is usable.])
fi
else
AC_MSG_WARN([OpenMP does not seem to be working -> Not used])
fi
else
have_omp=no
fi
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
#=========================================================================
# build static
#=========================================================================
#
#AC_MSG_CHECKING([whether to enable static build])
#AC_ARG_ENABLE([static],
# [AS_HELP_STRING([--enable-static],
# [build a static executable (default=no)]
# )
# ],
# [case "${enableval}" in
# yes) buildstatic="yes" ;;
# no) buildstatic="no";;
# *) AC_MSG_ERROR([bad value ${enableval} for --enable-static.]) ;;
# esac
# ],
# [buildstatic=no]
# )
#AC_MSG_RESULT([$buildstatic])
#
#if test x"$buildstatic" = x"yes"
#then
# AX_CHECK_COMPILE_FLAG([-static],[LDFLAGS="-static $LDFLAGS"],[AC_MSG_ERROR([Can not build static executable.])])
# AX_CHECK_COMPILE_FLAG([-static-libgcc],[LDFLAGS="-static-libgcc $LDFLAGS"],[AC_MSG_ERROR([Can not build static executable.])])
# AX_CHECK_COMPILE_FLAG([-static-libstdc++],[LDFLAGS="-static-libstdc++ $LDFLAGS"],[AC_MSG_ERROR([Can not build static executable.])])
#AX_CHECK_ZLIB(,[
# if test x"$buildstatic" = x"yes"
# then
# AC_MSG_ERROR([zlib does not work and is needed to have a static executable.])
# else
# AC_MSG_WARN([zlib does not work and might prevent the final executable to work.])
# fi
# ])
#AC_DEFINE([CURL_STATICLIB],[1],[define to 1 to specify that we are using static libcurl])
#fi
#AC_SUBST([AM_LDFLAGS])
##########################################################################
echo
echo "================================================================================"
echo "=== Libraries "
echo "================================================================================"
# check for ncurses library headers
AC_CHECK_HEADER([ncurses.h],[ncurses_check_h=yes],[ncurses_check_h=no])
AC_CHECK_LIB([ncurses],[initscr],[ncurses_check_lib=yes],[ncurses_check_lib=no])
if test x"$ncurses_check_h" == x"yes" && test x"$ncurses_check_lib" == x"yes"
then
LIBS="$LIBS -lncurses"
AC_DEFINE([HAVE_NCURSES],[1],[Define to 1 if ncurses is usable.])
fi
# check for readline library headers
AC_MSG_CHECKING([for user defined readline library prefix])
AC_ARG_WITH([readline],
[AS_HELP_STRING([--with-readline],
[prefix used for include and lib directories]
)
],
[readline_prefix="$with_readline";resultreadline=yes],
[readline_prefix="";resultreadline=no]
)
AC_MSG_RESULT([$resultreadline])
OLD_CPPFLAGS=$CPPFLAGS;
OLD_LDFLAGS=$LDFLAGS;
CPPFLAGS="-I$readline_prefix/include $CPPFLAGS"
LDFLAGS="-L$readline_prefix/lib $LDFLAGS"
AC_CHECK_HEADER([readline/readline.h],[readline_check_h=yes],[readline_check_h=no])
AC_CHECK_HEADER([readline/history.h],[history_check_h=yes],[history_check_h=no])
AC_CHECK_LIB([readline],[readline],[readline_check_lib=yes],[readline_check_lib=no])
if test x"$readline_check_h" == x"yes" && test x"$history_check_h" == x"yes" && test x"$readline_check_lib" == x"yes"
then
AC_MSG_CHECKING([if readline version is >= 6.3 ])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <cstdio>
#include <readline/readline.h>
#if RL_READLINE_VERSION < 0x603
#error readline version should be >= 6.3
#endif
]],[[]])
],
[
readline_version=yes
LIBS="$LIBS -lreadline"
AC_DEFINE([HAVE_READLINE],[1],[Define to 1 if readline is usable.])
have_readline_usable="yes"
],
[
readline_version=no
have_readline_usable="no"
]
)
AC_MSG_RESULT([$readline_version])
else
have_readline_usable="no"
CPPFLAGS=$OLD_CPPFLAGS;
LDFLAGS=$OLD_LDFLAGS;
fi
#=========================================================================
# cURL
#=========================================================================
AC_MSG_CHECKING([for user defined curl library prefix])
AC_ARG_WITH([curl],
[AS_HELP_STRING([--with-curl],
[prefix used for include and lib directories]
)
],
[curl_prefix="$with_curl";resultcurl=yes],
[curl_prefix="";resultcurl=no]
)
AC_MSG_RESULT([$resultcurl])
# store current *FLAGS and merge with AM_*FLAGS for compilation and linker check
OLD_CPPFLAGS=$CPPFLAGS;
OLD_LIBS=$LIBS;
#if test $resultcurl == "yes"
#then
# CPPFLAGS="$AM_CPPFLAGS -I$curl_prefix/include"
# LDFLAGS="$AM_LDFLAGS -L$curl_prefix/lib"
#fi
OLDPATH=$PATH
PATH="$PATH:$curl_prefix/bin"
AC_PATH_PROGS([CURLCONFIG],[curl-config],[no])
PATH=$OLDPATH
if test x"$CURLCONFIG" != x"no"; then
CURL_CFLAGS=$($CURLCONFIG --cflags)
CPPFLAGS="$CPPFLAGS $CURL_CFLAGS"
fi
if test x"$buildstatic" = x"yes"
then
CURL_LIBS=$($CURLCONFIG --static-libs)
LIBS="$LIBS $CURL_LIBS"
else
CURL_LIBS=$($CURLCONFIG --libs)
LIBS="$LIBS $CURL_LIBS"
fi
# check for curl library headers
AC_CHECK_HEADER([curl/curl.h],[curl_check_h=yes],[curl_check_h=no])
AC_CHECK_LIB([curl],[curl_easy_init],[curl_check_lib=yes],[curl_check_lib=no])
# handle check results
if test x"$curl_check_h" == x"yes" && test x"$curl_check_lib" == x"yes"
then
have_curl_usable="yes"
AC_DEFINE([HAVE_CURL],[1],[Define to 1 if libcurl is usable.])
else
have_curl_usable="no"
LIBS=$OLD_LIBS;
CPPFLAGS=$OLD_CPPFLAGS;
if test $resultcurl == "yes" ;
then
AC_MSG_NOTICE([ The install prefix --with-curl for the curl library was set.]);
AC_MSG_ERROR([ --> Maybe wrong ???]);
else
AC_MSG_NOTICE([ No non-standard install prefix was set.]);
AC_MSG_NOTICE([ --> You might want to use '--with-curl=ABSOLUTE_PATH' ?!?]);
fi
fi
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
#=========================================================================
# EIGEN
#=========================================================================
AC_MSG_CHECKING([for user defined eigen library prefix])
AC_ARG_WITH([eigen],
[AS_HELP_STRING([--with-eigen],
[Specify the directory to find the Eigen headers]
)
],
[eigen_prefix="$with_eigen";resulteigen=yes],
[eigen_prefix=$default_prefix/include/;resulteigen=no]
)
AC_MSG_RESULT([$resulteigen])
# store current *FLAGS and merge with AM_*FLAGS for compilation and linker check
OLD_CPPFLAGS=$CPPFLAGS;
CPPFLAGS="$CPPFLAGS -I$eigen_prefix/eigen3"
EIGEN_PATCH='
#ifdef __GNUC__
# if __GNUC__ >= 4
# if __GNUC_MINOR__ >= 6
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Weffc++"
# endif
# endif
#endif
'
# check for eigen headers
AC_CHECK_HEADER([Eigen/Dense],[eigen_check_h=yes],[eigen_check_h=no],[$EIGEN_PATCH])
# handle check results
if test x"$eigen_check_h" == x"yes"
then
have_eigen_usable="yes"
AC_DEFINE([HAVE_EIGEN],[1],[Define to 1 if eigen is usable.])
else
have_eigen_usable="no"
if test $resulteigen == "yes" ;
then
AC_MSG_NOTICE([ The install prefix --with-eigen for the eigen library was set.]);
AC_MSG_NOTICE([ Check that the directory Eigen is present in that prefix.]);
AC_MSG_ERROR([ --> Maybe wrong ???]);
else
AC_MSG_NOTICE([ No non-standard install prefix was set.]);
AC_MSG_NOTICE([ --> You might want to download Eigen3 at http://eigen.tuxfamily.org ?!?]);
AC_MSG_NOTICE([ and use the '--with-eigen=ABSOLUTE_PATH' ?!?]);
fi
fi
AC_SUBST([AM_CPPFLAGS])
#=========================================================================
# NetCDF
#=========================================================================
#---# Already done at the very beginning
#AC_MSG_CHECKING([for user defined NetCDF library prefix])
#AC_ARG_WITH([netcdf],
# [AS_HELP_STRING([--with-netcdf],
# [prefix used for include and lib directories]
# )
# ],
# [netcdf_prefix="$with_netcdf";resultnetcdf=yes],
# [netcdf_prefix="";resultnetcdf=no]
# )
#AC_MSG_RESULT([$resultnetcdf])
# store current *FLAGS and merge with AM_*FLAGS for compilation and linker check
OLD_CPPFLAGS=$CPPFLAGS;
OLD_LIBS=$LIBS;
OLD_LDFLAGS=$LDFLAGS;
#---# Already done at the very begining
#OLDPATH=$PATH
#PATH="$PATH:$netcdf_prefix/bin"
#AC_PATH_PROGS([NCCONFIG],[nc-config],[no])
#PATH=$OLDPATH
if test x"$NCCONFIG" == x"no"
then
NC_CFLAGS="-I$netcdf_prefix/include"
NC_LIBS="-L$netcdf_prefix/lib -lnetcdf"
else
NC_CFLAGS=$($NCCONFIG --cflags)
NC_LIBS=$($NCCONFIG --libs)
fi
CPPFLAGS="$CPPFLAGS $NC_CFLAGS"
LIBS="$LIBS $NC_LIBS"
# check for netcdf library headers
AC_CHECK_HEADER([netcdf.h],[netcdf_check_h=yes],[netcdf_check_h=no])
AC_CHECK_LIB([netcdf],[nc_open],[netcdf_check_lib=yes],[netcdf_check_lib=no])
# handle check results
if test x"$netcdf_check_h" == x"yes" && test x"$netcdf_check_lib" == x"yes"
then
have_netcdf_usable="yes"
AC_DEFINE([HAVE_NETCDF],[1],[Define to 1 if netCDF is usable.])
else
have_netcdf_usable="no"
LIBS=$OLD_LIBS;
CPPFLAGS=$OLD_CPPFLAGS;
LDFLAGS=$OLD_LDFLAGS;
if test $resultnetcdf == "yes" ;
then
AC_MSG_NOTICE([ The install prefix --with-netcdf for the NetCDF library was set.]);
AC_MSG_ERROR([ --> Maybe wrong ???]);
else
AC_MSG_NOTICE([ No non-standard install prefix was set.]);
AC_MSG_NOTICE([ --> You might want to use '--with-netcdf=ABSOLUTE_PATH' ?!?]);
fi
fi
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
##########################################################################
# check for libxml2
##########################################################################
AC_MSG_CHECKING([for user defined libxml2 library prefix])
AC_ARG_WITH([libxml2],
[AS_HELP_STRING([--with-libxml2],
[prefix used for include and lib directories]
)
],
[libxml2_prefix="$with_libjpeg";resultxml2=yes],
[libxml2_prefix=$default_prefix;resultxml2=no]
)
AC_MSG_RESULT([$resultxml2])
OLD_CPPFLAGS=$CPPFLAGS;
OLD_LDFLAGS=$LDFLAGS;
OLD_LIBS=$LIBS
OLDPATH=$PATH
if test x"$resultxml2" = x"yes"
then
PATH="$PATH:$libxml2_prefix/bin"
fi
AC_CHECK_PROGS([XML2CONFIG],[xml2-config])
PATH=$OLDPATH
CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS $($XML2CONFIG --cflags)"
LIBS="$LIBS $($XML2CONFIG --libs)"
AC_CHECK_HEADER([libxml/tree.h],[libxml2_check_h=yes],[libxml2_check_h=no])
AC_CHECK_LIB([xml2],[xmlParseFile],[libxml2_check_lib=yes],[libxml2_check_lib=no])
# handle check results
have_libxml2_usable="no"
if test x"$libxml2_check_h" == x"yes" && test x"$libxml2_check_lib" == x"yes"
then
have_libxml2_usable="yes"
AC_DEFINE([HAVE_LIBXML2],[1],[Define to 1 if libxml2 is usable.])
else
LIBS=$OLD_LIBS;
CPPFLAGS=$OLD_CPPFLAGS;
LDFLAGS=$OLD_LDFLAGS;
if test x"$resultlibxml2" == x"yes" ;
then
AC_MSG_NOTICE([ The install prefix --with-libxml2 for the XML library was set.]);
AC_MSG_ERROR([ --> Maybe wrong ???]);
else
AC_MSG_NOTICE([ No non-standard install prefix was set.]);
AC_MSG_NOTICE([ --> You might want to use '--with-libxml2=ABSOLUTE_PATH' ?!?]);
fi
fi
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
##########################################################################
# check for SPGlib
##########################################################################
AC_MSG_CHECKING([for user defined spglib library prefix])