libtool
[Top][All Lists]
Advanced

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

Trying to link a program using libtool in configure script


From: Christopher Hulbert
Subject: Trying to link a program using libtool in configure script
Date: Mon, 18 May 2009 14:36:19 -0400

I would like to perform configure tests trying to link a program (in
order to test for libraries) using libtool since that is what my
libraries and programs use anyways. So, based on AC_TRY_LINK and
AC_LINK_IFELSE, I've come up with the macro below which works for C. I
would like to extend it for the other languages (hence the use of
AC_LANG_CASE). Before I do that, I was hoping to get comments/feedback
on the current implementation. Specifically any issues I might have.
One concern I have is that AC_LANG_CASE is undocumented as far as I
can tell, and _AC_DO_STDERR seems to be (from the naming) meant for
autoconf use only. The current version seems to do what I want as far
as my limited testing has shown.

Chris

# VSIPL_LTLINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# ------------------------------------------------
# Tries to link a program using a libtool script. Requires that the libtool
# script be generated (e.g. LT_OUTPUT)
AC_DEFUN([VSIPL_LTLINK_IFELSE],
[
  AC_REQUIRE([LT_OUTPUT])
  AC_LANG_COMPILER_REQUIRE()
  AC_LANG_CASE(
  [C],
  [vsipl_ltcompile='./libtool --tag=CC --mode=compile $CC $CFLAGS
$CPPFLAGS $LT_CFLAGS -c -o conftest.lo conftest.$ac_ext
>&AS_MESSAGE_LOG_FD'
  vsipl_ltlink='./libtool --tag=CC --mode=link $CC $CFLAGS $CPPFLAGS
$LT_CFLAGS $LDFLAGS $LT_LDFLAGS -o conftest$ac_exeext conftest.lo
$LIBS >&AS_MESSAGE_LOG_FD'],
  [vsipl_ltcompile='exit 1'
  vsipl_ltlink='exit 1'])
  #
  # Generate the program
  #
  AC_LANG_CONFTEST([$1])


  rm -f conftest.lo conftest.$ac_objext conftest$ac_exeext
  AS_IF([_AC_DO_STDERR($vsipl_ltcompile) && _AC_DO_STDERR($vsipl_ltlink) && {
     test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
     test ! -s conftest.err
       } && test -s conftest$ac_exeext && {
     test "$cross_compiling" = yes ||
     AS_TEST_X([conftest$ac_exeext])
       }],
      [$2],
      [_AC_MSG_LOG_CONFTEST
    $3])
  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
  # interfere with the next link command; also delete a directory that is
  # left behind by Apple's compiler.  We do this before executing the actions.
  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
])

# VSIPL_TRY_LTLINK(INCLUDES, FUNCTION-BODY,
#                  [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# ------------------------------------------------
# Tries to link a program using a libtool script. Requires that the libtool
# script be generated (e.g. LT_OUTPUT)
AC_DEFUN([VSIPL_TRY_LTLINK],
[VSIPL_LTLINK_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4])])




reply via email to

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