# HG changeset patch # User Rik # Date 1356555398 28800 # Node ID cd115ec922489490b4dd0aae6088512127f14f78 # Parent 4bfe605f5ecfdf9fff894ff75b0b5d8ec32c7cb8 build: Check that system has math defines such as M_PI. * configure.ac: Check for math defines such as M_PI. Fail to build if no defines can be found. * liboctave/numeric/lo-specfun.cc: Use M_PI from math.h now that build system has verified that it is present. diff -r 4bfe605f5ecf -r cd115ec92248 configure.ac --- a/configure.ac Wed Dec 26 11:25:12 2012 -0800 +++ b/configure.ac Wed Dec 26 12:56:38 2012 -0800 @@ -2012,6 +2012,46 @@ AC_CHECK_FUNCS([acosh acoshf asinh asinhf atanh atanhf cbrt cbrtf]) AC_CHECK_FUNCS([erf erff erfc erfcf exp2f hypotf _hypotf log2 log2f]) +## Check for math defines such as M_LN2 in math.h +AC_CACHE_CHECK([for MATH DEFINES in math.h], + [octave_cv_header_math_defines], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + double x = M_LN2;]])], + octave_cv_header_math_defines=yes, + octave_cv_header_math_defines=no) + ]) + +if test $octave_cv_header_math_defines = no; then + ## Check again and try defining _USE_MATH_DEFINES + AC_CACHE_CHECK([whether _USE_MATH_DEFINES needs to be defined], + [octave_cv_header__use_math_defines], + [save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_USE_MATH_DEFINES" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + double x = M_LN2;]])], + octave_cv_header__use_math_defines=yes, + octave_cv_header__use_math_defines=no) + CPPFLAGS="$save_CPPFLAGS" + ]) + if test $octave_cv_header__use_math_defines = yes; then + octave_cv_header_math_defines=yes + AC_DEFINE(_USE_MATH_DEFINES, 1, + [Define to 1 if _USE_MATH_DEFINES is required to get math constants like M_LN2.]) + CPPFLAGS="$CPPFLAGS -D_USE_MATH_DEFINES" + fi +fi + +if test $octave_cv_header_math_defines = yes; then + AC_DEFINE(HAVE_MATH_DEFINES, 1, + [Define to 1 if defines such as M_PI are available in math.h]) +else + AC_MSG_ERROR([MATH DEFINES in math.h such as M_PI are required to build Octave]) +fi + ## Windows-specific tests for extra #defines case $canonical_host_type in *-*-msdosmsvc | *-*-mingw*) @@ -2026,15 +2066,6 @@ [AC_DEFINE(_WIN32_WINNT, 0x0403, [Define to 0x0403 to access InitializeCriticalSectionAndSpinCount.]) AC_MSG_RESULT([0x0403])]) - AC_MSG_CHECKING([whether _USE_MATH_DEFINES needs to be defined]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[ - int x = M_LN2;]])], - [AC_MSG_RESULT([no])], - [AC_DEFINE(_USE_MATH_DEFINES, 1, - [Define to 1 if your system needs to define math constants like M_LN2.]) - AC_MSG_RESULT([yes])]) ;; esac diff -r 4bfe605f5ecf -r cd115ec92248 liboctave/numeric/lo-specfun.cc --- a/liboctave/numeric/lo-specfun.cc Wed Dec 26 11:25:12 2012 -0800 +++ b/liboctave/numeric/lo-specfun.cc Wed Dec 26 12:56:38 2012 -0800 @@ -46,10 +46,6 @@ #include "mx-inlines.cc" #include "lo-mappers.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - #include "Faddeeva.hh" extern "C"