1 # lib-link.m4 serial 13 (gettext-0.16.2)
2 dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
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],
19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20 AC_REQUIRE([AC_LIB_RPATH])
21 define([Name],[translit([$1],[./-], [___])])
22 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
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)
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.
46 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
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. If found, it
50 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
51 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
52 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
53 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
54 dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
55 dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
56 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
58 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
59 AC_REQUIRE([AC_LIB_RPATH])
60 define([Name],[translit([$1],[./-], [___])])
61 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
64 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
66 AC_LIB_LINKFLAGS_BODY([$1], [$2])
68 dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
69 dnl because if the user has installed lib[]Name and not disabled its use
70 dnl via --without-lib[]Name-prefix, he wants to use it.
71 ac_save_CPPFLAGS="$CPPFLAGS"
72 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
74 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
76 LIBS="$LIBS $LIB[]NAME"
77 AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
80 if test "$ac_cv_lib[]Name" = yes; then
82 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
83 AC_MSG_CHECKING([how to link with lib[]$1])
84 AC_MSG_RESULT([$LIB[]NAME])
87 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
88 dnl $INC[]NAME either.
89 CPPFLAGS="$ac_save_CPPFLAGS"
94 AC_SUBST([HAVE_LIB]NAME)
97 AC_SUBST([LIB]NAME[_PREFIX])
102 dnl Determine the platform dependent parameters needed to use rpath:
105 dnl acl_hardcode_libdir_flag_spec,
106 dnl acl_hardcode_libdir_separator,
107 dnl acl_hardcode_direct,
108 dnl acl_hardcode_minus_L.
109 AC_DEFUN([AC_LIB_RPATH],
111 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
112 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
113 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
114 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
115 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
116 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
117 AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
118 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
119 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
125 acl_libext="$acl_cv_libext"
126 acl_shlibext="$acl_cv_shlibext"
127 acl_libname_spec="$acl_cv_libname_spec"
128 acl_library_names_spec="$acl_cv_library_names_spec"
129 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
130 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
131 acl_hardcode_direct="$acl_cv_hardcode_direct"
132 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
133 dnl Determine whether the user wants rpath handling at all.
135 [ --disable-rpath do not hardcode runtime library paths],
139 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
140 dnl the libraries corresponding to explicit and implicit dependencies.
141 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
142 dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
143 dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
144 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
146 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
147 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
148 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
149 dnl Autoconf >= 2.61 supports dots in --with options.
150 define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
151 dnl By default, look in $includedir and $libdir.
153 AC_LIB_WITH_FINAL_PREFIX([
154 eval additional_includedir=\"$includedir\"
155 eval additional_libdir=\"$libdir\"
157 AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
158 [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
159 --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
161 if test "X$withval" = "Xno"; then
164 if test "X$withval" = "X"; then
165 AC_LIB_WITH_FINAL_PREFIX([
166 eval additional_includedir=\"$includedir\"
167 eval additional_libdir=\"$libdir\"
170 additional_includedir="$withval/include"
171 additional_libdir="$withval/$acl_libdirstem"
175 dnl Search the library and its dependencies in $additional_libdir and
176 dnl $LDFLAGS. Using breadth-first-seach.
183 names_already_handled=
184 names_next_round='$1 $2'
185 while test -n "$names_next_round"; do
186 names_this_round="$names_next_round"
188 for name in $names_this_round; do
190 for n in $names_already_handled; do
191 if test "$n" = "$name"; then
196 if test -z "$already_handled"; then
197 names_already_handled="$names_already_handled $name"
198 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
199 dnl or AC_LIB_HAVE_LINKFLAGS call.
200 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
201 eval value=\"\$HAVE_LIB$uppername\"
202 if test -n "$value"; then
203 if test "$value" = yes; then
204 eval value=\"\$LIB$uppername\"
205 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
206 eval value=\"\$LTLIB$uppername\"
207 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
209 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
210 dnl that this library doesn't exist. So just drop it.
214 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
215 dnl and the already constructed $LIBNAME/$LTLIBNAME.
220 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
221 if test -n "$acl_shlibext"; then
222 shrext=".$acl_shlibext" # typically: shrext=.so
226 if test $use_additional = yes; then
227 dir="$additional_libdir"
228 dnl The same code as in the loop below:
229 dnl First look for a shared library.
230 if test -n "$acl_shlibext"; then
231 if test -f "$dir/$libname$shrext"; then
233 found_so="$dir/$libname$shrext"
235 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
237 for f in "$libname$shrext".*; do echo "$f"; done \
238 | sed -e "s,^$libname$shrext\\\\.,," \
239 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
240 | sed 1q ) 2>/dev/null`
241 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
243 found_so="$dir/$libname$shrext.$ver"
246 eval library_names=\"$acl_library_names_spec\"
247 for f in $library_names; do
248 if test -f "$dir/$f"; then
257 dnl Then look for a static library.
258 if test "X$found_dir" = "X"; then
259 if test -f "$dir/$libname.$acl_libext"; then
261 found_a="$dir/$libname.$acl_libext"
264 if test "X$found_dir" != "X"; then
265 if test -f "$dir/$libname.la"; then
266 found_la="$dir/$libname.la"
270 if test "X$found_dir" = "X"; then
271 for x in $LDFLAGS $LTLIB[]NAME; do
272 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
275 dir=`echo "X$x" | sed -e 's/^X-L//'`
276 dnl First look for a shared library.
277 if test -n "$acl_shlibext"; then
278 if test -f "$dir/$libname$shrext"; then
280 found_so="$dir/$libname$shrext"
282 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
284 for f in "$libname$shrext".*; do echo "$f"; done \
285 | sed -e "s,^$libname$shrext\\\\.,," \
286 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
287 | sed 1q ) 2>/dev/null`
288 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
290 found_so="$dir/$libname$shrext.$ver"
293 eval library_names=\"$acl_library_names_spec\"
294 for f in $library_names; do
295 if test -f "$dir/$f"; then
304 dnl Then look for a static library.
305 if test "X$found_dir" = "X"; then
306 if test -f "$dir/$libname.$acl_libext"; then
308 found_a="$dir/$libname.$acl_libext"
311 if test "X$found_dir" != "X"; then
312 if test -f "$dir/$libname.la"; then
313 found_la="$dir/$libname.la"
318 if test "X$found_dir" != "X"; then
323 if test "X$found_dir" != "X"; then
324 dnl Found the library.
325 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
326 if test "X$found_so" != "X"; then
327 dnl Linking with a shared library. We attempt to hardcode its
328 dnl directory into the executable's runpath, unless it's the
329 dnl standard /usr/lib.
330 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
331 dnl No hardcoding is needed.
332 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
334 dnl Use an explicit option to hardcode DIR into the resulting
336 dnl Potentially add DIR to ltrpathdirs.
337 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
339 for x in $ltrpathdirs; do
340 if test "X$x" = "X$found_dir"; then
345 if test -z "$haveit"; then
346 ltrpathdirs="$ltrpathdirs $found_dir"
348 dnl The hardcoding into $LIBNAME is system dependent.
349 if test "$acl_hardcode_direct" = yes; then
350 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
351 dnl resulting binary.
352 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
354 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
355 dnl Use an explicit option to hardcode DIR into the resulting
357 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
358 dnl Potentially add DIR to rpathdirs.
359 dnl The rpathdirs will be appended to $LIBNAME at the end.
361 for x in $rpathdirs; do
362 if test "X$x" = "X$found_dir"; then
367 if test -z "$haveit"; then
368 rpathdirs="$rpathdirs $found_dir"
371 dnl Rely on "-L$found_dir".
372 dnl But don't add it if it's already contained in the LDFLAGS
373 dnl or the already constructed $LIBNAME
375 for x in $LDFLAGS $LIB[]NAME; do
376 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
377 if test "X$x" = "X-L$found_dir"; then
382 if test -z "$haveit"; then
383 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
385 if test "$acl_hardcode_minus_L" != no; then
386 dnl FIXME: Not sure whether we should use
387 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
389 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
391 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
392 dnl here, because this doesn't fit in flags passed to the
393 dnl compiler. So give up. No hardcoding. This affects only
394 dnl very old systems.
395 dnl FIXME: Not sure whether we should use
396 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
398 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
404 if test "X$found_a" != "X"; then
405 dnl Linking with a static library.
406 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
408 dnl We shouldn't come here, but anyway it's good to have a
410 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
413 dnl Assume the include files are nearby.
414 additional_includedir=
416 */$acl_libdirstem | */$acl_libdirstem/)
417 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
418 LIB[]NAME[]_PREFIX="$basedir"
419 additional_includedir="$basedir/include"
422 if test "X$additional_includedir" != "X"; then
423 dnl Potentially add $additional_includedir to $INCNAME.
425 dnl 1. if it's the standard /usr/include,
426 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
427 dnl 3. if it's already present in $CPPFLAGS or the already
428 dnl constructed $INCNAME,
429 dnl 4. if it doesn't exist as a directory.
430 if test "X$additional_includedir" != "X/usr/include"; then
432 if test "X$additional_includedir" = "X/usr/local/include"; then
433 if test -n "$GCC"; then
435 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
439 if test -z "$haveit"; then
440 for x in $CPPFLAGS $INC[]NAME; do
441 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
442 if test "X$x" = "X-I$additional_includedir"; then
447 if test -z "$haveit"; then
448 if test -d "$additional_includedir"; then
449 dnl Really add $additional_includedir to $INCNAME.
450 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
456 dnl Look for dependencies.
457 if test -n "$found_la"; then
458 dnl Read the .la file. It defines the variables
459 dnl dlname, library_names, old_library, dependency_libs, current,
460 dnl age, revision, installed, dlopen, dlpreopen, libdir.
461 save_libdir="$libdir"
463 */* | *\\*) . "$found_la" ;;
464 *) . "./$found_la" ;;
466 libdir="$save_libdir"
467 dnl We use only dependency_libs.
468 for dep in $dependency_libs; do
471 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
472 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
474 dnl 1. if it's the standard /usr/lib,
475 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
476 dnl 3. if it's already present in $LDFLAGS or the already
477 dnl constructed $LIBNAME,
478 dnl 4. if it doesn't exist as a directory.
479 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
481 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
482 if test -n "$GCC"; then
484 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
488 if test -z "$haveit"; then
490 for x in $LDFLAGS $LIB[]NAME; do
491 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
492 if test "X$x" = "X-L$additional_libdir"; then
497 if test -z "$haveit"; then
498 if test -d "$additional_libdir"; then
499 dnl Really add $additional_libdir to $LIBNAME.
500 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
504 for x in $LDFLAGS $LTLIB[]NAME; do
505 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
506 if test "X$x" = "X-L$additional_libdir"; then
511 if test -z "$haveit"; then
512 if test -d "$additional_libdir"; then
513 dnl Really add $additional_libdir to $LTLIBNAME.
514 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
521 dir=`echo "X$dep" | sed -e 's/^X-R//'`
522 if test "$enable_rpath" != no; then
523 dnl Potentially add DIR to rpathdirs.
524 dnl The rpathdirs will be appended to $LIBNAME at the end.
526 for x in $rpathdirs; do
527 if test "X$x" = "X$dir"; then
532 if test -z "$haveit"; then
533 rpathdirs="$rpathdirs $dir"
535 dnl Potentially add DIR to ltrpathdirs.
536 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
538 for x in $ltrpathdirs; do
539 if test "X$x" = "X$dir"; then
544 if test -z "$haveit"; then
545 ltrpathdirs="$ltrpathdirs $dir"
550 dnl Handle this in the next round.
551 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
554 dnl Handle this in the next round. Throw away the .la's
555 dnl directory; it is already contained in a preceding -L
557 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
560 dnl Most likely an immediate library name.
561 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
562 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
568 dnl Didn't find the library; assume it is in the system directories
569 dnl known to the linker and runtime loader. (All the system
570 dnl directories known to the linker should also be known to the
571 dnl runtime loader, otherwise the system is severely misconfigured.)
572 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
573 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
579 if test "X$rpathdirs" != "X"; then
580 if test -n "$acl_hardcode_libdir_separator"; then
581 dnl Weird platform: only the last -rpath option counts, the user must
582 dnl pass all path elements in one option. We can arrange that for a
583 dnl single library, but not when more than one $LIBNAMEs are used.
585 for found_dir in $rpathdirs; do
586 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
588 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
589 acl_save_libdir="$libdir"
591 eval flag=\"$acl_hardcode_libdir_flag_spec\"
592 libdir="$acl_save_libdir"
593 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
595 dnl The -rpath options are cumulative.
596 for found_dir in $rpathdirs; do
597 acl_save_libdir="$libdir"
599 eval flag=\"$acl_hardcode_libdir_flag_spec\"
600 libdir="$acl_save_libdir"
601 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
605 if test "X$ltrpathdirs" != "X"; then
606 dnl When using libtool, the option that works for both libraries and
607 dnl executables is -R. The -R options are cumulative.
608 for found_dir in $ltrpathdirs; do
609 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
614 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
615 dnl unless already present in VAR.
616 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
617 dnl contains two or three consecutive elements that belong together.
618 AC_DEFUN([AC_LIB_APPENDTOVAR],
620 for element in [$2]; do
623 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
624 if test "X$x" = "X$element"; then
629 if test -z "$haveit"; then
630 [$1]="${[$1]}${[$1]:+ }$element"
635 dnl For those cases where a variable contains several -L and -l options
636 dnl referring to unknown libraries and directories, this macro determines the
637 dnl necessary additional linker options for the runtime path.
638 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
639 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
640 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
641 dnl otherwise linking without libtool is assumed.
642 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
644 AC_REQUIRE([AC_LIB_RPATH])
645 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
647 if test "$enable_rpath" != no; then
648 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
649 dnl Use an explicit option to hardcode directories into the resulting
654 if test -n "$next"; then
656 dnl No need to hardcode the standard /usr/lib.
657 if test "X$dir" != "X/usr/$acl_libdirstem"; then
658 rpathdirs="$rpathdirs $dir"
664 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
665 dnl No need to hardcode the standard /usr/lib.
666 if test "X$dir" != "X/usr/$acl_libdirstem"; then
667 rpathdirs="$rpathdirs $dir"
674 if test "X$rpathdirs" != "X"; then
675 if test -n ""$3""; then
676 dnl libtool is used for linking. Use -R options.
677 for dir in $rpathdirs; do
678 $1="${$1}${$1:+ }-R$dir"
681 dnl The linker is used for linking directly.
682 if test -n "$acl_hardcode_libdir_separator"; then
683 dnl Weird platform: only the last -rpath option counts, the user
684 dnl must pass all path elements in one option.
686 for dir in $rpathdirs; do
687 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
689 acl_save_libdir="$libdir"
691 eval flag=\"$acl_hardcode_libdir_flag_spec\"
692 libdir="$acl_save_libdir"
695 dnl The -rpath options are cumulative.
696 for dir in $rpathdirs; do
697 acl_save_libdir="$libdir"
699 eval flag=\"$acl_hardcode_libdir_flag_spec\"
700 libdir="$acl_save_libdir"
701 $1="${$1}${$1:+ }$flag"