[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libtool 1.9f: generation of libtool script
From: |
Sander Niemeijer |
Subject: |
Re: libtool 1.9f: generation of libtool script |
Date: |
Wed, 27 Oct 2004 16:28:47 +0200 |
On woensdag, okt 27, 2004, at 15:59 Europe/Amsterdam, Bob Friesenhahn
wrote:
On Wed, 27 Oct 2004, Sander Niemeijer wrote:
So my question is, is there still a way for me to perform my autoconf
test now that the libtool script creation step is moved? Is it maybe
possible to create the libtool script before AC_OUTPUT and still use
my current test? Or are there other ways for me to test linking
against a shared library, by e.g. using some combination of lt*
variables that are available in the configure script to perform a
compilation and link step?
Been there, done that. After the libtool configure stage has completed
in the configure.ac file, the variables $enabled_shared and
$enable_static are set to 'yes' so you can use these variables
directly rather than checking the output of libtool --config.
I am afraid this is not what I am looking for. Let me just give you the
macro(s) I made (see below). The main macro is LT_AC_CHECK_SHLIB that I
use from my configure.ac. This macro is similar to AC_CHECK_LIB (I
borrowed a lot of code from that macro) but it is intended to check
whether your system contains a _shared_ version of a library (whereas
AC_CHECK_LIB would accept both a static and a shared version, whichever
is available). The main difference between LT_AC_CHECK_SHLIB and
AC_CHECK_LIB is that the former is trying to build a testconf _shared
library_ with the system library whereas AC_CHECK_LIB tries to build a
testconf _application_ with the system library.
In order to build a shared testconf library I need libtool (building
shared libraries is what libtool was designed for). You can see its use
in the LT_AC_LINK_SHLIB_IFELSE macro. For the result of the
LT_AC_CHECK_SHLIB test I make use of the fact that libtool checks for
me whether the system library that is being linked against the testconf
library is a static library or not (and libtool gives an error if it is
a static version).
Now the problem is that LT_AC_LINK_SHLIB_IFELSE fails with libtool
1.9f, because the libtool script does not yet exist, whereas with
libtool 1.5.8 (and earlier) it did.
I hope this explains a bit better the problem I am having.
Best regards,
Sander Niemeijer
---
# LT_AC_CHECK_SHLIB(LIBRARY, FUNCTION,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
# [OTHER-LIBRARIES])
# -----------------------------------------------------------
#
# Use a cache variable name containing both the library and function
name,
# because the test really is for library $1 defining function $2, not
# just for library $1. Separate tests with the same $1 and different
$2s
# may have different results.
#
# Note that using directly AS_VAR_PUSHDEF([ac_Lib],
[lt_ac_cv_shlib_$1_$2])
# is asking for troubles, since LT_AC_CHECK_SHLIB($lib, fun) would give
# lt_ac_cv_shlib_$lib_fun, which is definitely not what was meant.
Hence
# the AS_LITERAL_IF indirection.
#
# FIXME: This macro is extremely suspicious. It DEFINEs
unconditionally,
# whatever the FUNCTION, in addition to not being a *S macro. Note
# that the cache does depend upon the function we are looking for.
#
AC_DEFUN([LT_AC_CHECK_SHLIB],
[m4_ifval([$3], , [LT_AH_CHECK_SHLIB([$1])])dnl
AS_LITERAL_IF([$1],
[AS_VAR_PUSHDEF([ac_Lib], [lt_ac_cv_shlib_$1_$2])],
[AS_VAR_PUSHDEF([ac_Lib], [lt_ac_cv_shlib_$1''_$2])])dnl
AC_CACHE_CHECK([for $2 in shared version of -l$1], ac_Lib,
[lt_ac_check_shlib_save_LIBS=$LIBS
LIBS="-l$1 $5 $LIBS"
LT_AC_LINK_SHLIB_IFELSE([AC_LANG_CALL([], [$2])],
[AS_VAR_SET(ac_Lib, yes)],
[AS_VAR_SET(ac_Lib, no)])
LIBS=$lt_ac_check_shlib_save_LIBS])
AS_IF([test AS_VAR_GET(ac_Lib) = yes],
[m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_SHLIB$1))])],
[$4])dnl
AS_VAR_POPDEF([ac_Lib])dnl
])# AC_CHECK_LIB
# LT_AH_CHECK_SHLIB(LIBNAME)
# ---------------------
m4_define([LT_AH_CHECK_SHLIB],
[AH_TEMPLATE(AS_TR_CPP(HAVE_SHLIB$1),
[Define to 1 if you have a shared version of the `]$1['
library (-l]$1[).])])
# LT_AC_LINK_SHLIB_IFELSE(LIBRARYCODE, [ACTION-IF-FOUND],
[ACTION-IF-NOT-FOUND])
# -----------------------------------------------------------------
# Try to link LIBRARYCODE into a libtool library.
AC_DEFUN([LT_AC_LINK_SHLIB_IFELSE],
[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
rm -rf $objdir
rm -f conftest.$ac_objext conftest.la
ac_ltcompile='./libtool --mode=compile $CC -c $CFLAGS $CPPFLAGS
conftest.$ac_ext -o conftest.lo >&AS_MESSAGE_LOG_FD'
ac_ltlink_la='./libtool --mode=link $CC -rpath `pwd` $CFLAGS $LDFLAGS
-o libconftest.la conftest.lo $LIBS >&AS_MESSAGE_LOG_FD'
AS_IF([AC_TRY_EVAL([ac_ltcompile]) &&
AC_TRY_EVAL([ac_ltlink_la]) &&
AC_TRY_COMMAND([test -s libconftest.la])],
[$2],
[_AC_MSG_LOG_CONFTEST
m4_ifvaln([$3], [$3])dnl])[]dnl
rm -rf $objdir
rm -f conftest* libconftest*[]dnl
])# _AC_LINK_IFELSE