autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: Macros for libs


From: Gary V. Vaughan
Subject: Re: RFC: Macros for libs
Date: Fri, 21 Sep 2001 18:46:22 +0100
User-agent: Mutt/1.3.22.1i

On Fri, Sep 21, 2001 at 06:48:05PM +0200, Akim Demaille wrote:
> we use the
> following macro.  I think it is the right way to write things, but I
> would like to hear comments about it.

You asked for it! =)O|  You probably noticed that I had to commit some
changes to this macro in M4 for it to work on my machine.

> m4_define([_AC_LIB_GMP],
> [AC_ARG_WITH(gmp,
> [  --without-gmp           don't use GNU multiple precision arithmetic 
> library],
> [use_gmp=$withval], [use_gmp=yes])

Although I removed this in the specific case of M4, I think it is nice
in normal circumstances.

> case $use_gmp:$GMP_LIB:$ac_cv_header_gmp_h in
>   *::yes)
>     AC_MSG_WARN([gmp library not found or does not appear to work
>                  but `gmp.h' is present])

The problem with this is that you end up with (approximately):

checking for libgmp...
**WARNING** gmp library not found or does no appear to work
**WARNING** but `gmp.h' is present
no

Where we would rather have:

checking for libgmp... no
**WARNING** gmp library not found or does no appear to work
**WARNING** but `gmp.h' is present

>     ac_cv_using_lib_gmp=no
>     ;;
>   *:-lgmp:no)
>     AC_MSG_WARN([gmp works but `gmp.h' is missing])
>     ac_cv_using_lib_gmp=no
>     ;;
>   yes:*:yes)
>     ac_cv_using_lib_gmp=yes
>     ;;
>   no:*)
>     ac_cv_using_lib_gmp=no
>     ;;
> esac
> 
> if test "$ac_cv_using_lib_gmp" = yes; then
>   AC_DEFINE(WITH_GMP, 1,
>     [Define to 1 if the GNU multiple precision library should be used.])

Do we even need this at all?  I'm also not keen on polluting two
namespaces:

AC_DEFINE(WITH_GMP)/AM_CONDITIONAL(USE_GMP, $USE_GMP)

> fi
> ])# _AC_LIB_GMP
> 
> AC_DEFUN([AC_LIB_GMP],
> [AC_CHECK_HEADERS([gmp.h])
> AC_CHECK_LIB([gmp], [mpq_init], [GMP_LIB=-lgmp])

This always fails on my machine, because the test program must be
linked with gmp.h to resolve the mpq_init macro to _gmpq_init.

Hence, I changed it to:

gmp_save_LIBS="$LIBS"
LIBS="$LIBS -lgmp"
AC_TRY_LINK([#if HAVE_GMP_H
#  include <gmp.h>
#endif],
  [mpq_t n; mpq_init (n);],
  [LIBADD_GMP=-lgmp])
LIBS="$gmp_save_LIBS"


> AC_SUBST([GMP_LIB])dnl
>
> AC_CACHE_CHECK([if using GNU multiple precision arithmetic library],
>                 [ac_cv_using_lib_gmp],
>                 [_AC_LIB_GMP])
> AC_SUBST([USE_GMP], [$ac_cv_using_lib_gmp])dnl
> ])# AC_LIB_GMP

HTH,
        Gary.
-- 
  ())_. Gary V. Vaughan     gary@(oranda.demon.co.uk|gnu.org)
  ( '/  Research Scientist  http://www.oranda.demon.co.uk       ,_())____
  / )=  GNU Hacker          http://www.gnu.org/software/libtool  \'      `&
`(_~)_  Tech' Author        http://sources.redhat.com/autobook   =`---d__/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]