Annotation of embedaddon/libiconv/srcm4/lib-link.m4, revision 1.1

1.1     ! misho       1: # lib-link.m4 serial 20 (gettext-0.18)
        !             2: dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
        !             3: dnl This file is free software; the Free Software Foundation
        !             4: dnl gives unlimited permission to copy and/or distribute it,
        !             5: dnl with or without modifications, as long as this notice is preserved.
        !             6: 
        !             7: dnl From Bruno Haible.
        !             8: 
        !             9: AC_PREREQ([2.54])
        !            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: dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
        !            16: dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
        !            17: AC_DEFUN([AC_LIB_LINKFLAGS],
        !            18: [
        !            19:   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
        !            20:   AC_REQUIRE([AC_LIB_RPATH])
        !            21:   pushdef([Name],[translit([$1],[./-], [___])])
        !            22:   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
        !            23:                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
        !            24:   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
        !            25:     AC_LIB_LINKFLAGS_BODY([$1], [$2])
        !            26:     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
        !            27:     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
        !            28:     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
        !            29:     ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
        !            30:   ])
        !            31:   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
        !            32:   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
        !            33:   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
        !            34:   LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
        !            35:   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
        !            36:   AC_SUBST([LIB]NAME)
        !            37:   AC_SUBST([LTLIB]NAME)
        !            38:   AC_SUBST([LIB]NAME[_PREFIX])
        !            39:   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
        !            40:   dnl results of this search when this library appears as a dependency.
        !            41:   HAVE_LIB[]NAME=yes
        !            42:   popdef([NAME])
        !            43:   popdef([Name])
        !            44: ])
        !            45: 
        !            46: dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
        !            47: dnl searches for libname and the libraries corresponding to explicit and
        !            48: dnl implicit dependencies, together with the specified include files and
        !            49: dnl the ability to compile and link the specified testcode. The missing-message
        !            50: dnl defaults to 'no' and may contain additional hints for the user.
        !            51: dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
        !            52: dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
        !            53: dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
        !            54: dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
        !            55: dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
        !            56: dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
        !            57: AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
        !            58: [
        !            59:   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
        !            60:   AC_REQUIRE([AC_LIB_RPATH])
        !            61:   pushdef([Name],[translit([$1],[./-], [___])])
        !            62:   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
        !            63:                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
        !            64: 
        !            65:   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
        !            66:   dnl accordingly.
        !            67:   AC_LIB_LINKFLAGS_BODY([$1], [$2])
        !            68: 
        !            69:   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
        !            70:   dnl because if the user has installed lib[]Name and not disabled its use
        !            71:   dnl via --without-lib[]Name-prefix, he wants to use it.
        !            72:   ac_save_CPPFLAGS="$CPPFLAGS"
        !            73:   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
        !            74: 
        !            75:   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
        !            76:     ac_save_LIBS="$LIBS"
        !            77:     LIBS="$LIBS $LIB[]NAME"
        !            78:     AC_TRY_LINK([$3], [$4],
        !            79:       [ac_cv_lib[]Name=yes],
        !            80:       [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
        !            81:     LIBS="$ac_save_LIBS"
        !            82:   ])
        !            83:   if test "$ac_cv_lib[]Name" = yes; then
        !            84:     HAVE_LIB[]NAME=yes
        !            85:     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
        !            86:     AC_MSG_CHECKING([how to link with lib[]$1])
        !            87:     AC_MSG_RESULT([$LIB[]NAME])
        !            88:   else
        !            89:     HAVE_LIB[]NAME=no
        !            90:     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
        !            91:     dnl $INC[]NAME either.
        !            92:     CPPFLAGS="$ac_save_CPPFLAGS"
        !            93:     LIB[]NAME=
        !            94:     LTLIB[]NAME=
        !            95:     LIB[]NAME[]_PREFIX=
        !            96:   fi
        !            97:   AC_SUBST([HAVE_LIB]NAME)
        !            98:   AC_SUBST([LIB]NAME)
        !            99:   AC_SUBST([LTLIB]NAME)
        !           100:   AC_SUBST([LIB]NAME[_PREFIX])
        !           101:   popdef([NAME])
        !           102:   popdef([Name])
        !           103: ])
        !           104: 
        !           105: dnl Determine the platform dependent parameters needed to use rpath:
        !           106: dnl   acl_libext,
        !           107: dnl   acl_shlibext,
        !           108: dnl   acl_hardcode_libdir_flag_spec,
        !           109: dnl   acl_hardcode_libdir_separator,
        !           110: dnl   acl_hardcode_direct,
        !           111: dnl   acl_hardcode_minus_L.
        !           112: AC_DEFUN([AC_LIB_RPATH],
        !           113: [
        !           114:   dnl Tell automake >= 1.10 to complain if config.rpath is missing.
        !           115:   m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
        !           116:   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
        !           117:   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
        !           118:   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
        !           119:   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
        !           120:   AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
        !           121:     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
        !           122:     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
        !           123:     . ./conftest.sh
        !           124:     rm -f ./conftest.sh
        !           125:     acl_cv_rpath=done
        !           126:   ])
        !           127:   wl="$acl_cv_wl"
        !           128:   acl_libext="$acl_cv_libext"
        !           129:   acl_shlibext="$acl_cv_shlibext"
        !           130:   acl_libname_spec="$acl_cv_libname_spec"
        !           131:   acl_library_names_spec="$acl_cv_library_names_spec"
        !           132:   acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
        !           133:   acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
        !           134:   acl_hardcode_direct="$acl_cv_hardcode_direct"
        !           135:   acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
        !           136:   dnl Determine whether the user wants rpath handling at all.
        !           137:   AC_ARG_ENABLE([rpath],
        !           138:     [  --disable-rpath         do not hardcode runtime library paths],
        !           139:     :, enable_rpath=yes)
        !           140: ])
        !           141: 
        !           142: dnl AC_LIB_FROMPACKAGE(name, package)
        !           143: dnl declares that libname comes from the given package. The configure file
        !           144: dnl will then not have a --with-libname-prefix option but a
        !           145: dnl --with-package-prefix option. Several libraries can come from the same
        !           146: dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
        !           147: dnl macro call that searches for libname.
        !           148: AC_DEFUN([AC_LIB_FROMPACKAGE],
        !           149: [
        !           150:   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
        !           151:                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
        !           152:   define([acl_frompackage_]NAME, [$2])
        !           153:   popdef([NAME])
        !           154:   pushdef([PACK],[$2])
        !           155:   pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
        !           156:                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
        !           157:   define([acl_libsinpackage_]PACKUP,
        !           158:     m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
        !           159:   popdef([PACKUP])
        !           160:   popdef([PACK])
        !           161: ])
        !           162: 
        !           163: dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
        !           164: dnl the libraries corresponding to explicit and implicit dependencies.
        !           165: dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
        !           166: dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
        !           167: dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
        !           168: AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
        !           169: [
        !           170:   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
        !           171:   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
        !           172:                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
        !           173:   pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
        !           174:   pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
        !           175:                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
        !           176:   pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
        !           177:   dnl Autoconf >= 2.61 supports dots in --with options.
        !           178:   pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
        !           179:   dnl By default, look in $includedir and $libdir.
        !           180:   use_additional=yes
        !           181:   AC_LIB_WITH_FINAL_PREFIX([
        !           182:     eval additional_includedir=\"$includedir\"
        !           183:     eval additional_libdir=\"$libdir\"
        !           184:   ])
        !           185:   AC_ARG_WITH(P_A_C_K[-prefix],
        !           186: [[  --with-]]P_A_C_K[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
        !           187:   --without-]]P_A_C_K[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
        !           188: [
        !           189:     if test "X$withval" = "Xno"; then
        !           190:       use_additional=no
        !           191:     else
        !           192:       if test "X$withval" = "X"; then
        !           193:         AC_LIB_WITH_FINAL_PREFIX([
        !           194:           eval additional_includedir=\"$includedir\"
        !           195:           eval additional_libdir=\"$libdir\"
        !           196:         ])
        !           197:       else
        !           198:         additional_includedir="$withval/include"
        !           199:         additional_libdir="$withval/$acl_libdirstem"
        !           200:         if test "$acl_libdirstem2" != "$acl_libdirstem" \
        !           201:            && ! test -d "$withval/$acl_libdirstem"; then
        !           202:           additional_libdir="$withval/$acl_libdirstem2"
        !           203:         fi
        !           204:       fi
        !           205:     fi
        !           206: ])
        !           207:   dnl Search the library and its dependencies in $additional_libdir and
        !           208:   dnl $LDFLAGS. Using breadth-first-seach.
        !           209:   LIB[]NAME=
        !           210:   LTLIB[]NAME=
        !           211:   INC[]NAME=
        !           212:   LIB[]NAME[]_PREFIX=
        !           213:   dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
        !           214:   dnl computed. So it has to be reset here.
        !           215:   HAVE_LIB[]NAME=
        !           216:   rpathdirs=
        !           217:   ltrpathdirs=
        !           218:   names_already_handled=
        !           219:   names_next_round='$1 $2'
        !           220:   while test -n "$names_next_round"; do
        !           221:     names_this_round="$names_next_round"
        !           222:     names_next_round=
        !           223:     for name in $names_this_round; do
        !           224:       already_handled=
        !           225:       for n in $names_already_handled; do
        !           226:         if test "$n" = "$name"; then
        !           227:           already_handled=yes
        !           228:           break
        !           229:         fi
        !           230:       done
        !           231:       if test -z "$already_handled"; then
        !           232:         names_already_handled="$names_already_handled $name"
        !           233:         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
        !           234:         dnl or AC_LIB_HAVE_LINKFLAGS call.
        !           235:         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
        !           236:         eval value=\"\$HAVE_LIB$uppername\"
        !           237:         if test -n "$value"; then
        !           238:           if test "$value" = yes; then
        !           239:             eval value=\"\$LIB$uppername\"
        !           240:             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
        !           241:             eval value=\"\$LTLIB$uppername\"
        !           242:             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
        !           243:           else
        !           244:             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
        !           245:             dnl that this library doesn't exist. So just drop it.
        !           246:             :
        !           247:           fi
        !           248:         else
        !           249:           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
        !           250:           dnl and the already constructed $LIBNAME/$LTLIBNAME.
        !           251:           found_dir=
        !           252:           found_la=
        !           253:           found_so=
        !           254:           found_a=
        !           255:           eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
        !           256:           if test -n "$acl_shlibext"; then
        !           257:             shrext=".$acl_shlibext"             # typically: shrext=.so
        !           258:           else
        !           259:             shrext=
        !           260:           fi
        !           261:           if test $use_additional = yes; then
        !           262:             dir="$additional_libdir"
        !           263:             dnl The same code as in the loop below:
        !           264:             dnl First look for a shared library.
        !           265:             if test -n "$acl_shlibext"; then
        !           266:               if test -f "$dir/$libname$shrext"; then
        !           267:                 found_dir="$dir"
        !           268:                 found_so="$dir/$libname$shrext"
        !           269:               else
        !           270:                 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
        !           271:                   ver=`(cd "$dir" && \
        !           272:                         for f in "$libname$shrext".*; do echo "$f"; done \
        !           273:                         | sed -e "s,^$libname$shrext\\\\.,," \
        !           274:                         | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
        !           275:                         | sed 1q ) 2>/dev/null`
        !           276:                   if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
        !           277:                     found_dir="$dir"
        !           278:                     found_so="$dir/$libname$shrext.$ver"
        !           279:                   fi
        !           280:                 else
        !           281:                   eval library_names=\"$acl_library_names_spec\"
        !           282:                   for f in $library_names; do
        !           283:                     if test -f "$dir/$f"; then
        !           284:                       found_dir="$dir"
        !           285:                       found_so="$dir/$f"
        !           286:                       break
        !           287:                     fi
        !           288:                   done
        !           289:                 fi
        !           290:               fi
        !           291:             fi
        !           292:             dnl Then look for a static library.
        !           293:             if test "X$found_dir" = "X"; then
        !           294:               if test -f "$dir/$libname.$acl_libext"; then
        !           295:                 found_dir="$dir"
        !           296:                 found_a="$dir/$libname.$acl_libext"
        !           297:               fi
        !           298:             fi
        !           299:             if test "X$found_dir" != "X"; then
        !           300:               if test -f "$dir/$libname.la"; then
        !           301:                 found_la="$dir/$libname.la"
        !           302:               fi
        !           303:             fi
        !           304:           fi
        !           305:           if test "X$found_dir" = "X"; then
        !           306:             for x in $LDFLAGS $LTLIB[]NAME; do
        !           307:               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
        !           308:               case "$x" in
        !           309:                 -L*)
        !           310:                   dir=`echo "X$x" | sed -e 's/^X-L//'`
        !           311:                   dnl First look for a shared library.
        !           312:                   if test -n "$acl_shlibext"; then
        !           313:                     if test -f "$dir/$libname$shrext"; then
        !           314:                       found_dir="$dir"
        !           315:                       found_so="$dir/$libname$shrext"
        !           316:                     else
        !           317:                       if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
        !           318:                         ver=`(cd "$dir" && \
        !           319:                               for f in "$libname$shrext".*; do echo "$f"; done \
        !           320:                               | sed -e "s,^$libname$shrext\\\\.,," \
        !           321:                               | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
        !           322:                               | sed 1q ) 2>/dev/null`
        !           323:                         if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
        !           324:                           found_dir="$dir"
        !           325:                           found_so="$dir/$libname$shrext.$ver"
        !           326:                         fi
        !           327:                       else
        !           328:                         eval library_names=\"$acl_library_names_spec\"
        !           329:                         for f in $library_names; do
        !           330:                           if test -f "$dir/$f"; then
        !           331:                             found_dir="$dir"
        !           332:                             found_so="$dir/$f"
        !           333:                             break
        !           334:                           fi
        !           335:                         done
        !           336:                       fi
        !           337:                     fi
        !           338:                   fi
        !           339:                   dnl Then look for a static library.
        !           340:                   if test "X$found_dir" = "X"; then
        !           341:                     if test -f "$dir/$libname.$acl_libext"; then
        !           342:                       found_dir="$dir"
        !           343:                       found_a="$dir/$libname.$acl_libext"
        !           344:                     fi
        !           345:                   fi
        !           346:                   if test "X$found_dir" != "X"; then
        !           347:                     if test -f "$dir/$libname.la"; then
        !           348:                       found_la="$dir/$libname.la"
        !           349:                     fi
        !           350:                   fi
        !           351:                   ;;
        !           352:               esac
        !           353:               if test "X$found_dir" != "X"; then
        !           354:                 break
        !           355:               fi
        !           356:             done
        !           357:           fi
        !           358:           if test "X$found_dir" != "X"; then
        !           359:             dnl Found the library.
        !           360:             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
        !           361:             if test "X$found_so" != "X"; then
        !           362:               dnl Linking with a shared library. We attempt to hardcode its
        !           363:               dnl directory into the executable's runpath, unless it's the
        !           364:               dnl standard /usr/lib.
        !           365:               if test "$enable_rpath" = no \
        !           366:                  || test "X$found_dir" = "X/usr/$acl_libdirstem" \
        !           367:                  || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
        !           368:                 dnl No hardcoding is needed.
        !           369:                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
        !           370:               else
        !           371:                 dnl Use an explicit option to hardcode DIR into the resulting
        !           372:                 dnl binary.
        !           373:                 dnl Potentially add DIR to ltrpathdirs.
        !           374:                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
        !           375:                 haveit=
        !           376:                 for x in $ltrpathdirs; do
        !           377:                   if test "X$x" = "X$found_dir"; then
        !           378:                     haveit=yes
        !           379:                     break
        !           380:                   fi
        !           381:                 done
        !           382:                 if test -z "$haveit"; then
        !           383:                   ltrpathdirs="$ltrpathdirs $found_dir"
        !           384:                 fi
        !           385:                 dnl The hardcoding into $LIBNAME is system dependent.
        !           386:                 if test "$acl_hardcode_direct" = yes; then
        !           387:                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
        !           388:                   dnl resulting binary.
        !           389:                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
        !           390:                 else
        !           391:                   if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
        !           392:                     dnl Use an explicit option to hardcode DIR into the resulting
        !           393:                     dnl binary.
        !           394:                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
        !           395:                     dnl Potentially add DIR to rpathdirs.
        !           396:                     dnl The rpathdirs will be appended to $LIBNAME at the end.
        !           397:                     haveit=
        !           398:                     for x in $rpathdirs; do
        !           399:                       if test "X$x" = "X$found_dir"; then
        !           400:                         haveit=yes
        !           401:                         break
        !           402:                       fi
        !           403:                     done
        !           404:                     if test -z "$haveit"; then
        !           405:                       rpathdirs="$rpathdirs $found_dir"
        !           406:                     fi
        !           407:                   else
        !           408:                     dnl Rely on "-L$found_dir".
        !           409:                     dnl But don't add it if it's already contained in the LDFLAGS
        !           410:                     dnl or the already constructed $LIBNAME
        !           411:                     haveit=
        !           412:                     for x in $LDFLAGS $LIB[]NAME; do
        !           413:                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
        !           414:                       if test "X$x" = "X-L$found_dir"; then
        !           415:                         haveit=yes
        !           416:                         break
        !           417:                       fi
        !           418:                     done
        !           419:                     if test -z "$haveit"; then
        !           420:                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
        !           421:                     fi
        !           422:                     if test "$acl_hardcode_minus_L" != no; then
        !           423:                       dnl FIXME: Not sure whether we should use
        !           424:                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
        !           425:                       dnl here.
        !           426:                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
        !           427:                     else
        !           428:                       dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
        !           429:                       dnl here, because this doesn't fit in flags passed to the
        !           430:                       dnl compiler. So give up. No hardcoding. This affects only
        !           431:                       dnl very old systems.
        !           432:                       dnl FIXME: Not sure whether we should use
        !           433:                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
        !           434:                       dnl here.
        !           435:                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
        !           436:                     fi
        !           437:                   fi
        !           438:                 fi
        !           439:               fi
        !           440:             else
        !           441:               if test "X$found_a" != "X"; then
        !           442:                 dnl Linking with a static library.
        !           443:                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
        !           444:               else
        !           445:                 dnl We shouldn't come here, but anyway it's good to have a
        !           446:                 dnl fallback.
        !           447:                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
        !           448:               fi
        !           449:             fi
        !           450:             dnl Assume the include files are nearby.
        !           451:             additional_includedir=
        !           452:             case "$found_dir" in
        !           453:               */$acl_libdirstem | */$acl_libdirstem/)
        !           454:                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
        !           455:                 if test "$name" = '$1'; then
        !           456:                   LIB[]NAME[]_PREFIX="$basedir"
        !           457:                 fi
        !           458:                 additional_includedir="$basedir/include"
        !           459:                 ;;
        !           460:               */$acl_libdirstem2 | */$acl_libdirstem2/)
        !           461:                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
        !           462:                 if test "$name" = '$1'; then
        !           463:                   LIB[]NAME[]_PREFIX="$basedir"
        !           464:                 fi
        !           465:                 additional_includedir="$basedir/include"
        !           466:                 ;;
        !           467:             esac
        !           468:             if test "X$additional_includedir" != "X"; then
        !           469:               dnl Potentially add $additional_includedir to $INCNAME.
        !           470:               dnl But don't add it
        !           471:               dnl   1. if it's the standard /usr/include,
        !           472:               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
        !           473:               dnl   3. if it's already present in $CPPFLAGS or the already
        !           474:               dnl      constructed $INCNAME,
        !           475:               dnl   4. if it doesn't exist as a directory.
        !           476:               if test "X$additional_includedir" != "X/usr/include"; then
        !           477:                 haveit=
        !           478:                 if test "X$additional_includedir" = "X/usr/local/include"; then
        !           479:                   if test -n "$GCC"; then
        !           480:                     case $host_os in
        !           481:                       linux* | gnu* | k*bsd*-gnu) haveit=yes;;
        !           482:                     esac
        !           483:                   fi
        !           484:                 fi
        !           485:                 if test -z "$haveit"; then
        !           486:                   for x in $CPPFLAGS $INC[]NAME; do
        !           487:                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
        !           488:                     if test "X$x" = "X-I$additional_includedir"; then
        !           489:                       haveit=yes
        !           490:                       break
        !           491:                     fi
        !           492:                   done
        !           493:                   if test -z "$haveit"; then
        !           494:                     if test -d "$additional_includedir"; then
        !           495:                       dnl Really add $additional_includedir to $INCNAME.
        !           496:                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
        !           497:                     fi
        !           498:                   fi
        !           499:                 fi
        !           500:               fi
        !           501:             fi
        !           502:             dnl Look for dependencies.
        !           503:             if test -n "$found_la"; then
        !           504:               dnl Read the .la file. It defines the variables
        !           505:               dnl dlname, library_names, old_library, dependency_libs, current,
        !           506:               dnl age, revision, installed, dlopen, dlpreopen, libdir.
        !           507:               save_libdir="$libdir"
        !           508:               case "$found_la" in
        !           509:                 */* | *\\*) . "$found_la" ;;
        !           510:                 *) . "./$found_la" ;;
        !           511:               esac
        !           512:               libdir="$save_libdir"
        !           513:               dnl We use only dependency_libs.
        !           514:               for dep in $dependency_libs; do
        !           515:                 case "$dep" in
        !           516:                   -L*)
        !           517:                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
        !           518:                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
        !           519:                     dnl But don't add it
        !           520:                     dnl   1. if it's the standard /usr/lib,
        !           521:                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
        !           522:                     dnl   3. if it's already present in $LDFLAGS or the already
        !           523:                     dnl      constructed $LIBNAME,
        !           524:                     dnl   4. if it doesn't exist as a directory.
        !           525:                     if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
        !           526:                        && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
        !           527:                       haveit=
        !           528:                       if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
        !           529:                          || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
        !           530:                         if test -n "$GCC"; then
        !           531:                           case $host_os in
        !           532:                             linux* | gnu* | k*bsd*-gnu) haveit=yes;;
        !           533:                           esac
        !           534:                         fi
        !           535:                       fi
        !           536:                       if test -z "$haveit"; then
        !           537:                         haveit=
        !           538:                         for x in $LDFLAGS $LIB[]NAME; do
        !           539:                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
        !           540:                           if test "X$x" = "X-L$additional_libdir"; then
        !           541:                             haveit=yes
        !           542:                             break
        !           543:                           fi
        !           544:                         done
        !           545:                         if test -z "$haveit"; then
        !           546:                           if test -d "$additional_libdir"; then
        !           547:                             dnl Really add $additional_libdir to $LIBNAME.
        !           548:                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
        !           549:                           fi
        !           550:                         fi
        !           551:                         haveit=
        !           552:                         for x in $LDFLAGS $LTLIB[]NAME; do
        !           553:                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
        !           554:                           if test "X$x" = "X-L$additional_libdir"; then
        !           555:                             haveit=yes
        !           556:                             break
        !           557:                           fi
        !           558:                         done
        !           559:                         if test -z "$haveit"; then
        !           560:                           if test -d "$additional_libdir"; then
        !           561:                             dnl Really add $additional_libdir to $LTLIBNAME.
        !           562:                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
        !           563:                           fi
        !           564:                         fi
        !           565:                       fi
        !           566:                     fi
        !           567:                     ;;
        !           568:                   -R*)
        !           569:                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
        !           570:                     if test "$enable_rpath" != no; then
        !           571:                       dnl Potentially add DIR to rpathdirs.
        !           572:                       dnl The rpathdirs will be appended to $LIBNAME at the end.
        !           573:                       haveit=
        !           574:                       for x in $rpathdirs; do
        !           575:                         if test "X$x" = "X$dir"; then
        !           576:                           haveit=yes
        !           577:                           break
        !           578:                         fi
        !           579:                       done
        !           580:                       if test -z "$haveit"; then
        !           581:                         rpathdirs="$rpathdirs $dir"
        !           582:                       fi
        !           583:                       dnl Potentially add DIR to ltrpathdirs.
        !           584:                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
        !           585:                       haveit=
        !           586:                       for x in $ltrpathdirs; do
        !           587:                         if test "X$x" = "X$dir"; then
        !           588:                           haveit=yes
        !           589:                           break
        !           590:                         fi
        !           591:                       done
        !           592:                       if test -z "$haveit"; then
        !           593:                         ltrpathdirs="$ltrpathdirs $dir"
        !           594:                       fi
        !           595:                     fi
        !           596:                     ;;
        !           597:                   -l*)
        !           598:                     dnl Handle this in the next round.
        !           599:                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
        !           600:                     ;;
        !           601:                   *.la)
        !           602:                     dnl Handle this in the next round. Throw away the .la's
        !           603:                     dnl directory; it is already contained in a preceding -L
        !           604:                     dnl option.
        !           605:                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
        !           606:                     ;;
        !           607:                   *)
        !           608:                     dnl Most likely an immediate library name.
        !           609:                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
        !           610:                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
        !           611:                     ;;
        !           612:                 esac
        !           613:               done
        !           614:             fi
        !           615:           else
        !           616:             dnl Didn't find the library; assume it is in the system directories
        !           617:             dnl known to the linker and runtime loader. (All the system
        !           618:             dnl directories known to the linker should also be known to the
        !           619:             dnl runtime loader, otherwise the system is severely misconfigured.)
        !           620:             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
        !           621:             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
        !           622:           fi
        !           623:         fi
        !           624:       fi
        !           625:     done
        !           626:   done
        !           627:   if test "X$rpathdirs" != "X"; then
        !           628:     if test -n "$acl_hardcode_libdir_separator"; then
        !           629:       dnl Weird platform: only the last -rpath option counts, the user must
        !           630:       dnl pass all path elements in one option. We can arrange that for a
        !           631:       dnl single library, but not when more than one $LIBNAMEs are used.
        !           632:       alldirs=
        !           633:       for found_dir in $rpathdirs; do
        !           634:         alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
        !           635:       done
        !           636:       dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
        !           637:       acl_save_libdir="$libdir"
        !           638:       libdir="$alldirs"
        !           639:       eval flag=\"$acl_hardcode_libdir_flag_spec\"
        !           640:       libdir="$acl_save_libdir"
        !           641:       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
        !           642:     else
        !           643:       dnl The -rpath options are cumulative.
        !           644:       for found_dir in $rpathdirs; do
        !           645:         acl_save_libdir="$libdir"
        !           646:         libdir="$found_dir"
        !           647:         eval flag=\"$acl_hardcode_libdir_flag_spec\"
        !           648:         libdir="$acl_save_libdir"
        !           649:         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
        !           650:       done
        !           651:     fi
        !           652:   fi
        !           653:   if test "X$ltrpathdirs" != "X"; then
        !           654:     dnl When using libtool, the option that works for both libraries and
        !           655:     dnl executables is -R. The -R options are cumulative.
        !           656:     for found_dir in $ltrpathdirs; do
        !           657:       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
        !           658:     done
        !           659:   fi
        !           660:   popdef([P_A_C_K])
        !           661:   popdef([PACKLIBS])
        !           662:   popdef([PACKUP])
        !           663:   popdef([PACK])
        !           664:   popdef([NAME])
        !           665: ])
        !           666: 
        !           667: dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
        !           668: dnl unless already present in VAR.
        !           669: dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
        !           670: dnl contains two or three consecutive elements that belong together.
        !           671: AC_DEFUN([AC_LIB_APPENDTOVAR],
        !           672: [
        !           673:   for element in [$2]; do
        !           674:     haveit=
        !           675:     for x in $[$1]; do
        !           676:       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
        !           677:       if test "X$x" = "X$element"; then
        !           678:         haveit=yes
        !           679:         break
        !           680:       fi
        !           681:     done
        !           682:     if test -z "$haveit"; then
        !           683:       [$1]="${[$1]}${[$1]:+ }$element"
        !           684:     fi
        !           685:   done
        !           686: ])
        !           687: 
        !           688: dnl For those cases where a variable contains several -L and -l options
        !           689: dnl referring to unknown libraries and directories, this macro determines the
        !           690: dnl necessary additional linker options for the runtime path.
        !           691: dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
        !           692: dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
        !           693: dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
        !           694: dnl otherwise linking without libtool is assumed.
        !           695: AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
        !           696: [
        !           697:   AC_REQUIRE([AC_LIB_RPATH])
        !           698:   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
        !           699:   $1=
        !           700:   if test "$enable_rpath" != no; then
        !           701:     if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
        !           702:       dnl Use an explicit option to hardcode directories into the resulting
        !           703:       dnl binary.
        !           704:       rpathdirs=
        !           705:       next=
        !           706:       for opt in $2; do
        !           707:         if test -n "$next"; then
        !           708:           dir="$next"
        !           709:           dnl No need to hardcode the standard /usr/lib.
        !           710:           if test "X$dir" != "X/usr/$acl_libdirstem" \
        !           711:              && test "X$dir" != "X/usr/$acl_libdirstem2"; then
        !           712:             rpathdirs="$rpathdirs $dir"
        !           713:           fi
        !           714:           next=
        !           715:         else
        !           716:           case $opt in
        !           717:             -L) next=yes ;;
        !           718:             -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
        !           719:                  dnl No need to hardcode the standard /usr/lib.
        !           720:                  if test "X$dir" != "X/usr/$acl_libdirstem" \
        !           721:                     && test "X$dir" != "X/usr/$acl_libdirstem2"; then
        !           722:                    rpathdirs="$rpathdirs $dir"
        !           723:                  fi
        !           724:                  next= ;;
        !           725:             *) next= ;;
        !           726:           esac
        !           727:         fi
        !           728:       done
        !           729:       if test "X$rpathdirs" != "X"; then
        !           730:         if test -n ""$3""; then
        !           731:           dnl libtool is used for linking. Use -R options.
        !           732:           for dir in $rpathdirs; do
        !           733:             $1="${$1}${$1:+ }-R$dir"
        !           734:           done
        !           735:         else
        !           736:           dnl The linker is used for linking directly.
        !           737:           if test -n "$acl_hardcode_libdir_separator"; then
        !           738:             dnl Weird platform: only the last -rpath option counts, the user
        !           739:             dnl must pass all path elements in one option.
        !           740:             alldirs=
        !           741:             for dir in $rpathdirs; do
        !           742:               alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
        !           743:             done
        !           744:             acl_save_libdir="$libdir"
        !           745:             libdir="$alldirs"
        !           746:             eval flag=\"$acl_hardcode_libdir_flag_spec\"
        !           747:             libdir="$acl_save_libdir"
        !           748:             $1="$flag"
        !           749:           else
        !           750:             dnl The -rpath options are cumulative.
        !           751:             for dir in $rpathdirs; do
        !           752:               acl_save_libdir="$libdir"
        !           753:               libdir="$dir"
        !           754:               eval flag=\"$acl_hardcode_libdir_flag_spec\"
        !           755:               libdir="$acl_save_libdir"
        !           756:               $1="${$1}${$1:+ }$flag"
        !           757:             done
        !           758:           fi
        !           759:         fi
        !           760:       fi
        !           761:     fi
        !           762:   fi
        !           763:   AC_SUBST([$1])
        !           764: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>