1 # lib-link.m4 serial 13 (gettext-0.17)
2 dnl Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free
3 dnl Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
12 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
13 dnl the libraries corresponding to explicit and implicit dependencies.
14 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
15 dnl augments the CPPFLAGS variable.
16 dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
17 dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
18 AC_DEFUN([AC_LIB_LINKFLAGS],
20 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
21 AC_REQUIRE([AC_LIB_RPATH])
22 define([Name],[translit([$1],[./-], [___])])
23 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
24 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
25 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
26 AC_LIB_LINKFLAGS_BODY([$1], [$2])
27 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
28 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
29 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
30 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
32 LIB[]NAME="$ac_cv_lib[]Name[]_libs"
33 LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
34 INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
35 LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
36 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
39 AC_SUBST([LIB]NAME[_PREFIX])
40 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
41 dnl results of this search when this library appears as a dependency.
47 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
48 dnl searches for libname and the libraries corresponding to explicit and
49 dnl implicit dependencies, together with the specified include files and
50 dnl the ability to compile and link the specified testcode. If found, it
51 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
52 dnl 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],
59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60 AC_REQUIRE([AC_LIB_RPATH])
61 define([Name],[translit([$1],[./-], [___])])
62 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
65 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
67 AC_LIB_LINKFLAGS_BODY([$1], [$2])
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)
75 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
77 LIBS="$LIBS $LIB[]NAME"
78 AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
81 if test "$ac_cv_lib[]Name" = yes; then
83 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
84 AC_MSG_CHECKING([how to link with lib[]$1])
85 AC_MSG_RESULT([$LIB[]NAME])
88 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
89 dnl $INC[]NAME either.
90 CPPFLAGS="$ac_save_CPPFLAGS"
95 AC_SUBST([HAVE_LIB]NAME)
98 AC_SUBST([LIB]NAME[_PREFIX])
103 dnl Determine the platform dependent parameters needed to use rpath:
106 dnl acl_hardcode_libdir_flag_spec,
107 dnl acl_hardcode_libdir_separator,
108 dnl acl_hardcode_direct,
109 dnl acl_hardcode_minus_L.
110 AC_DEFUN([AC_LIB_RPATH],
112 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
113 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
114 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
115 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
116 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
117 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
118 AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
119 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
120 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
126 acl_libext="$acl_cv_libext"
127 acl_shlibext="$acl_cv_shlibext"
128 acl_libname_spec="$acl_cv_libname_spec"
129 acl_library_names_spec="$acl_cv_library_names_spec"
130 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
131 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
132 acl_hardcode_direct="$acl_cv_hardcode_direct"
133 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
134 dnl Determine whether the user wants rpath handling at all.
136 [ --disable-rpath do not hardcode runtime library paths],
140 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
141 dnl the libraries corresponding to explicit and implicit dependencies.
142 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
143 dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
144 dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
145 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
147 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
148 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
149 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
150 dnl Autoconf >= 2.61 supports dots in --with options.
151 define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
152 dnl By default, look in $includedir and $libdir.
154 AC_LIB_WITH_FINAL_PREFIX([
155 eval additional_includedir=\"$includedir\"
156 eval additional_libdir=\"$libdir\"
158 AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
159 [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
160 --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
162 if test "X$withval" = "Xno"; then
165 if test "X$withval" = "X"; then
166 AC_LIB_WITH_FINAL_PREFIX([
167 eval additional_includedir=\"$includedir\"
168 eval additional_libdir=\"$libdir\"
171 additional_includedir="$withval/include"
172 additional_libdir="$withval/$acl_libdirstem"
176 dnl Search the library and its dependencies in $additional_libdir and
177 dnl $LDFLAGS. Using breadth-first-seach.
184 names_already_handled=
185 names_next_round='$1 $2'
186 while test -n "$names_next_round"; do
187 names_this_round="$names_next_round"
189 for name in $names_this_round; do
191 for n in $names_already_handled; do
192 if test "$n" = "$name"; then
197 if test -z "$already_handled"; then
198 names_already_handled="$names_already_handled $name"
199 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
200 dnl or AC_LIB_HAVE_LINKFLAGS call.
201 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
202 eval value=\"\$HAVE_LIB$uppername\"
203 if test -n "$value"; then
204 if test "$value" = yes; then
205 eval value=\"\$LIB$uppername\"
206 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
207 eval value=\"\$LTLIB$uppername\"
208 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
210 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
211 dnl that this library doesn't exist. So just drop it.
215 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
216 dnl and the already constructed $LIBNAME/$LTLIBNAME.
221 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
222 if test -n "$acl_shlibext"; then
223 shrext=".$acl_shlibext" # typically: shrext=.so
227 if test $use_additional = yes; then
228 dir="$additional_libdir"
229 dnl The same code as in the loop below:
230 dnl First look for a shared library.
231 if test -n "$acl_shlibext"; then
232 if test -f "$dir/$libname$shrext"; then
234 found_so="$dir/$libname$shrext"
236 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
238 for f in "$libname$shrext".*; do echo "$f"; done \
239 | sed -e "s,^$libname$shrext\\\\.,," \
240 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
241 | sed 1q ) 2>/dev/null`
242 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
244 found_so="$dir/$libname$shrext.$ver"
247 eval library_names=\"$acl_library_names_spec\"
248 for f in $library_names; do
249 if test -f "$dir/$f"; then
258 dnl Then look for a static library.
259 if test "X$found_dir" = "X"; then
260 if test -f "$dir/$libname.$acl_libext"; then
262 found_a="$dir/$libname.$acl_libext"
265 if test "X$found_dir" != "X"; then
266 if test -f "$dir/$libname.la"; then
267 found_la="$dir/$libname.la"
271 if test "X$found_dir" = "X"; then
272 for x in $LDFLAGS $LTLIB[]NAME; do
273 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
276 dir=`echo "X$x" | sed -e 's/^X-L//'`
277 dnl First look for a shared library.
278 if test -n "$acl_shlibext"; then
279 if test -f "$dir/$libname$shrext"; then
281 found_so="$dir/$libname$shrext"
283 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
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
291 found_so="$dir/$libname$shrext.$ver"
294 eval library_names=\"$acl_library_names_spec\"
295 for f in $library_names; do
296 if test -f "$dir/$f"; then
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
309 found_a="$dir/$libname.$acl_libext"
312 if test "X$found_dir" != "X"; then
313 if test -f "$dir/$libname.la"; then
314 found_la="$dir/$libname.la"
319 if test "X$found_dir" != "X"; then
324 if test "X$found_dir" != "X"; then
325 dnl Found the library.
326 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
327 if test "X$found_so" != "X"; then
328 dnl Linking with a shared library. We attempt to hardcode its
329 dnl directory into the executable's runpath, unless it's the
330 dnl standard /usr/lib.
331 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
332 dnl No hardcoding is needed.
333 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
335 dnl Use an explicit option to hardcode DIR into the resulting
337 dnl Potentially add DIR to ltrpathdirs.
338 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
340 for x in $ltrpathdirs; do
341 if test "X$x" = "X$found_dir"; then
346 if test -z "$haveit"; then
347 ltrpathdirs="$ltrpathdirs $found_dir"
349 dnl The hardcoding into $LIBNAME is system dependent.
350 if test "$acl_hardcode_direct" = yes; then
351 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
352 dnl resulting binary.
353 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
355 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
356 dnl Use an explicit option to hardcode DIR into the resulting
358 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
359 dnl Potentially add DIR to rpathdirs.
360 dnl The rpathdirs will be appended to $LIBNAME at the end.
362 for x in $rpathdirs; do
363 if test "X$x" = "X$found_dir"; then
368 if test -z "$haveit"; then
369 rpathdirs="$rpathdirs $found_dir"
372 dnl Rely on "-L$found_dir".
373 dnl But don't add it if it's already contained in the LDFLAGS
374 dnl or the already constructed $LIBNAME
376 for x in $LDFLAGS $LIB[]NAME; do
377 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
378 if test "X$x" = "X-L$found_dir"; then
383 if test -z "$haveit"; then
384 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
386 if test "$acl_hardcode_minus_L" != no; then
387 dnl FIXME: Not sure whether we should use
388 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
390 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
392 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
393 dnl here, because this doesn't fit in flags passed to the
394 dnl compiler. So give up. No hardcoding. This affects only
395 dnl very old systems.
396 dnl FIXME: Not sure whether we should use
397 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
399 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
405 if test "X$found_a" != "X"; then
406 dnl Linking with a static library.
407 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
409 dnl We shouldn't come here, but anyway it's good to have a
411 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
414 dnl Assume the include files are nearby.
415 additional_includedir=
417 */$acl_libdirstem | */$acl_libdirstem/)
418 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
419 LIB[]NAME[]_PREFIX="$basedir"
420 additional_includedir="$basedir/include"
423 if test "X$additional_includedir" != "X"; then
424 dnl Potentially add $additional_includedir to $INCNAME.
426 dnl 1. if it's the standard /usr/include,
427 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
428 dnl 3. if it's already present in $CPPFLAGS or the already
429 dnl constructed $INCNAME,
430 dnl 4. if it doesn't exist as a directory.
431 if test "X$additional_includedir" != "X/usr/include"; then
433 if test "X$additional_includedir" = "X/usr/local/include"; then
434 if test -n "$GCC"; then
436 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
440 if test -z "$haveit"; then
441 for x in $CPPFLAGS $INC[]NAME; do
442 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
443 if test "X$x" = "X-I$additional_includedir"; then
448 if test -z "$haveit"; then
449 if test -d "$additional_includedir"; then
450 dnl Really add $additional_includedir to $INCNAME.
451 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
457 dnl Look for dependencies.
458 if test -n "$found_la"; then
459 dnl Read the .la file. It defines the variables
460 dnl dlname, library_names, old_library, dependency_libs, current,
461 dnl age, revision, installed, dlopen, dlpreopen, libdir.
462 save_libdir="$libdir"
464 */* | *\\*) . "$found_la" ;;
465 *) . "./$found_la" ;;
467 libdir="$save_libdir"
468 dnl We use only dependency_libs.
469 for dep in $dependency_libs; do
472 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
473 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
475 dnl 1. if it's the standard /usr/lib,
476 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
477 dnl 3. if it's already present in $LDFLAGS or the already
478 dnl constructed $LIBNAME,
479 dnl 4. if it doesn't exist as a directory.
480 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
482 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
483 if test -n "$GCC"; then
485 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
489 if test -z "$haveit"; then
491 for x in $LDFLAGS $LIB[]NAME; do
492 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
493 if test "X$x" = "X-L$additional_libdir"; then
498 if test -z "$haveit"; then
499 if test -d "$additional_libdir"; then
500 dnl Really add $additional_libdir to $LIBNAME.
501 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
505 for x in $LDFLAGS $LTLIB[]NAME; do
506 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
507 if test "X$x" = "X-L$additional_libdir"; then
512 if test -z "$haveit"; then
513 if test -d "$additional_libdir"; then
514 dnl Really add $additional_libdir to $LTLIBNAME.
515 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
522 dir=`echo "X$dep" | sed -e 's/^X-R//'`
523 if test "$enable_rpath" != no; then
524 dnl Potentially add DIR to rpathdirs.
525 dnl The rpathdirs will be appended to $LIBNAME at the end.
527 for x in $rpathdirs; do
528 if test "X$x" = "X$dir"; then
533 if test -z "$haveit"; then
534 rpathdirs="$rpathdirs $dir"
536 dnl Potentially add DIR to ltrpathdirs.
537 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
539 for x in $ltrpathdirs; do
540 if test "X$x" = "X$dir"; then
545 if test -z "$haveit"; then
546 ltrpathdirs="$ltrpathdirs $dir"
551 dnl Handle this in the next round.
552 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
555 dnl Handle this in the next round. Throw away the .la's
556 dnl directory; it is already contained in a preceding -L
558 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
561 dnl Most likely an immediate library name.
562 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
563 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
569 dnl Didn't find the library; assume it is in the system directories
570 dnl known to the linker and runtime loader. (All the system
571 dnl directories known to the linker should also be known to the
572 dnl runtime loader, otherwise the system is severely misconfigured.)
573 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
574 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
580 if test "X$rpathdirs" != "X"; then
581 if test -n "$acl_hardcode_libdir_separator"; then
582 dnl Weird platform: only the last -rpath option counts, the user must
583 dnl pass all path elements in one option. We can arrange that for a
584 dnl single library, but not when more than one $LIBNAMEs are used.
586 for found_dir in $rpathdirs; do
587 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
589 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
590 acl_save_libdir="$libdir"
592 eval flag=\"$acl_hardcode_libdir_flag_spec\"
593 libdir="$acl_save_libdir"
594 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
596 dnl The -rpath options are cumulative.
597 for found_dir in $rpathdirs; do
598 acl_save_libdir="$libdir"
600 eval flag=\"$acl_hardcode_libdir_flag_spec\"
601 libdir="$acl_save_libdir"
602 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
606 if test "X$ltrpathdirs" != "X"; then
607 dnl When using libtool, the option that works for both libraries and
608 dnl executables is -R. The -R options are cumulative.
609 for found_dir in $ltrpathdirs; do
610 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
615 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
616 dnl unless already present in VAR.
617 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
618 dnl contains two or three consecutive elements that belong together.
619 AC_DEFUN([AC_LIB_APPENDTOVAR],
621 for element in [$2]; do
624 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
625 if test "X$x" = "X$element"; then
630 if test -z "$haveit"; then
631 [$1]="${[$1]}${[$1]:+ }$element"
636 dnl For those cases where a variable contains several -L and -l options
637 dnl referring to unknown libraries and directories, this macro determines the
638 dnl necessary additional linker options for the runtime path.
639 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
640 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
641 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
642 dnl otherwise linking without libtool is assumed.
643 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
645 AC_REQUIRE([AC_LIB_RPATH])
646 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
648 if test "$enable_rpath" != no; then
649 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
650 dnl Use an explicit option to hardcode directories into the resulting
655 if test -n "$next"; then
657 dnl No need to hardcode the standard /usr/lib.
658 if test "X$dir" != "X/usr/$acl_libdirstem"; then
659 rpathdirs="$rpathdirs $dir"
665 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
666 dnl No need to hardcode the standard /usr/lib.
667 if test "X$dir" != "X/usr/$acl_libdirstem"; then
668 rpathdirs="$rpathdirs $dir"
675 if test "X$rpathdirs" != "X"; then
676 if test -n ""$3""; then
677 dnl libtool is used for linking. Use -R options.
678 for dir in $rpathdirs; do
679 $1="${$1}${$1:+ }-R$dir"
682 dnl The linker is used for linking directly.
683 if test -n "$acl_hardcode_libdir_separator"; then
684 dnl Weird platform: only the last -rpath option counts, the user
685 dnl must pass all path elements in one option.
687 for dir in $rpathdirs; do
688 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
690 acl_save_libdir="$libdir"
692 eval flag=\"$acl_hardcode_libdir_flag_spec\"
693 libdir="$acl_save_libdir"
696 dnl The -rpath options are cumulative.
697 for dir in $rpathdirs; do
698 acl_save_libdir="$libdir"
700 eval flag=\"$acl_hardcode_libdir_flag_spec\"
701 libdir="$acl_save_libdir"
702 $1="${$1}${$1:+ }$flag"