2N/A# lib-link.m4 serial 25 (gettext-0.18.2)
2N/Adnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/A
2N/Adnl From Bruno Haible.
2N/A
2N/AAC_PREREQ([2.54])
2N/A
2N/Adnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
2N/Adnl the libraries corresponding to explicit and implicit dependencies.
2N/Adnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
2N/Adnl augments the CPPFLAGS variable.
2N/Adnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
2N/Adnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
2N/AAC_DEFUN([AC_LIB_LINKFLAGS],
2N/A[
2N/A AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2N/A AC_REQUIRE([AC_LIB_RPATH])
2N/A pushdef([Name],[m4_translit([$1],[./+-], [____])])
2N/A pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2N/A [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2N/A AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
2N/A AC_LIB_LINKFLAGS_BODY([$1], [$2])
2N/A ac_cv_lib[]Name[]_libs="$LIB[]NAME"
2N/A ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
2N/A ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
2N/A ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
2N/A ])
2N/A LIB[]NAME="$ac_cv_lib[]Name[]_libs"
2N/A LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
2N/A INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
2N/A LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
2N/A AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2N/A AC_SUBST([LIB]NAME)
2N/A AC_SUBST([LTLIB]NAME)
2N/A AC_SUBST([LIB]NAME[_PREFIX])
2N/A dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
2N/A dnl results of this search when this library appears as a dependency.
2N/A HAVE_LIB[]NAME=yes
2N/A popdef([NAME])
2N/A popdef([Name])
2N/A])
2N/A
2N/Adnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
2N/Adnl searches for libname and the libraries corresponding to explicit and
2N/Adnl implicit dependencies, together with the specified include files and
2N/Adnl the ability to compile and link the specified testcode. The missing-message
2N/Adnl defaults to 'no' and may contain additional hints for the user.
2N/Adnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
2N/Adnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
2N/Adnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
2N/Adnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
2N/Adnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
2N/Adnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
2N/AAC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
2N/A[
2N/A AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2N/A AC_REQUIRE([AC_LIB_RPATH])
2N/A pushdef([Name],[m4_translit([$1],[./+-], [____])])
2N/A pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2N/A [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2N/A
2N/A dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
2N/A dnl accordingly.
2N/A AC_LIB_LINKFLAGS_BODY([$1], [$2])
2N/A
2N/A dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
2N/A dnl because if the user has installed lib[]Name and not disabled its use
2N/A dnl via --without-lib[]Name-prefix, he wants to use it.
2N/A ac_save_CPPFLAGS="$CPPFLAGS"
2N/A AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2N/A
2N/A AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
2N/A ac_save_LIBS="$LIBS"
2N/A dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
2N/A dnl because these -l options might require -L options that are present in
2N/A dnl LIBS. -l options benefit only from the -L options listed before it.
2N/A dnl Otherwise, add it to the front of LIBS, because it may be a static
2N/A dnl library that depends on another static library that is present in LIBS.
2N/A dnl Static libraries benefit only from the static libraries listed after
2N/A dnl it.
2N/A case " $LIB[]NAME" in
2N/A *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
2N/A *) LIBS="$LIB[]NAME $LIBS" ;;
2N/A esac
2N/A AC_LINK_IFELSE(
2N/A [AC_LANG_PROGRAM([[$3]], [[$4]])],
2N/A [ac_cv_lib[]Name=yes],
2N/A [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
2N/A LIBS="$ac_save_LIBS"
2N/A ])
2N/A if test "$ac_cv_lib[]Name" = yes; then
2N/A HAVE_LIB[]NAME=yes
2N/A AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
2N/A AC_MSG_CHECKING([how to link with lib[]$1])
2N/A AC_MSG_RESULT([$LIB[]NAME])
2N/A else
2N/A HAVE_LIB[]NAME=no
2N/A dnl If $LIB[]NAME didn't lead to a usable library, we don't need
2N/A dnl $INC[]NAME either.
2N/A CPPFLAGS="$ac_save_CPPFLAGS"
2N/A LIB[]NAME=
2N/A LTLIB[]NAME=
2N/A LIB[]NAME[]_PREFIX=
2N/A fi
2N/A AC_SUBST([HAVE_LIB]NAME)
2N/A AC_SUBST([LIB]NAME)
2N/A AC_SUBST([LTLIB]NAME)
2N/A AC_SUBST([LIB]NAME[_PREFIX])
2N/A popdef([NAME])
2N/A popdef([Name])
2N/A])
2N/A
2N/Adnl Determine the platform dependent parameters needed to use rpath:
2N/Adnl acl_libext,
2N/Adnl acl_shlibext,
2N/Adnl acl_hardcode_libdir_flag_spec,
2N/Adnl acl_hardcode_libdir_separator,
2N/Adnl acl_hardcode_direct,
2N/Adnl acl_hardcode_minus_L.
2N/AAC_DEFUN([AC_LIB_RPATH],
2N/A[
2N/A dnl Tell automake >= 1.10 to complain if config.rpath is missing.
2N/A m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
2N/A AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
2N/A AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
2N/A AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
2N/A AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
2N/A AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
2N/A CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
2N/A ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
2N/A . ./conftest.sh
2N/A rm -f ./conftest.sh
2N/A acl_cv_rpath=done
2N/A ])
2N/A wl="$acl_cv_wl"
2N/A acl_libext="$acl_cv_libext"
2N/A acl_shlibext="$acl_cv_shlibext"
2N/A acl_libname_spec="$acl_cv_libname_spec"
2N/A acl_library_names_spec="$acl_cv_library_names_spec"
2N/A acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
2N/A acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
2N/A acl_hardcode_direct="$acl_cv_hardcode_direct"
2N/A acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
2N/A dnl Determine whether the user wants rpath handling at all.
2N/A AC_ARG_ENABLE([rpath],
2N/A [ --disable-rpath do not hardcode runtime library paths],
2N/A :, enable_rpath=yes)
2N/A])
2N/A
2N/Adnl AC_LIB_FROMPACKAGE(name, package)
2N/Adnl declares that libname comes from the given package. The configure file
2N/Adnl will then not have a --with-libname-prefix option but a
2N/Adnl --with-package-prefix option. Several libraries can come from the same
2N/Adnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
2N/Adnl macro call that searches for libname.
2N/AAC_DEFUN([AC_LIB_FROMPACKAGE],
2N/A[
2N/A pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2N/A [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2N/A define([acl_frompackage_]NAME, [$2])
2N/A popdef([NAME])
2N/A pushdef([PACK],[$2])
2N/A pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
2N/A [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2N/A define([acl_libsinpackage_]PACKUP,
2N/A m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
2N/A popdef([PACKUP])
2N/A popdef([PACK])
2N/A])
2N/A
2N/Adnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
2N/Adnl the libraries corresponding to explicit and implicit dependencies.
2N/Adnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
2N/Adnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
2N/Adnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
2N/AAC_DEFUN([AC_LIB_LINKFLAGS_BODY],
2N/A[
2N/A AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
2N/A pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2N/A [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2N/A pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
2N/A pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
2N/A [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2N/A pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
2N/A dnl Autoconf >= 2.61 supports dots in --with options.
2N/A pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
2N/A dnl By default, look in $includedir and $libdir.
2N/A use_additional=yes
2N/A AC_LIB_WITH_FINAL_PREFIX([
2N/A eval additional_includedir=\"$includedir\"
2N/A eval additional_libdir=\"$libdir\"
2N/A ])
2N/A AC_ARG_WITH(P_A_C_K[-prefix],
2N/A[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
2N/A --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
2N/A[
2N/A if test "X$withval" = "Xno"; then
2N/A use_additional=no
2N/A else
2N/A if test "X$withval" = "X"; then
2N/A AC_LIB_WITH_FINAL_PREFIX([
2N/A eval additional_includedir=\"$includedir\"
2N/A eval additional_libdir=\"$libdir\"
2N/A ])
2N/A else
2N/A additional_includedir="$withval/include"
2N/A additional_libdir="$withval/$acl_libdirstem"
2N/A if test "$acl_libdirstem2" != "$acl_libdirstem" \
2N/A && ! test -d "$withval/$acl_libdirstem"; then
2N/A additional_libdir="$withval/$acl_libdirstem2"
2N/A fi
2N/A fi
2N/A fi
2N/A])
2N/A dnl Search the library and its dependencies in $additional_libdir and
2N/A dnl $LDFLAGS. Using breadth-first-seach.
2N/A LIB[]NAME=
2N/A LTLIB[]NAME=
2N/A INC[]NAME=
2N/A LIB[]NAME[]_PREFIX=
2N/A dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
2N/A dnl computed. So it has to be reset here.
2N/A HAVE_LIB[]NAME=
2N/A rpathdirs=
2N/A ltrpathdirs=
2N/A names_already_handled=
2N/A names_next_round='$1 $2'
2N/A while test -n "$names_next_round"; do
2N/A names_this_round="$names_next_round"
2N/A names_next_round=
2N/A for name in $names_this_round; do
2N/A already_handled=
2N/A for n in $names_already_handled; do
2N/A if test "$n" = "$name"; then
2N/A already_handled=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$already_handled"; then
2N/A names_already_handled="$names_already_handled $name"
2N/A dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
2N/A dnl or AC_LIB_HAVE_LINKFLAGS call.
2N/A uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
2N/A eval value=\"\$HAVE_LIB$uppername\"
2N/A if test -n "$value"; then
2N/A if test "$value" = yes; then
2N/A eval value=\"\$LIB$uppername\"
2N/A test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
2N/A eval value=\"\$LTLIB$uppername\"
2N/A test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
2N/A else
2N/A dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
2N/A dnl that this library doesn't exist. So just drop it.
2N/A :
2N/A fi
2N/A else
2N/A dnl Search the library lib$name in $additional_libdir and $LDFLAGS
2N/A dnl and the already constructed $LIBNAME/$LTLIBNAME.
2N/A found_dir=
2N/A found_la=
2N/A found_so=
2N/A found_a=
2N/A eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
2N/A if test -n "$acl_shlibext"; then
2N/A shrext=".$acl_shlibext" # typically: shrext=.so
2N/A else
2N/A shrext=
2N/A fi
2N/A if test $use_additional = yes; then
2N/A dir="$additional_libdir"
2N/A dnl The same code as in the loop below:
2N/A dnl First look for a shared library.
2N/A if test -n "$acl_shlibext"; then
2N/A if test -f "$dir/$libname$shrext"; then
2N/A found_dir="$dir"
2N/A found_so="$dir/$libname$shrext"
2N/A else
2N/A if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
2N/A ver=`(cd "$dir" && \
2N/A for f in "$libname$shrext".*; do echo "$f"; done \
2N/A | sed -e "s,^$libname$shrext\\\\.,," \
2N/A | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
2N/A | sed 1q ) 2>/dev/null`
2N/A if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
2N/A found_dir="$dir"
2N/A found_so="$dir/$libname$shrext.$ver"
2N/A fi
2N/A else
2N/A eval library_names=\"$acl_library_names_spec\"
2N/A for f in $library_names; do
2N/A if test -f "$dir/$f"; then
2N/A found_dir="$dir"
2N/A found_so="$dir/$f"
2N/A break
2N/A fi
2N/A done
2N/A fi
2N/A fi
2N/A fi
2N/A dnl Then look for a static library.
2N/A if test "X$found_dir" = "X"; then
2N/A if test -f "$dir/$libname.$acl_libext"; then
2N/A found_dir="$dir"
2N/A found_a="$dir/$libname.$acl_libext"
2N/A fi
2N/A fi
2N/A if test "X$found_dir" != "X"; then
2N/A if test -f "$dir/$libname.la"; then
2N/A found_la="$dir/$libname.la"
2N/A fi
2N/A fi
2N/A fi
2N/A if test "X$found_dir" = "X"; then
2N/A for x in $LDFLAGS $LTLIB[]NAME; do
2N/A AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2N/A case "$x" in
2N/A -L*)
2N/A dir=`echo "X$x" | sed -e 's/^X-L//'`
2N/A dnl First look for a shared library.
2N/A if test -n "$acl_shlibext"; then
2N/A if test -f "$dir/$libname$shrext"; then
2N/A found_dir="$dir"
2N/A found_so="$dir/$libname$shrext"
2N/A else
2N/A if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
2N/A ver=`(cd "$dir" && \
2N/A for f in "$libname$shrext".*; do echo "$f"; done \
2N/A | sed -e "s,^$libname$shrext\\\\.,," \
2N/A | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
2N/A | sed 1q ) 2>/dev/null`
2N/A if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
2N/A found_dir="$dir"
2N/A found_so="$dir/$libname$shrext.$ver"
2N/A fi
2N/A else
2N/A eval library_names=\"$acl_library_names_spec\"
2N/A for f in $library_names; do
2N/A if test -f "$dir/$f"; then
2N/A found_dir="$dir"
2N/A found_so="$dir/$f"
2N/A break
2N/A fi
2N/A done
2N/A fi
2N/A fi
2N/A fi
2N/A dnl Then look for a static library.
2N/A if test "X$found_dir" = "X"; then
2N/A if test -f "$dir/$libname.$acl_libext"; then
2N/A found_dir="$dir"
2N/A found_a="$dir/$libname.$acl_libext"
2N/A fi
2N/A fi
2N/A if test "X$found_dir" != "X"; then
2N/A if test -f "$dir/$libname.la"; then
2N/A found_la="$dir/$libname.la"
2N/A fi
2N/A fi
2N/A ;;
2N/A esac
2N/A if test "X$found_dir" != "X"; then
2N/A break
2N/A fi
2N/A done
2N/A fi
2N/A if test "X$found_dir" != "X"; then
2N/A dnl Found the library.
2N/A LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
2N/A if test "X$found_so" != "X"; then
2N/A dnl Linking with a shared library. We attempt to hardcode its
2N/A dnl directory into the executable's runpath, unless it's the
2N/A dnl standard /usr/lib.
2N/A if test "$enable_rpath" = no \
2N/A || test "X$found_dir" = "X/usr/$acl_libdirstem" \
2N/A || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
2N/A dnl No hardcoding is needed.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2N/A else
2N/A dnl Use an explicit option to hardcode DIR into the resulting
2N/A dnl binary.
2N/A dnl Potentially add DIR to ltrpathdirs.
2N/A dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
2N/A haveit=
2N/A for x in $ltrpathdirs; do
2N/A if test "X$x" = "X$found_dir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A ltrpathdirs="$ltrpathdirs $found_dir"
2N/A fi
2N/A dnl The hardcoding into $LIBNAME is system dependent.
2N/A if test "$acl_hardcode_direct" = yes; then
2N/A dnl Using DIR/libNAME.so during linking hardcodes DIR into the
2N/A dnl resulting binary.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2N/A else
2N/A if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
2N/A dnl Use an explicit option to hardcode DIR into the resulting
2N/A dnl binary.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2N/A dnl Potentially add DIR to rpathdirs.
2N/A dnl The rpathdirs will be appended to $LIBNAME at the end.
2N/A haveit=
2N/A for x in $rpathdirs; do
2N/A if test "X$x" = "X$found_dir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A rpathdirs="$rpathdirs $found_dir"
2N/A fi
2N/A else
2N/A dnl Rely on "-L$found_dir".
2N/A dnl But don't add it if it's already contained in the LDFLAGS
2N/A dnl or the already constructed $LIBNAME
2N/A haveit=
2N/A for x in $LDFLAGS $LIB[]NAME; do
2N/A AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2N/A if test "X$x" = "X-L$found_dir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
2N/A fi
2N/A if test "$acl_hardcode_minus_L" != no; then
2N/A dnl FIXME: Not sure whether we should use
2N/A dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
2N/A dnl here.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2N/A else
2N/A dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
2N/A dnl here, because this doesn't fit in flags passed to the
2N/A dnl compiler. So give up. No hardcoding. This affects only
2N/A dnl very old systems.
2N/A dnl FIXME: Not sure whether we should use
2N/A dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
2N/A dnl here.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
2N/A fi
2N/A fi
2N/A fi
2N/A fi
2N/A else
2N/A if test "X$found_a" != "X"; then
2N/A dnl Linking with a static library.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
2N/A else
2N/A dnl We shouldn't come here, but anyway it's good to have a
2N/A dnl fallback.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
2N/A fi
2N/A fi
2N/A dnl Assume the include files are nearby.
2N/A additional_includedir=
2N/A case "$found_dir" in
2N/A */$acl_libdirstem | */$acl_libdirstem/)
2N/A basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
2N/A if test "$name" = '$1'; then
2N/A LIB[]NAME[]_PREFIX="$basedir"
2N/A fi
2N/A additional_includedir="$basedir/include"
2N/A ;;
2N/A */$acl_libdirstem2 | */$acl_libdirstem2/)
2N/A basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
2N/A if test "$name" = '$1'; then
2N/A LIB[]NAME[]_PREFIX="$basedir"
2N/A fi
2N/A additional_includedir="$basedir/include"
2N/A ;;
2N/A esac
2N/A if test "X$additional_includedir" != "X"; then
2N/A dnl Potentially add $additional_includedir to $INCNAME.
2N/A dnl But don't add it
2N/A dnl 1. if it's the standard /usr/include,
2N/A dnl 2. if it's /usr/local/include and we are using GCC on Linux,
2N/A dnl 3. if it's already present in $CPPFLAGS or the already
2N/A dnl constructed $INCNAME,
2N/A dnl 4. if it doesn't exist as a directory.
2N/A if test "X$additional_includedir" != "X/usr/include"; then
2N/A haveit=
2N/A if test "X$additional_includedir" = "X/usr/local/include"; then
2N/A if test -n "$GCC"; then
2N/A case $host_os in
2N/A linux* | gnu* | k*bsd*-gnu) haveit=yes;;
2N/A esac
2N/A fi
2N/A fi
2N/A if test -z "$haveit"; then
2N/A for x in $CPPFLAGS $INC[]NAME; do
2N/A AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2N/A if test "X$x" = "X-I$additional_includedir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A if test -d "$additional_includedir"; then
2N/A dnl Really add $additional_includedir to $INCNAME.
2N/A INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
2N/A fi
2N/A fi
2N/A fi
2N/A fi
2N/A fi
2N/A dnl Look for dependencies.
2N/A if test -n "$found_la"; then
2N/A dnl Read the .la file. It defines the variables
2N/A dnl dlname, library_names, old_library, dependency_libs, current,
2N/A dnl age, revision, installed, dlopen, dlpreopen, libdir.
2N/A save_libdir="$libdir"
2N/A case "$found_la" in
2N/A */* | *\\*) . "$found_la" ;;
2N/A *) . "./$found_la" ;;
2N/A esac
2N/A libdir="$save_libdir"
2N/A dnl We use only dependency_libs.
2N/A for dep in $dependency_libs; do
2N/A case "$dep" in
2N/A -L*)
2N/A additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
2N/A dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
2N/A dnl But don't add it
2N/A dnl 1. if it's the standard /usr/lib,
2N/A dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
2N/A dnl 3. if it's already present in $LDFLAGS or the already
2N/A dnl constructed $LIBNAME,
2N/A dnl 4. if it doesn't exist as a directory.
2N/A if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
2N/A && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
2N/A haveit=
2N/A if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
2N/A || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
2N/A if test -n "$GCC"; then
2N/A case $host_os in
2N/A linux* | gnu* | k*bsd*-gnu) haveit=yes;;
2N/A esac
2N/A fi
2N/A fi
2N/A if test -z "$haveit"; then
2N/A haveit=
2N/A for x in $LDFLAGS $LIB[]NAME; do
2N/A AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2N/A if test "X$x" = "X-L$additional_libdir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A if test -d "$additional_libdir"; then
2N/A dnl Really add $additional_libdir to $LIBNAME.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
2N/A fi
2N/A fi
2N/A haveit=
2N/A for x in $LDFLAGS $LTLIB[]NAME; do
2N/A AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2N/A if test "X$x" = "X-L$additional_libdir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A if test -d "$additional_libdir"; then
2N/A dnl Really add $additional_libdir to $LTLIBNAME.
2N/A LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
2N/A fi
2N/A fi
2N/A fi
2N/A fi
2N/A ;;
2N/A -R*)
2N/A dir=`echo "X$dep" | sed -e 's/^X-R//'`
2N/A if test "$enable_rpath" != no; then
2N/A dnl Potentially add DIR to rpathdirs.
2N/A dnl The rpathdirs will be appended to $LIBNAME at the end.
2N/A haveit=
2N/A for x in $rpathdirs; do
2N/A if test "X$x" = "X$dir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A rpathdirs="$rpathdirs $dir"
2N/A fi
2N/A dnl Potentially add DIR to ltrpathdirs.
2N/A dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
2N/A haveit=
2N/A for x in $ltrpathdirs; do
2N/A if test "X$x" = "X$dir"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A ltrpathdirs="$ltrpathdirs $dir"
2N/A fi
2N/A fi
2N/A ;;
2N/A -l*)
2N/A dnl Handle this in the next round.
2N/A names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
2N/A ;;
2N/A *.la)
2N/A dnl Handle this in the next round. Throw away the .la's
2N/A dnl directory; it is already contained in a preceding -L
2N/A dnl option.
2N/A names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
2N/A ;;
2N/A *)
2N/A dnl Most likely an immediate library name.
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
2N/A LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
2N/A ;;
2N/A esac
2N/A done
2N/A fi
2N/A else
2N/A dnl Didn't find the library; assume it is in the system directories
2N/A dnl known to the linker and runtime loader. (All the system
2N/A dnl directories known to the linker should also be known to the
2N/A dnl runtime loader, otherwise the system is severely misconfigured.)
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
2N/A LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
2N/A fi
2N/A fi
2N/A fi
2N/A done
2N/A done
2N/A if test "X$rpathdirs" != "X"; then
2N/A if test -n "$acl_hardcode_libdir_separator"; then
2N/A dnl Weird platform: only the last -rpath option counts, the user must
2N/A dnl pass all path elements in one option. We can arrange that for a
2N/A dnl single library, but not when more than one $LIBNAMEs are used.
2N/A alldirs=
2N/A for found_dir in $rpathdirs; do
2N/A alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
2N/A done
2N/A dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
2N/A acl_save_libdir="$libdir"
2N/A libdir="$alldirs"
2N/A eval flag=\"$acl_hardcode_libdir_flag_spec\"
2N/A libdir="$acl_save_libdir"
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
2N/A else
2N/A dnl The -rpath options are cumulative.
2N/A for found_dir in $rpathdirs; do
2N/A acl_save_libdir="$libdir"
2N/A libdir="$found_dir"
2N/A eval flag=\"$acl_hardcode_libdir_flag_spec\"
2N/A libdir="$acl_save_libdir"
2N/A LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
2N/A done
2N/A fi
2N/A fi
2N/A if test "X$ltrpathdirs" != "X"; then
2N/A dnl When using libtool, the option that works for both libraries and
2N/A dnl executables is -R. The -R options are cumulative.
2N/A for found_dir in $ltrpathdirs; do
2N/A LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
2N/A done
2N/A fi
2N/A popdef([P_A_C_K])
2N/A popdef([PACKLIBS])
2N/A popdef([PACKUP])
2N/A popdef([PACK])
2N/A popdef([NAME])
2N/A])
2N/A
2N/Adnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
2N/Adnl unless already present in VAR.
2N/Adnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
2N/Adnl contains two or three consecutive elements that belong together.
2N/AAC_DEFUN([AC_LIB_APPENDTOVAR],
2N/A[
2N/A for element in [$2]; do
2N/A haveit=
2N/A for x in $[$1]; do
2N/A AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2N/A if test "X$x" = "X$element"; then
2N/A haveit=yes
2N/A break
2N/A fi
2N/A done
2N/A if test -z "$haveit"; then
2N/A [$1]="${[$1]}${[$1]:+ }$element"
2N/A fi
2N/A done
2N/A])
2N/A
2N/Adnl For those cases where a variable contains several -L and -l options
2N/Adnl referring to unknown libraries and directories, this macro determines the
2N/Adnl necessary additional linker options for the runtime path.
2N/Adnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
2N/Adnl sets LDADDVAR to linker options needed together with LIBSVALUE.
2N/Adnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
2N/Adnl otherwise linking without libtool is assumed.
2N/AAC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
2N/A[
2N/A AC_REQUIRE([AC_LIB_RPATH])
2N/A AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
2N/A $1=
2N/A if test "$enable_rpath" != no; then
2N/A if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
2N/A dnl Use an explicit option to hardcode directories into the resulting
2N/A dnl binary.
2N/A rpathdirs=
2N/A next=
2N/A for opt in $2; do
2N/A if test -n "$next"; then
2N/A dir="$next"
2N/A dnl No need to hardcode the standard /usr/lib.
2N/A if test "X$dir" != "X/usr/$acl_libdirstem" \
2N/A && test "X$dir" != "X/usr/$acl_libdirstem2"; then
2N/A rpathdirs="$rpathdirs $dir"
2N/A fi
2N/A next=
2N/A else
2N/A case $opt in
2N/A -L) next=yes ;;
2N/A -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
2N/A dnl No need to hardcode the standard /usr/lib.
2N/A if test "X$dir" != "X/usr/$acl_libdirstem" \
2N/A && test "X$dir" != "X/usr/$acl_libdirstem2"; then
2N/A rpathdirs="$rpathdirs $dir"
2N/A fi
2N/A next= ;;
2N/A *) next= ;;
2N/A esac
2N/A fi
2N/A done
2N/A if test "X$rpathdirs" != "X"; then
2N/A if test -n ""$3""; then
2N/A dnl libtool is used for linking. Use -R options.
2N/A for dir in $rpathdirs; do
2N/A $1="${$1}${$1:+ }-R$dir"
2N/A done
2N/A else
2N/A dnl The linker is used for linking directly.
2N/A if test -n "$acl_hardcode_libdir_separator"; then
2N/A dnl Weird platform: only the last -rpath option counts, the user
2N/A dnl must pass all path elements in one option.
2N/A alldirs=
2N/A for dir in $rpathdirs; do
2N/A alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
2N/A done
2N/A acl_save_libdir="$libdir"
2N/A libdir="$alldirs"
2N/A eval flag=\"$acl_hardcode_libdir_flag_spec\"
2N/A libdir="$acl_save_libdir"
2N/A $1="$flag"
2N/A else
2N/A dnl The -rpath options are cumulative.
2N/A for dir in $rpathdirs; do
2N/A acl_save_libdir="$libdir"
2N/A libdir="$dir"
2N/A eval flag=\"$acl_hardcode_libdir_flag_spec\"
2N/A libdir="$acl_save_libdir"
2N/A $1="${$1}${$1:+ }$flag"
2N/A done
2N/A fi
2N/A fi
2N/A fi
2N/A fi
2N/A fi
2N/A AC_SUBST([$1])
2N/A])