beta-0.89.2
[luatex.git] / source / libs / mpfr / configure.ac
blob00354de953d41c2d1b715a3770e161fc41a25aaf
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl   Copyright (C) 2014 Taco Hoekwater <taco@metatex.org>
4 dnl   Copyright (C) 2014 Peter Breitenlohner <tex-live@tug.org>
5 dnl
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.
9 dnl
10 m4_include([version.ac])[] dnl define mpfr_version
11 AC_INIT([mpfr (TeX Live)], mpfr_version, [tex-k@tug.org])
12 AC_PREREQ([2.65])
13 AC_CONFIG_SRCDIR([mpfr-]mpfr_version[/src/mpfr.h])
14 AC_CONFIG_AUX_DIR([../../build-aux])
15 AC_CONFIG_MACRO_DIRS([../../m4 m4])
17 KPSE_BASIC([mpfr])
19 AC_PROG_CC
20 AC_PROG_RANLIB
21 AC_PROG_LN_S
23 KPSE_COMPILER_VISIBILITY
25 AC_CONFIG_HEADERS([config.h])
27 KPSE_CANONICAL_HOST
29 MPFR_CONFIGS
31 AM_CONDITIONAL([build], [test "x$enable_build" != xno])
33 KPSE_GMP_FLAGS
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([[
44 #if !defined __ICC
45 # error "ICC Not Found"
46 error
47 #endif
48 ]])], [
49  AC_MSG_RESULT([yes])
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.
61 AS_CASE([$host],
62         [*-apple-darwin*], [MPFR_LD_SEARCH_PATHS_FIRST])
64 KPSE_ADD_FLAGS([gmp])
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([[
76 #include "gmp.h"
77 #if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410)
78 # error "min GMP version is 4.1.0"
79 error
80 #endif
81 ]])], [AC_MSG_RESULT([yes])], [
82  AC_MSG_RESULT([no])
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([[
92 #include <stdio.h>
93 #include <string.h>
94 #include "gmp.h"
95 ]], [[
96   char buffer[100];
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)
101     return 0;
102   if (__GNU_MP_VERSION_PATCHLEVEL != 0)
103     return 1;
104   sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR);
105   return (strcmp (buffer, gmp_version) != 0) ? 1 : 0;
106 ]])],
107    [AC_MSG_RESULT([yes])
108     MPFR_CHECK_PRINTF_SPEC],
109    [AC_MSG_RESULT([no])
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([==========================================================])
116     ],
117    [AC_MSG_RESULT([can not test])])
120 KPSE_RESTORE_FLAGS
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])
131 AC_OUTPUT