patches/mpfr/2.4.1/150-test-tmul.patch
author Oron Peled <oron@actcom.co.il>
Mon Aug 03 00:49:25 2009 +0200 (2009-08-03)
branch1.4
changeset 1456 94fc77c37418
permissions -rw-r--r--
[complib:mpfr] Fix building MPFR in some weird cases

The tmul test uses a compiled-in input file in $(srcdir).
The problem is that the Makefile passes it unquoted. The C code
tries to stringify it using clever macros, which may *usually* work.

In my case the source directory was named:
.../toolchain-powerpc-e500v2-linux-gnuspe-1.0-2.fc10/.../tests
And guess what? During testing I found out the program fails because
it tries to open:
.../toolchain-powerpc-e500v2-1-gnuspe-1.0-2.fc10/.../tests

Yes, CPP tokenized the macro before stringifying it and not surprisingly
the 'linux' part was converted to 1.
[on Fedora-10: cpp (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)]

So the attached patch simplify the macros and pass the path as string
from the Makefile.

Manually backported from 1449:8ad2773e7ae3
oron@1456
     1
diff -up ./tests/Makefile.am.orig ./tests/Makefile.am
oron@1456
     2
--- ./tests/Makefile.am.orig	2009-07-28 16:28:55.377059021 +0300
oron@1456
     3
+++ ./tests/Makefile.am	2009-07-28 16:31:01.136810734 +0300
oron@1456
     4
@@ -20,7 +20,7 @@ check_PROGRAMS = tversion tinternals tin
oron@1456
     5
 
oron@1456
     6
 EXTRA_DIST = tgeneric.c tgeneric_ui.c mpf_compat.h inp_str.data tmul.dat
oron@1456
     7
 
oron@1456
     8
-tmul_CPPFLAGS = -DMPFR_SRCDIR=$(srcdir)
oron@1456
     9
+tmul_CPPFLAGS = -DMPFR_SRCDIR=\"$(srcdir)\"
oron@1456
    10
 
oron@1456
    11
 LDADD = libfrtests.la $(MPFR_LIBM) $(top_builddir)/libmpfr.la
oron@1456
    12
 INCLUDES = -I$(top_srcdir) -I$(top_builddir)
oron@1456
    13
diff -up ./tests/tmul.c.orig ./tests/tmul.c
oron@1456
    14
--- ./tests/tmul.c.orig	2009-07-28 16:29:03.761058919 +0300
oron@1456
    15
+++ ./tests/tmul.c	2009-07-28 16:30:46.369812215 +0300
oron@1456
    16
@@ -26,10 +26,8 @@ MA 02110-1301, USA. */
oron@1456
    17
 #include "mpfr-test.h"
oron@1456
    18
 
oron@1456
    19
 #ifndef MPFR_SRCDIR
oron@1456
    20
-#define MPFR_SRCDIR .
oron@1456
    21
+#define MPFR_SRCDIR "."
oron@1456
    22
 #endif
oron@1456
    23
-#define QUOTE(X) NAME(X)
oron@1456
    24
-#define NAME(X) #X
oron@1456
    25
 
oron@1456
    26
 #ifdef CHECK_EXTERNAL
oron@1456
    27
 static int
oron@1456
    28
@@ -482,10 +480,10 @@ check_regression (void)
oron@1456
    29
   mpfr_inits2 (6177, x, y, z, (mpfr_ptr) 0);
oron@1456
    30
   /* we read long strings from a file since ISO C90 does not support strings of
oron@1456
    31
      length > 509 */
oron@1456
    32
-  fp = fopen (QUOTE (MPFR_SRCDIR)"/tmul.dat", "r");
oron@1456
    33
+  fp = fopen (MPFR_SRCDIR "/tmul.dat", "r");
oron@1456
    34
   if (fp == NULL)
oron@1456
    35
     {
oron@1456
    36
-      fprintf (stderr, "Error, cannot open "QUOTE (MPFR_SRCDIR)"/tmul.dat\n");
oron@1456
    37
+      fprintf (stderr, "Error, cannot open " MPFR_SRCDIR "/tmul.dat\n");
oron@1456
    38
       exit (1);
oron@1456
    39
     }
oron@1456
    40
   get_string (s, fp);
oron@1456
    41