This repository has been archived by the owner on May 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
652 lines (537 loc) · 16.2 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
# Configuration script using Automake + Autoconf for FreeFem++
# ------------------------------------------------------------
# Antoine Le Hyaric - LJLL Paris 6 - [email protected] - 13/5/04
# $Id$
AC_INIT(FreeFem++,1.43,[email protected],freefem++)
AC_CONFIG_SRCDIR(src/FreeFem++-CoCoa)
# Automake 1.4 is too old
AM_INIT_AUTOMAKE(1.6.3 dist-zip)
AM_CONFIG_HEADER(config.h)
AC_PROG_MAKE_SET
AC_PROG_RANLIB
# Necessary compilers
AC_PROG_F77
AC_PROG_CC
AC_PROG_CXX
AC_PROG_YACC
AM_PROG_LEX
AC_LANG(C++)
# Some useful libraries
AC_CHECK_LIB(pthread,pthread_create)
# 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
# Checking wether we can produce a MacIntosh-specific version
# -----------------------------------------------------------
AC_MSG_CHECKING(wether we are on a MacIntosh)
ff_mac=no
ff_aglprog=
if test `uname` = Darwin;
then
ff_mac=yes
ff_aglprog=FreeFem++-agl${EXEEXT}
fi
AC_MSG_RESULT($ff_mac)
# Checking wether we can produce a Microsoft Windows-specific version
# -------------------------------------------------------------------
AC_MSG_CHECKING(wether we are on Microsoft Windows)
ff_uname=`uname`
case $ff_uname in
CYGWIN*)
ff_win32=yes
# We need Mingw (to avoid Cygwin's extra DLLs)
CXXFLAGS="$CXXFLAGS -mno-cygwin -I/usr/include/mingw"
LIBS="$LIBS -mno-cygwin -L/lib/mingw"
;;
*)ff_win32=no;;
esac
AC_MSG_RESULT($ff_win32)
# FreeFem++-specific version information
# --------------------------------------
AC_DEFINE_UNQUOTED(VersionFreeFempp,$VERSION,FreeFem++ version as a float)
FF_DATE=`date`
AC_DEFINE_UNQUOTED(VersionFreeFemDate,"$FF_DATE",FreeFem++ build date)
# 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 $VERSION
EOF
# Checking wether to produce a debug version
# ------------------------------------------
# Generic or hardware-dependant optimization
m4_include(acmacros.m4)
m4_include(acoptim.m4)
# ------------------------------
# compilation flags of FreeFem++
# ------------------------------
# -DDRAWING bamg active some drawing facility in bamg (inquire mesh)
# -DLONG_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
if test "$enable_debug" = yes;
then
CXXFLAGS="$CXXFLAGS -DDRAWING -DLONG_LONG -DCHECK_KN"
if test "$ff_mac" = yes;
then
CXXFLAGS="$CXXFLAGS -fno-inline -fpascal-strings -fexceptions"
fi
else
CXXFLAGS="$CXXFLAGS -DDRAWING -DLONG_LONG -DNCHECKPTR"
if test "$ff_mac" = yes;
then
CXXFLAGS="$CXXFLAGS -fpascal-strings"
fi
fi
# Checking wether we can produce a X11 version
# --------------------------------------------
AC_MSG_CHECKING(wether we can compile for X11)
ff_x11=no
# At the moment, we cannot compile for X11 on Mingw because /usr/X11R6
# is part of Cygwin, not Mingw.
if test -d /usr/X11R6 -a "$ff_win32" = no;
then
ff_x11=yes
ff_x11prog=FreeFem++-x11${EXEEXT}
CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include"
LIBS="$LIBS -L/usr/X11R6/lib -lX11 -lm"
fi
AC_MSG_RESULT($ff_x11)
# Checking that OpenGL is accessible
# ----------------------------------
# If we cannot find gl.h, no OpenGL version can be produced
AC_CHECK_HEADERS(GL/gl.h,
ff_gl_ok=yes,
ff_gl_ok=no)
AC_CHECK_HEADERS(GL/glx.h,
ff_glx_ok=yes,
ff_glx_ok=no)
if test "$ff_gl_ok" = yes
then
AC_CHECK_LIB(GL,
glBegin,
ff_gl_ok=yes,
ff_gl_ok=no)
AC_CHECK_LIB(GLU,
gluSphere,
ff_gl_ok=yes,
ff_gl_ok=no,
-lGL)
fi
# If we cannot find GL, we cannot compile FreeFem++-agl
if test "$ff_gl_ok" = no
then
ff_aglprog=
fi
# If we cannot find GLX, we cannot compile FreeFem++ with it
if test "$ff_glx_ok" = yes
then
ff_glxprog=FreeFem++-glx${EXEEXT}
fi
# Checking wether we can produce a parallel version
# -------------------------------------------------
AC_MSG_CHECKING(for mpiCC)
ff_save_cxx="$CXX"
CXX=mpiCC
AC_LINK_IFELSE(
[#include <stdio.h>
#include <mpi.h>
int main(int argc,char **argv){
char name[[BUFSIZ]];
int length;
MPI_Init(&argc, &argv);
MPI_Get_processor_name(name, &length);
printf("%s: hello world\n", name);
MPI_Finalize();
return 0;
}],
ff_mpi=yes,
ff_mpi=no)
CXX="$ff_save_cxx"
AC_MSG_RESULT($ff_mpi)
if test "$ff_mpi" = yes;
then
# We do not AC_DEFINE any special flag for parallel
# computation here, because it must only be set when the
# parallel program is compiled (see src/mpi/Makfile.am)
AC_SUBST(MPIPROG,FreeFem++-mpi${EXEEXT})
fi
# Looking for useful configuration utilities
# ------------------------------------------
AC_ARG_ENABLE(generic_blas,[ --enable-generic_blas Download generic blas (implie --enable-download)])
AC_ARG_ENABLE(download,[ --enable-download Download missing libraries (BLAS,ARPACK,UMFPACK)])
if test "$enable_generic_blas" = yes
then
enable_download = yes
fi
if test "$enable_download" = yes
then
AC_CHECK_PROG(ff_wget,wget,yes,no)
else
ff_wget=no
fi
# Looking for the BLAS
# --------------------
# User-specified location
ff_blas_ok=no
AC_ARG_WITH(blas,
--with-blas=library Use a specific version of the Blas,
ff_blas_ok=yes
ff_blas_lib="${withval}")
# Specific BLAS library location for FreeBSD
ff_freebsd_blas="-lf2c -lf77blas -latlas -lgslcblas"
# Trying blas library
for iblas in \
"-lblas" "-framework vecLib" "-L/usr/lib/atlas -lblas" \
"-L${curdir}/download/blas -lcblas -lf77blas" \
"-L${curdir}/download/blas/ATLAS/lib/ff++ -lcblas -lf77blas -latlas" \
"-L${curdir}/download/blas/WinNT_PPRO256 -lcblas -lf77blas -latlas" \
$ff_freebsd_blas
do
if test "$ff_blas_ok" = no;
then
AC_MSG_CHECKING(for daxpy_ in $iblas)
ff_save_libs="$LIBS"
LIBS="$LIBS $iblas"
AC_LINK_IFELSE(
[AC_LANG_CALL(,daxpy_)],
ff_blas_ok=yes
ff_blas_lib="$iblas",
LIBS="$ff_save_libs")
AC_MSG_RESULT($ff_blas_ok)
fi
done
# If all else fails, download!
if test "$ff_blas_ok" = no -a "$ff_wget" = yes
then
AC_CHECK_PROG(ff_unzip,unzip,yes,no)
AC_MSG_CHECKING(for BLAS version to download)
# Do not update $LIBS, but create an extra LIB variable,
# because this lib does not exist yet, and this could make the
# following tests fail.
# When compiling a generic version, we do not need an
# optimized version of the BLAS.
if test "$enable_generic" = yes -o "$enable_generic_blas" = yes
then
ff_download_blas=generic
ff_blas_lib="-L${curdir}/download/blas -lcblas -lf77blas"
AC_SUBST(GENERIC_BLAS,"libf77blas.a libcblas.a")
AC_SUBST(GENERIC_BLAS_BUILT_SOURCES,"BLAS CBLAS")
else
# There are precompiled versions for Windows. We cannot
# distinguish the different versions easily so we just
# download the most generic one. A more specific version can
# always be downloaded by hand.
# BUG: at the moment, some necessary symbols are missing from
# the precompiled version (e.g. _dgemm_).
### if test "$ff_win32" = yes -a "$enable_generic" = yes -a "$ff_unzip" = yes
if false
then
ff_download_blas=atlas-binary
ff_blas_lib="-L${curdir}/download/blas/WinNT_PPRO256 -lcblas -lf77blas -latlas"
else
ff_download_blas=atlas-source
ff_blas_lib="-L${curdir}/download/blas/ATLAS/lib/ff++ -lcblas -lf77blas -latlas"
fi
fi
AC_MSG_RESULT($ff_download_blas)
AC_SUBST(DOWNLOAD_BLAS,$ff_download_blas)
ff_blas_ok=yes
fi
AC_SUBST(BLASLIB,$ff_blas_lib)
#looking for cblas.h FH
if test "$ff_blas_ok" = yes;
then
AC_CHECK_HEADERS(cblas.h,
ff_cblas_h=yes,
ff_cblas_h=no)
AC_CHECK_HEADERS(vecLib/cblas.h,
ff_cblas_h=yes,
ff_cblas_h=no)
fi
# Looking for ARPACK
# ------------------
# We need the following g77 libraries to connect to the Fortran 77
# Arpack.
if test "$ff_blas_ok" = yes;
then
ff_g2c_ok=no
AC_CHECK_LIB(g2c,G77_second_0,
LIBS="$LIBS -lg2c"
ff_g2c_lib="-lg2c"
ff_g2c_ok=yes)
if test "$ff_g2c_ok" = no;
then
AC_MSG_CHECKING(for G77_second_0 in /sw/lib/libg2c.a)
ff_save_libs="$LIBS"
LIBS="$LIBS -L/sw/lib -lg2c"
AC_LINK_IFELSE(
[AC_LANG_CALL(,G77_second_0)],
ff_g2c_lib="-L/sw/lib -lg2c"
ff_g2c_ok=yes,
LIBS="$ff_save_libs")
AC_MSG_RESULT($ff_g2c_ok)
fi
fi
# Copy the result of g2c investigations into a separate variable
# because UMFPACK compilation will need it.
AC_SUBST(G2CLIB,$ff_g2c_lib)
# Arpack itself
ff_arpack_ok=no
ff_save_libs="$LIBS"
ff_arpack_libs=
if test "$ff_blas_ok" = yes;
then
# User-specified location
AC_ARG_WITH(arpack,
--with-arpack=library Use a specific version of Arpack,
ff_arpack_ok=yes
ff_arpack_libs="${withval}")
# Default locations
if test "$ff_arpack_ok" = no;
then
AC_CHECK_LIB(arpack,dsaupd_,
ff_arpack_libs="-larpack -llapack"
ff_arpack_ok=yes,,
-llapack)
fi
# Trying to "locate" Arpack
if test "$ff_arpack_ok" = no;
then
AC_MSG_CHECKING(for libarpack with locate)
ff_lib_arpack=`locate libarpack|grep 'libarpack.*.a$'|head -1`
LIBS="$ff_lib_arpack $LIBS"
AC_LINK_IFELSE(
[AC_LANG_CALL(,dsaupd_)],
ff_arpack_ok=yes
ff_arpack_libs=$ff_lib_arpack)
AC_MSG_RESULT($ff_arpack_ok)
fi
# If all else fails, download!
if test "$ff_arpack_ok" = no -a "$ff_wget" = yes
then
AC_MSG_NOTICE(using downloaded Arpack)
AC_SUBST(DOWNLOAD_ARPACK,arpack)
# Do not update $LIBS, but create an extra LIB variable,
# because this lib does not exist yet, and this could make the
# following tests fail.
AC_SUBST(ARPACKLIB,
${curdir}/download/arpack/ARPACK/libarpack_ff++.a)
ff_arpack_ok=yes
fi
fi
LIBS="$ff_arpack_libs $ff_save_libs"
if test "$ff_arpack_ok" = yes;
then
EIGENOBJ='eigenvalue.$(OBJEXT)'
AC_DEFINE(HAVE_LIBARPACK,1,Arpack is used for eigenvalue computation)
# Determines whether to run the eigenvalue tests
AC_SUBST([EIGENTEST],../regtests.sh)
fi
AC_SUBST([EIGENOBJ])
# Looking for UMFPACK
# -------------------
ff_amd_ok=no
ff_umfpack_ok=no
if test "$ff_blas_ok" = yes;
then
# User-specified location
AC_ARG_WITH(amd,
--with-amd=library Use a specific version of AMD,
ff_amd_ok=yes
ff_umfpack_lib="${withval}")
AC_ARG_WITH(umfpack,
--with-umfpack=library Use a specific version of Umfpack,
ff_umfpack_ok=yes
ff_umfpack_lib="$ff_umfpack_lib ${withval}"
AC_DEFINE(HAVE_LIBUMFPACK,1,
Umfpack is used for sparse matrices computations))
# Trying default locations
AC_CHECK_HEADERS(umfpack.h umfpack/umfpack.h,ff_umfpack_header=yes)
# Somes systems like FreeBSD hide umfpack.h in a directory
# called UMFPACK (all capitals). This breaks the standard
# #define produced by autoconf in config.h.in.
if test "$ff_umfpack_header" != yes;
then
AC_CHECK_HEADER(UMFPACK/umfpack.h,
AC_DEFINE(HAVE_BIG_UMFPACK_UMFPACK_H,1,
If umfpack.h is located in UMFPACK subdir))
fi
if test "$ff_amd_ok" = no;
then
AC_CHECK_LIB(amd,amd_info,
ff_umfpack_lib="-lamd"
ff_amd_ok=yes)
fi
if test "$ff_umfpack_ok" = no -a "$ff_amd_ok" = yes;
then
AC_CHECK_LIB(umfpack,umf_i_malloc,
AC_DEFINE(HAVE_LIBUMFPACK,1,UMFPACK)
ff_umfpack_lib="$ff_umfpack_lib -lumfpack"
ff_umfpack_ok=yes,,$ff_umfpack_lib)
fi
fi
# If all else fails, download!
if test "$ff_umfpack_ok" = no -a "$ff_wget" = yes
then
AC_MSG_NOTICE(using downloaded Umfpack)
AC_SUBST(DOWNLOAD_UMFPACK,umfpack)
# Do not update $LIBS, but create an extra LIB variable,
# because this lib does not exist yet, and this could make the
# following tests fail.
ff_umfpack_lib="${curdir}/download/umfpack/UMFPACKv4.3/UMFPACK/Lib/libumfpack.a ${curdir}/download/umfpack/UMFPACKv4.3/AMD/Lib/libamd.a"
AC_DEFINE(HAVE_LIBUMFPACK,1,UMFPACK)
ff_umfpack_ok=yes
fi
AC_SUBST(UMFPACKLIB,$ff_umfpack_lib)
# Checking for some functions that may not appear everywhere
# ----------------------------------------------------------
# asinh acosh atanh are not in Mingw yet
AC_CHECK_FUNCS(asinh acosh atanh)
# If times() and sysconf() are not here, UMFPACK should know
if test "$ff_umfpack_ok" = yes
then
AC_CHECK_FUNCS(times sysconf,
ff_umfpack_posix_ok=yes,
ff_umfpack_posix_ok=no)
if test "$ff_umfpack_posix_ok" = no
then
AC_SUBST(FF_UMFPACK_POSIX,-DNPOSIX)
fi
fi
# Dynamic loading of compiled functions
# -------------------------------------
# Availability of dlopen(). Use AC_COMPILE rather than
# AC_CHECK_HEADERS because the latter has problems seeing it (in
# Cygwin) when it does not compile (in Mingw).
AC_MSG_CHECKING(for dlfcn.h)
AC_COMPILE_IFELSE([#include <dlfcn.h>],
ff_dynload=yes,
ff_dynload=no)
AC_MSG_RESULT($ff_dynload)
# the -rdynamic don't exist on macos
if test "$ff_dynload" = yes ;
then
AC_DEFINE(HAVE_DLFCN_H,1,Dynamic loading - not mandatory)
AC_CHECK_LIB(dl,dlinfo)
# Activate dynamic loading tests (see examples++-load/Makefile.am)
AC_SUBST(LOAD_TESTS,../regtests.sh)
AC_SUBST(LOAD_COMPILE,myfunction.so)
# gcc on MacOS does not produce an error with "-rdynamic" but
# still complains about it.
if test "$ff_mac" = "no";
then
CHECK_COMPILE_FLAG(C++,-rdynamic,CXXFLAGS)
else
true
fi
fi
# Checking wether we can generate some documentation
# --------------------------------------------------
AC_CHECK_PROG(ff_latex,latex,yes,no)
AC_CHECK_PROG(ff_makeindex,makeindex,yes,no)
AC_CHECK_PROG(ff_dvips,dvips,yes,no)
if test "$ff_latex" = yes -a "$ff_makeindex" = yes -a "$ff_dvips" = yes;
then
AC_SUBST(DOCPS,manual.ps)
AC_SUBST(DOCPS,manual-full.ps)
AC_CHECK_PROG(ff_gzip,gzip,yes,no)
if test "$ff_gzip" = yes;
then
AC_SUBST(DOCPSGZ,manual.ps.gz)
AC_SUBST(DOCPSGZ,manual-full.ps.gz)
fi
fi
AC_CHECK_PROG(ff_pdflatex,pdflatex,yes,no)
if test "$ff_pdflatex" = yes;
then
AC_SUBST(DOCPDF,manual.pdf)
AC_SUBST(DOCPDF,manual-full.pdf)
fi
# Choosing compilation options for the standard version (in src/std)
# ------------------------------------------------------------------
# The "standard" configured version can use win32 (mingw) or x11
if test "$ff_win32" = yes;
then
ff_std_graph_obj=Pcrgraph.$OBJEXT
ff_std_ldflags=-mwindows
else
ff_std_graph_obj=Xrgraph.$OBJEXT
ff_std_ldflags=
# If the standard version already uses x11, we do not need to
# make the contents of the src/x11 directory.
ff_x11prog=
fi
AC_SUBST(STD_GRAPH_OBJ,$ff_std_graph_obj)
AC_SUBST(STD_LDFLAGS,$ff_std_ldflags)
# Can we produce an IDE?
# ----------------------
AC_CHECK_PROG(ff_fltkconfig,fltk-config,yes,no)
# Downloading and compiling FLTK. (todo)
###if test "$ff_fltkconfig" = no
###then
### AC_SUBST(DOWNLOAD_FLTK,fltk)
### ff_fltkconfig=yes
###fi
if test "$ff_fltkconfig" = no
then
# For the moment, FreeFem++-ide${EXEEXT} is not built because it first
# needs FreeFEM++ to accept several successive runs without restart.
ff_ideprog="FreeFem++-cs${EXEEXT} FreeFem++-cs-server${EXEEXT}"
fi
# creating all makefiles
# ----------------------
AC_SUBST(GLXPROG,$ff_glxprog)
AC_SUBST(AGLPROG,$ff_aglprog)
AC_SUBST(X11PROG,$ff_x11prog)
AC_SUBST(IDEPROG,$ff_ideprog)
AC_OUTPUT(Makefile
download/Makefile
download/blas/Makefile
download/arpack/Makefile
download/umfpack/Makefile
src/Makefile
src/bamglib/Makefile
src/iml/Makefile
src/Graphics/Makefile
src/femlib/Makefile
src/Algo/Makefile
src/umfpack/Makefile
src/lglib/Makefile
src/fflib/Makefile
src/std/Makefile
src/x11/Makefile
src/ide/Makefile
src/nw/Makefile
src/mpi/Makefile
src/agl/Makefile
src/glx/Makefile
examples++/Makefile
examples++-eigen/Makefile
examples++-tutorial/Makefile
examples++-mpi/Makefile
examples++-load/Makefile
examples++-bug/Makefile
examples++-other/Makefile
DOC/Makefile)