summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac22
-rw-r--r--src/Makefile.am21
2 files changed, 40 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index efdd01259..e8e170b06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,7 +132,9 @@ AC_ARG_WITH(mini_gmp,
test -z "$use_gmp_build"; then
if test -f "$withval/mini-gmp.c" && test -f "$withval/mini-gmp.h"; then
AC_DEFINE([MPFR_USE_MINI_GMP],1,[Use mini-gmp])
- CPPFLAGS="$CPPFLAGS -I$withval"
+dnl Once the Automake 1.15 bug with automatic dependency tracking has become
+dnl obsolete and the src/Makefile.am changes have been reverted, one should
+dnl add back: CPPFLAGS="$CPPFLAGS -I$withval"
mini_gmp_path="$withval"
AC_SUBST(mini_gmp_path)
else
@@ -783,6 +785,11 @@ dnl Setup for mini-gmp
dnl First check whether mini-gmp defines GMP_NUMB_BITS.
AC_MSG_CHECKING(for GMP_NUMB_BITS)
how="from mini-gmp.h"
+dnl With the code working with Automake 1.15 (see --with-mini-gmp code
+dnl above), CPPFLAGS has not been modified, thus one needs a temporary
+dnl one to find the mini-gmp.h header file.
+saved_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$mini_gmp_path"
AC_COMPUTE_INT(mini_gmp_numb_bits, [(GMP_NUMB_BITS)],
[#include <mini-gmp.h>],
[how="not in mini-gmp.h; guessed"
@@ -791,8 +798,21 @@ AC_COMPUTE_INT(mini_gmp_numb_bits, [(GMP_NUMB_BITS)],
[AC_MSG_FAILURE([cannot define GMP_NUMB_BITS])])
AC_DEFINE_UNQUOTED([GMP_NUMB_BITS], $mini_gmp_numb_bits, [number of bits in a limb])
])
+CPPFLAGS="$saved_CPPFLAGS"
AC_MSG_RESULT([$mini_gmp_numb_bits bits ($how)])
+dnl Also added for the code avoiding the Automake 1.15 bug:
+dnl Let us make the configure script clean up the mini-gmp.* files
+dnl and add the symbolic links to mini-gmp.{c,h} instead of relying
+dnl on timestamp-based make rules, which may not work when testing
+dnl several mini-gmp versions (whose source can go back in time).
+mkdir -p "$ac_top_build_prefix"src
+rm -f -- "$ac_top_build_prefix"src/mini-gmp.*
+for i in c h
+do
+ ln -s -- "$mini_gmp_path/mini-gmp.$i" "$ac_top_build_prefix"src/mini-gmp.$i
+done
+
fi
dnl End of setup related to GMP / mini-gmp
diff --git a/src/Makefile.am b/src/Makefile.am
index a4c363413..1c1a8812d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -93,17 +93,34 @@ $(srcdir)/get_patches.c: $(top_srcdir)/PATCHES $(top_srcdir)/tools/get_patches.s
(cd $(top_srcdir) && ./tools/get_patches.sh) > $@ || rm -f $@
if MINI_GMP
+
# The mini-gmp.{c,h} files are external files, not part of MPFR, thus they
# must not be put in the tarballs by "make dist". Hence the use of nodist_
# on the corresponding sources (this is needed even when --with-mini-gmp
# has not been used).
-nodist_include_HEADERS += $(mini_gmp_path)/mini-gmp.h
+nodist_include_HEADERS += mini-gmp.h
+
# The noinst_ below seems OK as libminigmp should be included in libmpfr,
# and this is confirmed by ldd (replacing noinst_ by lib_ does not seem to
# do this and makes linking of the test programs fail).
noinst_LTLIBRARIES = libminigmp.la
-nodist_libminigmp_la_SOURCES = $(mini_gmp_path)/mini-gmp.h $(mini_gmp_path)/mini-gmp.c
+nodist_libminigmp_la_SOURCES = mini-gmp.h mini-gmp.c
libmpfr_la_LIBADD += libminigmp.la
+
+DISTCLEANFILES = $(nodist_libminigmp_la_SOURCES)
+
+# Note: Due to a bug in Automake 1.15 (fixed in Automake 1.16) when using
+# automatic dependency tracking (used by default and highly recommended),
+# the _SOURCES paths must not depend on Make variables. Thus mini-gmp.{c,h}
+# are assumed to be sources in the build directory. They should be added
+# by the configure.ac code when --with-mini-gmp is used, preferably as
+# symbolic links, so that during mini-gmp development/patching, it doesn't
+# matter which pathname is used (when build directory = source directory,
+# one could easily mistakenly edit the copy). Once this Automake bug has
+# become obsolete, the above code could be reverted to:
+# nodist_include_HEADERS += $(mini_gmp_path)/mini-gmp.h
+# nodist_libminigmp_la_SOURCES = $(mini_gmp_path)/mini-gmp.h $(mini_gmp_path)/mini-gmp.c
+
endif
# For check-gmp-symbols