1 # -*- buffer-read-only: t -*- vi: set ro:
2 # DO NOT EDIT! GENERATED AUTOMATICALLY!
3 # lib-link.m4 serial 13 (gettext-0.17)
4 dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
13 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
14 dnl the libraries corresponding to explicit and implicit dependencies.
15 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
16 dnl augments the CPPFLAGS variable.
17 dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
18 dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
19 AC_DEFUN([AC_LIB_LINKFLAGS],
21 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
22 AC_REQUIRE([AC_LIB_RPATH])
23 define([Name],[translit([$1],[./-], [___])])
24 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
25 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
26 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
27 AC_LIB_LINKFLAGS_BODY([$1], [$2])
28 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
29 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
30 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
31 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
33 LIB[]NAME="$ac_cv_lib[]Name[]_libs"
34 LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
35 INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
36 LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
37 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
40 AC_SUBST([LIB]NAME[_PREFIX])
41 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
42 dnl results of this search when this library appears as a dependency.
48 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
49 dnl searches for libname and the libraries corresponding to explicit and
50 dnl implicit dependencies, together with the specified include files and
51 dnl the ability to compile and link the specified testcode. If found, it
52 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
53 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
54 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
55 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
56 dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
57 dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
58 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
60 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
61 AC_REQUIRE([AC_LIB_RPATH])
62 define([Name],[translit([$1],[./-], [___])])
63 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
64 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
66 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
68 AC_LIB_LINKFLAGS_BODY([$1], [$2])
70 dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
71 dnl because if the user has installed lib[]Name and not disabled its use
72 dnl via --without-lib[]Name-prefix, he wants to use it.
73 ac_save_CPPFLAGS="$CPPFLAGS"
74 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
76 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
78 LIBS="$LIBS $LIB[]NAME"
79 AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
82 if test "$ac_cv_lib[]Name" = yes; then
84 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
85 AC_MSG_CHECKING([how to link with lib[]$1])
86 AC_MSG_RESULT([$LIB[]NAME])
89 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
90 dnl $INC[]NAME either.
91 CPPFLAGS="$ac_save_CPPFLAGS"
96 AC_SUBST([HAVE_LIB]NAME)
99 AC_SUBST([LIB]NAME[_PREFIX])
104 dnl Determine the platform dependent parameters needed to use rpath:
107 dnl acl_hardcode_libdir_flag_spec,
108 dnl acl_hardcode_libdir_separator,
109 dnl acl_hardcode_direct,
110 dnl acl_hardcode_minus_L.
111 AC_DEFUN([AC_LIB_RPATH],
113 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
114 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
115 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
116 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
117 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
118 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
119 AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
120 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
121 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
127 acl_libext="$acl_cv_libext"
128 acl_shlibext="$acl_cv_shlibext"
129 acl_libname_spec="$acl_cv_libname_spec"
130 acl_library_names_spec="$acl_cv_library_names_spec"
131 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
132 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
133 acl_hardcode_direct="$acl_cv_hardcode_direct"
134 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
135 dnl Determine whether the user wants rpath handling at all.
137 [ --disable-rpath do not hardcode runtime library paths],
141 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
142 dnl the libraries corresponding to explicit and implicit dependencies.
143 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
144 dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
145 dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
146 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
148 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
149 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
150 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
151 dnl Autoconf >= 2.61 supports dots in --with options.
152 define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
153 dnl By default, look in $includedir and $libdir.
155 AC_LIB_WITH_FINAL_PREFIX([
156 eval additional_includedir=\"$includedir\"
157 eval additional_libdir=\"$libdir\"
159 AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
160 [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
161 --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
163 if test "X$withval" = "Xno"; then
166 if test "X$withval" = "X"; then
167 AC_LIB_WITH_FINAL_PREFIX([
168 eval additional_includedir=\"$includedir\"
169 eval additional_libdir=\"$libdir\"
172 additional_includedir="$withval/include"
173 additional_libdir="$withval/$acl_libdirstem"
177 dnl Search the library and its dependencies in $additional_libdir and
178 dnl $LDFLAGS. Using breadth-first-seach.
185 names_already_handled=
186 names_next_round='$1 $2'
187 while test -n "$names_next_round"; do
188 names_this_round="$names_next_round"
190 for name in $names_this_round; do
192 for n in $names_already_handled; do
193 if test "$n" = "$name"; then
198 if test -z "$already_handled"; then
199 names_already_handled="$names_already_handled $name"
200 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
201 dnl or AC_LIB_HAVE_LINKFLAGS call.
202 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
203 eval value=\"\$HAVE_LIB$uppername\"
204 if test -n "$value"; then
205 if test "$value" = yes; then
206 eval value=\"\$LIB$uppername\"
207 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
208 eval value=\"\$LTLIB$uppername\"
209 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
211 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
212 dnl that this library doesn't exist. So just drop it.
216 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
217 dnl and the already constructed $LIBNAME/$LTLIBNAME.
222 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
223 if test -n "$acl_shlibext"; then
224 shrext=".$acl_shlibext" # typically: shrext=.so
228 if test $use_additional = yes; then
229 dir="$additional_libdir"
230 dnl The same code as in the loop below:
231 dnl First look for a shared library.
232 if test -n "$acl_shlibext"; then
233 if test -f "$dir/$libname$shrext"; then
235 found_so="$dir/$libname$shrext"
237 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
239 for f in "$libname$shrext".*; do echo "$f"; done \
240 | sed -e "s,^$libname$shrext\\\\.,," \
241 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
242 | sed 1q ) 2>/dev/null`
243 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
245 found_so="$dir/$libname$shrext.$ver"
248 eval library_names=\"$acl_library_names_spec\"
249 for f in $library_names; do
250 if test -f "$dir/$f"; then
259 dnl Then look for a static library.
260 if test "X$found_dir" = "X"; then
261 if test -f "$dir/$libname.$acl_libext"; then
263 found_a="$dir/$libname.$acl_libext"
266 if test "X$found_dir" != "X"; then
267 if test -f "$dir/$libname.la"; then
268 found_la="$dir/$libname.la"
272 if test "X$found_dir" = "X"; then
273 for x in $LDFLAGS $LTLIB[]NAME; do
274 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
277 dir=`echo "X$x" | sed -e 's/^X-L//'`
278 dnl First look for a shared library.
279 if test -n "$acl_shlibext"; then
280 if test -f "$dir/$libname$shrext"; then
282 found_so="$dir/$libname$shrext"
284 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
286 for f in "$libname$shrext".*; do echo "$f"; done \
287 | sed -e "s,^$libname$shrext\\\\.,," \
288 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
289 | sed 1q ) 2>/dev/null`
290 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
292 found_so="$dir/$libname$shrext.$ver"
295 eval library_names=\"$acl_library_names_spec\"
296 for f in $library_names; do
297 if test -f "$dir/$f"; then
306 dnl Then look for a static library.
307 if test "X$found_dir" = "X"; then
308 if test -f "$dir/$libname.$acl_libext"; then
310 found_a="$dir/$libname.$acl_libext"
313 if test "X$found_dir" != "X"; then
314 if test -f "$dir/$libname.la"; then
315 found_la="$dir/$libname.la"
320 if test "X$found_dir" != "X"; then
325 if test "X$found_dir" != "X"; then
326 dnl Found the library.
327 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
328 if test "X$found_so" != "X"; then
329 dnl Linking with a shared library. We attempt to hardcode its
330 dnl directory into the executable's runpath, unless it's the
331 dnl standard /usr/lib.
332 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
333 dnl No hardcoding is needed.
334 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
336 dnl Use an explicit option to hardcode DIR into the resulting
338 dnl Potentially add DIR to ltrpathdirs.
339 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
341 for x in $ltrpathdirs; do
342 if test "X$x" = "X$found_dir"; then
347 if test -z "$haveit"; then
348 ltrpathdirs="$ltrpathdirs $found_dir"
350 dnl The hardcoding into $LIBNAME is system dependent.
351 if test "$acl_hardcode_direct" = yes; then
352 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
353 dnl resulting binary.
354 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
356 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
357 dnl Use an explicit option to hardcode DIR into the resulting
359 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
360 dnl Potentially add DIR to rpathdirs.
361 dnl The rpathdirs will be appended to $LIBNAME at the end.
363 for x in $rpathdirs; do
364 if test "X$x" = "X$found_dir"; then
369 if test -z "$haveit"; then
370 rpathdirs="$rpathdirs $found_dir"
373 dnl Rely on "-L$found_dir".
374 dnl But don't add it if it's already contained in the LDFLAGS
375 dnl or the already constructed $LIBNAME
377 for x in $LDFLAGS $LIB[]NAME; do
378 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
379 if test "X$x" = "X-L$found_dir"; then
384 if test -z "$haveit"; then
385 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
387 if test "$acl_hardcode_minus_L" != no; then
388 dnl FIXME: Not sure whether we should use
389 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
391 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
393 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
394 dnl here, because this doesn't fit in flags passed to the
395 dnl compiler. So give up. No hardcoding. This affects only
396 dnl very old systems.
397 dnl FIXME: Not sure whether we should use
398 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
400 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
406 if test "X$found_a" != "X"; then
407 dnl Linking with a static library.
408 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
410 dnl We shouldn't come here, but anyway it's good to have a
412 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
415 dnl Assume the include files are nearby.
416 additional_includedir=
418 */$acl_libdirstem | */$acl_libdirstem/)
419 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
420 LIB[]NAME[]_PREFIX="$basedir"
421 additional_includedir="$basedir/include"
424 if test "X$additional_includedir" != "X"; then
425 dnl Potentially add $additional_includedir to $INCNAME.
427 dnl 1. if it's the standard /usr/include,
428 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
429 dnl 3. if it's already present in $CPPFLAGS or the already
430 dnl constructed $INCNAME,
431 dnl 4. if it doesn't exist as a directory.
432 if test "X$additional_includedir" != "X/usr/include"; then
434 if test "X$additional_includedir" = "X/usr/local/include"; then
435 if test -n "$GCC"; then
437 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
441 if test -z "$haveit"; then
442 for x in $CPPFLAGS $INC[]NAME; do
443 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
444 if test "X$x" = "X-I$additional_includedir"; then
449 if test -z "$haveit"; then
450 if test -d "$additional_includedir"; then
451 dnl Really add $additional_includedir to $INCNAME.
452 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
458 dnl Look for dependencies.
459 if test -n "$found_la"; then
460 dnl Read the .la file. It defines the variables
461 dnl dlname, library_names, old_library, dependency_libs, current,
462 dnl age, revision, installed, dlopen, dlpreopen, libdir.
463 save_libdir="$libdir"
465 */* | *\\*) . "$found_la" ;;
466 *) . "./$found_la" ;;
468 libdir="$save_libdir"
469 dnl We use only dependency_libs.
470 for dep in $dependency_libs; do
473 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
474 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
476 dnl 1. if it's the standard /usr/lib,
477 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
478 dnl 3. if it's already present in $LDFLAGS or the already
479 dnl constructed $LIBNAME,
480 dnl 4. if it doesn't exist as a directory.
481 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
483 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
484 if test -n "$GCC"; then
486 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
490 if test -z "$haveit"; then
492 for x in $LDFLAGS $LIB[]NAME; do
493 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
494 if test "X$x" = "X-L$additional_libdir"; then
499 if test -z "$haveit"; then
500 if test -d "$additional_libdir"; then
501 dnl Really add $additional_libdir to $LIBNAME.
502 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
506 for x in $LDFLAGS $LTLIB[]NAME; do
507 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
508 if test "X$x" = "X-L$additional_libdir"; then
513 if test -z "$haveit"; then
514 if test -d "$additional_libdir"; then
515 dnl Really add $additional_libdir to $LTLIBNAME.
516 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
523 dir=`echo "X$dep" | sed -e 's/^X-R//'`
524 if test "$enable_rpath" != no; then
525 dnl Potentially add DIR to rpathdirs.
526 dnl The rpathdirs will be appended to $LIBNAME at the end.
528 for x in $rpathdirs; do
529 if test "X$x" = "X$dir"; then
534 if test -z "$haveit"; then
535 rpathdirs="$rpathdirs $dir"
537 dnl Potentially add DIR to ltrpathdirs.
538 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
540 for x in $ltrpathdirs; do
541 if test "X$x" = "X$dir"; then
546 if test -z "$haveit"; then
547 ltrpathdirs="$ltrpathdirs $dir"
552 dnl Handle this in the next round.
553 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
556 dnl Handle this in the next round. Throw away the .la's
557 dnl directory; it is already contained in a preceding -L
559 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
562 dnl Most likely an immediate library name.
563 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
564 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
570 dnl Didn't find the library; assume it is in the system directories
571 dnl known to the linker and runtime loader. (All the system
572 dnl directories known to the linker should also be known to the
573 dnl runtime loader, otherwise the system is severely misconfigured.)
574 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
575 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
581 if test "X$rpathdirs" != "X"; then
582 if test -n "$acl_hardcode_libdir_separator"; then
583 dnl Weird platform: only the last -rpath option counts, the user must
584 dnl pass all path elements in one option. We can arrange that for a
585 dnl single library, but not when more than one $LIBNAMEs are used.
587 for found_dir in $rpathdirs; do
588 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
590 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
591 acl_save_libdir="$libdir"
593 eval flag=\"$acl_hardcode_libdir_flag_spec\"
594 libdir="$acl_save_libdir"
595 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
597 dnl The -rpath options are cumulative.
598 for found_dir in $rpathdirs; do
599 acl_save_libdir="$libdir"
601 eval flag=\"$acl_hardcode_libdir_flag_spec\"
602 libdir="$acl_save_libdir"
603 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
607 if test "X$ltrpathdirs" != "X"; then
608 dnl When using libtool, the option that works for both libraries and
609 dnl executables is -R. The -R options are cumulative.
610 for found_dir in $ltrpathdirs; do
611 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
616 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
617 dnl unless already present in VAR.
618 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
619 dnl contains two or three consecutive elements that belong together.
620 AC_DEFUN([AC_LIB_APPENDTOVAR],
622 for element in [$2]; do
625 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
626 if test "X$x" = "X$element"; then
631 if test -z "$haveit"; then
632 [$1]="${[$1]}${[$1]:+ }$element"
637 dnl For those cases where a variable contains several -L and -l options
638 dnl referring to unknown libraries and directories, this macro determines the
639 dnl necessary additional linker options for the runtime path.
640 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
641 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
642 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
643 dnl otherwise linking without libtool is assumed.
644 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
646 AC_REQUIRE([AC_LIB_RPATH])
647 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
649 if test "$enable_rpath" != no; then
650 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
651 dnl Use an explicit option to hardcode directories into the resulting
656 if test -n "$next"; then
658 dnl No need to hardcode the standard /usr/lib.
659 if test "X$dir" != "X/usr/$acl_libdirstem"; then
660 rpathdirs="$rpathdirs $dir"
666 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
667 dnl No need to hardcode the standard /usr/lib.
668 if test "X$dir" != "X/usr/$acl_libdirstem"; then
669 rpathdirs="$rpathdirs $dir"
676 if test "X$rpathdirs" != "X"; then
677 if test -n ""$3""; then
678 dnl libtool is used for linking. Use -R options.
679 for dir in $rpathdirs; do
680 $1="${$1}${$1:+ }-R$dir"
683 dnl The linker is used for linking directly.
684 if test -n "$acl_hardcode_libdir_separator"; then
685 dnl Weird platform: only the last -rpath option counts, the user
686 dnl must pass all path elements in one option.
688 for dir in $rpathdirs; do
689 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
691 acl_save_libdir="$libdir"
693 eval flag=\"$acl_hardcode_libdir_flag_spec\"
694 libdir="$acl_save_libdir"
697 dnl The -rpath options are cumulative.
698 for dir in $rpathdirs; do
699 acl_save_libdir="$libdir"
701 eval flag=\"$acl_hardcode_libdir_flag_spec\"
702 libdir="$acl_save_libdir"
703 $1="${$1}${$1:+ }$flag"