Blame m4/lib-link.m4

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