Next: Emacs, Previous: Profiling, Up: MPIR Basics [Index]
Autoconf based applications can easily check whether MPIR is installed. The
only thing to be noted is that GMP/MPIR library symbols from version 3 of GMP
and version 1 of MPIR onwards have prefixes like __gmpz
. The following
therefore would be a simple test,
AC_CHECK_LIB(mpir, __gmpz_init)
This just uses the default AC_CHECK_LIB
actions for found or not found,
but an application that must have MPIR would want to generate an error if not
found. For example,
AC_CHECK_LIB(mpir, __gmpz_init, , [AC_MSG_ERROR([MPIR not found, see http://www.mpir.org/])])
If functions added in some particular version of GMP/MPIR are required, then one of
those can be used when checking. For example mpz_mul_si
was added in
GMP 3.1,
AC_CHECK_LIB(mpir, __gmpz_mul_si, , [AC_MSG_ERROR( [GMP/MPIR not found, or not GMP 3.1 or up or MPIR 1.0 or up, see http://www.mpir.org/])])
An alternative would be to test the version number in mpir.h using say
AC_EGREP_CPP
. That would make it possible to test the exact version,
if some particular sub-minor release is known to be necessary.
In general it’s recommended that applications should simply demand a new enough MPIR rather than trying to provide supplements for features not available in past versions.
Occasionally an application will need or want to know the size of a type at
configuration or preprocessing time, not just with sizeof
in the code.
This can be done in the normal way with mp_limb_t
etc, but GMP 4.0 or
up and MPIR 1.0 and up is best for this, since prior versions needed certain
‘-D’ defines on systems using a long long
limb. The following
would suit Autoconf 2.50 or up,
AC_CHECK_SIZEOF(mp_limb_t, , [#include <mpir.h>])
Next: Emacs, Previous: Profiling, Up: MPIR Basics [Index]