Blame m4/lib-link.m4

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