1 # lib-link.m4 serial 26 (gettext-0.18.2)
2 dnl Copyright (C) 2001-2014 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],[m4_translit([$1],[./+-], [____])])
22 pushdef([NAME],[m4_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],[m4_translit([$1],[./+-], [____])])
62 pushdef([NAME],[m4_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 dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
78 dnl because these -l options might require -L options that are present in
79 dnl LIBS. -l options benefit only from the -L options listed before it.
80 dnl Otherwise, add it to the front of LIBS, because it may be a static
81 dnl library that depends on another static library that is present in LIBS.
82 dnl Static libraries benefit only from the static libraries listed after
85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86 *) LIBS="$LIB[]NAME $LIBS" ;;
89 [AC_LANG_PROGRAM([[$3]], [[$4]])],
90 [ac_cv_lib[]Name=yes],
91 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
94 if test "$ac_cv_lib[]Name" = yes; then
96 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
97 AC_MSG_CHECKING([how to link with lib[]$1])
98 AC_MSG_RESULT([$LIB[]NAME])
101 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
102 dnl $INC[]NAME either.
103 CPPFLAGS="$ac_save_CPPFLAGS"
108 AC_SUBST([HAVE_LIB]NAME)
110 AC_SUBST([LTLIB]NAME)
111 AC_SUBST([LIB]NAME[_PREFIX])
116 dnl Determine the platform dependent parameters needed to use rpath:
119 dnl acl_libname_spec,
120 dnl acl_library_names_spec,
121 dnl acl_hardcode_libdir_flag_spec,
122 dnl acl_hardcode_libdir_separator,
123 dnl acl_hardcode_direct,
124 dnl acl_hardcode_minus_L.
125 AC_DEFUN([AC_LIB_RPATH],
127 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
128 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
129 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
130 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
131 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
132 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
133 AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
134 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
135 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
141 acl_libext="$acl_cv_libext"
142 acl_shlibext="$acl_cv_shlibext"
143 acl_libname_spec="$acl_cv_libname_spec"
144 acl_library_names_spec="$acl_cv_library_names_spec"
145 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
146 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
147 acl_hardcode_direct="$acl_cv_hardcode_direct"
148 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
149 dnl Determine whether the user wants rpath handling at all.
150 AC_ARG_ENABLE([rpath],
151 [ --disable-rpath do not hardcode runtime library paths],
155 dnl AC_LIB_FROMPACKAGE(name, package)
156 dnl declares that libname comes from the given package. The configure file
157 dnl will then not have a --with-libname-prefix option but a
158 dnl --with-package-prefix option. Several libraries can come from the same
159 dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
160 dnl macro call that searches for libname.
161 AC_DEFUN([AC_LIB_FROMPACKAGE],
163 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
164 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
165 define([acl_frompackage_]NAME, [$2])
168 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
169 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
170 define([acl_libsinpackage_]PACKUP,
171 m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
176 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
177 dnl the libraries corresponding to explicit and implicit dependencies.
178 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
179 dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
180 dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
181 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
183 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
184 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
185 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
186 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
187 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
188 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
189 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
190 dnl Autoconf >= 2.61 supports dots in --with options.
191 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
192 dnl By default, look in $includedir and $libdir.
194 AC_LIB_WITH_FINAL_PREFIX([
195 eval additional_includedir=\"$includedir\"
196 eval additional_libdir=\"$libdir\"
198 AC_ARG_WITH(P_A_C_K[-prefix],
199 [[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
200 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
202 if test "X$withval" = "Xno"; then
205 if test "X$withval" = "X"; then
206 AC_LIB_WITH_FINAL_PREFIX([
207 eval additional_includedir=\"$includedir\"
208 eval additional_libdir=\"$libdir\"
211 additional_includedir="$withval/include"
212 additional_libdir="$withval/$acl_libdirstem"
213 if test "$acl_libdirstem2" != "$acl_libdirstem" \
214 && ! test -d "$withval/$acl_libdirstem"; then
215 additional_libdir="$withval/$acl_libdirstem2"
220 dnl Search the library and its dependencies in $additional_libdir and
221 dnl $LDFLAGS. Using breadth-first-seach.
226 dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
227 dnl computed. So it has to be reset here.
231 names_already_handled=
232 names_next_round='$1 $2'
233 while test -n "$names_next_round"; do
234 names_this_round="$names_next_round"
236 for name in $names_this_round; do
238 for n in $names_already_handled; do
239 if test "$n" = "$name"; then
244 if test -z "$already_handled"; then
245 names_already_handled="$names_already_handled $name"
246 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
247 dnl or AC_LIB_HAVE_LINKFLAGS call.
248 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
249 eval value=\"\$HAVE_LIB$uppername\"
250 if test -n "$value"; then
251 if test "$value" = yes; then
252 eval value=\"\$LIB$uppername\"
253 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
254 eval value=\"\$LTLIB$uppername\"
255 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
257 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
258 dnl that this library doesn't exist. So just drop it.
262 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
263 dnl and the already constructed $LIBNAME/$LTLIBNAME.
268 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
269 if test -n "$acl_shlibext"; then
270 shrext=".$acl_shlibext" # typically: shrext=.so
274 if test $use_additional = yes; then
275 dir="$additional_libdir"
276 dnl The same code as in the loop below:
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"
318 if test "X$found_dir" = "X"; then
319 for x in $LDFLAGS $LTLIB[]NAME; do
320 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
323 dir=`echo "X$x" | sed -e 's/^X-L//'`
324 dnl First look for a shared library.
325 if test -n "$acl_shlibext"; then
326 if test -f "$dir/$libname$shrext"; then
328 found_so="$dir/$libname$shrext"
330 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
332 for f in "$libname$shrext".*; do echo "$f"; done \
333 | sed -e "s,^$libname$shrext\\\\.,," \
334 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
335 | sed 1q ) 2>/dev/null`
336 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
338 found_so="$dir/$libname$shrext.$ver"
341 eval library_names=\"$acl_library_names_spec\"
342 for f in $library_names; do
343 if test -f "$dir/$f"; then
352 dnl Then look for a static library.
353 if test "X$found_dir" = "X"; then
354 if test -f "$dir/$libname.$acl_libext"; then
356 found_a="$dir/$libname.$acl_libext"
359 if test "X$found_dir" != "X"; then
360 if test -f "$dir/$libname.la"; then
361 found_la="$dir/$libname.la"
366 if test "X$found_dir" != "X"; then
371 if test "X$found_dir" != "X"; then
372 dnl Found the library.
373 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
374 if test "X$found_so" != "X"; then
375 dnl Linking with a shared library. We attempt to hardcode its
376 dnl directory into the executable's runpath, unless it's the
377 dnl standard /usr/lib.
378 if test "$enable_rpath" = no \
379 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
380 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
381 dnl No hardcoding is needed.
382 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
384 dnl Use an explicit option to hardcode DIR into the resulting
386 dnl Potentially add DIR to ltrpathdirs.
387 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
389 for x in $ltrpathdirs; do
390 if test "X$x" = "X$found_dir"; then
395 if test -z "$haveit"; then
396 ltrpathdirs="$ltrpathdirs $found_dir"
398 dnl The hardcoding into $LIBNAME is system dependent.
399 if test "$acl_hardcode_direct" = yes; then
400 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
401 dnl resulting binary.
402 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
404 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
405 dnl Use an explicit option to hardcode DIR into the resulting
407 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
408 dnl Potentially add DIR to rpathdirs.
409 dnl The rpathdirs will be appended to $LIBNAME at the end.
411 for x in $rpathdirs; do
412 if test "X$x" = "X$found_dir"; then
417 if test -z "$haveit"; then
418 rpathdirs="$rpathdirs $found_dir"
421 dnl Rely on "-L$found_dir".
422 dnl But don't add it if it's already contained in the LDFLAGS
423 dnl or the already constructed $LIBNAME
425 for x in $LDFLAGS $LIB[]NAME; do
426 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
427 if test "X$x" = "X-L$found_dir"; then
432 if test -z "$haveit"; then
433 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
435 if test "$acl_hardcode_minus_L" != no; then
436 dnl FIXME: Not sure whether we should use
437 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
439 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
441 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
442 dnl here, because this doesn't fit in flags passed to the
443 dnl compiler. So give up. No hardcoding. This affects only
444 dnl very old systems.
445 dnl FIXME: Not sure whether we should use
446 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
448 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
454 if test "X$found_a" != "X"; then
455 dnl Linking with a static library.
456 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
458 dnl We shouldn't come here, but anyway it's good to have a
460 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
463 dnl Assume the include files are nearby.
464 additional_includedir=
466 */$acl_libdirstem | */$acl_libdirstem/)
467 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
468 if test "$name" = '$1'; then
469 LIB[]NAME[]_PREFIX="$basedir"
471 additional_includedir="$basedir/include"
473 */$acl_libdirstem2 | */$acl_libdirstem2/)
474 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
475 if test "$name" = '$1'; then
476 LIB[]NAME[]_PREFIX="$basedir"
478 additional_includedir="$basedir/include"
481 if test "X$additional_includedir" != "X"; then
482 dnl Potentially add $additional_includedir to $INCNAME.
484 dnl 1. if it's the standard /usr/include,
485 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
486 dnl 3. if it's already present in $CPPFLAGS or the already
487 dnl constructed $INCNAME,
488 dnl 4. if it doesn't exist as a directory.
489 if test "X$additional_includedir" != "X/usr/include"; then
491 if test "X$additional_includedir" = "X/usr/local/include"; then
492 if test -n "$GCC"; then
494 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
498 if test -z "$haveit"; then
499 for x in $CPPFLAGS $INC[]NAME; do
500 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
501 if test "X$x" = "X-I$additional_includedir"; then
506 if test -z "$haveit"; then
507 if test -d "$additional_includedir"; then
508 dnl Really add $additional_includedir to $INCNAME.
509 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
515 dnl Look for dependencies.
516 if test -n "$found_la"; then
517 dnl Read the .la file. It defines the variables
518 dnl dlname, library_names, old_library, dependency_libs, current,
519 dnl age, revision, installed, dlopen, dlpreopen, libdir.
520 save_libdir="$libdir"
522 */* | *\\*) . "$found_la" ;;
523 *) . "./$found_la" ;;
525 libdir="$save_libdir"
526 dnl We use only dependency_libs.
527 for dep in $dependency_libs; do
530 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
531 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
533 dnl 1. if it's the standard /usr/lib,
534 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
535 dnl 3. if it's already present in $LDFLAGS or the already
536 dnl constructed $LIBNAME,
537 dnl 4. if it doesn't exist as a directory.
538 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
539 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
541 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
542 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
543 if test -n "$GCC"; then
545 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
549 if test -z "$haveit"; then
551 for x in $LDFLAGS $LIB[]NAME; do
552 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
553 if test "X$x" = "X-L$additional_libdir"; then
558 if test -z "$haveit"; then
559 if test -d "$additional_libdir"; then
560 dnl Really add $additional_libdir to $LIBNAME.
561 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
565 for x in $LDFLAGS $LTLIB[]NAME; do
566 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
567 if test "X$x" = "X-L$additional_libdir"; then
572 if test -z "$haveit"; then
573 if test -d "$additional_libdir"; then
574 dnl Really add $additional_libdir to $LTLIBNAME.
575 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
582 dir=`echo "X$dep" | sed -e 's/^X-R//'`
583 if test "$enable_rpath" != no; then
584 dnl Potentially add DIR to rpathdirs.
585 dnl The rpathdirs will be appended to $LIBNAME at the end.
587 for x in $rpathdirs; do
588 if test "X$x" = "X$dir"; then
593 if test -z "$haveit"; then
594 rpathdirs="$rpathdirs $dir"
596 dnl Potentially add DIR to ltrpathdirs.
597 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
599 for x in $ltrpathdirs; do
600 if test "X$x" = "X$dir"; then
605 if test -z "$haveit"; then
606 ltrpathdirs="$ltrpathdirs $dir"
611 dnl Handle this in the next round.
612 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
615 dnl Handle this in the next round. Throw away the .la's
616 dnl directory; it is already contained in a preceding -L
618 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
621 dnl Most likely an immediate library name.
622 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
623 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
629 dnl Didn't find the library; assume it is in the system directories
630 dnl known to the linker and runtime loader. (All the system
631 dnl directories known to the linker should also be known to the
632 dnl runtime loader, otherwise the system is severely misconfigured.)
633 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
634 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
640 if test "X$rpathdirs" != "X"; then
641 if test -n "$acl_hardcode_libdir_separator"; then
642 dnl Weird platform: only the last -rpath option counts, the user must
643 dnl pass all path elements in one option. We can arrange that for a
644 dnl single library, but not when more than one $LIBNAMEs are used.
646 for found_dir in $rpathdirs; do
647 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
649 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
650 acl_save_libdir="$libdir"
652 eval flag=\"$acl_hardcode_libdir_flag_spec\"
653 libdir="$acl_save_libdir"
654 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
656 dnl The -rpath options are cumulative.
657 for found_dir in $rpathdirs; do
658 acl_save_libdir="$libdir"
660 eval flag=\"$acl_hardcode_libdir_flag_spec\"
661 libdir="$acl_save_libdir"
662 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
666 if test "X$ltrpathdirs" != "X"; then
667 dnl When using libtool, the option that works for both libraries and
668 dnl executables is -R. The -R options are cumulative.
669 for found_dir in $ltrpathdirs; do
670 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
680 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
681 dnl unless already present in VAR.
682 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
683 dnl contains two or three consecutive elements that belong together.
684 AC_DEFUN([AC_LIB_APPENDTOVAR],
686 for element in [$2]; do
689 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
690 if test "X$x" = "X$element"; then
695 if test -z "$haveit"; then
696 [$1]="${[$1]}${[$1]:+ }$element"
701 dnl For those cases where a variable contains several -L and -l options
702 dnl referring to unknown libraries and directories, this macro determines the
703 dnl necessary additional linker options for the runtime path.
704 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
705 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
706 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
707 dnl otherwise linking without libtool is assumed.
708 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
710 AC_REQUIRE([AC_LIB_RPATH])
711 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
713 if test "$enable_rpath" != no; then
714 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
715 dnl Use an explicit option to hardcode directories into the resulting
720 if test -n "$next"; then
722 dnl No need to hardcode the standard /usr/lib.
723 if test "X$dir" != "X/usr/$acl_libdirstem" \
724 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
725 rpathdirs="$rpathdirs $dir"
731 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
732 dnl No need to hardcode the standard /usr/lib.
733 if test "X$dir" != "X/usr/$acl_libdirstem" \
734 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
735 rpathdirs="$rpathdirs $dir"
742 if test "X$rpathdirs" != "X"; then
743 if test -n ""$3""; then
744 dnl libtool is used for linking. Use -R options.
745 for dir in $rpathdirs; do
746 $1="${$1}${$1:+ }-R$dir"
749 dnl The linker is used for linking directly.
750 if test -n "$acl_hardcode_libdir_separator"; then
751 dnl Weird platform: only the last -rpath option counts, the user
752 dnl must pass all path elements in one option.
754 for dir in $rpathdirs; do
755 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
757 acl_save_libdir="$libdir"
759 eval flag=\"$acl_hardcode_libdir_flag_spec\"
760 libdir="$acl_save_libdir"
763 dnl The -rpath options are cumulative.
764 for dir in $rpathdirs; do
765 acl_save_libdir="$libdir"
767 eval flag=\"$acl_hardcode_libdir_flag_spec\"
768 libdir="$acl_save_libdir"
769 $1="${$1}${$1:+ }$flag"