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

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

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