pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PATCH: GNU fix m4 math.h compilation failure on Solaris 10



At Thu, 8 May 2008 15:53:41 +0200,
Thomas Klausner wrote:
> 
> On Wed, May 07, 2008 at 02:27:04PM -0400, Lowry, Zach B CTR USAF AFMC 
> AEDC/ATA wrote:
> > The attached patch fixes a failure for m4 in 2008Q1 on Solaris 10.
> > Solaris 10's math.h is weird and needs special handling in GNU m4 [0].
> > This fix should be committed to pkgsrc-current for devel/m4 and possibly
> > other GNU packages. 
> 
> Please send me the patch for inclusion into pkgsrc -- it wasn't
> attached.
> 
> Thanks,
>  Thomas

Here's a patch for devel/m4 in 2008Q1 (m4-1.4.11) to fix that problem,
based upon Eric Blake's work.

    cf. http://lists.gnu.org/archive/html/bug-m4/2008-04/msg00085.html


--- Makefile.in.orig    2008-04-02 21:45:30.000000000 +0900
+++ Makefile.in 2008-07-05 05:58:39.000000000 +0900
@@ -386,12 +386,14 @@
 REPLACE_GETLINE = @REPLACE_GETLINE@
 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@
 REPLACE_ISFINITE = @REPLACE_ISFINITE@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LDEXPL = @REPLACE_LDEXPL@
 REPLACE_LSEEK = @REPLACE_LSEEK@
 REPLACE_MEMMEM = @REPLACE_MEMMEM@
 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_NAN = @REPLACE_NAN@
 REPLACE_PRINTF = @REPLACE_PRINTF@
 REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_ROUND = @REPLACE_ROUND@
--- configure.orig      2008-04-02 21:45:03.000000000 +0900
+++ configure   2008-07-05 06:46:20.000000000 +0900
@@ -790,8 +790,10 @@
 REPLACE_FLOORL
 REPLACE_FREXP
 REPLACE_FREXPL
+REPLACE_HUGE_VAL
 REPLACE_ISFINITE
 REPLACE_LDEXPL
+REPLACE_NAN
 REPLACE_ROUND
 REPLACE_ROUNDF
 REPLACE_ROUNDL
@@ -7366,8 +7368,10 @@
   REPLACE_FLOORL=0;
   REPLACE_FREXP=0;
   REPLACE_FREXPL=0;
+  REPLACE_HUGE_VAL=0;
   REPLACE_ISFINITE=0;
   REPLACE_LDEXPL=0;
+  REPLACE_NAN=0;
   REPLACE_ROUND=0;
   REPLACE_ROUNDF=0;
   REPLACE_ROUNDL=0;
@@ -16379,6 +16383,119 @@
 
 
 
+  { echo "$as_me:$LINENO: checking whether NAN macro works" >&5
+echo $ECHO_N "checking whether NAN macro works... $ECHO_C" >&6; }
+if test "${gl_cv_header_math_nan_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <math.h>
+int
+main ()
+{
+/* Solaris 10 has a broken definition of NAN.  Other platforms
+        fail to provide NAN, or provide it only in C99 mode; this
+        test only needs to fail when NAN is provided but wrong.  */
+         float f = 1.0f;
+#ifdef NAN
+        f = NAN;
+#endif
+        return f == 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  gl_cv_header_math_nan_works=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       gl_cv_header_math_nan_works=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $gl_cv_header_math_nan_works" >&5
+echo "${ECHO_T}$gl_cv_header_math_nan_works" >&6; }
+  if test $gl_cv_header_math_nan_works = no; then
+    REPLACE_NAN=1
+  fi
+  { echo "$as_me:$LINENO: checking whether HUGE_VAL works" >&5
+echo $ECHO_N "checking whether HUGE_VAL works... $ECHO_C" >&6; }
+if test "${gl_cv_header_math_huge_val_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <math.h>
+int
+main ()
+{
+/* Solaris 10 has a broken definition of HUGE_VAL.  */
+        double d = HUGE_VAL;
+        return d == 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  gl_cv_header_math_huge_val_works=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       gl_cv_header_math_huge_val_works=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $gl_cv_header_math_huge_val_works" >&5
+echo "${ECHO_T}$gl_cv_header_math_huge_val_works" >&6; }
+  if test $gl_cv_header_math_huge_val_works = no; then
+    REPLACE_HUGE_VAL=1
+  fi
 
 
 
@@ -27058,8 +27175,10 @@
 REPLACE_FLOORL!$REPLACE_FLOORL$ac_delim
 REPLACE_FREXP!$REPLACE_FREXP$ac_delim
 REPLACE_FREXPL!$REPLACE_FREXPL$ac_delim
+REPLACE_HUGE_VAL!$REPLACE_HUGE_VAL$ac_delim
 REPLACE_ISFINITE!$REPLACE_ISFINITE$ac_delim
 REPLACE_LDEXPL!$REPLACE_LDEXPL$ac_delim
+REPLACE_NAN!$REPLACE_NAN$ac_delim
 REPLACE_ROUND!$REPLACE_ROUND$ac_delim
 REPLACE_ROUNDF!$REPLACE_ROUNDF$ac_delim
 REPLACE_ROUNDL!$REPLACE_ROUNDL$ac_delim
@@ -27081,7 +27200,7 @@
 GNULIB_FCHDIR!$GNULIB_FCHDIR$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 99; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
--- doc/Makefile.in.orig        2008-04-02 21:45:28.000000000 +0900
+++ doc/Makefile.in     2008-07-05 05:57:57.000000000 +0900
@@ -380,12 +380,14 @@
 REPLACE_GETLINE = @REPLACE_GETLINE@
 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@
 REPLACE_ISFINITE = @REPLACE_ISFINITE@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LDEXPL = @REPLACE_LDEXPL@
 REPLACE_LSEEK = @REPLACE_LSEEK@
 REPLACE_MEMMEM = @REPLACE_MEMMEM@
 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_NAN = @REPLACE_NAN@
 REPLACE_PRINTF = @REPLACE_PRINTF@
 REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_ROUND = @REPLACE_ROUND@
--- examples/Makefile.in.orig   2008-04-02 21:45:28.000000000 +0900
+++ examples/Makefile.in        2008-07-05 05:59:06.000000000 +0900
@@ -355,12 +355,14 @@
 REPLACE_GETLINE = @REPLACE_GETLINE@
 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@
 REPLACE_ISFINITE = @REPLACE_ISFINITE@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LDEXPL = @REPLACE_LDEXPL@
 REPLACE_LSEEK = @REPLACE_LSEEK@
 REPLACE_MEMMEM = @REPLACE_MEMMEM@
 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_NAN = @REPLACE_NAN@
 REPLACE_PRINTF = @REPLACE_PRINTF@
 REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_ROUND = @REPLACE_ROUND@
--- lib/Makefile.am.orig        2008-04-02 09:56:18.000000000 +0900
+++ lib/Makefile.am     2008-07-05 06:01:46.000000000 +0900
@@ -582,8 +582,10 @@
              -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \
              -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
              -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
+             -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
              -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
              -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
+             -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \
              -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
              -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
              -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
--- lib/Makefile.in.orig        2008-04-02 21:45:29.000000000 +0900
+++ lib/Makefile.in     2008-07-05 06:00:27.000000000 +0900
@@ -399,11 +399,13 @@
 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
 REPLACE_ISFINITE = @REPLACE_ISFINITE@
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LDEXPL = @REPLACE_LDEXPL@
 REPLACE_LSEEK = @REPLACE_LSEEK@
 REPLACE_MEMMEM = @REPLACE_MEMMEM@
 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_NAN = @REPLACE_NAN@
 REPLACE_PRINTF = @REPLACE_PRINTF@
 REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_ROUND = @REPLACE_ROUND@
@@ -1083,8 +1085,10 @@
              -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \
              -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
              -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
+             -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
              -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
              -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
+             -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \
              -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
              -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
              -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
--- lib/math.in.h.orig  2008-04-01 11:59:24.000000000 +0900
+++ lib/math.in.h       2008-07-05 06:07:06.000000000 +0900
@@ -34,8 +34,11 @@
 
 /* POSIX allows platforms that don't support NAN.  But all major
    machines in the past 15 years have supported something close to
-   IEEE NaN, so we define this unconditionally.  */
-#ifndef NAN
+   IEEE NaN, so we define this unconditionally.  We also must define
+   it on platforms like Solaris 10, where NAN is present but defined
+   as a function pointer rather than a floating point constant.  */
+#if !defined NAN || @REPLACE_NAN@
+# undef NAN
   /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0.  */
 # ifdef __DECC
 static float
@@ -50,6 +53,13 @@
 # endif
 #endif
 
+/* Solaris 10 defines HUGE_VAL, but as a function pointer rather
+   than a floating point constant.  */
+#if @REPLACE_HUGE_VAL@
+# undef HUGE_VAL
+# define HUGE_VAL (1.0 / 0.0)
+#endif
+
 /* Write x as
      x = mantissa * 2^exp
    where
--- m4/math_h.m4.orig   2008-01-27 08:05:11.000000000 +0900
+++ m4/math_h.m4        2008-07-05 06:04:14.000000000 +0900
@@ -8,6 +8,31 @@
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([math.h])
+  AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
+      [[/* Solaris 10 has a broken definition of NAN.  Other platforms
+        fail to provide NAN, or provide it only in C99 mode; this
+        test only needs to fail when NAN is provided but wrong.  */
+         float f = 1.0f;
+#ifdef NAN
+        f = NAN;
+#endif
+        return f == 0;]])],
+      [gl_cv_header_math_nan_works=yes],
+      [gl_cv_header_math_nan_works=no])])
+  if test $gl_cv_header_math_nan_works = no; then
+    REPLACE_NAN=1
+  fi
+  AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
+      [[/* Solaris 10 has a broken definition of HUGE_VAL.  */
+        double d = HUGE_VAL;
+        return d == 0;]])],
+      [gl_cv_header_math_huge_val_works=yes],
+      [gl_cv_header_math_huge_val_works=no])])
+  if test $gl_cv_header_math_huge_val_works = no; then
+    REPLACE_HUGE_VAL=1
+  fi
 ])
 
 AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -56,8 +81,10 @@
   REPLACE_FLOORL=0;            AC_SUBST([REPLACE_FLOORL])
   REPLACE_FREXP=0;             AC_SUBST([REPLACE_FREXP])
   REPLACE_FREXPL=0;            AC_SUBST([REPLACE_FREXPL])
+  REPLACE_HUGE_VAL=0;          AC_SUBST([REPLACE_HUGE_VAL])
   REPLACE_ISFINITE=0;          AC_SUBST([REPLACE_ISFINITE])
   REPLACE_LDEXPL=0;            AC_SUBST([REPLACE_LDEXPL])
+  REPLACE_NAN=0;               AC_SUBST([REPLACE_NAN])
   REPLACE_ROUND=0;             AC_SUBST([REPLACE_ROUND])
   REPLACE_ROUNDF=0;            AC_SUBST([REPLACE_ROUNDF])
   REPLACE_ROUNDL=0;            AC_SUBST([REPLACE_ROUNDL])
--- src/Makefile.in.orig        2008-04-02 21:45:29.000000000 +0900
+++ src/Makefile.in     2008-07-05 06:05:08.000000000 +0900
@@ -381,12 +381,14 @@
 REPLACE_GETLINE = @REPLACE_GETLINE@
 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@
 REPLACE_ISFINITE = @REPLACE_ISFINITE@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LDEXPL = @REPLACE_LDEXPL@
 REPLACE_LSEEK = @REPLACE_LSEEK@
 REPLACE_MEMMEM = @REPLACE_MEMMEM@
 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_NAN = @REPLACE_NAN@
 REPLACE_PRINTF = @REPLACE_PRINTF@
 REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_ROUND = @REPLACE_ROUND@
--- tests/Makefile.in.orig      2008-04-02 21:45:30.000000000 +0900
+++ tests/Makefile.in   2008-07-05 06:05:56.000000000 +0900
@@ -695,12 +695,14 @@
 REPLACE_GETLINE = @REPLACE_GETLINE@
 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@
 REPLACE_ISFINITE = @REPLACE_ISFINITE@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LDEXPL = @REPLACE_LDEXPL@
 REPLACE_LSEEK = @REPLACE_LSEEK@
 REPLACE_MEMMEM = @REPLACE_MEMMEM@
 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_NAN = @REPLACE_NAN@
 REPLACE_PRINTF = @REPLACE_PRINTF@
 REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_ROUND = @REPLACE_ROUND@

Attachment: pgpLbeE9FkRHX.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index