xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/tversion.c (revision d909946ca08dceb44d7d0f22ec9488679695d976)
1 /* Test file for mpfr_version.
2 
3 Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramel projects, INRIA.
5 
6 This file is part of the GNU MPFR Library.
7 
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 
23 #include <stdlib.h>
24 
25 #include "mpfr-test.h"
26 
27 int
28 main (void)
29 {
30   char buffer[256];
31 
32 #ifdef __MPIR_VERSION
33   printf ("[tversion] MPIR: header %d.%d.%d, library %s\n",
34           __MPIR_VERSION, __MPIR_VERSION_MINOR, __MPIR_VERSION_PATCHLEVEL,
35           mpir_version);
36 #else
37   printf ("[tversion] GMP: header %d.%d.%d, library %s\n",
38           __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL,
39           gmp_version);
40 #endif
41   printf ("[tversion] MPFR tuning parameters from %s\n", MPFR_TUNE_CASE);
42 
43   /* Test the MPFR version. */
44   test_version ();
45 
46   sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
47            __GNU_MP_VERSION_PATCHLEVEL);
48   if (strcmp (buffer, gmp_version) == 0)
49     return 0;
50   if (__GNU_MP_VERSION_PATCHLEVEL == 0)
51     {
52       sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR);
53       if (strcmp (buffer, gmp_version) == 0)
54         return 0;
55     }
56 
57   /* In some cases, it may be acceptable to have different versions for
58      the header and the library, in particular when shared libraries are
59      used (e.g., after a bug-fix upgrade of the library, and versioning
60      ensures that this can be done only when the binary interface is
61      compatible). However, when recompiling software like here, this
62      should never happen (except if GMP has been upgraded between two
63      "make check" runs, but there's no reason for that). A difference
64      between the versions of gmp.h and libgmp probably indicates either
65      a bad configuration or some other inconsistency in the development
66      environment, and it is better to fail (in particular for automatic
67      installations). */
68   printf ("ERROR! The versions of gmp.h (%s) and libgmp (%s) do not "
69           "match.\nThe possible causes are:\n", buffer, gmp_version);
70   printf ("  * A bad configuration in your include/library search paths.\n"
71           "  * An inconsistency in the include/library search paths of\n"
72           "    your development environment; an example:\n"
73           "      http://gcc.gnu.org/ml/gcc-help/2010-11/msg00359.html\n"
74           "  * GMP has been upgraded after the first \"make check\".\n"
75           "    In such a case, try again after a \"make clean\".\n"
76           "  * A new or non-standard version naming is used in GMP.\n"
77           "    In this case, a patch may already be available on the\n"
78           "    MPFR web site.  Otherwise please report the problem.\n");
79   printf ("In the first two cases, this may lead to errors, in particular"
80           " with MPFR.\nIf some other tests fail, please solve that"
81           " problem first.\n");
82 
83   return 1;
84 }
85