aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorCharles Karney <charles.karney@sri.com>2017-08-06 11:29:18 -0400
committerCharles Karney <charles.karney@sri.com>2017-08-06 11:29:18 -0400
commit5a0ef580bf85bc0cd4cf3b3bd7780c6e117844d5 (patch)
treec054f4865877dae3422cf63d3370b52872ce571b /configure.ac
parent2d46accd49209e0b6c7c40626c1498a46399163d (diff)
downloadPROJ-5a0ef580bf85bc0cd4cf3b3bd7780c6e117844d5.tar.gz
PROJ-5a0ef580bf85bc0cd4cf3b3bd7780c6e117844d5.zip
Add tests for C99 math functions, hypot, atanh, cbrt, etc.
This tests whether the functions are declared in <math.h>. If they are, then -DHAVE_C99_MATH=1 is added to the C flags. The intention is that this flag is only seen when building proj.4 and shouldn't be referenced in any of the installed include files. The next update to geodesic.c will use this flag. Left unaddressed is what to do if HAVE_C99_MATH is 0. The strategy in geodesic.c is to assume that the missing functions will need to be defined explicitly. A less safe alternative is to assume that the functions are in fact available in libm and that all that needs to be done is to declare the functions.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac14
1 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 68df28ec..e99389ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,20 @@ CFLAGS="$save_CFLAGS"
dnl We check for headers
AC_HEADER_STDC
+dnl Check for C99 math functions
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wall -Werror"
+AC_MSG_CHECKING([for C99 math functions])
+AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [#include <math.h>],
+ [int q;
+ return (int)(hypot(3.0, 4.0) + atanh(0.8) + cbrt(8.0) +
+ remquo(100.0, 90.0, &q) +
+ remainder(100.0, 90.0) + copysign(1.0, -0.0));])],
+ [AC_MSG_RESULT([yes]);C99_MATH="-DHAVE_C99_MATH=1"],
+ [AC_MSG_RESULT([no]);C99_MATH="-DHAVE_C99_MATH=0"])
+CFLAGS="$save_CFLAGS $C99_MATH"
+
AC_CHECK_FUNC(localeconv, [AC_DEFINE(HAVE_LOCALECONV,1,[Define to 1 if you have localeconv])])
dnl ---------------------------------------------------------------------------