[complib:mpfr] Fix building MPFR in some weird cases 1.4
authorOron Peled <oron@actcom.co.il>
Mon Aug 03 00:49:25 2009 +0200 (2009-08-03)
branch1.4
changeset 145694fc77c37418
parent 1455 e6a3b4ffe576
child 1457 366b6c794c70
[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
patches/mpfr/2.4.1/150-test-tmul.patch
scripts/build/mpfr.sh
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/mpfr/2.4.1/150-test-tmul.patch	Mon Aug 03 00:49:25 2009 +0200
     1.3 @@ -0,0 +1,41 @@
     1.4 +diff -up ./tests/Makefile.am.orig ./tests/Makefile.am
     1.5 +--- ./tests/Makefile.am.orig	2009-07-28 16:28:55.377059021 +0300
     1.6 ++++ ./tests/Makefile.am	2009-07-28 16:31:01.136810734 +0300
     1.7 +@@ -20,7 +20,7 @@ check_PROGRAMS = tversion tinternals tin
     1.8 + 
     1.9 + EXTRA_DIST = tgeneric.c tgeneric_ui.c mpf_compat.h inp_str.data tmul.dat
    1.10 + 
    1.11 +-tmul_CPPFLAGS = -DMPFR_SRCDIR=$(srcdir)
    1.12 ++tmul_CPPFLAGS = -DMPFR_SRCDIR=\"$(srcdir)\"
    1.13 + 
    1.14 + LDADD = libfrtests.la $(MPFR_LIBM) $(top_builddir)/libmpfr.la
    1.15 + INCLUDES = -I$(top_srcdir) -I$(top_builddir)
    1.16 +diff -up ./tests/tmul.c.orig ./tests/tmul.c
    1.17 +--- ./tests/tmul.c.orig	2009-07-28 16:29:03.761058919 +0300
    1.18 ++++ ./tests/tmul.c	2009-07-28 16:30:46.369812215 +0300
    1.19 +@@ -26,10 +26,8 @@ MA 02110-1301, USA. */
    1.20 + #include "mpfr-test.h"
    1.21 + 
    1.22 + #ifndef MPFR_SRCDIR
    1.23 +-#define MPFR_SRCDIR .
    1.24 ++#define MPFR_SRCDIR "."
    1.25 + #endif
    1.26 +-#define QUOTE(X) NAME(X)
    1.27 +-#define NAME(X) #X
    1.28 + 
    1.29 + #ifdef CHECK_EXTERNAL
    1.30 + static int
    1.31 +@@ -482,10 +480,10 @@ check_regression (void)
    1.32 +   mpfr_inits2 (6177, x, y, z, (mpfr_ptr) 0);
    1.33 +   /* we read long strings from a file since ISO C90 does not support strings of
    1.34 +      length > 509 */
    1.35 +-  fp = fopen (QUOTE (MPFR_SRCDIR)"/tmul.dat", "r");
    1.36 ++  fp = fopen (MPFR_SRCDIR "/tmul.dat", "r");
    1.37 +   if (fp == NULL)
    1.38 +     {
    1.39 +-      fprintf (stderr, "Error, cannot open "QUOTE (MPFR_SRCDIR)"/tmul.dat\n");
    1.40 ++      fprintf (stderr, "Error, cannot open " MPFR_SRCDIR "/tmul.dat\n");
    1.41 +       exit (1);
    1.42 +     }
    1.43 +   get_string (s, fp);
    1.44 +
     2.1 --- a/scripts/build/mpfr.sh	Mon Aug 03 23:11:53 2009 +0200
     2.2 +++ b/scripts/build/mpfr.sh	Mon Aug 03 00:49:25 2009 +0200
     2.3 @@ -30,6 +30,15 @@
     2.4      # do that in the future...
     2.5      # It seems that MPFR >= 2.4.0 do not need this...
     2.6      case "${CT_MPFR_VERSION}" in
     2.7 +        2.4.1)
     2.8 +            CT_Pushd "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}"
     2.9 +            if [ ! -f .autoreconf.ct-ng ]; then
    2.10 +                CT_DoLog DEBUG "Running autoreconf"
    2.11 +                CT_DoExecLog ALL autoreconf
    2.12 +                touch .autoreconf.ct-ng
    2.13 +            fi
    2.14 +            CT_Popd
    2.15 +            ;;
    2.16          1.*|2.0.*|2.1.*|2.2.*|2.3.*)
    2.17              CT_Pushd "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}"
    2.18              if [ ! -f .autotools.ct-ng ]; then