Blame m4/lib-link.m4

Packit Service 50ad14
# lib-link.m4 serial 4 (gettext-0.12)
Packit Service 50ad14
dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
Packit Service 50ad14
dnl This file is free software, distributed under the terms of the GNU
Packit Service 50ad14
dnl General Public License.  As a special exception to the GNU General
Packit Service 50ad14
dnl Public License, this file may be distributed as part of a program
Packit Service 50ad14
dnl that contains a configuration script generated by Autoconf, under
Packit Service 50ad14
dnl the same distribution terms as the rest of that program.
Packit Service 50ad14
Packit Service 50ad14
dnl From Bruno Haible.
Packit Service 50ad14
Packit Service 50ad14
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
Packit Service 50ad14
dnl the libraries corresponding to explicit and implicit dependencies.
Packit Service 50ad14
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
Packit Service 50ad14
dnl augments the CPPFLAGS variable.
Packit Service 50ad14
AC_DEFUN([AC_LIB_LINKFLAGS],
Packit Service 50ad14
[
Packit Service 50ad14
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
Packit Service 50ad14
  AC_REQUIRE([AC_LIB_RPATH])
Packit Service 50ad14
  define([Name],[translit([$1],[./-], [___])])
Packit Service 50ad14
  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
Packit Service 50ad14
                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
Packit Service 50ad14
  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
Packit Service 50ad14
    AC_LIB_LINKFLAGS_BODY([$1], [$2])
Packit Service 50ad14
    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
Packit Service 50ad14
    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
Packit Service 50ad14
    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
Packit Service 50ad14
  ])
Packit Service 50ad14
  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
Packit Service 50ad14
  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
Packit Service 50ad14
  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
Packit Service 50ad14
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
Packit Service 50ad14
  AC_SUBST([LIB]NAME)
Packit Service 50ad14
  AC_SUBST([LTLIB]NAME)
Packit Service 50ad14
  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
Packit Service 50ad14
  dnl results of this search when this library appears as a dependency.
Packit Service 50ad14
  HAVE_LIB[]NAME=yes
Packit Service 50ad14
  undefine([Name])
Packit Service 50ad14
  undefine([NAME])
Packit Service 50ad14
])
Packit Service 50ad14
Packit Service 50ad14
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
Packit Service 50ad14
dnl searches for libname and the libraries corresponding to explicit and
Packit Service 50ad14
dnl implicit dependencies, together with the specified include files and
Packit Service 50ad14
dnl the ability to compile and link the specified testcode. If found, it
Packit Service 50ad14
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
Packit Service 50ad14
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
Packit Service 50ad14
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
Packit Service 50ad14
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
Packit Service 50ad14
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
Packit Service 50ad14
[
Packit Service 50ad14
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
Packit Service 50ad14
  AC_REQUIRE([AC_LIB_RPATH])
Packit Service 50ad14
  define([Name],[translit([$1],[./-], [___])])
Packit Service 50ad14
  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
Packit Service 50ad14
                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
Packit Service 50ad14
Packit Service 50ad14
  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
Packit Service 50ad14
  dnl accordingly.
Packit Service 50ad14
  AC_LIB_LINKFLAGS_BODY([$1], [$2])
Packit Service 50ad14
Packit Service 50ad14
  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
Packit Service 50ad14
  dnl because if the user has installed lib[]Name and not disabled its use
Packit Service 50ad14
  dnl via --without-lib[]Name-prefix, he wants to use it.
Packit Service 50ad14
  ac_save_CPPFLAGS="$CPPFLAGS"
Packit Service 50ad14
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
Packit Service 50ad14
Packit Service 50ad14
  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
Packit Service 50ad14
    ac_save_LIBS="$LIBS"
Packit Service 50ad14
    LIBS="$LIBS $LIB[]NAME"
Packit Service 50ad14
    AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
Packit Service 50ad14
    LIBS="$ac_save_LIBS"
Packit Service 50ad14
  ])
Packit Service 50ad14
  if test "$ac_cv_lib[]Name" = yes; then
Packit Service 50ad14
    HAVE_LIB[]NAME=yes
Packit Service 50ad14
    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
Packit Service 50ad14
    AC_MSG_CHECKING([how to link with lib[]$1])
Packit Service 50ad14
    AC_MSG_RESULT([$LIB[]NAME])
Packit Service 50ad14
  else
Packit Service 50ad14
    HAVE_LIB[]NAME=no
Packit Service 50ad14
    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
Packit Service 50ad14
    dnl $INC[]NAME either.
Packit Service 50ad14
    CPPFLAGS="$ac_save_CPPFLAGS"
Packit Service 50ad14
    LIB[]NAME=
Packit Service 50ad14
    LTLIB[]NAME=
Packit Service 50ad14
  fi
Packit Service 50ad14
  AC_SUBST([HAVE_LIB]NAME)
Packit Service 50ad14
  AC_SUBST([LIB]NAME)
Packit Service 50ad14
  AC_SUBST([LTLIB]NAME)
Packit Service 50ad14
  undefine([Name])
Packit Service 50ad14
  undefine([NAME])
Packit Service 50ad14
])
Packit Service 50ad14
Packit Service 50ad14
dnl Determine the platform dependent parameters needed to use rpath:
Packit Service 50ad14
dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
Packit Service 50ad14
dnl hardcode_direct, hardcode_minus_L.
Packit Service 50ad14
AC_DEFUN([AC_LIB_RPATH],
Packit Service 50ad14
[
Packit Service 50ad14
  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
Packit Service 50ad14
  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
Packit Service 50ad14
  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
Packit Service 50ad14
  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
Packit Service 50ad14
  AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
Packit Service 50ad14
    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
Packit Service 50ad14
    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
Packit Service 50ad14
    . ./conftest.sh
Packit Service 50ad14
    rm -f ./conftest.sh
Packit Service 50ad14
    acl_cv_rpath=done
Packit Service 50ad14
  ])
Packit Service 50ad14
  wl="$acl_cv_wl"
Packit Service 50ad14
  libext="$acl_cv_libext"
Packit Service 50ad14
  shlibext="$acl_cv_shlibext"
Packit Service 50ad14
  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
Packit Service 50ad14
  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
Packit Service 50ad14
  hardcode_direct="$acl_cv_hardcode_direct"
Packit Service 50ad14
  hardcode_minus_L="$acl_cv_hardcode_minus_L"
Packit Service 50ad14
  dnl Determine whether the user wants rpath handling at all.
Packit Service 50ad14
  AC_ARG_ENABLE(rpath,
Packit Service 50ad14
    [  --disable-rpath         do not hardcode runtime library paths],
Packit Service 50ad14
    :, enable_rpath=yes)
Packit Service 50ad14
])
Packit Service 50ad14
Packit Service 50ad14
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
Packit Service 50ad14
dnl the libraries corresponding to explicit and implicit dependencies.
Packit Service 50ad14
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
Packit Service 50ad14
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
Packit Service 50ad14
[
Packit Service 50ad14
  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
Packit Service 50ad14
                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
Packit Service 50ad14
  dnl By default, look in $includedir and $libdir.
Packit Service 50ad14
  use_additional=yes
Packit Service 50ad14
  AC_LIB_WITH_FINAL_PREFIX([
Packit Service 50ad14
    eval additional_includedir=\"$includedir\"
Packit Service 50ad14
    eval additional_libdir=\"$libdir\"
Packit Service 50ad14
  ])
Packit Service 50ad14
  AC_LIB_ARG_WITH([lib$1-prefix],
Packit Service 50ad14
[  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
Packit Service 50ad14
  --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
Packit Service 50ad14
[
Packit Service 50ad14
    if test "X$withval" = "Xno"; then
Packit Service 50ad14
      use_additional=no
Packit Service 50ad14
    else
Packit Service 50ad14
      if test "X$withval" = "X"; then
Packit Service 50ad14
        AC_LIB_WITH_FINAL_PREFIX([
Packit Service 50ad14
          eval additional_includedir=\"$includedir\"
Packit Service 50ad14
          eval additional_libdir=\"$libdir\"
Packit Service 50ad14
        ])
Packit Service 50ad14
      else
Packit Service 50ad14
        additional_includedir="$withval/include"
Packit Service 50ad14
        additional_libdir="$withval/lib"
Packit Service 50ad14
      fi
Packit Service 50ad14
    fi
Packit Service 50ad14
])
Packit Service 50ad14
  dnl Search the library and its dependencies in $additional_libdir and
Packit Service 50ad14
  dnl $LDFLAGS. Using breadth-first-seach.
Packit Service 50ad14
  LIB[]NAME=
Packit Service 50ad14
  LTLIB[]NAME=
Packit Service 50ad14
  INC[]NAME=
Packit Service 50ad14
  rpathdirs=
Packit Service 50ad14
  ltrpathdirs=
Packit Service 50ad14
  names_already_handled=
Packit Service 50ad14
  names_next_round='$1 $2'
Packit Service 50ad14
  while test -n "$names_next_round"; do
Packit Service 50ad14
    names_this_round="$names_next_round"
Packit Service 50ad14
    names_next_round=
Packit Service 50ad14
    for name in $names_this_round; do
Packit Service 50ad14
      already_handled=
Packit Service 50ad14
      for n in $names_already_handled; do
Packit Service 50ad14
        if test "$n" = "$name"; then
Packit Service 50ad14
          already_handled=yes
Packit Service 50ad14
          break
Packit Service 50ad14
        fi
Packit Service 50ad14
      done
Packit Service 50ad14
      if test -z "$already_handled"; then
Packit Service 50ad14
        names_already_handled="$names_already_handled $name"
Packit Service 50ad14
        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
Packit Service 50ad14
        dnl or AC_LIB_HAVE_LINKFLAGS call.
Packit Service 50ad14
        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
Packit Service 50ad14
        eval value=\"\$HAVE_LIB$uppername\"
Packit Service 50ad14
        if test -n "$value"; then
Packit Service 50ad14
          if test "$value" = yes; then
Packit Service 50ad14
            eval value=\"\$LIB$uppername\"
Packit Service 50ad14
            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
Packit Service 50ad14
            eval value=\"\$LTLIB$uppername\"
Packit Service 50ad14
            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
Packit Service 50ad14
          else
Packit Service 50ad14
            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
Packit Service 50ad14
            dnl that this library doesn't exist. So just drop it.
Packit Service 50ad14
            :
Packit Service 50ad14
          fi
Packit Service 50ad14
        else
Packit Service 50ad14
          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
Packit Service 50ad14
          dnl and the already constructed $LIBNAME/$LTLIBNAME.
Packit Service 50ad14
          found_dir=
Packit Service 50ad14
          found_la=
Packit Service 50ad14
          found_so=
Packit Service 50ad14
          found_a=
Packit Service 50ad14
          if test $use_additional = yes; then
Packit Service 50ad14
            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
Packit Service 50ad14
              found_dir="$additional_libdir"
Packit Service 50ad14
              found_so="$additional_libdir/lib$name.$shlibext"
Packit Service 50ad14
              if test -f "$additional_libdir/lib$name.la"; then
Packit Service 50ad14
                found_la="$additional_libdir/lib$name.la"
Packit Service 50ad14
              fi
Packit Service 50ad14
            else
Packit Service 50ad14
              if test -f "$additional_libdir/lib$name.$libext"; then
Packit Service 50ad14
                found_dir="$additional_libdir"
Packit Service 50ad14
                found_a="$additional_libdir/lib$name.$libext"
Packit Service 50ad14
                if test -f "$additional_libdir/lib$name.la"; then
Packit Service 50ad14
                  found_la="$additional_libdir/lib$name.la"
Packit Service 50ad14
                fi
Packit Service 50ad14
              fi
Packit Service 50ad14
            fi
Packit Service 50ad14
          fi
Packit Service 50ad14
          if test "X$found_dir" = "X"; then
Packit Service 50ad14
            for x in $LDFLAGS $LTLIB[]NAME; do
Packit Service 50ad14
              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
Packit Service 50ad14
              case "$x" in
Packit Service 50ad14
                -L*)
Packit Service 50ad14
                  dir=`echo "X$x" | sed -e 's/^X-L//'`
Packit Service 50ad14
                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
Packit Service 50ad14
                    found_dir="$dir"
Packit Service 50ad14
                    found_so="$dir/lib$name.$shlibext"
Packit Service 50ad14
                    if test -f "$dir/lib$name.la"; then
Packit Service 50ad14
                      found_la="$dir/lib$name.la"
Packit Service 50ad14
                    fi
Packit Service 50ad14
                  else
Packit Service 50ad14
                    if test -f "$dir/lib$name.$libext"; then
Packit Service 50ad14
                      found_dir="$dir"
Packit Service 50ad14
                      found_a="$dir/lib$name.$libext"
Packit Service 50ad14
                      if test -f "$dir/lib$name.la"; then
Packit Service 50ad14
                        found_la="$dir/lib$name.la"
Packit Service 50ad14
                      fi
Packit Service 50ad14
                    fi
Packit Service 50ad14
                  fi
Packit Service 50ad14
                  ;;
Packit Service 50ad14
              esac
Packit Service 50ad14
              if test "X$found_dir" != "X"; then
Packit Service 50ad14
                break
Packit Service 50ad14
              fi
Packit Service 50ad14
            done
Packit Service 50ad14
          fi
Packit Service 50ad14
          if test "X$found_dir" != "X"; then
Packit Service 50ad14
            dnl Found the library.
Packit Service 50ad14
            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
Packit Service 50ad14
            if test "X$found_so" != "X"; then
Packit Service 50ad14
              dnl Linking with a shared library. We attempt to hardcode its
Packit Service 50ad14
              dnl directory into the executable's runpath, unless it's the
Packit Service 50ad14
              dnl standard /usr/lib.
Packit Service 50ad14
              if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
Packit Service 50ad14
                dnl No hardcoding is needed.
Packit Service 50ad14
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
Packit Service 50ad14
              else
Packit Service 50ad14
                dnl Use an explicit option to hardcode DIR into the resulting
Packit Service 50ad14
                dnl binary.
Packit Service 50ad14
                dnl Potentially add DIR to ltrpathdirs.
Packit Service 50ad14
                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
Packit Service 50ad14
                haveit=
Packit Service 50ad14
                for x in $ltrpathdirs; do
Packit Service 50ad14
                  if test "X$x" = "X$found_dir"; then
Packit Service 50ad14
                    haveit=yes
Packit Service 50ad14
                    break
Packit Service 50ad14
                  fi
Packit Service 50ad14
                done
Packit Service 50ad14
                if test -z "$haveit"; then
Packit Service 50ad14
                  ltrpathdirs="$ltrpathdirs $found_dir"
Packit Service 50ad14
                fi
Packit Service 50ad14
                dnl The hardcoding into $LIBNAME is system dependent.
Packit Service 50ad14
                if test "$hardcode_direct" = yes; then
Packit Service 50ad14
                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
Packit Service 50ad14
                  dnl resulting binary.
Packit Service 50ad14
                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
Packit Service 50ad14
                else
Packit Service 50ad14
                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
Packit Service 50ad14
                    dnl Use an explicit option to hardcode DIR into the resulting
Packit Service 50ad14
                    dnl binary.
Packit Service 50ad14
                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
Packit Service 50ad14
                    dnl Potentially add DIR to rpathdirs.
Packit Service 50ad14
                    dnl The rpathdirs will be appended to $LIBNAME at the end.
Packit Service 50ad14
                    haveit=
Packit Service 50ad14
                    for x in $rpathdirs; do
Packit Service 50ad14
                      if test "X$x" = "X$found_dir"; then
Packit Service 50ad14
                        haveit=yes
Packit Service 50ad14
                        break
Packit Service 50ad14
                      fi
Packit Service 50ad14
                    done
Packit Service 50ad14
                    if test -z "$haveit"; then
Packit Service 50ad14
                      rpathdirs="$rpathdirs $found_dir"
Packit Service 50ad14
                    fi
Packit Service 50ad14
                  else
Packit Service 50ad14
                    dnl Rely on "-L$found_dir".
Packit Service 50ad14
                    dnl But don't add it if it's already contained in the LDFLAGS
Packit Service 50ad14
                    dnl or the already constructed $LIBNAME
Packit Service 50ad14
                    haveit=
Packit Service 50ad14
                    for x in $LDFLAGS $LIB[]NAME; do
Packit Service 50ad14
                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
Packit Service 50ad14
                      if test "X$x" = "X-L$found_dir"; then
Packit Service 50ad14
                        haveit=yes
Packit Service 50ad14
                        break
Packit Service 50ad14
                      fi
Packit Service 50ad14
                    done
Packit Service 50ad14
                    if test -z "$haveit"; then
Packit Service 50ad14
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
Packit Service 50ad14
                    fi
Packit Service 50ad14
                    if test "$hardcode_minus_L" != no; then
Packit Service 50ad14
                      dnl FIXME: Not sure whether we should use
Packit Service 50ad14
                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
Packit Service 50ad14
                      dnl here.
Packit Service 50ad14
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
Packit Service 50ad14
                    else
Packit Service 50ad14
                      dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
Packit Service 50ad14
                      dnl here, because this doesn't fit in flags passed to the
Packit Service 50ad14
                      dnl compiler. So give up. No hardcoding. This affects only
Packit Service 50ad14
                      dnl very old systems.
Packit Service 50ad14
                      dnl FIXME: Not sure whether we should use
Packit Service 50ad14
                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
Packit Service 50ad14
                      dnl here.
Packit Service 50ad14
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
Packit Service 50ad14
                    fi
Packit Service 50ad14
                  fi
Packit Service 50ad14
                fi
Packit Service 50ad14
              fi
Packit Service 50ad14
            else
Packit Service 50ad14
              if test "X$found_a" != "X"; then
Packit Service 50ad14
                dnl Linking with a static library.
Packit Service 50ad14
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
Packit Service 50ad14
              else
Packit Service 50ad14
                dnl We shouldn't come here, but anyway it's good to have a
Packit Service 50ad14
                dnl fallback.
Packit Service 50ad14
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
Packit Service 50ad14
              fi
Packit Service 50ad14
            fi
Packit Service 50ad14
            dnl Assume the include files are nearby.
Packit Service 50ad14
            additional_includedir=
Packit Service 50ad14
            case "$found_dir" in
Packit Service 50ad14
              */lib | */lib/)
Packit Service 50ad14
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
Packit Service 50ad14
                additional_includedir="$basedir/include"
Packit Service 50ad14
                ;;
Packit Service 50ad14
            esac
Packit Service 50ad14
            if test "X$additional_includedir" != "X"; then
Packit Service 50ad14
              dnl Potentially add $additional_includedir to $INCNAME.
Packit Service 50ad14
              dnl But don't add it
Packit Service 50ad14
              dnl   1. if it's the standard /usr/include,
Packit Service 50ad14
              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
Packit Service 50ad14
              dnl   3. if it's already present in $CPPFLAGS or the already
Packit Service 50ad14
              dnl      constructed $INCNAME,
Packit Service 50ad14
              dnl   4. if it doesn't exist as a directory.
Packit Service 50ad14
              if test "X$additional_includedir" != "X/usr/include"; then
Packit Service 50ad14
                haveit=
Packit Service 50ad14
                if test "X$additional_includedir" = "X/usr/local/include"; then
Packit Service 50ad14
                  if test -n "$GCC"; then
Packit Service 50ad14
                    case $host_os in
Packit Service 50ad14
                      linux*) haveit=yes;;
Packit Service 50ad14
                    esac
Packit Service 50ad14
                  fi
Packit Service 50ad14
                fi
Packit Service 50ad14
                if test -z "$haveit"; then
Packit Service 50ad14
                  for x in $CPPFLAGS $INC[]NAME; do
Packit Service 50ad14
                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
Packit Service 50ad14
                    if test "X$x" = "X-I$additional_includedir"; then
Packit Service 50ad14
                      haveit=yes
Packit Service 50ad14
                      break
Packit Service 50ad14
                    fi
Packit Service 50ad14
                  done
Packit Service 50ad14
                  if test -z "$haveit"; then
Packit Service 50ad14
                    if test -d "$additional_includedir"; then
Packit Service 50ad14
                      dnl Really add $additional_includedir to $INCNAME.
Packit Service 50ad14
                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
Packit Service 50ad14
                    fi
Packit Service 50ad14
                  fi
Packit Service 50ad14
                fi
Packit Service 50ad14
              fi
Packit Service 50ad14
            fi
Packit Service 50ad14
            dnl Look for dependencies.
Packit Service 50ad14
            if test -n "$found_la"; then
Packit Service 50ad14
              dnl Read the .la file. It defines the variables
Packit Service 50ad14
              dnl dlname, library_names, old_library, dependency_libs, current,
Packit Service 50ad14
              dnl age, revision, installed, dlopen, dlpreopen, libdir.
Packit Service 50ad14
              save_libdir="$libdir"
Packit Service 50ad14
              case "$found_la" in
Packit Service 50ad14
                */* | *\\*) . "$found_la" ;;
Packit Service 50ad14
                *) . "./$found_la" ;;
Packit Service 50ad14
              esac
Packit Service 50ad14
              libdir="$save_libdir"
Packit Service 50ad14
              dnl We use only dependency_libs.
Packit Service 50ad14
              for dep in $dependency_libs; do
Packit Service 50ad14
                case "$dep" in
Packit Service 50ad14
                  -L*)
Packit Service 50ad14
                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
Packit Service 50ad14
                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
Packit Service 50ad14
                    dnl But don't add it
Packit Service 50ad14
                    dnl   1. if it's the standard /usr/lib,
Packit Service 50ad14
                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
Packit Service 50ad14
                    dnl   3. if it's already present in $LDFLAGS or the already
Packit Service 50ad14
                    dnl      constructed $LIBNAME,
Packit Service 50ad14
                    dnl   4. if it doesn't exist as a directory.
Packit Service 50ad14
                    if test "X$additional_libdir" != "X/usr/lib"; then
Packit Service 50ad14
                      haveit=
Packit Service 50ad14
                      if test "X$additional_libdir" = "X/usr/local/lib"; then
Packit Service 50ad14
                        if test -n "$GCC"; then
Packit Service 50ad14
                          case $host_os in
Packit Service 50ad14
                            linux*) haveit=yes;;
Packit Service 50ad14
                          esac
Packit Service 50ad14
                        fi
Packit Service 50ad14
                      fi
Packit Service 50ad14
                      if test -z "$haveit"; then
Packit Service 50ad14
                        haveit=
Packit Service 50ad14
                        for x in $LDFLAGS $LIB[]NAME; do
Packit Service 50ad14
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
Packit Service 50ad14
                          if test "X$x" = "X-L$additional_libdir"; then
Packit Service 50ad14
                            haveit=yes
Packit Service 50ad14
                            break
Packit Service 50ad14
                          fi
Packit Service 50ad14
                        done
Packit Service 50ad14
                        if test -z "$haveit"; then
Packit Service 50ad14
                          if test -d "$additional_libdir"; then
Packit Service 50ad14
                            dnl Really add $additional_libdir to $LIBNAME.
Packit Service 50ad14
                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
Packit Service 50ad14
                          fi
Packit Service 50ad14
                        fi
Packit Service 50ad14
                        haveit=
Packit Service 50ad14
                        for x in $LDFLAGS $LTLIB[]NAME; do
Packit Service 50ad14
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
Packit Service 50ad14
                          if test "X$x" = "X-L$additional_libdir"; then
Packit Service 50ad14
                            haveit=yes
Packit Service 50ad14
                            break
Packit Service 50ad14
                          fi
Packit Service 50ad14
                        done
Packit Service 50ad14
                        if test -z "$haveit"; then
Packit Service 50ad14
                          if test -d "$additional_libdir"; then
Packit Service 50ad14
                            dnl Really add $additional_libdir to $LTLIBNAME.
Packit Service 50ad14
                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
Packit Service 50ad14
                          fi
Packit Service 50ad14
                        fi
Packit Service 50ad14
                      fi
Packit Service 50ad14
                    fi
Packit Service 50ad14
                    ;;
Packit Service 50ad14
                  -R*)
Packit Service 50ad14
                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
Packit Service 50ad14
                    if test "$enable_rpath" != no; then
Packit Service 50ad14
                      dnl Potentially add DIR to rpathdirs.
Packit Service 50ad14
                      dnl The rpathdirs will be appended to $LIBNAME at the end.
Packit Service 50ad14
                      haveit=
Packit Service 50ad14
                      for x in $rpathdirs; do
Packit Service 50ad14
                        if test "X$x" = "X$dir"; then
Packit Service 50ad14
                          haveit=yes
Packit Service 50ad14
                          break
Packit Service 50ad14
                        fi
Packit Service 50ad14
                      done
Packit Service 50ad14
                      if test -z "$haveit"; then
Packit Service 50ad14
                        rpathdirs="$rpathdirs $dir"
Packit Service 50ad14
                      fi
Packit Service 50ad14
                      dnl Potentially add DIR to ltrpathdirs.
Packit Service 50ad14
                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
Packit Service 50ad14
                      haveit=
Packit Service 50ad14
                      for x in $ltrpathdirs; do
Packit Service 50ad14
                        if test "X$x" = "X$dir"; then
Packit Service 50ad14
                          haveit=yes
Packit Service 50ad14
                          break
Packit Service 50ad14
                        fi
Packit Service 50ad14
                      done
Packit Service 50ad14
                      if test -z "$haveit"; then
Packit Service 50ad14
                        ltrpathdirs="$ltrpathdirs $dir"
Packit Service 50ad14
                      fi
Packit Service 50ad14
                    fi
Packit Service 50ad14
                    ;;
Packit Service 50ad14
                  -l*)
Packit Service 50ad14
                    dnl Handle this in the next round.
Packit Service 50ad14
                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
Packit Service 50ad14
                    ;;
Packit Service 50ad14
                  *.la)
Packit Service 50ad14
                    dnl Handle this in the next round. Throw away the .la's
Packit Service 50ad14
                    dnl directory; it is already contained in a preceding -L
Packit Service 50ad14
                    dnl option.
Packit Service 50ad14
                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
Packit Service 50ad14
                    ;;
Packit Service 50ad14
                  *)
Packit Service 50ad14
                    dnl Most likely an immediate library name.
Packit Service 50ad14
                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
Packit Service 50ad14
                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
Packit Service 50ad14
                    ;;
Packit Service 50ad14
                esac
Packit Service 50ad14
              done
Packit Service 50ad14
            fi
Packit Service 50ad14
          else
Packit Service 50ad14
            dnl Didn't find the library; assume it is in the system directories
Packit Service 50ad14
            dnl known to the linker and runtime loader. (All the system
Packit Service 50ad14
            dnl directories known to the linker should also be known to the
Packit Service 50ad14
            dnl runtime loader, otherwise the system is severely misconfigured.)
Packit Service 50ad14
            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
Packit Service 50ad14
            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
Packit Service 50ad14
          fi
Packit Service 50ad14
        fi
Packit Service 50ad14
      fi
Packit Service 50ad14
    done
Packit Service 50ad14
  done
Packit Service 50ad14
  if test "X$rpathdirs" != "X"; then
Packit Service 50ad14
    if test -n "$hardcode_libdir_separator"; then
Packit Service 50ad14
      dnl Weird platform: only the last -rpath option counts, the user must
Packit Service 50ad14
      dnl pass all path elements in one option. We can arrange that for a
Packit Service 50ad14
      dnl single library, but not when more than one $LIBNAMEs are used.
Packit Service 50ad14
      alldirs=
Packit Service 50ad14
      for found_dir in $rpathdirs; do
Packit Service 50ad14
        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
Packit Service 50ad14
      done
Packit Service 50ad14
      dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
Packit Service 50ad14
      acl_save_libdir="$libdir"
Packit Service 50ad14
      libdir="$alldirs"
Packit Service 50ad14
      eval flag=\"$hardcode_libdir_flag_spec\"
Packit Service 50ad14
      libdir="$acl_save_libdir"
Packit Service 50ad14
      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
Packit Service 50ad14
    else
Packit Service 50ad14
      dnl The -rpath options are cumulative.
Packit Service 50ad14
      for found_dir in $rpathdirs; do
Packit Service 50ad14
        acl_save_libdir="$libdir"
Packit Service 50ad14
        libdir="$found_dir"
Packit Service 50ad14
        eval flag=\"$hardcode_libdir_flag_spec\"
Packit Service 50ad14
        libdir="$acl_save_libdir"
Packit Service 50ad14
        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
Packit Service 50ad14
      done
Packit Service 50ad14
    fi
Packit Service 50ad14
  fi
Packit Service 50ad14
  if test "X$ltrpathdirs" != "X"; then
Packit Service 50ad14
    dnl When using libtool, the option that works for both libraries and
Packit Service 50ad14
    dnl executables is -R. The -R options are cumulative.
Packit Service 50ad14
    for found_dir in $ltrpathdirs; do
Packit Service 50ad14
      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
Packit Service 50ad14
    done
Packit Service 50ad14
  fi
Packit Service 50ad14
])
Packit Service 50ad14
Packit Service 50ad14
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
Packit Service 50ad14
dnl unless already present in VAR.
Packit Service 50ad14
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
Packit Service 50ad14
dnl contains two or three consecutive elements that belong together.
Packit Service 50ad14
AC_DEFUN([AC_LIB_APPENDTOVAR],
Packit Service 50ad14
[
Packit Service 50ad14
  for element in [$2]; do
Packit Service 50ad14
    haveit=
Packit Service 50ad14
    for x in $[$1]; do
Packit Service 50ad14
      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
Packit Service 50ad14
      if test "X$x" = "X$element"; then
Packit Service 50ad14
        haveit=yes
Packit Service 50ad14
        break
Packit Service 50ad14
      fi
Packit Service 50ad14
    done
Packit Service 50ad14
    if test -z "$haveit"; then
Packit Service 50ad14
      [$1]="${[$1]}${[$1]:+ }$element"
Packit Service 50ad14
    fi
Packit Service 50ad14
  done
Packit Service 50ad14
])