1 # lib-link.m4 serial 19 (gettext-0.18)
2 dnl Copyright (C) 2001-2009 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.
215 names_already_handled=
216 names_next_round='$1 $2'
217 while test -n "$names_next_round"; do
218 names_this_round="$names_next_round"
220 for name in $names_this_round; do
222 for n in $names_already_handled; do
223 if test "$n" = "$name"; then
228 if test -z "$already_handled"; then
229 names_already_handled="$names_already_handled $name"
230 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
231 dnl or AC_LIB_HAVE_LINKFLAGS call.
232 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
233 eval value=\"\$HAVE_LIB$uppername\"
234 if test -n "$value"; then
235 if test "$value" = yes; then
236 eval value=\"\$LIB$uppername\"
237 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
238 eval value=\"\$LTLIB$uppername\"
239 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
241 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
242 dnl that this library doesn't exist. So just drop it.
246 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
247 dnl and the already constructed $LIBNAME/$LTLIBNAME.
252 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
253 if test -n "$acl_shlibext"; then
254 shrext=".$acl_shlibext" # typically: shrext=.so
258 if test $use_additional = yes; then
259 dir="$additional_libdir"
260 dnl The same code as in the loop below:
261 dnl First look for a shared library.
262 if test -n "$acl_shlibext"; then
263 if test -f "$dir/$libname$shrext"; then
265 found_so="$dir/$libname$shrext"
267 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
269 for f in "$libname$shrext".*; do echo "$f"; done \
270 | sed -e "s,^$libname$shrext\\\\.,," \
271 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
272 | sed 1q ) 2>/dev/null`
273 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
275 found_so="$dir/$libname$shrext.$ver"
278 eval library_names=\"$acl_library_names_spec\"
279 for f in $library_names; do
280 if test -f "$dir/$f"; then
289 dnl Then look for a static library.
290 if test "X$found_dir" = "X"; then
291 if test -f "$dir/$libname.$acl_libext"; then
293 found_a="$dir/$libname.$acl_libext"
296 if test "X$found_dir" != "X"; then
297 if test -f "$dir/$libname.la"; then
298 found_la="$dir/$libname.la"
302 if test "X$found_dir" = "X"; then
303 for x in $LDFLAGS $LTLIB[]NAME; do
304 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
307 dir=`echo "X$x" | sed -e 's/^X-L//'`
308 dnl First look for a shared library.
309 if test -n "$acl_shlibext"; then
310 if test -f "$dir/$libname$shrext"; then
312 found_so="$dir/$libname$shrext"
314 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
316 for f in "$libname$shrext".*; do echo "$f"; done \
317 | sed -e "s,^$libname$shrext\\\\.,," \
318 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
319 | sed 1q ) 2>/dev/null`
320 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
322 found_so="$dir/$libname$shrext.$ver"
325 eval library_names=\"$acl_library_names_spec\"
326 for f in $library_names; do
327 if test -f "$dir/$f"; then
336 dnl Then look for a static library.
337 if test "X$found_dir" = "X"; then
338 if test -f "$dir/$libname.$acl_libext"; then
340 found_a="$dir/$libname.$acl_libext"
343 if test "X$found_dir" != "X"; then
344 if test -f "$dir/$libname.la"; then
345 found_la="$dir/$libname.la"
350 if test "X$found_dir" != "X"; then
355 if test "X$found_dir" != "X"; then
356 dnl Found the library.
357 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
358 if test "X$found_so" != "X"; then
359 dnl Linking with a shared library. We attempt to hardcode its
360 dnl directory into the executable's runpath, unless it's the
361 dnl standard /usr/lib.
362 if test "$enable_rpath" = no \
363 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
364 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
365 dnl No hardcoding is needed.
366 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
368 dnl Use an explicit option to hardcode DIR into the resulting
370 dnl Potentially add DIR to ltrpathdirs.
371 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
373 for x in $ltrpathdirs; do
374 if test "X$x" = "X$found_dir"; then
379 if test -z "$haveit"; then
380 ltrpathdirs="$ltrpathdirs $found_dir"
382 dnl The hardcoding into $LIBNAME is system dependent.
383 if test "$acl_hardcode_direct" = yes; then
384 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
385 dnl resulting binary.
386 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
388 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
389 dnl Use an explicit option to hardcode DIR into the resulting
391 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
392 dnl Potentially add DIR to rpathdirs.
393 dnl The rpathdirs will be appended to $LIBNAME at the end.
395 for x in $rpathdirs; do
396 if test "X$x" = "X$found_dir"; then
401 if test -z "$haveit"; then
402 rpathdirs="$rpathdirs $found_dir"
405 dnl Rely on "-L$found_dir".
406 dnl But don't add it if it's already contained in the LDFLAGS
407 dnl or the already constructed $LIBNAME
409 for x in $LDFLAGS $LIB[]NAME; do
410 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
411 if test "X$x" = "X-L$found_dir"; then
416 if test -z "$haveit"; then
417 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
419 if test "$acl_hardcode_minus_L" != no; then
420 dnl FIXME: Not sure whether we should use
421 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
423 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
425 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
426 dnl here, because this doesn't fit in flags passed to the
427 dnl compiler. So give up. No hardcoding. This affects only
428 dnl very old systems.
429 dnl FIXME: Not sure whether we should use
430 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
432 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
438 if test "X$found_a" != "X"; then
439 dnl Linking with a static library.
440 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
442 dnl We shouldn't come here, but anyway it's good to have a
444 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
447 dnl Assume the include files are nearby.
448 additional_includedir=
450 */$acl_libdirstem | */$acl_libdirstem/)
451 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
452 if test "$name" = '$1'; then
453 LIB[]NAME[]_PREFIX="$basedir"
455 additional_includedir="$basedir/include"
457 */$acl_libdirstem2 | */$acl_libdirstem2/)
458 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
459 if test "$name" = '$1'; then
460 LIB[]NAME[]_PREFIX="$basedir"
462 additional_includedir="$basedir/include"
465 if test "X$additional_includedir" != "X"; then
466 dnl Potentially add $additional_includedir to $INCNAME.
468 dnl 1. if it's the standard /usr/include,
469 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
470 dnl 3. if it's already present in $CPPFLAGS or the already
471 dnl constructed $INCNAME,
472 dnl 4. if it doesn't exist as a directory.
473 if test "X$additional_includedir" != "X/usr/include"; then
475 if test "X$additional_includedir" = "X/usr/local/include"; then
476 if test -n "$GCC"; then
478 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
482 if test -z "$haveit"; then
483 for x in $CPPFLAGS $INC[]NAME; do
484 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
485 if test "X$x" = "X-I$additional_includedir"; then
490 if test -z "$haveit"; then
491 if test -d "$additional_includedir"; then
492 dnl Really add $additional_includedir to $INCNAME.
493 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
499 dnl Look for dependencies.
500 if test -n "$found_la"; then
501 dnl Read the .la file. It defines the variables
502 dnl dlname, library_names, old_library, dependency_libs, current,
503 dnl age, revision, installed, dlopen, dlpreopen, libdir.
504 save_libdir="$libdir"
506 */* | *\\*) . "$found_la" ;;
507 *) . "./$found_la" ;;
509 libdir="$save_libdir"
510 dnl We use only dependency_libs.
511 for dep in $dependency_libs; do
514 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
515 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
517 dnl 1. if it's the standard /usr/lib,
518 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
519 dnl 3. if it's already present in $LDFLAGS or the already
520 dnl constructed $LIBNAME,
521 dnl 4. if it doesn't exist as a directory.
522 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
523 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
525 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
526 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
527 if test -n "$GCC"; then
529 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
533 if test -z "$haveit"; then
535 for x in $LDFLAGS $LIB[]NAME; do
536 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
537 if test "X$x" = "X-L$additional_libdir"; then
542 if test -z "$haveit"; then
543 if test -d "$additional_libdir"; then
544 dnl Really add $additional_libdir to $LIBNAME.
545 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
549 for x in $LDFLAGS $LTLIB[]NAME; do
550 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
551 if test "X$x" = "X-L$additional_libdir"; then
556 if test -z "$haveit"; then
557 if test -d "$additional_libdir"; then
558 dnl Really add $additional_libdir to $LTLIBNAME.
559 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
566 dir=`echo "X$dep" | sed -e 's/^X-R//'`
567 if test "$enable_rpath" != no; then
568 dnl Potentially add DIR to rpathdirs.
569 dnl The rpathdirs will be appended to $LIBNAME at the end.
571 for x in $rpathdirs; do
572 if test "X$x" = "X$dir"; then
577 if test -z "$haveit"; then
578 rpathdirs="$rpathdirs $dir"
580 dnl Potentially add DIR to ltrpathdirs.
581 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
583 for x in $ltrpathdirs; do
584 if test "X$x" = "X$dir"; then
589 if test -z "$haveit"; then
590 ltrpathdirs="$ltrpathdirs $dir"
595 dnl Handle this in the next round.
596 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
599 dnl Handle this in the next round. Throw away the .la's
600 dnl directory; it is already contained in a preceding -L
602 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
605 dnl Most likely an immediate library name.
606 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
607 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
613 dnl Didn't find the library; assume it is in the system directories
614 dnl known to the linker and runtime loader. (All the system
615 dnl directories known to the linker should also be known to the
616 dnl runtime loader, otherwise the system is severely misconfigured.)
617 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
618 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
624 if test "X$rpathdirs" != "X"; then
625 if test -n "$acl_hardcode_libdir_separator"; then
626 dnl Weird platform: only the last -rpath option counts, the user must
627 dnl pass all path elements in one option. We can arrange that for a
628 dnl single library, but not when more than one $LIBNAMEs are used.
630 for found_dir in $rpathdirs; do
631 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
633 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
634 acl_save_libdir="$libdir"
636 eval flag=\"$acl_hardcode_libdir_flag_spec\"
637 libdir="$acl_save_libdir"
638 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
640 dnl The -rpath options are cumulative.
641 for found_dir in $rpathdirs; do
642 acl_save_libdir="$libdir"
644 eval flag=\"$acl_hardcode_libdir_flag_spec\"
645 libdir="$acl_save_libdir"
646 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
650 if test "X$ltrpathdirs" != "X"; then
651 dnl When using libtool, the option that works for both libraries and
652 dnl executables is -R. The -R options are cumulative.
653 for found_dir in $ltrpathdirs; do
654 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
664 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
665 dnl unless already present in VAR.
666 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
667 dnl contains two or three consecutive elements that belong together.
668 AC_DEFUN([AC_LIB_APPENDTOVAR],
670 for element in [$2]; do
673 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
674 if test "X$x" = "X$element"; then
679 if test -z "$haveit"; then
680 [$1]="${[$1]}${[$1]:+ }$element"
685 dnl For those cases where a variable contains several -L and -l options
686 dnl referring to unknown libraries and directories, this macro determines the
687 dnl necessary additional linker options for the runtime path.
688 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
689 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
690 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
691 dnl otherwise linking without libtool is assumed.
692 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
694 AC_REQUIRE([AC_LIB_RPATH])
695 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
697 if test "$enable_rpath" != no; then
698 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
699 dnl Use an explicit option to hardcode directories into the resulting
704 if test -n "$next"; then
706 dnl No need to hardcode the standard /usr/lib.
707 if test "X$dir" != "X/usr/$acl_libdirstem" \
708 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
709 rpathdirs="$rpathdirs $dir"
715 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
716 dnl No need to hardcode the standard /usr/lib.
717 if test "X$dir" != "X/usr/$acl_libdirstem" \
718 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
719 rpathdirs="$rpathdirs $dir"
726 if test "X$rpathdirs" != "X"; then
727 if test -n ""$3""; then
728 dnl libtool is used for linking. Use -R options.
729 for dir in $rpathdirs; do
730 $1="${$1}${$1:+ }-R$dir"
733 dnl The linker is used for linking directly.
734 if test -n "$acl_hardcode_libdir_separator"; then
735 dnl Weird platform: only the last -rpath option counts, the user
736 dnl must pass all path elements in one option.
738 for dir in $rpathdirs; do
739 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
741 acl_save_libdir="$libdir"
743 eval flag=\"$acl_hardcode_libdir_flag_spec\"
744 libdir="$acl_save_libdir"
747 dnl The -rpath options are cumulative.
748 for dir in $rpathdirs; do
749 acl_save_libdir="$libdir"
751 eval flag=\"$acl_hardcode_libdir_flag_spec\"
752 libdir="$acl_save_libdir"
753 $1="${$1}${$1:+ }$flag"