lib-link.m4
上传用户:riyaled888
上传日期:2009-03-27
资源大小:7338k
文件大小:23k
源码类别:

多媒体

开发平台:

MultiPlatform

  1. # lib-link.m4 serial 3 (gettext-0.11.3)
  2. dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
  3. dnl This file is free software, distributed under the terms of the GNU
  4. dnl General Public License.  As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8. dnl From Bruno Haible.
  9. dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
  10. dnl the libraries corresponding to explicit and implicit dependencies.
  11. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
  12. dnl augments the CPPFLAGS variable.
  13. AC_DEFUN([AC_LIB_LINKFLAGS],
  14. [
  15.   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  16.   AC_REQUIRE([AC_LIB_RPATH])
  17.   define([Name],[translit([$1],[./-], [___])])
  18.   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  19.                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  20.   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
  21.     AC_LIB_LINKFLAGS_BODY([$1], [$2])
  22.     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
  23.     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
  24.     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
  25.   ])
  26.   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
  27.   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
  28.   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
  29.   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
  30.   AC_SUBST([LIB]NAME)
  31.   AC_SUBST([LTLIB]NAME)
  32.   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
  33.   dnl results of this search when this library appears as a dependency.
  34.   HAVE_LIB[]NAME=yes
  35.   undefine([Name])
  36.   undefine([NAME])
  37. ])
  38. dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
  39. dnl searches for libname and the libraries corresponding to explicit and
  40. dnl implicit dependencies, together with the specified include files and
  41. dnl the ability to compile and link the specified testcode. If found, it
  42. dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
  43. dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
  44. dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
  45. dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
  46. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
  47. [
  48.   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  49.   AC_REQUIRE([AC_LIB_RPATH])
  50.   define([Name],[translit([$1],[./-], [___])])
  51.   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  52.                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  53.   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
  54.   dnl accordingly.
  55.   AC_LIB_LINKFLAGS_BODY([$1], [$2])
  56.   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
  57.   dnl because if the user has installed lib[]Name and not disabled its use
  58.   dnl via --without-lib[]Name-prefix, he wants to use it.
  59.   ac_save_CPPFLAGS="$CPPFLAGS"
  60.   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
  61.   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
  62.     ac_save_LIBS="$LIBS"
  63.     LIBS="$LIBS $LIB[]NAME"
  64.     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
  65.     LIBS="$ac_save_LIBS"
  66.   ])
  67.   if test "$ac_cv_lib[]Name" = yes; then
  68.     HAVE_LIB[]NAME=yes
  69.     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
  70.     AC_MSG_CHECKING([how to link with lib[]$1])
  71.     AC_MSG_RESULT([$LIB[]NAME])
  72.   else
  73.     HAVE_LIB[]NAME=no
  74.     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
  75.     dnl $INC[]NAME either.
  76.     CPPFLAGS="$ac_save_CPPFLAGS"
  77.     LIB[]NAME=
  78.     LTLIB[]NAME=
  79.   fi
  80.   AC_SUBST([HAVE_LIB]NAME)
  81.   AC_SUBST([LIB]NAME)
  82.   AC_SUBST([LTLIB]NAME)
  83.   undefine([Name])
  84.   undefine([NAME])
  85. ])
  86. dnl Determine the platform dependent parameters needed to use rpath:
  87. dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
  88. dnl hardcode_direct, hardcode_minus_L,
  89. dnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec.
  90. AC_DEFUN([AC_LIB_RPATH],
  91. [
  92.   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
  93.   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
  94.   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
  95.   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
  96.   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
  97.     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" 
  98.     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
  99.     . ./conftest.sh
  100.     rm -f ./conftest.sh
  101.     acl_cv_rpath=done
  102.   ])
  103.   wl="$acl_cv_wl"
  104.   libext="$acl_cv_libext"
  105.   shlibext="$acl_cv_shlibext"
  106.   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
  107.   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
  108.   hardcode_direct="$acl_cv_hardcode_direct"
  109.   hardcode_minus_L="$acl_cv_hardcode_minus_L"
  110.   sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec"
  111.   sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec"
  112.   dnl Determine whether the user wants rpath handling at all.
  113.   AC_ARG_ENABLE(rpath,
  114.     [  --disable-rpath         do not hardcode runtime library paths],
  115.     :, enable_rpath=yes)
  116. ])
  117. dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
  118. dnl the libraries corresponding to explicit and implicit dependencies.
  119. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
  120. AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
  121. [
  122.   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  123.                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  124.   dnl By default, look in $includedir and $libdir.
  125.   use_additional=yes
  126.   AC_LIB_WITH_FINAL_PREFIX([
  127.     eval additional_includedir="$includedir"
  128.     eval additional_libdir="$libdir"
  129.   ])
  130.   AC_ARG_WITH([lib$1-prefix],
  131. [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
  132.   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
  133. [
  134.     if test "X$withval" = "Xno"; then
  135.       use_additional=no
  136.     else
  137.       if test "X$withval" = "X"; then
  138.         AC_LIB_WITH_FINAL_PREFIX([
  139.           eval additional_includedir="$includedir"
  140.           eval additional_libdir="$libdir"
  141.         ])
  142.       else
  143.         additional_includedir="$withval/include"
  144.         additional_libdir="$withval/lib"
  145.       fi
  146.     fi
  147. ])
  148.   dnl Search the library and its dependencies in $additional_libdir and
  149.   dnl $LDFLAGS. Using breadth-first-seach.
  150.   LIB[]NAME=
  151.   LTLIB[]NAME=
  152.   INC[]NAME=
  153.   rpathdirs=
  154.   ltrpathdirs=
  155.   names_already_handled=
  156.   names_next_round='$1 $2'
  157.   while test -n "$names_next_round"; do
  158.     names_this_round="$names_next_round"
  159.     names_next_round=
  160.     for name in $names_this_round; do
  161.       already_handled=
  162.       for n in $names_already_handled; do
  163.         if test "$n" = "$name"; then
  164.           already_handled=yes
  165.           break
  166.         fi
  167.       done
  168.       if test -z "$already_handled"; then
  169.         names_already_handled="$names_already_handled $name"
  170.         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
  171.         dnl or AC_LIB_HAVE_LINKFLAGS call.
  172.         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
  173.         eval value="$HAVE_LIB$uppername"
  174.         if test -n "$value"; then
  175.           if test "$value" = yes; then
  176.             eval value="$LIB$uppername"
  177.             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
  178.             eval value="$LTLIB$uppername"
  179.             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
  180.           else
  181.             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
  182.             dnl that this library doesn't exist. So just drop it.
  183.             :
  184.           fi
  185.         else
  186.           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
  187.           dnl and the already constructed $LIBNAME/$LTLIBNAME.
  188.           found_dir=
  189.           found_la=
  190.           found_so=
  191.           found_a=
  192.           if test $use_additional = yes; then
  193.             if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
  194.               found_dir="$additional_libdir"
  195.               found_so="$additional_libdir/lib$name.$shlibext"
  196.               if test -f "$additional_libdir/lib$name.la"; then
  197.                 found_la="$additional_libdir/lib$name.la"
  198.               fi
  199.             else
  200.               if test -f "$additional_libdir/lib$name.$libext"; then
  201.                 found_dir="$additional_libdir"
  202.                 found_a="$additional_libdir/lib$name.$libext"
  203.                 if test -f "$additional_libdir/lib$name.la"; then
  204.                   found_la="$additional_libdir/lib$name.la"
  205.                 fi
  206.               fi
  207.             fi
  208.           fi
  209.           if test "X$found_dir" = "X"; then
  210.             for x in $LDFLAGS $LTLIB[]NAME; do
  211.               AC_LIB_WITH_FINAL_PREFIX([eval x="$x"])
  212.               case "$x" in
  213.                 -L*)
  214.                   dir=`echo "X$x" | sed -e 's/^X-L//'`
  215.                   if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
  216.                     found_dir="$dir"
  217.                     found_so="$dir/lib$name.$shlibext"
  218.                     if test -f "$dir/lib$name.la"; then
  219.                       found_la="$dir/lib$name.la"
  220.                     fi
  221.                   else
  222.                     if test -f "$dir/lib$name.$libext"; then
  223.                       found_dir="$dir"
  224.                       found_a="$dir/lib$name.$libext"
  225.                       if test -f "$dir/lib$name.la"; then
  226.                         found_la="$dir/lib$name.la"
  227.                       fi
  228.                     fi
  229.                   fi
  230.                   ;;
  231.               esac
  232.               if test "X$found_dir" != "X"; then
  233.                 break
  234.               fi
  235.             done
  236.           fi
  237.           if test "X$found_dir" != "X"; then
  238.             dnl Found the library.
  239.             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
  240.             if test "X$found_so" != "X"; then
  241.               dnl Linking with a shared library. We attempt to hardcode its
  242.               dnl directory into the executable's runpath, unless it's the
  243.               dnl standard /usr/lib.
  244.               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
  245.                 dnl No hardcoding is needed.
  246.                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  247.               else
  248.                 dnl Use an explicit option to hardcode DIR into the resulting
  249.                 dnl binary.
  250.                 dnl Potentially add DIR to ltrpathdirs.
  251.                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
  252.                 haveit=
  253.                 for x in $ltrpathdirs; do
  254.                   if test "X$x" = "X$found_dir"; then
  255.                     haveit=yes
  256.                     break
  257.                   fi
  258.                 done
  259.                 if test -z "$haveit"; then
  260.                   ltrpathdirs="$ltrpathdirs $found_dir"
  261.                 fi
  262.                 dnl The hardcoding into $LIBNAME is system dependent.
  263.                 if test "$hardcode_direct" = yes; then
  264.                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
  265.                   dnl resulting binary.
  266.                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  267.                 else
  268.                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
  269.                     dnl Use an explicit option to hardcode DIR into the resulting
  270.                     dnl binary.
  271.                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  272.                     dnl Potentially add DIR to rpathdirs.
  273.                     dnl The rpathdirs will be appended to $LIBNAME at the end.
  274.                     haveit=
  275.                     for x in $rpathdirs; do
  276.                       if test "X$x" = "X$found_dir"; then
  277.                         haveit=yes
  278.                         break
  279.                       fi
  280.                     done
  281.                     if test -z "$haveit"; then
  282.                       rpathdirs="$rpathdirs $found_dir"
  283.                     fi
  284.                   else
  285.                     dnl Rely on "-L$found_dir".
  286.                     dnl But don't add it if it's already contained in the LDFLAGS
  287.                     dnl or the already constructed $LIBNAME
  288.                     haveit=
  289.                     for x in $LDFLAGS $LIB[]NAME; do
  290.                       AC_LIB_WITH_FINAL_PREFIX([eval x="$x"])
  291.                       if test "X$x" = "X-L$found_dir"; then
  292.                         haveit=yes
  293.                         break
  294.                       fi
  295.                     done
  296.                     if test -z "$haveit"; then
  297.                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
  298.                     fi
  299.                     if test "$hardcode_minus_L" != no; then
  300.                       dnl FIXME: Not sure whether we should use
  301.                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  302.                       dnl here.
  303.                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  304.                     else
  305.                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
  306.                       dnl here, because this doesn't fit in flags passed to the
  307.                       dnl compiler. So give up. No hardcoding. This affects only
  308.                       dnl very old systems.
  309.                       dnl FIXME: Not sure whether we should use
  310.                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  311.                       dnl here.
  312.                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
  313.                     fi
  314.                   fi
  315.                 fi
  316.               fi
  317.             else
  318.               if test "X$found_a" != "X"; then
  319.                 dnl Linking with a static library.
  320.                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
  321.               else
  322.                 dnl We shouldn't come here, but anyway it's good to have a
  323.                 dnl fallback.
  324.                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
  325.               fi
  326.             fi
  327.             dnl Assume the include files are nearby.
  328.             additional_includedir=
  329.             case "$found_dir" in
  330.               */lib | */lib/)
  331.                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
  332.                 additional_includedir="$basedir/include"
  333.                 ;;
  334.             esac
  335.             if test "X$additional_includedir" != "X"; then
  336.               dnl Potentially add $additional_includedir to $INCNAME.
  337.               dnl But don't add it
  338.               dnl   1. if it's the standard /usr/include,
  339.               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
  340.               dnl   3. if it's already present in $CPPFLAGS or the already
  341.               dnl      constructed $INCNAME,
  342.               dnl   4. if it doesn't exist as a directory.
  343.               if test "X$additional_includedir" != "X/usr/include"; then
  344.                 haveit=
  345.                 if test "X$additional_includedir" = "X/usr/local/include"; then
  346.                   if test -n "$GCC"; then
  347.                     case $host_os in
  348.                       linux*) haveit=yes;;
  349.                     esac
  350.                   fi
  351.                 fi
  352.                 if test -z "$haveit"; then
  353.                   for x in $CPPFLAGS $INC[]NAME; do
  354.                     AC_LIB_WITH_FINAL_PREFIX([eval x="$x"])
  355.                     if test "X$x" = "X-I$additional_includedir"; then
  356.                       haveit=yes
  357.                       break
  358.                     fi
  359.                   done
  360.                   if test -z "$haveit"; then
  361.                     if test -d "$additional_includedir"; then
  362.                       dnl Really add $additional_includedir to $INCNAME.
  363.                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
  364.                     fi
  365.                   fi
  366.                 fi
  367.               fi
  368.             fi
  369.             dnl Look for dependencies.
  370.             if test -n "$found_la"; then
  371.               dnl Read the .la file. It defines the variables
  372.               dnl dlname, library_names, old_library, dependency_libs, current,
  373.               dnl age, revision, installed, dlopen, dlpreopen, libdir.
  374.               save_libdir="$libdir"
  375.               case "$found_la" in
  376.                 */* | *\*) . "$found_la" ;;
  377.                 *) . "./$found_la" ;;
  378.               esac
  379.               libdir="$save_libdir"
  380.               dnl We use only dependency_libs.
  381.               for dep in $dependency_libs; do
  382.                 case "$dep" in
  383.                   -L*)
  384.                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
  385.                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
  386.                     dnl But don't add it
  387.                     dnl   1. if it's the standard /usr/lib,
  388.                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
  389.                     dnl   3. if it's already present in $LDFLAGS or the already
  390.                     dnl      constructed $LIBNAME,
  391.                     dnl   4. if it doesn't exist as a directory.
  392.                     if test "X$additional_libdir" != "X/usr/lib"; then
  393.                       haveit=
  394.                       if test "X$additional_libdir" = "X/usr/local/lib"; then
  395.                         if test -n "$GCC"; then
  396.                           case $host_os in
  397.                             linux*) haveit=yes;;
  398.                           esac
  399.                         fi
  400.                       fi
  401.                       if test -z "$haveit"; then
  402.                         haveit=
  403.                         for x in $LDFLAGS $LIB[]NAME; do
  404.                           AC_LIB_WITH_FINAL_PREFIX([eval x="$x"])
  405.                           if test "X$x" = "X-L$additional_libdir"; then
  406.                             haveit=yes
  407.                             break
  408.                           fi
  409.                         done
  410.                         if test -z "$haveit"; then
  411.                           if test -d "$additional_libdir"; then
  412.                             dnl Really add $additional_libdir to $LIBNAME.
  413.                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
  414.                           fi
  415.                         fi
  416.                         haveit=
  417.                         for x in $LDFLAGS $LTLIB[]NAME; do
  418.                           AC_LIB_WITH_FINAL_PREFIX([eval x="$x"])
  419.                           if test "X$x" = "X-L$additional_libdir"; then
  420.                             haveit=yes
  421.                             break
  422.                           fi
  423.                         done
  424.                         if test -z "$haveit"; then
  425.                           if test -d "$additional_libdir"; then
  426.                             dnl Really add $additional_libdir to $LTLIBNAME.
  427.                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
  428.                           fi
  429.                         fi
  430.                       fi
  431.                     fi
  432.                     ;;
  433.                   -R*)
  434.                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
  435.                     if test "$enable_rpath" != no; then
  436.                       dnl Potentially add DIR to rpathdirs.
  437.                       dnl The rpathdirs will be appended to $LIBNAME at the end.
  438.                       haveit=
  439.                       for x in $rpathdirs; do
  440.                         if test "X$x" = "X$dir"; then
  441.                           haveit=yes
  442.                           break
  443.                         fi
  444.                       done
  445.                       if test -z "$haveit"; then
  446.                         rpathdirs="$rpathdirs $dir"
  447.                       fi
  448.                       dnl Potentially add DIR to ltrpathdirs.
  449.                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
  450.                       haveit=
  451.                       for x in $ltrpathdirs; do
  452.                         if test "X$x" = "X$dir"; then
  453.                           haveit=yes
  454.                           break
  455.                         fi
  456.                       done
  457.                       if test -z "$haveit"; then
  458.                         ltrpathdirs="$ltrpathdirs $dir"
  459.                       fi
  460.                     fi
  461.                     ;;
  462.                   -l*)
  463.                     dnl Handle this in the next round.
  464.                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
  465.                     ;;
  466.                   *.la)
  467.                     dnl Handle this in the next round. Throw away the .la's
  468.                     dnl directory; it is already contained in a preceding -L
  469.                     dnl option.
  470.                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,.la$,,'`
  471.                     ;;
  472.                   *)
  473.                     dnl Most likely an immediate library name.
  474.                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
  475.                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
  476.                     ;;
  477.                 esac
  478.               done
  479.             fi
  480.           else
  481.             dnl Didn't find the library; assume it is in the system directories
  482.             dnl known to the linker and runtime loader. (All the system
  483.             dnl directories known to the linker should also be known to the
  484.             dnl runtime loader, otherwise the system is severely misconfigured.)
  485.             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
  486.             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
  487.           fi
  488.         fi
  489.       fi
  490.     done
  491.   done
  492.   if test "X$rpathdirs" != "X"; then
  493.     if test -n "$hardcode_libdir_separator"; then
  494.       dnl Weird platform: only the last -rpath option counts, the user must
  495.       dnl pass all path elements in one option. We can arrange that for a
  496.       dnl single library, but not when more than one $LIBNAMEs are used.
  497.       alldirs=
  498.       for found_dir in $rpathdirs; do
  499.         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
  500.       done
  501.       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
  502.       acl_save_libdir="$libdir"
  503.       libdir="$alldirs"
  504.       eval flag="$hardcode_libdir_flag_spec"
  505.       libdir="$acl_save_libdir"
  506.       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
  507.     else
  508.       dnl The -rpath options are cumulative.
  509.       for found_dir in $rpathdirs; do
  510.         acl_save_libdir="$libdir"
  511.         libdir="$found_dir"
  512.         eval flag="$hardcode_libdir_flag_spec"
  513.         libdir="$acl_save_libdir"
  514.         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
  515.       done
  516.     fi
  517.   fi
  518.   if test "X$ltrpathdirs" != "X"; then
  519.     dnl When using libtool, the option that works for both libraries and
  520.     dnl executables is -R. The -R options are cumulative.
  521.     for found_dir in $ltrpathdirs; do
  522.       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
  523.     done
  524.   fi
  525. ])
  526. dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
  527. dnl unless already present in VAR.
  528. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
  529. dnl contains two or three consecutive elements that belong together.
  530. AC_DEFUN([AC_LIB_APPENDTOVAR],
  531. [
  532.   for element in [$2]; do
  533.     haveit=
  534.     for x in $[$1]; do
  535.       AC_LIB_WITH_FINAL_PREFIX([eval x="$x"])
  536.       if test "X$x" = "X$element"; then
  537.         haveit=yes
  538.         break
  539.       fi
  540.     done
  541.     if test -z "$haveit"; then
  542.       [$1]="${[$1]}${[$1]:+ }$element"
  543.     fi
  544.   done
  545. ])