This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
2151 lines (1824 loc) · 67.5 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
# ------------------------------------------------------------
# Antoine Le Hyaric - LJLL Paris 6 - [email protected] - 13/5/04
# $Id: configure.ac,v 1.338 2010/05/10 21:35:07 hecht Exp $
# Version numbering: x.xx-pp where "pp" is the package version (when
# the same FreeFem++ version is packaged several times). For
# coherency, this should have the same value as the top-most package
# number in debian/changelog.
AC_INIT(FreeFem++,3.47,[email protected],freefem++)
dnl : ${CFLAGS=""}
dnl : ${CXXFLAGS=""}
dnl : ${FCFLAGS=""}
dnl : ${FFLAGS=""}
# progg test expact under windows
ff_TEST_FFPP="../src/nw/FreeFem++"
ff_TEST_FFPP_MPI="../src/mpi/FreeFem++-mpi"
AC_PREREQ(2.69) dnl for AC_LANG_CASE and check stuff
dnl AC_CONFIG_SRCDIR(src/FreeFem++-CoCoa)
# Automake 1.11 is too old for check ...
# ALH - 10/9/13 - FFCS needs to skip this automake version requirement when compiling on older platforms (eg cygwin or
# last Ubuntu LTS). So we fix a low hardcoded requirement and test for higher versions when not in FFCS.
AM_INIT_AUTOMAKE(1.11 dist-zip)
if test "$enable_ffcs" != yes
then
if test `echo $am__api_version|awk '{if($1>1.13)print "ok";}'` != ok
then
AC_MSG_ERROR([Automake version needs to be 1.13 or later to enable "make check"])
fi
fi
AC_CONFIG_HEADERS(config.h)
AC_PROG_MAKE_SET
dnl AM_COLOR_TESTS=always
AC_PROG_RANLIB
ff_where_lib_conf=examples++-load/WHERE_LIBRARY-config
dnl search of associad software
m4_define([AC_FF_ADDWHERELIB],
[ if test -z "$ff_where_lib_conf_$1" ; then
echo "$1 LD $2" >>$ff_where_lib_conf
test -n "$3" && echo "$1 INCLUDE $3 " >>$ff_where_lib_conf
ff_where_lib_conf_$1=1
ff_where_lib_$1="$2"
ff_where_inc_$1="$3"
AC_MSG_NOTICE([ ++ add $1 : $2 $3 in $ff_where_lib_conf "])
else
AC_MSG_NOTICE([ -- do not add $1 : $2 $3 in $ff_where_lib_conf "])
fi
]) dnl
m4_define([AC_FF_WHERELIB],
[ if test -z "$ff_where_lib_conf_$1" ; then
AC_MSG_CHECKING(check $1)
ff_save_libs=$LIBS
LIBS="$LIBS $2 $4"
AC_LINK_IFELSE([AC_LANG_PROGRAM([m4_if($3,,,[#include <$3>])],[])], [ff_WHERE=yes],[ff_WHERE=no])
if test "$ff_WHERE" = "yes" ; then
echo "$1 LD $2" >>$ff_where_lib_conf
ff_WHERE_INC=`AS_DIRNAME(["$3"])`
case "$ff_WHERE_INC" in
/*) echo "$1 INCLUDE -I$ff_WHERE_INC" >>$ff_where_lib_conf ;;
esac
ff_where_lib_conf_$1=1
fi
AC_MSG_RESULT($ff_WHERE)
ff_$1_ok=$ff_WHERE;
LIBS=$ff_save_libs
fi
])dnl end m4_define AC_FF_WHERELIB
define([AC_FF_PETSC_AWK],[awk -F'=' '"$1 "==[$]1 {print [$]2}' [$]ffconfpetsc])
m4_define([AC_FF_PETSC_WHERELIB],
[
ff_$2=`AC_FF_PETSC_AWK($2)`
ff_$3=`AC_FF_PETSC_AWK($3)`
if test -n "[$]ff_$2"; then
ff_$1_ok=yes;
AC_FF_ADDWHERELIB($1,[$]ff_$2,[$]ff_$3)
AC_SUBST([TOOL_COMPILE_$1],"")
fi
]
)dnl end m4_defineAC_FF_PETSC_WHERELIB
# ALH - this is required by FFCS that needs to deactivate some tools that do not work on all platforms. Some FF users
# may also find interesting to specify a local version of a tool instead of downloading it.
# m4 macro parameters: $1 = tool name, $2 = dynamic library name, $3 = download directory name if different from $1
m4_define([TOOL_PARAMETERS],
[AC_ARG_WITH($1_include,AC_HELP_STRING([--with-$1-include=],[Include directives for $1 instead of automatic download]))
AC_ARG_WITH($1_ldflags,AC_HELP_STRING([--with-$1-ldflags=],[Link-time directives for $1 instead of automatic download]))
if test "$with_$1_include" != "" || test "$with_$1_ldflags" != ""
then
# some directives have been specified, use them instead of downloading
AC_FF_ADDWHERELIB($1,$with_$1_ldflags,$with_$1_include)
AC_SUBST([TOOL_COMPILE_$1],"")
enable_$1_download=no
fi
])
m4_define([TOOL_DISABLE],
[AC_ARG_ENABLE($1,AC_HELP_STRING([--disable-$1],[Do not use $1]))
if test "$enable_$1" = "no"
then
AC_SUBST([TOOL_COMPILE_$1],"")
AC_SUBST([TOOL_DYLIB_$1],"")
elif test "$ff_$1_ok" = "yes" ; then
AC_SUBST([TOOL_DYLIB_$1],$2)
enable_$1_download=no
else
AC_SUBST([TOOL_COMPILE_$1],ifelse($3,,$1,$3))
AC_SUBST([TOOL_DYLIB_$1],$2)
enable_$1_download=yes
fi
# Also allow to disable the download of one tool if it is already locally installed
TOOL_PARAMETERS($1,$2,$3)
])
ff_HOSTARCH_pastix=
echo "# Build with freefem++ with ./configure " `date` >$ff_where_lib_conf
# To allow anonymous CVS version to contain a "./configure" and
# Makefiles
AM_MAINTAINER_MODE
echo >config_LIB_INFO
# Necessary compilers
AC_PROG_CC
AC_PROG_CXX
AC_LANG(C++)
if test `uname` != Darwin; then
ff_ldeg="-Wl,--end-group"
ff_ldbg="-Wl,--start-group"
fi
# suffix of dynamic lib ..
# ---------------------------
ff_uname=`uname`
# flag to build window 32 version ff_mingw = yes
# bof bof F. Hecht
case $ff_uname in
CYGWIN*|MINGW*|MSYS_NT*)
ff_suffix_dylib="dll"
ff_suffix_dylib_a="dll.a";;
Darwin)
ff_suffix_dylib="dylib"
ff_suffix_dylib_a="dylib";;
*)
ff_suffix_dylib="so";
ff_suffix_dylib_a="so";
esac
# end suffix ...
AC_CHECK_PROG(ff_m4,m4,yes,no)
AC_CHECK_PROG(ff_bison,bison,yes,no)
AC_CHECK_PROG(ff_flex,flex,yes,no)
dnl AC_CHECK_PROG(ff_cmake,cmake,yes,no)
AC_CHECK_PROG(ff_patch,patch,yes,no)
case "$ff_m4 $ff_bison $ff_patch $ff_flex" in
*no*)
AC_MSG_NOTICE([ to install missing package under debian or ubuntu, try ])
test "$ff_m4" = no && AC_MSG_NOTICE([ sudo apt-get install m4])
test "$ff_bison" = no && AC_MSG_NOTICE([ sudo apt-get install bison])
test "$ff_flex" = no && AC_MSG_NOTICE([ sudo apt-get install flex])
test "$ff_patch" = no && AC_MSG_NOTICE([ sudo apt-get install patch])
AC_MSG_ERROR([ Sorry missing m4,bison,flex,patch command !]);;
esac
if test -z "$CXX"; then
AC_MSG_NOTICE( [ fatal error : c++ compiler ! ] );
AC_MSG_ERROR([ Sorry no c++ compiler !])
fi
AC_COMPUTE_INT(ff_size_long,[sizeof(long)])
AC_COMPUTE_INT(ff_size_int,[sizeof(int)])
AC_COMPUTE_INT(ff_size_ptr,[sizeof(int*)])
AC_SUBST(SIZEOF_LONG,$ff_size_long)
AC_SUBST(SIZEOF_INT,$ff_size_int)
AC_SUBST(SIZEOF_PTR,$ff_size_ptr)
if test "0$ff_size_ptr" -eq 4 ;then
AC_SUBST(SIZEOF_PTRINBIT,32)
elif test "0$ff_size_ptr" -eq 8 ;then
AC_SUBST(SIZEOF_PTRINBIT,64)
else
AC_MSG_NOTICE( [ fatal error : sizeof pointer $ff_size_ptr ! or no c++ compiler: $CXX] );
AC_MSG_ERROR([ Sorry sizeof c++ pointer $ff_size_ptr are not 4 or 8 ])
fi
# FFCS - build the code for FreeFem++-cs
AC_ARG_ENABLE(ffcs,AC_HELP_STRING([--enable-ffcs],[build FreeFem++ for use by FreeFem++-cs]))
if test "$enable_ffcs" = yes
then
AC_DEFINE_UNQUOTED(ENABLE_FFCS,$enable_ffcs,[build FreeFem++ for use by FreeFem++-cs])
else
enable_ffcs=no
fi
AC_SUBST(ENABLE_FFCS,"$enable_ffcs")
AM_CONDITIONAL([ENABLE_FFCS],[test $enable_ffcs = yes])
# dur dur car sous MacOsX le fortran n'est pas standard.
ff_AR="ar"
ff_ARFLAGS="rv"
ff_RANLIB="ranlib"
AC_ARG_ENABLE(fortran,AC_HELP_STRING([--disable-fortran],[No Fortran compiler available ( ARPACK need it)]))
ff_g2c_lib="";
if test "$enable_fortran" != no
then
# ALH-FFCS-2/3/10: add gfortran-mp-4.4 for MacPorts on MacOS 10.6
# FH add iforr
AC_PROG_FC(gfortran f90 xlf90 g95 ifort gfortran-mp-4.4)
AC_PROG_F77(gfortran f90 xlf xlf90 g95 f77 fort77 "$FC" ifort gfortran-mp-4.4)
# if test -n "$F77"
# then
ff_flibs=""
# modif FH
AC_F77_LIBRARY_LDFLAGS
dnl AC_F77_WRAPPERS
# correct pb of double def under macos
case $F77 in
*fort77)
if test -z "$FLIBS" ; then
# FLIBS=`fort77 -v a.out 2>&1|awk '/a.out/ && /fort77/ { print $(NF-2),$(NF-1)}'`
# FH to remove " "
FLIBS=`fort77 -v a.out 2>&1|awk '/a.out/ && /fort77/ { print "echo",$(NF-2),$(NF-1)}'|sh`
AC_MSG_WARN([ fort77 FLIBS : $FLIBS ])
fi
;;
*g77)
for i in $FLIBS; do
case $i in
# save last directory of the list
-L*)
d=`expr $i : '-L\(.*\)'`;
echo " try $d "
if test -e "$d/libg2c.so" ; then
ff_flibs="$d/libg2c.so"
elif test -e "$d/libg2c.dylib" ; then
ff_flibs="$d/libg2c.dylib"
elif test -e "$d/libg2c.a" ; then
ff_flibs="$d/libg2c.a"
elif test -e $d/libg2c.so -o -e $d/libg2c.a ; then
ff_flibs="$i"
fi;;
esac
done
if test -e "$ff_flibs" ;then
FLIBS="$ff_flibs"
else
FLIBS="$ff_flibs -lg2c"
fi
AC_MSG_WARN([ get dir of -lg2c FLIBS : $FLIBS ])
;;
# add FH sep 2006 / modif 2009
*gfortran)
ff_okkk=0
for i in $FLIBS; do
case $i in
-L*)
d=`expr $i : '-L\(.*\)'`;
if test -e "$d/libgfortran.$ff_suffix_dylib_a" -a -e "$d/libquadmath.$ff_suffix_dylib_a" ; then
ff_flibs="$d/libgfortran.$ff_suffix_dylib_a $d/libquadmath.$ff_suffix_dylib_a"
ff_okkk=1
elif test -e "$d/libgfortran.a" -a -e "$d/libquadmath.a" ; then
ff_flibs="$d/libgfortran.a $d/libquadmath.a"
ff_okkk=1
elif test -e "$d/libgfortran.$ff_suffix_dylib_a" ; then
ff_flibs="$d/libgfortran.$ff_suffix_dylib_a"
ff_okkk=2
elif test -e "$d/libgfortran.a" ; then
ff_flibs="$d/libgfortran.a"
ff_okkk=2
fi;;
esac
done
if test "$ff_okkk" -ge 1 ;then
FLIBS="$ff_flibs"
else
FLIBS="$ff_flibs -lgfortran"
fi
AC_MSG_WARN([ get dir of -lgfortran FLIBS : $FLIBS ])
;;
esac
AC_ARG_WITH(flib,[ --with-flib= the fortran library ])
# correct FH sep 2006 -o -> -a
if test "$with_flib" != no -a -n "$with_flib"
then
ff_g2c_lib="$with_flib"
FLIBS="$with_flib"
fi
# add FH oct 2007 for download f2c
if test -z "$F77" ; then
ff_f77=`pwd`/download/bin/fort77
ff_flibs=`pwd`/download/lib/libf2c.a
if test -x $ff_f77 -a -f $ff_flibs ; then
AC_MSG_WARN([ no fortran, but find download f2c/fort]);
F77=$ff_f77
FLIBS=$ff_flibs
else
AC_MSG_NOTICE( [ fatal error : no fortran ] );
AC_MSG_NOTICE( [add --disable-fortran ] );
AC_MSG_NOTICE( [or try to compile f2c in directory download/f2c ] );
AC_MSG_NOTICE( [ just do: make install ] );
AC_MSG_ERROR([ Fatal error No Fortran compiler . ],1);
fi
fi
# check if the FLIBS is correct
ff_libs="$LIBS"
LIBS="$ff_libs $FLIBS"
AC_TRY_LINK_FUNC(exit,ff_err=,ff_err=ok);
if test "$ff_err" = "ok" ; then AC_MSG_ERROR([ Fatal FLIBS: $FLIBS is incorrect. ],1); fi
LIBS="$ff_libs"
echo "F77 LD $ff_libs" >config_LIB_INFO
AC_MSG_CHECKING([ Size of fortran 77 integer ])
## AC_LANG(fortran);
AC_LANG_PUSH([Fortran 77])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
program test
integer p,i
p=1024*1024
i= p*p
open(7,file="conftest.out")
if (i>0) then
write(7,*) 8
else
write(7,*) 4
endif
close(7)
end
]])] ,ff_f77intsize=`cat conftest.out`,ff_f77intsize=4,ff_f77intsize=4)
## AC_LANG(C++)
AC_LANG_POP([Fortran 77])
AC_MSG_RESULT($ff_f77intsize)
AC_F77_WRAPPERS
ff_cfagsf77=""
case $ac_cv_f77_mangling in
# "lower case, no underscore, no extra underscore")
# "lower case, no underscore, extra underscore")
# ;;
"lower case, underscore, no extra underscore") ff_cfagsf77="-DAdd_";;
"lower case, underscore, extra underscore") ff_cfagsf77="-DAdd__ -Df77IsF2C";;
"upper case, no underscore, no extra underscore") ff_cfagsf77="-DUPPER";;
"upper case, no underscore, extra underscore") ff_cfagsf77="-DUPPER -DAdd__";;
"upper case, underscore, no extra underscore") ff_cfagsf77="-DUPPER -DAdd_";;
"upper case, underscore, extra underscore") ff_cfagsf77="-DUPPER -DAdd__";;
*) ;;
esac
AC_SUBST(CFLAGSF77,$ff_cfagsf77)
if test $ff_f77intsize -ne 4
then
AC_MSG_ERROR([ Fatal Error: Your fortran 77 compiler have by not 4 bytes integer ( $ff_f77intsize bytes) ],1);
fi
test -f /mingw/bin/libpthread-2.dll && ff_pthread_dll=/mingw/bin/libpthread-2.dll ; \
AC_FF_ADDWHERELIB(f77,$FLIBS,$ff_cfagsf77 $ff_pthread_dll)
AC_FF_ADDWHERELIB(fc,$FLIBS,$ff_cfagsf77 $ff_pthread_dll)
fi
# fin test FORTRAN ..........
# ----------------------------
AC_ARG_ENABLE(c,AC_HELP_STRING([--disable-c],[No C compiler available (C BLAS need it)]))
if test "$enable_c" != no
then
AC_PROG_CC
AM_PROG_CC_C_O
else
# We need to define this otherwise ./configure crashes with
# the message "configure: error: conditional "am__fastdepCC"
# was never defined".
am__fastdepCC_TRUE=
am__fastdepCC_FALSE='#'
fi
AM_PROG_LEX
AC_PROG_YACC
AC_LANG(C++)
# Some useful libraries
AC_CHECK_LIB(pthread,pthread_create,ff_pthread="-lpthread",ff_pthread="")
AC_CHECK_LIB(iomp5,omp_get_wtime,ff_iomp5="-liomp5",ff_iomp5="")
AC_CHECK_LIB([rt],[clock_gettime])
if test -n "$ff_pthread" ; then
AC_FF_ADDWHERELIB(pthread,$ff_pthread,)
fi
# Necessary absolute pathname for local directory when some libraries
# are used from several different locations (for instance locally in
# configure.ac and in a subdir).
curdir=`pwd`
# Configure options
# -----------------
echo $ac_configure_args > configure.param
echo "$PATH" > config.path
eval for i in $ac_configure_args\; do echo \$i\; done | sed -e "s/$/'/" -e "s/^/'/" > config.param
# by default the suffix of the .so lib file is .so
# it is .dll under windows
# it is .dylib under macos X
# suffix of dynamic lib
# Checking wether we can produce a MacIntosh-specific version
# -----------------------------------------------------------
AC_MSG_CHECKING(wether we are on a MacIntosh)
ff_mac=no
if test `uname` = Darwin;
then
ff_HOSTARCH_pastix=i686_mac
ff_suffix_dylib="dylib"
ff_suffix_dylib_a="dylib"
ff_mac=yes
AC_DEFINE_UNQUOTED(FF_PREFIX_DIR_APPLE,"/Applications/FreeFem++.app/Contents/",FreeFem prefix dir)
fi
AC_MSG_RESULT($ff_mac)
AC_MSG_CHECKING(wether we are on SunOS)
ff_sunos=no
if test `uname -s` = SunOS;
then
ff_sunos=yes
fi
AC_MSG_RESULT($ff_sunos)
# glut ------------
# ----------------
ff_glut=""
ff_glut_ok=""
AC_ARG_WITH(glut,[ --with-glut glutlib and include ])
if test "$with_glut" != no -a -n "$with_glut" ; then
ff_libs_save="$LIBS"
LIBS="$LIBS"
dnl not works .... so no check .... FH
ff_glut="$with_glut";ff_glut_ok=yes
dnl AC_SEARCH_LIBS(abort,[$with_glut],[ff_glut="$with_glut";ff_glut_ok=yes],[ff_glut="";ff_glut_ok="no"])
LIBS="$ff_libs_save"
dnl AC_MSG_ERROR([ Sorry bad --with-glut : $with_glut !])
elif test "$with_glut" = no ; then
ff_glut_ok="no"
fi
# Checking wether we can produce a Microsoft Windows-specific version
# -------------------------------------------------------------------
AC_ARG_ENABLE(cygwindll,[ --enable-cygwindll Forces the use of the Cygwin DLL (not recommended)])
AC_ARG_ENABLE(mingw64,[ --enable-mingw64 Uses mingw64 compilers on Cygwin])
AC_MSG_CHECKING(wether we are on Microsoft Windows)
ff_uname=`uname`
# flag to build window 32 version ff_mingw = yes
ff_mingw=no
ff_fpic=yes
case $ff_uname in
CYGWIN*)
ff_fpic=no
# ff_nocygwin=-mno-cygwin
AC_SUBST(GCCNOCYGWIN,$ff_nocygwin);;
MINGW*|MSYS_NT*)
enable_cygwindll=no;;
esac
case $ff_uname in
CYGWIN*|MINGW*)
ff_fpic=no
ff_suffix_dylib="dll";
ff_suffix_dylib_a="dll.a";
ff_win32=yes;
# FFCS - 8/3/12 - remove -D_MSC_VER under MinGW64 because it forces system calls to be compiled into any object
# (which creates thousands of duplicate definitions for sytem calls like time()).
# We need Mingw to avoid Cygwin's extra DLLs
if test "$enable_cygwindll" != yes
then
# CHECK_COMPILE_FLAG(C++,-mwindows,CXXFLAGS)
# FFCS: on Windows, FF crashes when compiling GL/glut.h and the option "--disable-opengl" is not
# operational because ff_glut_ok is forced to yes here.
if test $enable_ffcs = yes
then
ff_glut_ok=no
ff_glut=""
enable_opengl=no
fi
ff_mingw=yes
enable_cygwindll=no;
ff_pthread="-mthreads"
# FFCS does not use the Cygwin MinGW compilers any more
if test $enable_ffcs = no
then
CXXFLAGS="$CXXFLAGS $ff_nocygwin -I/usr/include/mingw"
FFLAGS="$FFLAGS $ff_nocygwin"
CFLAGS="$CFLAGS $ff_nocygwin -I/usr/include/mingw"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],[],
[ff_nocygwin="";
AC_MSG_NOTICE([Sorry $ff_nocygwin optio is wrong try whitout , but try with gcc-3.3])
])
CXXFLAGS="$CXXFLAGS $ff_nocygwin -I/usr/include/mingw"
FFLAGS="$FFLAGS $ff_nocygwin"
CFLAGS="$CFLAGS $ff_nocygwin -I/usr/include/mingw"
CNOFLAGS="$CNOFLAGS $ff_nocygwin -I/usr/include/mingw"
fi
LIBS="$LIBS $ff_nocygwin -mthreads -lws2_32 -lcomdlg32"
LIBSNOCONSOLE="-mwindows"
# FFCS uses a specific compiler, so we specify its libraries explicitely
if test $enable_ffcs = no
then
test -z "$MPIRUN" && MPIRUN=`which mpiexe.exe`
if test "$enable_fortran" != no -o "$with_flib" != no ; then
case "$F77" in
*gfortran) FLIBS="$ff_nocygwin -lgfortran -lquadmath";;
*g77) FLIBS="$ff_nocygwin -lg2c";;
*) AC_MSG_ERROR([ Sorry no known FLIBS with this $F77 !]) ;;
esac
fi
fi
if test -z "$ff_glut" -a "$ff_glut_ok" != "no" ; then
ff_glutname="glut32"
# check abort a existing function just to find in glut32.dll exist in the path
# because glutInit is not the real symbol on win32 dur dur FH !!!!!!!!!
AC_CHECK_LIB(glut32,abort,ff_glut="-l$ff_glutname -mthreads -lglu32 -lopengl32",ff_glut="")
if test -z "$ff_glut" ; then
ff_glutname="freeglut"
AC_CHECK_LIB(freeglut,abort,ff_glut="-l$ff_glutname -mthreads -lglu32 -lopengl32",ff_glut_ok=no)
fi
fi
# Resources for FreeFem++-cs in Microsoft Windows format
AC_SUBST(FFGLUTNAME,$ff_glutname)
AC_SUBST(WINDRESOBJ,windres.o)
AC_SUBST(LIBSNOCONSOLE,$LIBSNOCONSOLE)
AC_SUBST(WIN32DLLTARGET,win32-dll-target)
ff_TEST_FFPP="../src/bin-win32/FreeFem++.exe"
ff_TEST_FFPP_MPI="../src/bin-win32/FreeFem++-mpi.exe"
AC_DEFINE(PURE_WIN32,1,A pure windows applications no cygwin dll)
ff_dynload=yes
fi
;;
*) ff_win32=no;;
esac
AC_MSG_RESULT($ff_win32)
if test "$ff_win32" = no
then
enable_cygwindll=no
fi
# FreeFem++-specific version information
# --------------------------------------
# Version numbering, converted to a floating point value
ff_numver="`echo $VERSION|sed 's/-\(.*\)/+\1.0*0.000001/'`"
AC_DEFINE_UNQUOTED(VersionFreeFempp,$ff_numver,FreeFem++ version as a float)
# Since src/fflib/strversionnumber.cpp is recreated at each build, this
# date is only useful for config-version.h
test "$prefix" = NONE && prefix="$ac_default_prefix"
ff_prefix_dir="${prefix}/lib/ff++/$VERSION"
AC_MSG_CHECKING(prefix dir freefem++ )
AC_MSG_RESULT($ff_prefix_dir)
FF_DATE=`date`
AC_DEFINE_UNQUOTED(VersionFreeFemDate,"$FF_DATE",FreeFem++ build date)
AC_DEFINE_UNQUOTED(FF_PREFIX_DIR,"${ff_prefix_dir}",FreeFem prefix dir)
AC_SUBST(ff_prefix_dir,$ff_prefix_dir)
# Separate configuration header file for version information, included
# in config-macos9.h
cat << EOF > config-version.h
/* FreeFem++ version information for MacOS 9 configuration */
/* File generated by configure.ac */
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "$PACKAGE_STRING"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
/* Define to the version of this package. */
#define PACKAGE_VERSION "$PACKAGE_VERSION"
/* Version number of package */
#define VERSION "$VERSION"
/* FreeFem++ build date */
#define VersionFreeFemDate "$FF_DATE"
/* FreeFem++ version as a float */
#define VersionFreeFempp ($ff_numver)
EOF
# Checking wether to produce a debug version
# ------------------------------------------
# Generic or hardware-dependant optimization
m4_include(acmacros.m4)
m4_include(acoptim.m4)
# [[file:ax_lib_hdf5.m4]]
m4_include(ax_lib_hdf5.m4)
# [[file:ax_lib_gsl.m4]]
m4_include(ax_lib_gsl.m4)
# Checking c++11 for schwarz/hpddm interface of P. Jolivet ...
# F.Hecht:
# do not compile all with c++11 version to much
# probleme to day (frev 2015) with g++ 4.8.1
ff_cxx_save=$CXXFLAGS
CHECK_COMPILE_FLAG(C++,[-std=c++11],CXXFLAGS,ff_cxx11)
dnl CXXFLAGS="$CXX11FLAGS $CXXFLAGS"
dnl ff_cxx11="no"
dnl if test -n "$CXX11FLAGS" ; then ff_cxx11="yes" ; fi
if test "$ff_cxx11" = yes ; then
CXX11FLAGS="-std=c++11";
AC_FF_ADDWHERELIB(cxx11,$CXX11FLAGS,$CXX11FLAGS)
fi
CXXFLAGS="$ff_cxx_save"
AC_SUBST(WITH_CXX11,$ff_cxx11)
AC_SUBST(CXX11FLAGS,$CXX11FLAGS)
#end Checking c++11
# ------------------------------
# compilation flags of FreeFem++
# ------------------------------
# -DDRAWING bamg active some drawing facility in bamg (inquire mesh)
# -DBAMG_LONG_LONG active the use of long long in bamg
# -DDEBUG active the checking in bamg
# -DNCHECKPTR remove check pointer facility
# -DCHECK_KN active subscripting of some array
# -DWITHCHECK of the dynamic type ckecking of the langague (very slow)
# -DEIGENVALUE to compile the eigen value part
# ------------------------------------------------
# FreeFrem++-specific optimizations -fpascal-strings
if test "$enable_debug" = yes;
then
CXXFLAGS="$CXXFLAGS -DBAMG_LONG_LONG -DCHECK_KN"
if test "$ff_mac" = yes;
then
CXXFLAGS="$CXXFLAGS -fno-inline -fexceptions"
fi
else
CXXFLAGS="$CXXFLAGS -DBAMG_LONG_LONG -DNCHECKPTR"
if test "$ff_mac" = yes;
then
CXXFLAGS="$CXXFLAGS "
fi
fi
#whether or not to add a suffix to the package name
#--------------------------------------------------
AC_ARG_WITH(suffix,[ --with-suffix=[G3/G4/G4,P4,..] or --without-suffix (default no suffix to package name)])
AC_MSG_CHECKING(suffix to add to package name)
ff_suffix=
if test "$with_suffix" = yes -o "$with_suffix" = no -o "$with_suffix" = ""
then
AC_MSG_RESULT(none)
else
ff_suffix="-$with_suffix"
AC_MSG_RESULT($ff_suffix)
fi
AC_SUBST(ADD_PACKAGE_NAME,$ff_suffix)
# Checking that OpenGL is accessible
# ----------------------------------
ff_gl_ok=no
ff_glx_ok=no
ff_libs="$LIBS"
AC_ARG_WITH(flib,[ --with-flib= the fortran library ])
AC_ARG_ENABLE([opengl],AS_HELP_STRING([--enable-opengl],
[Enable/disable support for OpenGL]))
# echo " .... LIBS = $LIBS .... "
if test x$enable_opengl != xno; then
# GL libraries seem to depend on some dlopen capabilities
if test "$enable_static" != yes -a "$ff_glut_ok" != yes
then
# If we cannot find gl.h, no OpenGL version can be produced
AC_CHECK_HEADERS(OpenGL/gl.h,
ff_gl_ok=yes
,
ff_gl_ok=no
)
if test "$ff_gl_ok" = no
then
AC_CHECK_HEADERS(GL/gl.h,
ff_gl_ok=yes
,
ff_gl_ok=no
)
fi
AC_CHECK_HEADERS(GLUT/glut.h,
ff_glut_ok=yes,
ff_glut_ok=no)
if test "$ff_glut_ok" = no
then
AC_CHECK_HEADERS(GL/glut.h,
ff_glut_ok=yes,
ff_glut_ok=no)
fi
# GLUT .....
if test "$ff_glut_ok" = yes
then
for glut in \
"-framework GLUT -framework OpenGL -framework Cocoa" \
"-lglut -lGLU -lGL"
do
ff_glut="$glut"
ff_libs1="$LIBS"
LIBS="$LIBS $ff_glut"
AC_TRY_LINK_FUNC(glutInit,
ff_glut_ok=yes
LIBS="$ff_libs1"
break,
ff_glut_ok=next);
LIBS="$ff_libs1"
done
fi
fi
fi
AC_SUBST(LIBSPTHREAD,$ff_pthread)
# ALH - 16/9/13 - at the moment the requirements for medit (glut) are not compatible with FFCS so medit is
# only compiled with FF.
if test $enable_ffcs = no
then
if test "$ff_glut_ok" = yes
then
AC_SUBST(LIBSGLUT,$ff_glut)
if test -n "$ff_pthread" ; then
ff_ffglutprog="ffglut${EXEEXT}"
AC_DEFINE_UNQUOTED(PROG_FFGLUT,"$ff_ffglutprog", the ffglut application for the new graphics )
fi
ff_meditprog="ffmedit${EXEEXT}"
fi
fi
AC_ARG_WITH(suffix,[ --with-suffix=[G3/G4/G4,P4,..] or --without-suffix (default no suffix package name)])
if test "$with_suffix" = yes
then
with_suffix=""
elif test "$with_suffix" = no -o -z "$with_suffix"
then
with_suffix=""
else
with_suffix="-$with_suffix"
fi
AC_MSG_CHECKING(add suffix $with_suffix )
AC_SUBST(ADD_PACKAGE_NAME,$with_suffix)
AC_MSG_RESULT(yes)
# Checking wether we can produce a parallel version
# -------------------------------------------------
if test $enable_ffcs = no
then
# FF case
m4_include(acmpi.m4)
else
# FFCS - use the same MPI configuration choices as FFCS
if test -z "$MPICXX"
then
ff_mpi=no
else
ff_mpi=yes
AC_SUBST(MPICXX,$MPICXX)
AC_SUBST(MPICC,$MPICC)
AC_SUBST(MPIF77,$MPIF77)
AC_SUBST(MPIFC,$MPIFC)
AC_SUBST(MPIPROG,"FreeFem++-mpi${EXEEXT}")
AC_SUBST(MPI_INCLUDE,"-I $MPI_INC_DIR")
AC_SUBST(MPI_INC_DIR,$MPI_INC_DIR)
AC_SUBST(MPI_LIB_DIRS,"")
AC_SUBST(MPI_LIB,$MPI_LIB)
AC_SUBST(MPI_LIBC,"")
AC_SUBST(MPI_LIBFC,"")
# Extra MPI-dependant configuration options that are set by FF
# during MPI configuration. FFCS - 25/2/13 - Fred noticed that if
# PASTIX_HOSTARCH stays blank, pastix compilation breaks. At least
# i686_pc_linux and i686_mac are required by pastix on the
# corresponding platforms.
if test"$ff_HOSTARCH_pastix" = ""
then
ff_HOSTARCH_pastix=i686_pc_linux
fi
AC_SUBST(PASTIX_HOSTARCH,$ff_HOSTARCH_pastix)
# these values should not be empty otherwise
# examples++-load/ff-get-dep will think that they are not
# defined
AC_FF_ADDWHERELIB(mpi,-DDUMMY,-I$MPI_INC_DIR)
# mpifc and mpif77 libraries should always be specified
# because FF never calls the Fortran MPI compiler. It always
# uses mpicxx in [[file:examples++-load/ff-c++]]. The
# resulting Fortran libraries (eg Mumps) would compile even
# without the proper Fortran libs, but they would not load
# properly.
# under Win32, libmpi_f77.a is not the right name and FFCS
# mingw/mpicxx adds the right libraries by itself
# With mpich2 Debian wheezy 32 bits, libmpi_f77.a is not available (request from Cico, 14/10/13)
if test -f /usr/lib/openmpi/lib/libmpi_f77.a
then
AC_FF_ADDWHERELIB(mpifc,-lmpi_f77,)
AC_FF_ADDWHERELIB(mpif77,-lmpi_f77,)
else
AC_FF_ADDWHERELIB(mpifc,-DDUMMY,)
AC_FF_ADDWHERELIB(mpif77,-DDUMMY,)
fi
# FFCS - MPI_DOUBLE_COMPLEX kept from original FF configure script
AC_MSG_CHECKING( MPI_DOUBLE_COMPLEX)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
#include <mpi.h>
MPI_Datatype xxxx=MPI_DOUBLE_COMPLEX;
])],
ff_mpi_double_complex=yes,
ff_mpi_double_complex=no)
AC_MSG_RESULT($ff_mpi_double_complex)
if test "$ff_mpi_double_complex" = yes ; then
AC_DEFINE(HAVE_MPI_DOUBLE_COMPLEX,1, mpi_double_complex)
fi
fi
fi
# FFCS needs to change some of the FF makefiles to compile without MPI
AM_CONDITIONAL([FFCS_MPIOK],[test $ff_mpi = yes])
# Looking for useful configuration utilities
# ------------------------------------------
AC_ARG_ENABLE(download,AC_HELP_STRING([--enable-download],[Download missing libraries (BLAS,ARPACK,UMFPACK,...)]))
## PETSc
AC_ARG_WITH(petsc,[ --with-petsc=/usr/local/petsc/conf/petscvariables --without-petsc ])
# /usr/local/petsc/conf/petscvariables
#/usr/local/ff++/petsc/lib/petsc/conf/petscvariables
ff_petsc_ok=no
## echo --$with_petsc--
if test "$with_petsc" != no -a $ff_mpi = yes; then
for d in "$with_petsc" /usr/local/ff++/petsc/lib /usr /usr/local /opt/usr /opt/local ;do
for dd in "" "/petsc/conf/petscvariables" "/lib/petsc-conf/petscvariables" ; do
ffconfpetsc="$d$dd"
if test -f "$ffconfpetsc" ; then
if test "$ff_petsc_ok" = no ; then
PETSC_MPIRUN=`awk -F' *= *' '"MPIEXEC"==$1 {print $2}' "$ffconfpetsc"`
test "$PETSC_MPIRUN" = "$MPIRUN" || cmp -s `which "$PETSC_MPIRUN"` `which "$MPIRUN"`
if test "$?" -eq 0 ; then
AC_FF_PETSC_WHERELIB(petsc,PETSC_WITH_EXTERNAL_LIB,PETSC_CC_INCLUDES)
AC_FF_PETSC_WHERELIB(parmetis,PARMETIS_LIB,PARMETIS_INCLUDE)
AC_FF_PETSC_WHERELIB(metis,METIS_LIB,METIS_INCLUDE)
AC_FF_PETSC_WHERELIB(ptscotch,PTSCOTCH_LIB,PTSCOTCH_INCLUDE)
AC_FF_PETSC_WHERELIB(scotch,SCOTCH_LIB,SCOTCH_INCLUDE)
AC_FF_PETSC_WHERELIB(fftw3_mpi,FFTW_LIB,FFTW_INCLUDE)
AC_FF_PETSC_WHERELIB(mumps,MUMPS_LIB,MUMPS_INCLUDE)
AC_FF_PETSC_WHERELIB(scalapack,SCALAPACK_LIB,SCALAPACK_INCLUDE)
AC_FF_PETSC_WHERELIB(suitesparse,SUITESPARSE_LIB,SUITESPARSE_INCLUDE)
AC_FF_PETSC_WHERELIB(blaslapack,BLASLAPACK_LIB,BLASLAPACK_INCLUDE)
# PETSC_WITH_EXTERNAL_LIB=`awk -F'=' '"PETSC_WITH_EXTERNAL_LIB "==$1 {print $2}' $ffconfpetsc`
# PETSC_CC_INCLUDES=`awk -F'=' '"PETSC_CC_INCLUDES "==$1 {print $2}' $ffconfpetsc`
# if test -n "$PETSC_WITH_EXTERNAL_LIB"; then
# ff_petsc_ok=yes;
# AC_FF_ADDWHERELIB(petsc,$PETSC_WITH_EXTERNAL_LIB,$PETSC_CC_INCLUDES)
# fi
else
AC_MSG_NOTICE([" Warning PETSC MPI and FF++ MPI not the same: $PETSC_MPIRUN != $MPIRUN." ]);
fi
fi
else
# test "$ff_petsc_ok" = no && echo " *** try $ffconfpetsc"
ffconfpetsc="";
fi
done
done
fi
if test "$ff_petsc_ok" != no ; then
AC_MSG_NOTICE([ with petsc $ff_petsc_ok])
else
AC_MSG_NOTICE([ without petsc ***** ])
fi
if test "$ff_where_lib_conf_fftw3_mpi" = 1 ; then
ff_where_fftw3=`echo $ff_where_lib_fftw3_mpi| sed -e 's/-lfftw3_mpi//g'`
AC_FF_ADDWHERELIB(fftw3,$ff_where_fftw3,$ff_where_inc_fftw3_mpi)
AC_MSG_NOTICE([ fftw3 from petsc ***** ])
fi
#replacing wget with another command
ff_wget_command="wget --no-check-certificate"
ff_wget=no
AC_ARG_WITH(wget,
[ --with-wget=command Replace "wget" with another command. Implies --enable-download],
enable_download=yes
ff_wget=yes
ff_wget_command="${withval}")
ff_mkl_libpath=yes
AC_ARG_WITH(mkl,
[ --with-mkl= the MKL LIBPATH : (ie. /opt/intel/mkl/RR.r.y.xxx/lib/<arch>)],
ff_mkl_libpath="${withval}")
# if enabling downloads find wget or curl to do download
# ------------------------------------------------------
if test "$ff_wget" = no
then
ff_wget=""
AC_CHECK_PROG(ff_wget,wget --no-check-certificate,yes,no)
fi
if test "$ff_wget" = no
then
ff_wget_command="curl --fail -O "
ff_curl=""
AC_CHECK_PROG(ff_curl,curl -O,yes,no)
ff_wget="$ff_curl"
fi
# for automatique compilation of
# lib in download
if test "$ff_wget" != yes -a "$enable_download" = "yes" ; then
enable_download=no
AC_MSG_ERROR([ enable-download and no wget or curl. ],1);
fi
if test "$enable_download" = "yes" ; then
DOWNLOADCOMPILE="compile-pkg install-other"
else
DOWNLOADCOMPILE=
fi
AC_SUBST(WGET,$ff_wget_command)
AC_SUBST(DOWNLOADCOMPILE,$DOWNLOADCOMPILE)