--- /dev/null
+diff -Nur arprec-2.2.8.orig/arprec-config.in arprec-2.2.8/arprec-config.in
+--- arprec-2.2.8.orig/arprec-config.in 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/arprec-config.in 2012-01-13 04:23:40.000000000 +0000
+@@ -17,7 +17,7 @@
+ FC="@FC@"
+ FCLIBS="-L$libdir -larprecmod -larprec @LIBS@ @FCLIBS@"
+ FCFLAGS="@CONFIG_FCFLAGS@"
+-MODINC="@ax_f90_modflag@$libdir/arprec"
++MODINC="@ax_f90_modflag@$includedir/arprec"
+ FMAINLIB="-L$libdir -larprec_f_main"
+
+ configure_args="@CONFIGURE_ARGS@"
+diff -Nur arprec-2.2.8.orig/configure.ac arprec-2.2.8/configure.ac
+--- arprec-2.2.8.orig/configure.ac 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/configure.ac 2012-01-12 19:30:38.000000000 +0000
+@@ -233,8 +233,9 @@
+ AM_CONDITIONAL(HAVE_FORTRAN, [test "x$enable_fortran" = "xyes"])
+ AM_CONDITIONAL(UPCASE_MODULE, [test "$module_case" = "uppercase"])
+
+-# Check ranlib
+-AC_PROG_RANLIB
++# Check libtool (will check for ranlib and friends)
++AC_DISABLE_SHARED
++AC_PROG_LIBTOOL
+
+ # Checks for libraries.
+
+diff -Nur arprec-2.2.8.orig/fortran/Makefile.am arprec-2.2.8/fortran/Makefile.am
+--- arprec-2.2.8.orig/fortran/Makefile.am 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/fortran/Makefile.am 2012-01-13 00:06:20.000000000 +0000
+@@ -1,10 +1,10 @@
+ if HAVE_FORTRAN
+ AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include
+-LDADD = libarprec_f_main.a libarprecmod.a $(top_builddir)/src/libarprec.a $(FCLIBS)
++LDADD = libarprec_f_main.la libarprecmod.la $(top_builddir)/src/libarprec.la $(FCLIBS)
+
+-lib_LIBRARIES = libarprecmod.a libarprec_f_main.a
+-libarprecmod_a_SOURCES = f_mp.cpp mp_mod.f mp_modm.f mp_modx.f
+-libarprec_f_main_a_SOURCES = main.cpp
++lib_LTLIBRARIES = libarprecmod.la libarprec_f_main.la
++libarprecmod_la_SOURCES = f_mp.cpp mp_mod.f mp_modm.f mp_modx.f
++libarprec_f_main_la_SOURCES = main.cpp
+
+ if UPCASE_MODULE
+ MPCOMPLEXMOD = MPCOMPLEXMOD.$(module_ext)
+@@ -29,15 +29,16 @@
+ MODULES = $(MPCOMPLEXMOD) $(MPDEFMOD) $(MPGENMOD) $(MPINTMOD) \
+ $(MPMODULE) $(MPMODULEM) $(MPMODULEX) $(MPREALMOD)
+
+-$(MPDEFMOD) $(MPINTMOD) $(MPREALMOD) $(MPCOMPLEXMOD) $(MPGENMOD) $(MPMODULE): mp_mod.o
++$(MPDEFMOD) $(MPINTMOD) $(MPREALMOD) $(MPCOMPLEXMOD) $(MPGENMOD) $(MPMODULE): mp_mod.lo
+
+-mp_modm.o: mp_mod.o
+-$(MPMODULEM): mp_modm.o
++mp_modm.lo: mp_mod.lo
++$(MPMODULEM): mp_modm.lo
+
+-mp_modx.o: mp_mod.o
+-$(MPMODULEX): mp_modx.o
++mp_modx.lo: mp_mod.lo
++$(MPMODULEX): mp_modx.lo
+
+-pkglib_DATA = $(MODULES)
++arprecmoddir = $(includedir)/arprec
++arprecmod_HEADERS = $(MODULES)
+
+ DEMO = pslq1$(EXEEXT) pslq2$(EXEEXT) pslq3$(EXEEXT) pslqm1$(EXEEXT) \
+ pslqm2$(EXEEXT) pslqm3$(EXEEXT) quadgs$(EXEEXT) quaderf$(EXEEXT) \
+diff -Nur arprec-2.2.8.orig/m4/ax_cxx_fma.m4 arprec-2.2.8/m4/ax_cxx_fma.m4
+--- arprec-2.2.8.orig/m4/ax_cxx_fma.m4 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/m4/ax_cxx_fma.m4 2012-01-12 23:13:06.000000000 +0000
+@@ -19,14 +19,14 @@
+ case $name in
+ ibm)
+ # IBM VisualAge C++ __fmadd / __fmsub.
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ #include <builtins.h>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ double x = __fmadd(1.0 + d, 1.0 - d, -1.0);
+ double y = __fmsub(1.0 + d, 1.0 - d, 1.0);
+ return (x == -d*d && y == -d*d) ? 0 : 1;
+- }],
++ }])],
+ [ax_cxx_fma="__fmadd(x,y,z)"
+ ax_cxx_fms="__fmsub(x,y,z)"
+ AC_DEFINE([ARPREC_VACPP_BUILTINS_H], [1],
+@@ -34,22 +34,22 @@
+ ;;
+ gnu)
+ # Later gcc (3.4 and later) have __builtin_fma that seems to work.
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return (__builtin_fma(1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="__builtin_fma(x,y,z)"
+ ax_cxx_fms="__builtin_fma(x,y,-z)"])
+ ;;
+ c99)
+ # Try C99 fma() function. Some platforms doesn't seem to implement this
+ # correctly (Apple gcc-3.3 for example).
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return (fma(1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="fma(x,y,z)"
+ ax_cxx_fms="fma(x,y,-z)"])
+ ;;
+@@ -57,11 +57,11 @@
+ # Try relying on the compiler to optimize x * y + z into an fma.
+ # This method is not recommended since if it is inlined it does not
+ # always produce the same correct code.
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return ( (1.0 + d) * (1.0 - d) - 1.0 == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="((x)*(y) + (z))"
+ ax_cxx_fms="((x)*(y) - (z))"])
+ ;;
+diff -Nur arprec-2.2.8.orig/m4/ax_f90_module_flag.m4 arprec-2.2.8/m4/ax_f90_module_flag.m4
+--- arprec-2.2.8.orig/m4/ax_f90_module_flag.m4 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/m4/ax_f90_module_flag.m4 2012-01-12 23:11:22.000000000 +0000
+@@ -16,7 +16,7 @@
+
+ AC_DEFUN([AX_F90_MODULE_FLAG],[
+ AC_CACHE_CHECK([fortran 90 modules inclusion flag],
+-ax_f90_modflag,
++ax_cv_f90_modflag,
+ [AC_LANG_PUSH(Fortran)
+ i=0
+ while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do
+@@ -24,24 +24,24 @@
+ done
+ mkdir tmpdir_$i
+ cd tmpdir_$i
+-AC_COMPILE_IFELSE([module conftest_module
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([module conftest_module
+ contains
+ subroutine conftest_routine
+ write(*,'(a)') 'gotcha!'
+ end subroutine conftest_routine
+ end module conftest_module
+- ],[],[])
++ ])],[],[])
+ cd ..
+ ax_f90_modflag="not found"
+ for ax_flag in "-I " "-M" "-p"; do
+ if test "$ax_f90_modflag" = "not found" ; then
+ ax_save_FCFLAGS="$FCFLAGS"
+ FCFLAGS="$ax_save_FCFLAGS ${ax_flag}tmpdir_$i"
+- AC_COMPILE_IFELSE([program conftest_program
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([program conftest_program
+ use conftest_module
+ call conftest_routine
+ end program conftest_program
+- ],[ax_f90_modflag="$ax_flag"],[])
++ ])],[ax_f90_modflag="$ax_flag"],[])
+ FCFLAGS="$ax_save_FCFLAGS"
+ fi
+ done
+diff -Nur arprec-2.2.8.orig/m4/ax_f90_module_style.m4 arprec-2.2.8/m4/ax_f90_module_style.m4
+--- arprec-2.2.8.orig/m4/ax_f90_module_style.m4 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/m4/ax_f90_module_style.m4 2012-01-12 23:11:22.000000000 +0000
+@@ -21,7 +21,7 @@
+
+ AC_DEFUN([AX_F90_MODULE_STYLE],[
+ AC_CACHE_CHECK([fortran 90 modules naming style],
+-ax_f90_module_style,
++ax_cv_f90_module_style,
+ [AC_LANG_PUSH(Fortran)
+ i=0
+ while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do
+@@ -29,13 +29,13 @@
+ done
+ mkdir tmpdir_$i
+ cd tmpdir_$i
+-AC_COMPILE_IFELSE([module conftest_module
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([module conftest_module
+ contains
+ subroutine conftest_routine
+ write(*,'(a)') 'gotcha!'
+ end subroutine conftest_routine
+ end module conftest_module
+- ],
++ ])],
+ [ax_f90_modext=`ls | sed -n 's,conftest_module\.,,p'`
+ if test x$ax_f90_modext = x ; then
+ dnl Some F90 compilers put module filename in uppercase letters
+diff -Nur arprec-2.2.8.orig/m4/ax_fc_backslash_flag.m4 arprec-2.2.8/m4/ax_fc_backslash_flag.m4
+--- arprec-2.2.8.orig/m4/ax_fc_backslash_flag.m4 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/m4/ax_fc_backslash_flag.m4 2012-01-12 23:13:50.000000000 +0000
+@@ -11,9 +11,9 @@
+ if test "x$ax_flag" != "xnone"; then
+ FCFLAGS="$save_FCFLAGS $ax_flag"
+ fi
+- AC_COMPILE_IFELSE([[program test
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([program test
+ print *, '\'
+- end program]], [ax_fc_backslash_flag=$ax_flag])
++ end program])], [ax_fc_backslash_flag=$ax_flag])
+ fi
+ done
+ AC_LANG_POP(Fortran)
+diff -Nur arprec-2.2.8.orig/m4/ax_fc_etime.m4 arprec-2.2.8/m4/ax_fc_etime.m4
+--- arprec-2.2.8.orig/m4/ax_fc_etime.m4 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/m4/ax_fc_etime.m4 2012-01-12 23:11:22.000000000 +0000
+@@ -4,9 +4,9 @@
+ ax_fc_etime=
+ ax_fc_etime_names="etime etime_"
+ for name in $ax_fc_etime_names; do
+- AC_LINK_IFELSE([AC_LANG_PROGRAM(, [[
++ AC_LINK_IFELSE([AC_LANG_PROGRAM(, [AC_LANG_SOURCE([
+ real*4 t(2), tot
+- tot = $name(t)]])],
++ tot = $name(t)])])],
+ [ax_fc_etime=$name], [])
+ if test "x$ax_fc_etime" != "x"; then
+ break;
+diff -Nur arprec-2.2.8.orig/Makefile.am arprec-2.2.8/Makefile.am
+--- arprec-2.2.8.orig/Makefile.am 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/Makefile.am 2012-01-12 23:53:09.000000000 +0000
+@@ -2,21 +2,20 @@
+ SUBDIRS = src tests include fortran toolkit
+
+ bin_SCRIPTS=arprec-config
+-docdir=${datadir}/doc/${PACKAGE}
+ dist_doc_DATA = README doc/arprec.pdf
+
+ cpp-demo:
+- cd tests && make demo
++ $(MAKE) -C tests demo
+
+ if HAVE_FORTRAN
+
+ fortran-demo:
+- cd fortran && make demo
++ $(MAKE) -C fortran demo
+
+ demo: fortran-demo cpp-demo
+
+ toolkit:
+- cd toolkit && make toolkit
++ $(MAKE) -C toolkit toolkit
+
+ else
+
+@@ -31,7 +30,7 @@
+ endif
+
+ time:
+- cd tests && make time
++ $(MAKE) -C tests time
+
+ changelog:
+ git log >ChangeLog
+diff -Nur arprec-2.2.8.orig/src/Makefile.am arprec-2.2.8/src/Makefile.am
+--- arprec-2.2.8.orig/src/Makefile.am 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/src/Makefile.am 2012-01-12 19:20:48.000000000 +0000
+@@ -13,9 +13,9 @@
+ dble.cpp \
+ small_inline.h
+
+-lib_LIBRARIES = libarprec.a
++lib_LTLIBRARIES = libarprec.la
+
+-libarprec_a_SOURCES = $(SRC)
++libarprec_la_SOURCES = $(SRC)
+
+ AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include
+
+diff -Nur arprec-2.2.8.orig/tests/Makefile.am arprec-2.2.8/tests/Makefile.am
+--- arprec-2.2.8.orig/tests/Makefile.am 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/tests/Makefile.am 2012-01-12 19:20:19.000000000 +0000
+@@ -1,4 +1,4 @@
+-LDADD = $(top_builddir)/src/libarprec.a
++LDADD = $(top_builddir)/src/libarprec.la
+ AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include
+
+ TESTS = mp_test c_mp_test io
+diff -Nur arprec-2.2.8.orig/toolkit/Makefile.am arprec-2.2.8/toolkit/Makefile.am
+--- arprec-2.2.8.orig/toolkit/Makefile.am 2012-01-12 19:17:33.000000000 +0000
++++ arprec-2.2.8/toolkit/Makefile.am 2012-01-13 04:29:03.000000000 +0000
+@@ -1,9 +1,9 @@
+ if HAVE_FORTRAN
+ AM_CPPFLAGS=-I$(top_builddir)
+ AM_FFLAGS=@ax_f90_modflag@$(top_builddir)/fortran
+-LDADD = $(top_builddir)/fortran/libarprec_f_main.a \
+- $(top_builddir)/fortran/libarprecmod.a \
+- $(top_builddir)/src/libarprec.a $(FCLIBS)
++LDADD = $(top_builddir)/fortran/libarprec_f_main.la \
++ $(top_builddir)/fortran/libarprecmod.la \
++ $(top_builddir)/src/libarprec.la $(FCLIBS)
+
+ TOOLKIT = mathinit$(EXEEXT) mathtool$(EXEEXT)
+ EXTRA_PROGRAMS = $(TOOLKIT)
+@@ -19,6 +19,18 @@
+ nodist_mathtool_SOURCES = second.f
+ nodist_EXTRA_mathtool_SOURCES = dummy.cpp
+ mathtool_LINK = $(CXXLINK)
++if UPCASE_MODULE
++GLOBDATAMOD = GLOBDATA.$(module_ext)
++else
++GLOBDATAMOD = globdata.$(module_ext)
++endif
++$(GLOBDATAMOD): globdata.o
++mathinit.o: $(GLOBDATAMOD)
++mathtool.o: $(GLOBDATAMOD)
++pqlsub.o: $(GLOBDATAMOD)
++rootsub.o: $(GLOBDATAMOD)
++quadsub.o: $(GLOBDATAMOD)
++zetapz.o: $(GLOBDATAMOD)
+
+ toolkit: $(TOOLKIT)
+