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