1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3define([QD_PATCH_VERSION], 23)
4AC_PREREQ([2.69])
5AC_INIT([qd],[2.3.QD_PATCH_VERSION],[dhbailey@lbl.gov])
6AC_CONFIG_SRCDIR([src/qd_real.cpp])
7AC_CONFIG_MACRO_DIR([m4])
8
9PACKAGE="qd"
10MAJOR_VERSION="2"
11MINOR_VERSION="3"
12PATCH_VERSION="QD_PATCH_VERSION"
13VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION
14AC_DEFINE_UNQUOTED([MAJOR_VERSION],$MAJOR_VERSION,[qd major version number])
15AC_DEFINE_UNQUOTED([MINOR_VERSION],$MINOR_VERSION,[qd minor version number])
16AC_DEFINE_UNQUOTED([PATCH_VERSION],$PATCH_VERSION,[qd patch number (sub minor version)])
17echo "configuring $PACKAGE $VERSION..."
18
19AC_CONFIG_AUX_DIR([config])
20AM_INIT_AUTOMAKE([foreign tar-ustar])
21AC_CONFIG_HEADERS([config.h])
22AC_CONFIG_HEADERS([include/qd/qd_config.h])
23
24AC_CANONICAL_HOST
25
26# Checks for arguments
27# --enable-inline
28AC_ARG_ENABLE([inline], AS_HELP_STRING(--enable-inline, [inline commonly used functions.  [[default=yes]]]))
29AC_MSG_CHECKING([if commonly used function is to be inlined])
30if test "$enable_inline" != "no"; then
31  enable_inline="yes"
32  AC_DEFINE([QD_INLINE], [1], [Define to 1 to inline commonly used functions.])
33fi
34AC_MSG_RESULT($enable_inline)
35
36# --enable-ieee-add
37AC_ARG_ENABLE([ieee-add], AS_HELP_STRING(--enable-ieee-add, [use addition that satisfies IEEE-style error bound instead of Cray-style error bound.  [[default=no]]]))
38AC_MSG_CHECKING([if addition with IEEE-style error bound is to be used])
39if test "$enable_ieee_add" = "yes"; then
40  AC_DEFINE([QD_IEEE_ADD], [1], [Define to 1 to use additions with IEEE-style error bounds.])
41else
42  enable_ieee_add="no"
43fi
44AC_MSG_RESULT($enable_ieee_add)
45
46# --enable-sloppy-mul
47AC_ARG_ENABLE([sloppy-mul], AS_HELP_STRING(--enable-sloppy-mul, [use fast but slightly inaccurate multiplication.  [[default=yes]]]))
48AC_MSG_CHECKING([if sloppy multiplication is to be used])
49if test "$enable_sloppy_mul" != "no"; then
50  enable_sloppy_mul="yes"
51  AC_DEFINE([QD_SLOPPY_MUL], [1], [Define to 1 to use sloppy multiplication (which is faster by slightly inaccurate).])
52fi
53AC_MSG_RESULT($enable_sloppy_mul)
54
55# --enable-sloppy-div
56AC_ARG_ENABLE([sloppy-div], AS_HELP_STRING(--enable-sloppy-div, [use fast but slightly inaccurate division.  [[default=yes]]]))
57AC_MSG_CHECKING([if sloppy division is to be used])
58if test "$enable_sloppy_div" != "no"; then
59  enable_sloppy_div="yes"
60  AC_DEFINE([QD_SLOPPY_DIV], [1], [Define to 1 to use sloppy division (which is faster by slightly inaccurate).])
61fi
62AC_MSG_RESULT($enable_sloppy_div)
63
64
65# Checks for programs.
66AC_LANG(C++)
67AC_PROG_CXX
68AC_PROG_CC
69
70
71# --enable-fma
72AC_ARG_ENABLE([fma], AS_HELP_STRING(--enable-fma, [use fused multiply-add/subtract (auto,gnu,ia64,c99,ibm,compiler).  Use this option with care.  [[default=auto]]]))
73if test "x$enable_fma" = "x"; then
74  enable_fma="auto"
75fi
76case "$enable_fma" in
77  yes)
78    AX_CXX_FMA
79    if test "x$ax_cxx_fma" = "x"; then
80      AC_MSG_ERROR([Cannot find working fused multiply add.])
81    fi
82  ;;
83  auto)
84    case $host in
85      powerpc*-*-*)
86        AX_CXX_FMA(["ibm gnu"])
87      ;;
88      ia64-*)
89        AX_CXX_FMA(["ia64 gnu"])
90      ;;
91    esac
92  ;;
93  no)
94    ax_cxx_fma=
95  ;;
96  *)
97    AX_CXX_FMA([$enable_fma])
98    if test "x$ax_cxx_fma" = "x"; then
99      AC_MSG_ERROR([Cannot find working fused multiply add.])
100    fi
101  ;;
102esac
103if test "x$ax_cxx_fma" = "x"; then
104  ax_cxx_fma="none"
105  ax_cxx_fms="none"
106else
107  AC_DEFINE_UNQUOTED([QD_FMA(x,y,z)], [$ax_cxx_fma],
108    [If fused multiply-add is available, define correct macro for using it.])
109  AC_DEFINE_UNQUOTED([QD_FMS(x,y,z)], [$ax_cxx_fms],
110    [If fused multiply-subtract is available, define correct macro for using it.])
111fi
112
113# Checks for libraries.
114
115# Checks for header files.
116AC_CHECK_HEADERS([ieeefp.h])
117
118CONFIGURE_ARGS=$ac_configure_args
119AC_SUBST(CONFIGURE_ARGS)
120
121# Checks for typedefs, structures, and compiler characteristics.
122AC_HEADER_STDBOOL
123AC_STRUCT_TM
124
125# Check for x86 FPU fix
126AC_MSG_CHECKING([whether x86 FPU control code is needed])
127x86_fix="no"
128case "$host" in
129  i?86-*-* | k?*-*-* | athlon-*-* | x86_64-*-*)
130    AC_DEFINE([X86], [1], [Whether to use x86 fpu fix.])
131    x86_fix="yes"
132  ;;
133esac
134AC_MSG_RESULT($x86_fix)
135if test "$x86_fix" = "yes"; then
136  AC_CHECK_HEADERS([fpu_control.h])
137fi
138
139# Checks for library functions.
140AC_CHECK_FUNCS([gettimeofday])
141AX_CXX_CLOCK_GETTIME
142if test "$ax_cxx_clock_gettime" = "yes"; then
143  AC_SEARCH_LIBS([clock_gettime], [rt],
144    [AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
145      [Define to 1 if your system has the clock_gettime function.])])
146fi
147AX_CXX_ISNAN
148AC_DEFINE_UNQUOTED([QD_ISNAN(x)], [$ax_cxx_isnan], [Define this macro to be the isnan(x) function.])
149AX_CXX_ISINF
150AC_DEFINE_UNQUOTED([QD_ISINF(x)], [$ax_cxx_isinf], [Define this macro to be the isinf(x) function.])
151AX_CXX_ISFINITE
152AC_DEFINE_UNQUOTED([QD_ISFINITE(x)], [$ax_cxx_isfinite], [Define this macro to be the isfinite(x) function.])
153AX_CXX_COPYSIGN
154AC_DEFINE_UNQUOTED([QD_COPYSIGN(x, y)], [$ax_cxx_copysign], [Define this macro to be the copysign(x, y) function.])
155
156AC_DEFINE([QD_API], [], [Any special symbols needed for exporting APIs.])
157
158# check for C++ std includes
159AC_DEFINE([QD_HAVE_STD], [1], [Define to 1 if your compiler have the C++ standard include files.])
160
161# Check for fortran-90 compiler
162
163AC_ARG_ENABLE([fortran], AS_HELP_STRING(--enable-fortran, [build Fortran 77/90 interfaces [[default=auto]]]))
164if test "$enable_fortran" != "no"; then
165  AC_LANG_PUSH(Fortran)
166  AC_PROG_FC([xlf95 ifort pathf95 f95 gfortran g95 pgf95 lf95 fort ifc efc pathf90 xlf90 pgf90 epcf90 xlf f90])
167  if test "$FC" != ""; then
168    enable_fortran="yes"
169    AC_DEFINE([HAVE_FORTRAN], [1], [Define to 1 if Fortran interface is to be compiled.])
170    AC_SUBST(FC, "$FC")
171
172    AC_FC_LIBRARY_LDFLAGS
173    AC_FC_FREEFORM
174
175    FC_PROG_NAME=`basename $FC`
176
177    case $host in
178      i?86-*-* | k?*-*-* | athlon-*-* | ia64-*-* | x86_64-*-*)
179        case "$FC_PROG_NAME" in
180          ifc|ifort|efc)
181            REQ_FCFLAGS="$REQ_FCFLAGS -mp -Vaxlib"
182          ;;
183        esac
184      ;;
185      powerpc*-*-*)
186        case "$FC_PROG_NAME" in
187          xlf*)
188            REQ_FCFLAGS="$REQ_FCFLAGS -qstrict"
189          ;;
190        esac
191      ;;
192    esac
193
194    AX_FC_ETIME
195    AC_SUBST(ETIME, $ax_fc_etime)
196    AX_CXX_FC_LIB
197
198    AC_FC_WRAPPERS
199    AC_FC_MAIN
200    AX_F90_MODULE_FLAG
201    AC_SUBST(ax_f90_modflag)
202    AX_F90_MODULE_STYLE
203    module_case=`echo "$ax_f90_module_style" | sed 's/,.*$//'`
204    module_ext=`echo "$ax_f90_module_style" | sed 's/^.*, //'`
205    AC_SUBST(module_ext)
206  else
207    enable_fortran="no"
208  fi
209  AC_SUBST(REQ_FCFLAGS)
210  FCFLAGS="$FCFLAGS $REQ_FCFLAGS"
211  AC_LANG_POP(Fortran)
212fi
213
214AM_CONDITIONAL(UPCASE_MODULE, [test "$module_case" = "uppercase"])
215AM_CONDITIONAL(HAVE_FORTRAN, [test "$enable_fortran" = "yes"])
216
217AC_SUBST(F77, $FC)
218AC_SUBST(FFLAGS, $FCFLAGS)
219
220# Add libraries
221AC_CHECK_LIB(m,sqrt)
222
223# libtool stuff
224LT_INIT
225
226# Output
227AC_CONFIG_FILES([Makefile src/Makefile include/Makefile
228                 tests/Makefile fortran/Makefile qd-config
229                 fortran/second.f qd.pc])
230AC_OUTPUT
231chmod +x qd-config
232
233echo
234echo "Using "
235echo "  C++ Compiler      = $CXX"
236echo "  C++ Flags         = $CXXFLAGS $DEFS"
237if test "$enable_fortran" = "yes"; then
238  echo "  F90 Compiler      = $FC"
239  echo "  F90 Flags         = $FCFLAGS $FCFLAGS_f90"
240  echo "  F90 Libs          = $FCLIBS"
241fi
242echo "  enable fortran    = $enable_fortran"
243echo "  enable inline     = $enable_inline"
244echo "  enable x86 fix    = $x86_fix"
245echo "  enable ieee add   = $enable_ieee_add"
246echo "  enable sloppy mul = $enable_sloppy_mul"
247echo "  enable sloppy div = $enable_sloppy_div"
248echo "  fma               = $ax_cxx_fma"
249echo "  fms               = $ax_cxx_fms"
250
251