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