bug-autoconf
[Top][All Lists]
Advanced

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

AC_CHECK_LIB inside condition


From: Boye Annfelt Høverstad
Subject: AC_CHECK_LIB inside condition
Date: Fri, 12 May 2006 09:57:10 +0200 (MEST)

Hi,

The macro AC_CHECK_LIB seems to malfunction if it is first used inside a conditionally executed block.

My relatively uninformed guess is that the first occurrence of AC_CHECK_LIB is translated in the configure script to something that defines certain variables. If the condition guarding the first call to AC_CHECK_LIB is false, the variables are never initialized correctly and the subsequent call to AC_CHECK_LIB will fail.

I am relatively new to autoconf, so please bear with me if this problem in fact stems from my misuse of the program rather than a bug. I have searched the bug mail archive without finding a description of this problem.

Here is an example script:

AC_PREREQ(2.50)
AC_INIT([testprogram], [1], [name])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([1.9 foreign])
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_HEADER([config.h])

dnl AC_CHECK_LIB([BOGUS], [dummy])

if test "x$TEST" = "xtrue"; then
  AC_MSG_RESULT([The test is true])
  AC_CHECK_LIB([BOGUS], [dummy])
else
  AC_MSG_RESULT([The test is false])
  AC_CHECK_LIB([BOGUS], [dummy])
fi

AC_CHECK_LIB([pthread], [pthread_create])
if test "x$ac_cv_lib_pthread_pthread_create" = "xyes" ; then
  AC_MSG_NOTICE([Found the pthread library.])
else
  AC_MSG_ERROR([Failed to detect pthread library!])
fi

AC_CONFIG_FILES([Makefile])
AC_PROG_CXX
AC_OUTPUT


After compiling, when run as "configure TEST=true", the pthread library will be found. If run as "configure", the test will be false, the first conditional block is never executed, and the pthread library is not
found.

When the script fails, a look at config.log reveals that the compiler name has not been set correctly (line three below, the other two included for context):

configure:2906: result: The test is false
configure:2909: checking for dummy in -lBOGUS
configure:2939:  -o conftest    conftest.c -lBOGUS   >&5

A workaround is to put an AC_CHECK_LIB before the conditional block, for instance by uncommenting the dnl-line in the script above.

A note about this in the manual could perhaps be an easy fix to the problem.

Versions used:

aclocal (GNU automake) 1.9.6
libtoolize (GNU libtool) 1.5.22
automake (GNU automake) 1.9.6
autoconf (GNU Autoconf) 2.59


Best regards,

Boye




reply via email to

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