1 # lib-link.m4 serial 20 (gettext-0.18)
2 dnl Copyright (C) 2001-2010 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 pushdef([Name],[translit([$1],[./-], [___])])
22 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
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, [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],
59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60 AC_REQUIRE([AC_LIB_RPATH])
61 pushdef([Name],[translit([$1],[./-], [___])])
62 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
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],
79 [ac_cv_lib[]Name=yes],
80 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
83 if test "$ac_cv_lib[]Name" = yes; then
85 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
86 AC_MSG_CHECKING([how to link with lib[]$1])
87 AC_MSG_RESULT([$LIB[]NAME])
90 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
91 dnl $INC[]NAME either.
92 CPPFLAGS="$ac_save_CPPFLAGS"
97 AC_SUBST([HAVE_LIB]NAME)
100 AC_SUBST([LIB]NAME[_PREFIX])
105 dnl Determine the platform dependent parameters needed to use rpath:
108 dnl acl_hardcode_libdir_flag_spec,
109 dnl acl_hardcode_libdir_separator,
110 dnl acl_hardcode_direct,
111 dnl acl_hardcode_minus_L.
112 AC_DEFUN([AC_LIB_RPATH],
114 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
115 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
116 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
117 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
118 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
119 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
120 AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
121 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
122 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
128 acl_libext="$acl_cv_libext"
129 acl_shlibext="$acl_cv_shlibext"
130 acl_libname_spec="$acl_cv_libname_spec"
131 acl_library_names_spec="$acl_cv_library_names_spec"
132 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
133 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
134 acl_hardcode_direct="$acl_cv_hardcode_direct"
135 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
136 dnl Determine whether the user wants rpath handling at all.
137 AC_ARG_ENABLE([rpath],
138 [ --disable-rpath do not hardcode runtime library paths],
142 dnl AC_LIB_FROMPACKAGE(name, package)
143 dnl declares that libname comes from the given package. The configure file
144 dnl will then not have a --with-libname-prefix option but a
145 dnl --with-package-prefix option. Several libraries can come from the same
146 dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
147 dnl macro call that searches for libname.
148 AC_DEFUN([AC_LIB_FROMPACKAGE],
150 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
151 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
152 define([acl_frompackage_]NAME, [$2])
155 pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
156 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
157 define([acl_libsinpackage_]PACKUP,
158 m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
163 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
164 dnl the libraries corresponding to explicit and implicit dependencies.
165 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
166 dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
167 dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
168 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
170 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
171 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
172 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
173 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
174 pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
175 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
176 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
177 dnl Autoconf >= 2.61 supports dots in --with options.
178 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
179 dnl By default, look in $includedir and $libdir.
181 AC_LIB_WITH_FINAL_PREFIX([
182 eval additional_includedir=\"$includedir\"
183 eval additional_libdir=\"$libdir\"
185 AC_ARG_WITH(P_A_C_K[-prefix],
186 [[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
187 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
189 if test "X$withval" = "Xno"; then
192 if test "X$withval" = "X"; then
193 AC_LIB_WITH_FINAL_PREFIX([
194 eval additional_includedir=\"$includedir\"
195 eval additional_libdir=\"$libdir\"
198 additional_includedir="$withval/include"
199 additional_libdir="$withval/$acl_libdirstem"
200 if test "$acl_libdirstem2" != "$acl_libdirstem" \
201 && ! test -d "$withval/$acl_libdirstem"; then
202 additional_libdir="$withval/$acl_libdirstem2"
207 dnl Search the library and its dependencies in $additional_libdir and
208 dnl $LDFLAGS. Using breadth-first-seach.
213 dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
214 dnl computed. So it has to be reset here.
218 names_already_handled=
219 names_next_round='$1 $2'
220 while test -n "$names_next_round"; do
221 names_this_round="$names_next_round"
223 for name in $names_this_round; do
225 for n in $names_already_handled; do
226 if test "$n" = "$name"; then
231 if test -z "$already_handled"; then
232 names_already_handled="$names_already_handled $name"
233 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
234 dnl or AC_LIB_HAVE_LINKFLAGS call.
235 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
236 eval value=\"\$HAVE_LIB$uppername\"
237 if test -n "$value"; then
238 if test "$value" = yes; then
239 eval value=\"\$LIB$uppername\"
240 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
241 eval value=\"\$LTLIB$uppername\"
242 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
244 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
245 dnl that this library doesn't exist. So just drop it.
249 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
250 dnl and the already constructed $LIBNAME/$LTLIBNAME.
255 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
256 if test -n "$acl_shlibext"; then
257 shrext=".$acl_shlibext" # typically: shrext=.so
261 if test $use_additional = yes; then
262 dir="$additional_libdir"
263 dnl The same code as in the loop below:
264 dnl First look for a shared library.
265 if test -n "$acl_shlibext"; then
266 if test -f "$dir/$libname$shrext"; then
268 found_so="$dir/$libname$shrext"
270 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
272 for f in "$libname$shrext".*; do echo "$f"; done \
273 | sed -e "s,^$libname$shrext\\\\.,," \
274 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
275 | sed 1q ) 2>/dev/null`
276 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
278 found_so="$dir/$libname$shrext.$ver"
281 eval library_names=\"$acl_library_names_spec\"
282 for f in $library_names; do
283 if test -f "$dir/$f"; then
292 dnl Then look for a static library.
293 if test "X$found_dir" = "X"; then
294 if test -f "$dir/$libname.$acl_libext"; then
296 found_a="$dir/$libname.$acl_libext"
299 if test "X$found_dir" != "X"; then
300 if test -f "$dir/$libname.la"; then
301 found_la="$dir/$libname.la"
305 if test "X$found_dir" = "X"; then
306 for x in $LDFLAGS $LTLIB[]NAME; do
307 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
310 dir=`echo "X$x" | sed -e 's/^X-L//'`
311 dnl First look for a shared library.
312 if test -n "$acl_shlibext"; then
313 if test -f "$dir/$libname$shrext"; then
315 found_so="$dir/$libname$shrext"
317 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
319 for f in "$libname$shrext".*; do echo "$f"; done \
320 | sed -e "s,^$libname$shrext\\\\.,," \
321 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
322 | sed 1q ) 2>/dev/null`
323 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
325 found_so="$dir/$libname$shrext.$ver"
328 eval library_names=\"$acl_library_names_spec\"
329 for f in $library_names; do
330 if test -f "$dir/$f"; then
339 dnl Then look for a static library.
340 if test "X$found_dir" = "X"; then
341 if test -f "$dir/$libname.$acl_libext"; then
343 found_a="$dir/$libname.$acl_libext"
346 if test "X$found_dir" != "X"; then
347 if test -f "$dir/$libname.la"; then
348 found_la="$dir/$libname.la"
353 if test "X$found_dir" != "X"; then
358 if test "X$found_dir" != "X"; then
359 dnl Found the library.
360 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
361 if test "X$found_so" != "X"; then
362 dnl Linking with a shared library. We attempt to hardcode its
363 dnl directory into the executable's runpath, unless it's the
364 dnl standard /usr/lib.
365 if test "$enable_rpath" = no \
366 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
367 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
368 dnl No hardcoding is needed.
369 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
371 dnl Use an explicit option to hardcode DIR into the resulting
373 dnl Potentially add DIR to ltrpathdirs.
374 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
376 for x in $ltrpathdirs; do
377 if test "X$x" = "X$found_dir"; then
382 if test -z "$haveit"; then
383 ltrpathdirs="$ltrpathdirs $found_dir"
385 dnl The hardcoding into $LIBNAME is system dependent.
386 if test "$acl_hardcode_direct" = yes; then
387 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
388 dnl resulting binary.
389 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
391 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
392 dnl Use an explicit option to hardcode DIR into the resulting
394 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
395 dnl Potentially add DIR to rpathdirs.
396 dnl The rpathdirs will be appended to $LIBNAME at the end.
398 for x in $rpathdirs; do
399 if test "X$x" = "X$found_dir"; then
404 if test -z "$haveit"; then
405 rpathdirs="$rpathdirs $found_dir"
408 dnl Rely on "-L$found_dir".
409 dnl But don't add it if it's already contained in the LDFLAGS
410 dnl or the already constructed $LIBNAME
412 for x in $LDFLAGS $LIB[]NAME; do
413 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
414 if test "X$x" = "X-L$found_dir"; then
419 if test -z "$haveit"; then
420 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
422 if test "$acl_hardcode_minus_L" != no; then
423 dnl FIXME: Not sure whether we should use
424 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
426 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
428 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
429 dnl here, because this doesn't fit in flags passed to the
430 dnl compiler. So give up. No hardcoding. This affects only
431 dnl very old systems.
432 dnl FIXME: Not sure whether we should use
433 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
435 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
441 if test "X$found_a" != "X"; then
442 dnl Linking with a static library.
443 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
445 dnl We shouldn't come here, but anyway it's good to have a
447 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
450 dnl Assume the include files are nearby.
451 additional_includedir=
453 */$acl_libdirstem | */$acl_libdirstem/)
454 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
455 if test "$name" = '$1'; then
456 LIB[]NAME[]_PREFIX="$basedir"
458 additional_includedir="$basedir/include"
460 */$acl_libdirstem2 | */$acl_libdirstem2/)
461 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
462 if test "$name" = '$1'; then
463 LIB[]NAME[]_PREFIX="$basedir"
465 additional_includedir="$basedir/include"
468 if test "X$additional_includedir" != "X"; then
469 dnl Potentially add $additional_includedir to $INCNAME.
471 dnl 1. if it's the standard /usr/include,
472 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
473 dnl 3. if it's already present in $CPPFLAGS or the already
474 dnl constructed $INCNAME,
475 dnl 4. if it doesn't exist as a directory.
476 if test "X$additional_includedir" != "X/usr/include"; then
478 if test "X$additional_includedir" = "X/usr/local/include"; then
479 if test -n "$GCC"; then
481 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
485 if test -z "$haveit"; then
486 for x in $CPPFLAGS $INC[]NAME; do
487 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
488 if test "X$x" = "X-I$additional_includedir"; then
493 if test -z "$haveit"; then
494 if test -d "$additional_includedir"; then
495 dnl Really add $additional_includedir to $INCNAME.
496 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
502 dnl Look for dependencies.
503 if test -n "$found_la"; then
504 dnl Read the .la file. It defines the variables
505 dnl dlname, library_names, old_library, dependency_libs, current,
506 dnl age, revision, installed, dlopen, dlpreopen, libdir.
507 save_libdir="$libdir"
509 */* | *\\*) . "$found_la" ;;
510 *) . "./$found_la" ;;
512 libdir="$save_libdir"
513 dnl We use only dependency_libs.
514 for dep in $dependency_libs; do
517 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
518 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
520 dnl 1. if it's the standard /usr/lib,
521 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
522 dnl 3. if it's already present in $LDFLAGS or the already
523 dnl constructed $LIBNAME,
524 dnl 4. if it doesn't exist as a directory.
525 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
526 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
528 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
529 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
530 if test -n "$GCC"; then
532 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
536 if test -z "$haveit"; then
538 for x in $LDFLAGS $LIB[]NAME; do
539 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
540 if test "X$x" = "X-L$additional_libdir"; then
545 if test -z "$haveit"; then
546 if test -d "$additional_libdir"; then
547 dnl Really add $additional_libdir to $LIBNAME.
548 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
552 for x in $LDFLAGS $LTLIB[]NAME; do
553 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
554 if test "X$x" = "X-L$additional_libdir"; then
559 if test -z "$haveit"; then
560 if test -d "$additional_libdir"; then
561 dnl Really add $additional_libdir to $LTLIBNAME.
562 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
569 dir=`echo "X$dep" | sed -e 's/^X-R//'`
570 if test "$enable_rpath" != no; then
571 dnl Potentially add DIR to rpathdirs.
572 dnl The rpathdirs will be appended to $LIBNAME at the end.
574 for x in $rpathdirs; do
575 if test "X$x" = "X$dir"; then
580 if test -z "$haveit"; then
581 rpathdirs="$rpathdirs $dir"
583 dnl Potentially add DIR to ltrpathdirs.
584 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
586 for x in $ltrpathdirs; do
587 if test "X$x" = "X$dir"; then
592 if test -z "$haveit"; then
593 ltrpathdirs="$ltrpathdirs $dir"
598 dnl Handle this in the next round.
599 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
602 dnl Handle this in the next round. Throw away the .la's
603 dnl directory; it is already contained in a preceding -L
605 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
608 dnl Most likely an immediate library name.
609 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
610 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
616 dnl Didn't find the library; assume it is in the system directories
617 dnl known to the linker and runtime loader. (All the system
618 dnl directories known to the linker should also be known to the
619 dnl runtime loader, otherwise the system is severely misconfigured.)
620 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
621 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
627 if test "X$rpathdirs" != "X"; then
628 if test -n "$acl_hardcode_libdir_separator"; then
629 dnl Weird platform: only the last -rpath option counts, the user must
630 dnl pass all path elements in one option. We can arrange that for a
631 dnl single library, but not when more than one $LIBNAMEs are used.
633 for found_dir in $rpathdirs; do
634 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
636 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
637 acl_save_libdir="$libdir"
639 eval flag=\"$acl_hardcode_libdir_flag_spec\"
640 libdir="$acl_save_libdir"
641 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
643 dnl The -rpath options are cumulative.
644 for found_dir in $rpathdirs; do
645 acl_save_libdir="$libdir"
647 eval flag=\"$acl_hardcode_libdir_flag_spec\"
648 libdir="$acl_save_libdir"
649 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
653 if test "X$ltrpathdirs" != "X"; then
654 dnl When using libtool, the option that works for both libraries and
655 dnl executables is -R. The -R options are cumulative.
656 for found_dir in $ltrpathdirs; do
657 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
667 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
668 dnl unless already present in VAR.
669 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
670 dnl contains two or three consecutive elements that belong together.
671 AC_DEFUN([AC_LIB_APPENDTOVAR],
673 for element in [$2]; do
676 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
677 if test "X$x" = "X$element"; then
682 if test -z "$haveit"; then
683 [$1]="${[$1]}${[$1]:+ }$element"
688 dnl For those cases where a variable contains several -L and -l options
689 dnl referring to unknown libraries and directories, this macro determines the
690 dnl necessary additional linker options for the runtime path.
691 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
692 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
693 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
694 dnl otherwise linking without libtool is assumed.
695 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
697 AC_REQUIRE([AC_LIB_RPATH])
698 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
700 if test "$enable_rpath" != no; then
701 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
702 dnl Use an explicit option to hardcode directories into the resulting
707 if test -n "$next"; then
709 dnl No need to hardcode the standard /usr/lib.
710 if test "X$dir" != "X/usr/$acl_libdirstem" \
711 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
712 rpathdirs="$rpathdirs $dir"
718 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
719 dnl No need to hardcode the standard /usr/lib.
720 if test "X$dir" != "X/usr/$acl_libdirstem" \
721 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
722 rpathdirs="$rpathdirs $dir"
729 if test "X$rpathdirs" != "X"; then
730 if test -n ""$3""; then
731 dnl libtool is used for linking. Use -R options.
732 for dir in $rpathdirs; do
733 $1="${$1}${$1:+ }-R$dir"
736 dnl The linker is used for linking directly.
737 if test -n "$acl_hardcode_libdir_separator"; then
738 dnl Weird platform: only the last -rpath option counts, the user
739 dnl must pass all path elements in one option.
741 for dir in $rpathdirs; do
742 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
744 acl_save_libdir="$libdir"
746 eval flag=\"$acl_hardcode_libdir_flag_spec\"
747 libdir="$acl_save_libdir"
750 dnl The -rpath options are cumulative.
751 for dir in $rpathdirs; do
752 acl_save_libdir="$libdir"
754 eval flag=\"$acl_hardcode_libdir_flag_spec\"
755 libdir="$acl_save_libdir"
756 $1="${$1}${$1:+ }$flag"