File: configure.ac

package info (click to toggle)
gyoto 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 8,588 kB
  • sloc: cpp: 33,490; sh: 18,775; xml: 2,633; python: 1,424; makefile: 681; ansic: 314
file content (827 lines) | stat: -rw-r--r-- 25,039 bytes parent folder | download
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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Few bits where taken from pyconf, bearing this notice:
dnl Copyright 2012, 2013 Brandon Invergo <brandon@invergo.net>
dnl
dnl Copying and distribution of this file, with or without modification,
dnl are permitted in any medium without royalty provided the copyright
dnl notice and this notice are preserved.  This file is offered as-is,
dnl without any warranty.


AC_PREREQ([2.69])
AC_INIT([Gyoto], [1.3.1], [gyoto@sympa.obspm.fr])
gyoto_test_CXXFLAGS=${CXXFLAGS+set}
gyoto_test_CPPFLAGS=${CPPFLAGS+set}
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([include/GyotoKerrKS.h])
AC_CONFIG_MACRO_DIR([m4])
AC_LANG(C++)
LT_INIT([dlopen disable-static])
AC_CONFIG_HEADERS([config.h include/GyotoConfig.h])
AC_SUBST([VERBATIM], [])


# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
# C: current; R: revision; A: age
# Linux library name is: libgyoto.so.(C-A).A.R
VERSINFO_C=7
VERSINFO_R=0
VERSINFO_A=0
VERSINFO=${VERSINFO_C}:${VERSINFO_R}:${VERSINFO_A}
AC_SUBST([VERSINFO])

## Needed for gcc-5, should be harmless for other compilers:
#
AX_APPEND_COMPILE_FLAGS([-P], [CPPFLAGS])

## Ensure local build does not have a release soname by default
#
FEATURES=""
AC_ARG_ENABLE([release],
  [AS_HELP_STRING([--enable-release],
     [enable a release build (remove -unreleased from SONAME)])])
AS_IF([test "x$enable_release" != "xyes"],
  [FEATURES+="-unreleased"])

## An additional directory to look for plug-ins
#  Default /usr/local/lib/gyoto, only if ${prefix} is not /usr/local
AC_ARG_ENABLE([localpkglibdir],
  [AS_HELP_STRING([--enable-localpkglibdir[[=PKGLIBDIR]]],
     [additional directory to look for plug-ins [/usr/local/lib/gyoto, only if PREFIX is not /usr/local]. If specified, Gyoto will look for additional plug-ins in LOCALPKGLIBDIR/GYOTO_SOVERS and  LOCALPKGLIBDIR before looking in PKGLIBDIR/GYOTO_SOVERS and PKGLIBDIR])],
  [],
  [AS_IF([test x${prefix} == xNONE || test "x${prefix}" == x/usr/local],
     [enable_localpkglibdir=no],
     [enable_localpkglibdir=yes])])
AS_IF([test x$enable_localpkglibdir != "xno"],
  [AS_IF([test x$enable_localpkglibdir == "xyes"],
     [localpkglibdir="/usr/local/lib/"${PACKAGE}],
     [localpkglibdir=$enable_localpkglibdir]
  )],
  [localpkglibdir=""])
AM_CONDITIONAL(HAVE_LOCALPKGLIBDIR, [test "x$localpkglibdir" != "x"])
AC_SUBST(localpkglibdir)

## SIGFPE delivery
#
AC_ARG_WITH([fenv],
  [AS_HELP_STRING([--without-fenv],
     [do not use fenv.h (see BUGS.md)],)],
   [],
   [with_fenv=auto])
AS_IF([test "x$with_fenv" != xno],
  [AC_MSG_CHECKING([for fenv.h])
   AC_TRY_LINK(
     [#include <fenv.h>],
     [feenableexcept(FE_DIVBYZERO);],
     [AC_DEFINE([HAVE_FENV_H], [1], [Define to 1 to use fenv.h.])
      HAVE_FENV_H=1
      AC_MSG_RESULT(yes)],
     [AC_MSG_RESULT(no)])
  ])
AS_IF([test "x$with_fenv" = xyes && test "x$HAVE_FENV_H" != x1],
  [AC_MSG_ERROR(fenv.h required but not usable")])

## IS SIZE_T EQUIVALENT TO UNSIGNED LONG?
#
AC_MSG_CHECKING(whether size_t is the same as unsigned long)

AC_ARG_WITH([size_t],
  [AS_HELP_STRING([--with-size_t=same|distinct|auto],
     [consider size_t as the same as or distinct from unsigned long (auto). Should normally be specified only if cross-compiling.])],
  [AS_IF([test "x$with_size__t" != xsame && test "x$with_size__t" != xdistinct && test "x$with_size__t" != xauto],
     [AC_MSG_ERROR([with-size_t should be one of same, distinct or auto])])
  ],
  [with_size__t=auto]
)

AS_IF([test "x$with_size__t" = xauto],
  [AC_TRY_RUN(
     [
      #include <sys/types.h>
      typedef void (* set_size_t_t) (size_t val);
      typedef void (* set_unsigned_long_t) (unsigned long);
      size_t size_t_value;
      void set_size_t (size_t v) {size_t_value = v;}
        int main(int, char**) {
        set_unsigned_long_t ulsetter = &set_size_t;
        (*ulsetter)(25);
        if (size_t_value != 25) return 1;
        return 0;
      }
     ],
     [with_size__t="same"],
     [with_size__t="distinct"])
  ]
)

AS_IF([test "x$with_size__t" = xsame],
  [AC_DEFINE([GYOTO_SIZE__T_IS_UNSIGNED_LONG], [1], [Define to 1 if size_t and unsigned long are the same])]
)

AC_MSG_RESULT($with_size__t)

# PYTHON STUFF
AC_ARG_WITH([python],
	[AC_HELP_STRING([--with-python@<:@=interpreter@:>@],
	   [force (or disable) python support, possibly specifying interpreter])],
	[
	 case $with_python in
	   yes | no) ;;
	   *)
	       PYTHON=`which $with_python` || AC_MSG_ERROR([$with_python: command not found])
	       with_python=yes
	 esac
	],
	[])

PC_PROG_PYTHON([python3], [2.7], [4.0])
PC_PYTHON_PROG_PYTHON_CONFIG
PC_PYTHON_CHECK_HEADERS(
 [
  PC_PYTHON_CHECK_INCLUDES
  PC_PYTHON_CHECK_CFLAGS
  PC_PYTHON_CHECK_LDFLAGS
  PC_PYTHON_CHECK_LIBS
  PC_PYTHON_CHECK_SITE_DIR
  PC_PYTHON_SITE_PACKAGE_DIR
  PC_PYTHON_CHECK_EXEC_DIR
  PC_PYTHON_CHECK_EXTENSION_SUFFIX
  PC_PYTHON_CHECK_EXEC_DIR
],[PYTHON=""])
AS_IF([test "x$with_python" = xno], [PYTHON=""])
AS_IF([test "x$with_python" = xyes && test "x$PYTHON" = x],
  [AC_MSG_ERROR([Python requested but no supported version found (>=2.7, <4.0)])])

AC_ARG_WITH([virtualenv],
	[AS_HELP_STRING([--with-virtualenv], [install to a Python virtualenv])],
	[],
	[with_virtualenv=no])
AS_IF([test "x$with_virtualenv" != xno],
	    AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
	    AS_IF([test "x$VIRTUALENV" = xno],
	    [AC_MSG_FAILURE(
		[--with-virtualenv given but virtualenv could not be found])]),
	AC_SUBST([VIRTUALENV], [no]))
AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])

AX_PKG_SWIG(2.0)

# DONE WITH PYTHON STUFF

# Checks for programs.

############### CHECK FOR OPTIONAL FEATURES #########################
## ADVANCED INTEGRATORS
# Check for C++11
AC_ARG_ENABLE([c++11],
  [AS_HELP_STRING([--disable-c++11],
     [disable C++11 features (including advanced integrators)])])
AS_IF([test "x$enable_c__11" != "xno"],
  [AX_CXX_COMPILE_STDCXX_11(, [optional])]
)
AS_IF([test "x$HAVE_CXX11" != "x1" && test "x$enable_c__11" = "xyes"],
  [AC_MSG_ERROR([C++11 requested but not found])])

AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
    [compile with MPI (parallelization) support. If none is found,
    MPI is not used. Default: auto])
],,[with_mpi=auto])

# Check for boost

have_boost=no
AS_IF([test "x$with_boost" != "xno"],
  [have_boost=yes
   BOOST_REQUIRE([1.53.1], [have_boost=no])
   AS_IF([test "x$have_boost" == "xyes"],
     [BOOST_FIND_HEADER([boost/multiprecision/cpp_dec_float.hpp],
        [AC_MSG_WARN([Boost.multiprecision not found])
	 have_boost=partial],
        [])
      BOOST_FIND_HEADER([boost/array.hpp],
        [AC_MSG_WARN([boost/array.hpp not found])
	 have_boost=partial],
        [])
      BOOST_FIND_HEADER([boost/numeric/odeint/stepper/controlled_step_result.hpp],
        [AC_MSG_WARN([Boost.odeint not found])
	 have_boost=partial],
        [])
     ])
   ],
   [have_boost=no]
)

AS_IF([test "x$HAVE_CXX11" == "x1" &&  test "x$ac_cv_header_boost_numeric_odeint_stepper_controlled_step_result_hpp" == xyes],
  [AC_DEFINE([GYOTO_HAVE_BOOST_INTEGRATORS], [1], [Define to 1 if C++11 and Boost.odeint are both available]
  )]
)

AS_IF([test "x$have_boost" != "xyes"],
  [FEATURES+="-noboost"]
)

# If --with-mpi=auto is used, try to find MPI, but use standard C compiler if it is not found.
# If --with-mpi=yes is used, try to find MPI and fail if it isn't found.
# If --with-mpi=no is used, use a standard C compiler instead.

have_mpi=no
AC_CHECK_PROGS([MPICXX], [mpic++ mpicxx])
AS_IF([test "x$MPICXX" != x && test "x$have_boost" == xyes && test "x$with_mpi" != xno],
  [
   ax_save_CXX=$CXX
   ax_save_CPP=$CXXCPP
   CXX=$MPICXX
   CXXCPP="$MPICXX -E"
   BOOST_FIND_HEADER([boost/mpi/environment.hpp],
     [have_mpi=no
      CXX=$ax_save_CXX
      AS_IF([test "x$with_mpi" == xyes],
        [ AC_MSG_ERROR([MPI features require boost.mpi])
      ])],
     [
      BOOST_FIND_LIBS([mpi], [mpi], [], [boost/mpi/environment.hpp],
        [boost::mpi::environment()], [])
      BOOST_FIND_LIBS([serialization], [serialization], [],
        [boost/serialization/base_object.hpp],
        [], [])
      have_mpi=yes
    ])
  ]
)

AS_IF([test "x$have_mpi" == xyes],
[ AC_SUBST(MPICXX)
  AC_DEFINE([HAVE_MPI], [1], [Define to 1 if you have MPI])],
[ AS_IF([test "x$with_mpi" == xyes],
  [ AC_ERROR([MPI requested but not found])
  ],
  [FEATURES+="-nompi"
   MPICXX=""])
])

AM_CONDITIONAL(HAVE_MPI, [test "x$have_mpi" == xyes])

AC_PROG_MKDIR_P
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG([])
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AC_CHECK_PROGS([PDFLATEX], [pdflatex])
AC_CHECK_PROGS([BIBTEX], [bibtex])
AC_CHECK_PROGS([KPSEWHICH], [kpsewhich])

# Provide additional defaults for user variables

AX_APPEND_COMPILE_FLAGS([-rdynamic], [LDFLAGS])

AC_ARG_ENABLE([native],
  [AC_HELP_STRING([--enable-native],
     [append "-march=native" to CXXFLAGS if supported])],
  [AS_IF([test "x$enable_native" = "xyes"],
     [AX_APPEND_COMPILE_FLAGS([[-march=native]])])])

AC_ARG_ENABLE([hardening],
  [AS_HELP_STRING([--enable-hardening],
     [add warnings and hardening flags if supported])],
  [AS_IF([test "x$enable_hardening" = "xyes"],
     [AX_APPEND_COMPILE_FLAGS([-pedantic -Wall -W -Wundef -Wshadow -Wcast-qual \
        -Wcast-align -Wconversion -Winline -Wabi -Woverloaded-virtual \
        -Wno-long-long -Wformat -Wformat-security -Werror=format-security \
        -fstack-protector "--param ssp-buffer-size=4"])
      AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2], [CPPFLAGS])
      AX_APPEND_COMPILE_FLAGS([-fPIE], [CXXFLAGS_EXEC])
      AX_APPEND_LINK_FLAGS([-pie], [LDFLAGS_EXEC], [-fPIE])
     ])
  ]
)

AC_SUBST([CXXFLAGS_EXEC])
AC_SUBST([LDFLAGS_EXEC])

AC_ARG_ENABLE([deprecated],
  [AS_HELP_STRING([--enable-deprecated],
     [enable deprecated method names (needing this is a bug)])],
  [AS_IF([test "x$enable_deprecated" = "xno"],
     [AX_APPEND_COMPILE_FLAGS([-DGYOTO_NO_DEPRECATED], [CPPFLAGS])])],
  [AX_APPEND_COMPILE_FLAGS([-DGYOTO_NO_DEPRECATED], [CPPFLAGS])]
)


# Guess *LD_LIBRARY_PATH variable for make check
AC_SUBST([target_os])
SYS=other
DYLIB_VAR=LD_LIBRARY_PATH
case "x$target_os" in
     xdarwin*|xmacos)
	DYLIB_VAR=DYLD_LIBRARY_PATH
	SYS=Darwin
	;;
     *) ;;
esac
plugin_sfx=so
AC_DEFINE_UNQUOTED([GYOTO_PLUGIN_SFX],["${plugin_sfx}"],
  [Suffix for Gyoto plug-ins])
AC_SUBST([GYOTO_PLUGIN_SFX],[${plugin_sfx}])
AC_SUBST([DYLIB_VAR])
# Used in yorick/stdplug/Makefile
AC_SUBST([SYS])
AC_SUBST([plugin_sfx])

# Checks for libraries.
AC_CHECK_LIB([dl], [dlopen])

# Checks for header files.
# We are not using those tests to far
# AC_CHECK_HEADERS([float.h stddef.h string.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_STRTOD
# other functions we may need to check for according to autoscan:
# floor getcwd pow sqrt strdup
AC_CHECK_FUNCS([sincos])

## YORICK
# Check for Yorick
yorick_exe=yorick
YORICK=
AC_MSG_CHECKING([whether to use yorick])
AC_ARG_WITH([yorick],
  [AC_HELP_STRING([--with-yorick[[=yorick-executable]]],
     [force using yorick and optionnally specify which one [default=yorick,
      only if found]])],
  [AS_IF([test "x$with_yorick" == "xno"],
     [AC_MSG_RESULT([no])],
     [AS_IF([test "x$with_yorick" != "xyes"],
        [YORICK=$with_yorick],
        [YORICK=$yorick_exe])
      AS_IF([$YORICK -batch],
        [AC_MSG_RESULT([$YORICK])],
        [AC_MSG_ERROR([$YORICK does not work])])
     ])
   AC_SUBST([YORICK])
  ],
  [AC_CHECK_PROGS([YORICK],$yorick_exe)]
)

AM_CONDITIONAL(HAVE_YORICK, [test "x$YORICK" != "x"])

# Only if YORICK available, check for install directories
AS_IF([test "x$YORICK" != "x"],
  [AC_MSG_CHECKING([install path for Yorick platform-dependent files])
   Y_EXE_HOME=`echo write,format=\"%s\",Y_HOME\; quit | ${YORICK}| tail -1`
   Y_EXE_SITE=`echo write,format=\"%s\",Y_SITE\; quit | ${YORICK}| tail -1`
   Y_INST_HOME=
   Y_INST_SITE=
   AC_ARG_WITH([yorick-home],
     [AC_HELP_STRING([--with-yorick-home=DIR],
        [architecture-dependent Yorick files [default: the
         yorick directory if it is under ${exec_prefix}, else
         ${exec_prefix}/lib/yorick]])],
     [Y_INST_HOME=${with_yorick_home}
      Y_INST_SITE=${with_yorick_home}
     ],
     [AS_IF([echo ${Y_EXE_HOME} | grep ${exec_prefix}],
        [Y_INST_HOME=Y_EXE_HOME
	 Y_INST_SITE=Y_EXE_SITE],
	[Y_INST_HOME='${exec_prefix}/lib/yorick'
	 Y_INST_SITE='${prefix}/lib/yorick']
      )])
   AC_MSG_RESULT([$Y_INST_HOME])
   AC_SUBST([Y_INST_HOME])

   AC_MSG_CHECKING([install path for Yorick platform-independent files])
   AC_ARG_WITH([yorick-site],
     [AC_HELP_STRING([--with-yorick-site=DIR],
        [architecture-independent Yorick files
	 [default: the yorick directory if it is under ${prefix}, else
	  ${prefix}/lib/yorick]])
     ],
     [Y_INST_SITE=${with_yorick_site}])
   AC_MSG_RESULT([$Y_INST_SITE])
   AC_SUBST([Y_INST_SITE])

  ]
)

## DEBUGGING INFORMATION
# Enable debugging by default
GYOTO_DEBUG_ENABLED=yes
AC_ARG_ENABLE([debugging],
  [AS_HELP_STRING([--disable-debugging],
     [remove debugging code for hypothetical speed gain])],
  [AS_IF([test "x$enable_debugging" == "xno"],
     [GYOTO_DEBUG_ENABLED=0])
  ])
AS_IF([test "x$GYOTO_DEBUG_ENABLED" == xyes],
  [AC_DEFINE([GYOTO_DEBUG_ENABLED],
     [1],
     [Enable debugging information gathering code for putative speed gain])
  ]
)

## POSIX THREADS
# Check for pthreads
use_pthreads=yes
AC_ARG_ENABLE([pthreads],
  [AS_HELP_STRING([--disable-pthreads],
     [disable POSIX threads parallelization])],
  [AS_IF([test "x$enable_pthreads" = "xno"], [use_pthreads=no])])
AS_IF([test "x$use_pthreads" == "xyes"], [AX_PTHREAD],
      [FEATURES+="-nopthreads"])

## UDUNITS
# Check for UDUNITS
pkg_requires=
pkg_cflags=
pkg_libs=

AC_ARG_WITH([udunits-inc],
  [AS_HELP_STRING([(--with-udunits-inc=)],
     [deprecated, use --with-udunits-headers])],
  [with_udunits_headers=$withval
   AC_MSG_WARN([--with-udunits-inc option is deprecated, use --with-udunits-headers instead])
  ]
)

AC_ARG_WITH([udunits-lib],
  [AS_HELP_STRING([(--with-udunits-lib=)],
     [deprecated, use --with-udunits-libs])],
  [with_udunits_libs=${withval}
   AC_MSG_WARN([--with-udunits-lib option is deprecated, use --with-udunits-libs instead])
  ]
)


GYOTO_ARG_LIB(udunits, udunits, -ludunits2,
	      [#include <udunits2.h>],
	      [ut_set_error_message_handler(ut_ignore);])
AS_IF([test "x$have_udunits" == "xno"],
  [FEATURES+="-nounits"]
)

## XERCES
# Check for Xerces-c
GYOTO_ARG_LIB(xerces, xerces-c, -lxerces-c,
	      [#include <xercesc/util/PlatformUtils.hpp>],
	      [xercesc::XMLPlatformUtils::Initialize();])
AS_IF([test "x$have_xerces" == "xno"],
  [FEATURES+="-noxml"
   AS_IF([test "x$have_mpi" == "xyes"],
     [AC_MSG_ERROR([The MPI feature set requires Xerces. Please reconfigure with --without-mpi or with --with-xerces.])])
  ]
)

## CFITSIO
# Check for CFITSIO
GYOTO_ARG_LIB(cfitsio, cfitsio, -lcfitsio,
	      [#include <fitsio.h>
	       #include <string>],
	      [fitsfile* fptr=NULL; std::string file=""; int status=0;
	       fits_open_file(&fptr, file.c_str(), 0, &status);])
AS_IF([test "x$have_cfitsio" == "xno"],
  [FEATURES+="-nofits"]
)

## ARBLIB
# Check for ARBLIB
have_2f1=no
# If AEAE if explicitely requested, skip ARBLIB checks.
case "x$with_aeae" in
     x)    ;;
     xno)  ;;
     x*)  with_arblib=no ;;
esac
AC_MSG_CHECKING(whether arblib library name is provided)
AS_IF([test "x$with_arblib_ldflags" == "x"],
  [arblib_ldflags=-lflint-arb],
  [with_arblib=yes
   arblib_ldflags=$with_arblib_ldflags]
)
AC_MSG_RESULT([$arblib_ldflags])
GYOTO_ARG_LIB(arblib, arblib, $arblib_ldflags,
	      [#include <acb_hypgeom.h>],
	      [double hypergeom = 0., rad=0., kappaIndex=5., thetae=1;
  	 acb_t FF, aa, bb, cc, zed;
	 acb_init(FF);
	 acb_init(aa);
	 acb_init(bb);
	 acb_init(cc);
	 acb_init(zed);
	 acb_set_d_d(aa,   kappaIndex-1./3.,  0.);
	 acb_set_d_d(bb,   kappaIndex+1.,     0.);
	 acb_set_d_d(cc,   kappaIndex+2./3.,  0.);
	 acb_set_d_d(zed, -kappaIndex*thetae, 0.);
	 slong prec=53;
	 acb_hypgeom_2f1(FF, aa, bb, cc, zed, ACB_HYPGEOM_2F1_AC, prec);
	 hypergeom = arf_get_d(&acb_realref(FF)->mid, ARF_RND_NEAR);
	 rad = mag_get_d(&acb_realref(FF)->rad);
	 acb_clear(FF);
	 acb_clear(aa);
	 acb_clear(bb);
	 acb_clear(cc);
	 acb_clear(zed);])
AC_ARG_WITH([arblib-ldflags],
  [AS_HELP_STRING([--with-arblib-ldflags=-l<libname>],
     [linker flag for arblib (-lflint-arb on Debian derivatives, -larb on Arch Linux...) possibly with dependencies (e.g. "-larb -lflint").])]
)
AS_IF([test "x$have_arblib" == "xyes"],
  [have_2f1=yes
   with_aeae=no
  ],
  [arblib_ldflags=
  ]
)

## AEAE
# Check for AEAE
AC_MSG_CHECKING(whether aeae should be used)
aeae_headers=
AC_ARG_WITH(
  [aeae],
  [AS_HELP_STRING( [--with-aeae[[=/path/to/AEAE]]],
     [Force using AEAE, optionally specifying full path to location of source code, or force disable it.])],
  [
   AS_IF([test "x$with_aeae" == "xno"],
     [AC_MSG_RESULT(no)],
     [test "x$with_aeae" != "xyes"],
     [aeae_headers=$with_aeae
      case "x$aeae_headers" in
	   x\-I*) ;;
	   x) ;;
	   x*) aeae_headers=-I$aeae_headers ;;
      esac
      with_aeae=yes
      AC_MSG_RESULT(yes)],
     [AC_MSG_RESULT(yes)])
  ],
  [with_aeae=check
   AC_MSG_RESULT(probe)
  ]
)
have_aeae=no
AS_IF([test "x$with_aeae" != "xno"],
  [
   AS_IF([test "x$have_aeae" == "xno"],
     [AC_MSG_CHECKING([for aeae])
      TMPCPPFLAGS=$CPPFLAGS
      CPPFLAGS="$TMPCPPFLAGS $aeae_headers"
      AC_TRY_LINK(
        [#include <complex>
	 #include <iostream>
	 #define SIGN(a) (((a) < 0) ? (-1) : (1))
	 using namespace std;
	 #include "complex_functions.H"
	 #include "hyp_2F1.cpp"],
        [double hypergeom = 0., kappaIndex=5., thetae=1;
	 complex<double> aa=kappaIndex-1./3., bb=kappaIndex+1.,
	 cc=kappaIndex+2./3., zed=-kappaIndex*thetae;
	 const complex<double> FF = hyp_2F1(aa,bb,cc,zed);
	 hypergeom = FF.real();
	],
        [have_aeae=yes
         AC_MSG_RESULT(yes)],
        [AC_MSG_RESULT(no)])
      CPPFLAGS=$TMPCPPFLAGS
      AEAE_CFLAGS="$aeae_headers"
      pkg_cflags="${pkg_cflags} ${AEAE_CFLAGS}"
     ]
   )
  ],
  []
)
AS_IF([test "x$have_aeae" == "xno"],
  [AS_IF([test "x$with_aeae" == "xyes"],
     [AC_MSG_ERROR([aeae requested but not found])
     ],
     []
   )
  ],
  [have_2f1=yes
   AC_DEFINE([GYOTO_USE_AEAE],
     [1],
     [Define to 1 if you have aeae])
  ]
)
AM_CONDITIONAL([HAVE_AEAE], [test "x$have_aeae" == "xyes"])
AM_CONDITIONAL([HAVE_2F1], [test "x$have_2f1" == "xyes"])
AC_SUBST([AEAE_CFLAGS])


## LORENE
# Check for LORENE
AC_MSG_CHECKING([for LORENE])
AC_ARG_VAR([MAKE_S],
  [make command which does not print directories [[make -w]]])
AS_IF([test "x$MAKE_S" = "x"],
  [MAKE_S="make -s"])
AC_ARG_VAR([HOME_LORENE],
  [path to Lorene build directory (see also --with-lorene)])
# first check whether LORENE is required and get HOME_LORENE
require_lorene=no
AC_ARG_WITH([lorene],
  [AS_HELP_STRING([--with-lorene[[=${HOME_LORENE}]]],
     [force using the optional LORENE library, possibly specifying HOME_LORENE
      [default=${HOME_LORENE}]])],
  [AS_IF([test "x$with_lorene" == "xno"],
     [HOME_LORENE=""
      AC_MSG_RESULT([no])
     ],
     [test "x$with_lorene" == "xyes"],
     [require_lorene=yes
      AS_IF([test "x$HOME_LORENE" != "x"],
      [AC_MSG_RESULT($HOME_LORENE)],
      [AC_MSG_ERROR([--with-lorene passed with no path: please specify LORENE
                    path either using the HOME_LORENE environment variable
                    or --with-lorene=<path>.])])
     ],
     [require_lorene=yes
      HOME_LORENE="$with_lorene"
      AC_MSG_RESULT($HOME_LORENE)
     ])
  ],
  [AS_IF([test "x$HOME_LORENE" != "x"],
     [AC_MSG_RESULT($HOME_LORENE)],
     [AC_MSG_RESULT([no])])
  ]
)
# then check whether LORENE is actually installed in HOME_LORENE
# finally output HOME_LORENE
AC_SUBST([HOME_LORENE])
AM_CONDITIONAL([HAVE_LORENE], [test "x$HOME_LORENE" != "x"])
AS_IF([test "x$HOME_LORENE" != "x"],
  [
   AS_IF([test ! -r ${HOME_LORENE}/local_settings],
     [AC_MSG_ERROR([${HOME_LORENE}/local_settings not found])])
cat >conftest.make <<_ACEOF
include \$(HOME_LORENE)/local_settings
conftest.make:
	touch conftest.make

%: conftest.make
	@echo \$(\$@)
_ACEOF
   LORENELDFLAGS="-L$HOME_LORENE/Lib -llorene"
   LORENELDFLAGS="$LORENELDFLAGS `$MAKE_S HOME_LORENE=$HOME_LORENE -f conftest.make LIB_LAPACK | tr -d '\n\r'`"
   LORENELDFLAGS="$LORENELDFLAGS `$MAKE_S HOME_LORENE=$HOME_LORENE -f conftest.make LIB_GSL | tr -d '\n\r'`"
   LORENELDFLAGS="$LORENELDFLAGS `$MAKE_S HOME_LORENE=$HOME_LORENE -f conftest.make LIB_PGPLOT | tr -d '\n\r'`"
   LORENELDFLAGS="$LORENELDFLAGS `$MAKE_S HOME_LORENE=$HOME_LORENE -f conftest.make LIB_LORENE | tr -d '\n\r'`"
   LORENELDFLAGS="$LORENELDFLAGS `$MAKE_S HOME_LORENE=$HOME_LORENE -f conftest.make LIB_CXX | tr -d '\n\r'`"
   LORENECPPFLAGS=`$MAKE_S HOME_LORENE=$HOME_LORENE -f conftest.make INC | tr -d '\n\r'`
   LORENECPPFLAGS="$LORENECPPFLAGS"
   rm conftest.make
   AC_SUBST([LORENECPPFLAGS])
   AC_SUBST([LORENELDFLAGS])
   pkg_cflags="${pkg_cflags} ${LORENECPPFLAGS}"
   pkg_libss="${pkg_libss} ${LORENELDFLAGS}"

  ]
)

## DOCUMENTATION
# disable doc
AC_ARG_ENABLE([doc],
  [AS_HELP_STRING([--disable-doc],
     [disable building documentation (automatically)])],
  [AS_IF([test "x$enable_doc" == "xyes"],
     [mkdoc=yes],
     [test "x$enable_doc" == "xno"],
     [mkdoc=no],
     [AC_MSG_ERROR([Please set --disable-doc or --enable-doc only to ``yes'' or ``no''])])
  ],
  [mkdoc=yes])

# check if doxygen is available
AM_CONDITIONAL([MKREF], [test "x$DOXYGEN" != "x"])

# check if all the necessary LaTeX tools are available
AM_CONDITIONAL([MKGUIDE], [test "x$KPSEWHICH" != "x" && ${KPSEWHICH} kluwer.bst && test "x$PDFLATEX" != "x" && test "x$BIBTEX" != "x"])

####################   FINALIZATION   ###################################
# Finalization: select output files, subdirs etc.
AC_SUBST([pkg_requires])
AC_SUBST([pkg_cflags])
AC_SUBST([pkg_libs])
mySUBDIRS="lib"
build_exec=no
AS_IF([test "x$have_mpi" == xyes], [build_exec=yes])
AS_IF([test "x$use_xerces" != "x" && test "x$use_cfitsio" != "x"], [build_exec=yes])
AS_IF([test "x$build_exec" == xyes], [mySUBDIRS="$mySUBDIRS bin"])

AM_CONDITIONAL([BUILD_GYOTO], [test "x$use_xerces" != "x" && test "x$use_cfitsio" != "x"])

sovers=$(( VERSINFO_C - VERSINFO_A ))
sovers+=$FEATURES
AC_SUBST([FEATURES])
AC_SUBST([sovers])
AC_DEFINE_UNQUOTED([GYOTO_SOVERS], ["${sovers}"], [Gyoto ABI version])

AS_IF([test "x$PYTHON" != "x"],
 [AC_CONFIG_SUBDIRS([plugins/python])
  mySUBDIRS="$mySUBDIRS python"
 ])

AC_CONFIG_FILES([Makefile
                 bin/Makefile
                 doc/Makefile
                 doc/doxyfile
                 doc/user_guide/Makefile
                 lib/Makefile
                 lib/gyoto.pc
                 lib/gyoto-uninstalled.pc
                 ])
AS_IF([test "x$YORICK" != "x"],
  [mySUBDIRS="$mySUBDIRS yorick"
   AC_CONFIG_FILES([yorick/Makefile],
 		   [oldpwd=`pwd`
		    cd yorick
		    $YORICK -batch make.i
		    cd $oldpwd],
		   YORICK=$YORICK)
   AC_CONFIG_FILES([yorick/stdplug/Makefile],
 		   [oldpwd=`pwd`
		    cd yorick/stdplug
		    $YORICK -batch make.i
		    cd $oldpwd],
		   YORICK=$YORICK)
   AC_CONFIG_FILES([yorick/gyoto.info
		    yorick/yorick1
		    yorick/setpaths.i
		   ],
		   [chmod a+x yorick/yorick1])
   AC_CONFIG_FILES([gyoto],
		   [chmod a+x gyoto])
  ]
)
AS_IF([test "x$PYTHON" != "x"],
  [
   AC_CONFIG_FILES([python/Makefile python/setup.py])
  ]
)
AS_IF([test "x$DOXYGEN" != "x" && test "x$mkdoc" == "xyes"],
  [mySUBDIRS="$mySUBDIRS doc"
  ]
)
AC_SUBST([mySUBDIRS])
AC_OUTPUT

########################## SUMMARY ############################

AS_IF([test "x$have_xerces" == "xno" || test "x$have_cfitsio" == "xno" ],
  [
   AC_MSG_WARN(
     [

                   Building without xerces-c and/or cfitsio.

                *** The gyoto executable will not be built! ***

      Gyoto can still be used as a C++ library and through the Yorick plug-in
        (although without XML support and/or without certain object types).
     ])
  ])
AS_IF([test "x$have_udunits" == "xno"],
  [
   AC_MSG_WARN(
     [

                         Building without udunits

                     *** Unit conversions disabled ***

     ])
  ])
AS_IF([test "x$have_boost" == "xno"],
  [
   AC_MSG_WARN(
     [

                         Building without boost

                   *** Advanced integrators disabled ***

        The advanced integrators require the Boost library (>=1.53)
            and a C++ compiler that supports the c++11 standard.

     ])
  ])
AS_IF([test "x$have_2f1" == "xno"],
  [
   AC_MSG_WARN(
     [

                         Building without 2F1

                   *** Hypergeometric functions unavailable ***

                      Astrobj::Jet requires ARBLIB or AEAE.

     ])
  ])