1 dnl Process this file with autoconf to produce a configure script.
3 dnl Copyright (C) 2014 Taco Hoekwater <taco@metatex.org>
4 dnl Copyright (C) 2014 Peter Breitenlohner <tex-live@tug.org>
6 dnl This file is free software; the copyright holder
7 dnl gives unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
10 m4_include([version.ac])[] dnl define mpfr_version
11 AC_INIT([mpfr (TeX Live)], mpfr_version, [tex-k@tug.org])
13 AC_CONFIG_SRCDIR([mpfr-]mpfr_version[/src/mpfr.h])
14 AC_CONFIG_AUX_DIR([../../build-aux])
15 AC_CONFIG_MACRO_DIRS([../../m4 m4])
23 KPSE_COMPILER_VISIBILITY
25 AC_CONFIG_HEADERS([config.h])
31 AM_CONDITIONAL([build], [test "x$enable_build" != xno])
35 if test "x$enable_build" != xno || test -f config.force; then
37 AC_CHECK_HEADER([limits.h], [], [AC_MSG_ERROR([limits.h not found])])
38 AC_CHECK_HEADER([float.h], [], [AC_MSG_ERROR([float.h not found])])
39 AC_CHECK_HEADER([string.h], [], [AC_MSG_ERROR([string.h not found])])
41 dnl Add some specific flags for ICC
42 AC_MSG_CHECKING([for ICC])
43 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
45 # error "ICC Not Found"
50 CFLAGS="-fp_port -mp -wd1572 -wd265 -wd186 -wd239 $CFLAGS"
51 ], [AC_MSG_RESULT([no])])
53 dnl This allows to take the first GMP library in the library paths,
54 dnl whether it is dynamic or static. This behavior is more sensible,
55 dnl in particular because it is the only way to link with a version
56 dnl only available in static form when another version is available
57 dnl in dynamic, and also for consistency, because the compiler will
58 dnl take the first gmp.h found in the include paths (so, we need to
59 dnl take a library that corresponds to this header file). This is a
60 dnl common problem with darwin.
62 [*-apple-darwin*], [MPFR_LD_SEARCH_PATHS_FIRST])
66 AC_CHECK_HEADER([gmp.h], [], [AC_MSG_ERROR([gmp.h not found])])
68 dnl Check minimal GMP version
69 dnl We only guarantee that with a *functional* and recent enough GMP version,
70 dnl MPFR will compile; we do not guarantee that GMP will compile.
71 dnl In particular fat builds are broken in GMP 4.3.2 and GMP 5.0.0
72 dnl (at least on 64-bit Core 2 under Linux),
73 dnl see http://gmplib.org/list-archives/gmp-bugs/2011-August/002345.html.
74 AC_MSG_CHECKING([for recent GMP])
75 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
77 #if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410)
78 # error "min GMP version is 4.1.0"
81 ]])], [AC_MSG_RESULT([yes])], [
83 AC_MSG_ERROR([GMP 4.1.0 min required])
86 AC_CHECK_FUNC([__gmpz_init], [],
87 [AC_MSG_ERROR([Sorry, cannot find/use libgmp])])
89 dnl Check for corresponding 'gmp.h' and libgmp.a
90 AC_MSG_CHECKING([if gmp.h version and libgmp version are the same])
91 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
97 sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
98 __GNU_MP_VERSION_PATCHLEVEL);
99 printf ("(%s/%s) ", buffer, gmp_version);
100 if (strcmp (buffer, gmp_version) == 0)
102 if (__GNU_MP_VERSION_PATCHLEVEL != 0)
104 sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR);
105 return (strcmp (buffer, gmp_version) != 0) ? 1 : 0;
107 [AC_MSG_RESULT([yes])
108 MPFR_CHECK_PRINTF_SPEC],
110 AC_MSG_WARN([==========================================================])
111 AC_MSG_WARN(['gmp.h' and 'libgmp' seem to have different versions or])
112 AC_MSG_WARN([we cannot run a program linked with GMP (if you cannot])
113 AC_MSG_WARN([see the version numbers above). A cause may be incompatible])
114 AC_MSG_WARN([GMP versions See 'config.log' for details..])
115 AC_MSG_WARN([==========================================================])
117 [AC_MSG_RESULT([can not test])])
122 echo timestamp >config.force
125 AC_SUBST([MPFR_TREE], [mpfr-]mpfr_version)
127 AC_CONFIG_LINKS([mparam.h:mpfr-]mpfr_version[/src/mparam_h.in])
129 AC_CONFIG_FILES([Makefile include/Makefile])