source: trunk/essentials/app-arch/tar/m4/lib-link.m4

Last change on this file was 3342, checked in by bird, 18 years ago

tar 1.16.1

File size: 27.0 KB
Line 
1# lib-link.m4 serial 10 (gettext-0.16.2)
2dnl Copyright (C) 2001-2006 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ(2.54)
10
11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12dnl the libraries corresponding to explicit and implicit dependencies.
13dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14dnl augments the CPPFLAGS variable.
15dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
17AC_DEFUN([AC_LIB_LINKFLAGS],
18[
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"
30 ])
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)
36 AC_SUBST([LIB]NAME)
37 AC_SUBST([LTLIB]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.
41 HAVE_LIB[]NAME=yes
42 undefine([Name])
43 undefine([NAME])
44])
45
46dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
47dnl searches for libname and the libraries corresponding to explicit and
48dnl implicit dependencies, together with the specified include files and
49dnl the ability to compile and link the specified testcode. If found, it
50dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
51dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
52dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
53dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
54dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
55dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
56AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
57[
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___])])
63
64 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
65 dnl accordingly.
66 AC_LIB_LINKFLAGS_BODY([$1], [$2])
67
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)
73
74 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
75 ac_save_LIBS="$LIBS"
76 LIBS="$LIBS $LIB[]NAME"
77 AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
78 LIBS="$ac_save_LIBS"
79 ])
80 if test "$ac_cv_lib[]Name" = yes; then
81 HAVE_LIB[]NAME=yes
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])
85 else
86 HAVE_LIB[]NAME=no
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"
90 LIB[]NAME=
91 LTLIB[]NAME=
92 LIB[]NAME[]_PREFIX=
93 fi
94 AC_SUBST([HAVE_LIB]NAME)
95 AC_SUBST([LIB]NAME)
96 AC_SUBST([LTLIB]NAME)
97 AC_SUBST([LIB]NAME[_PREFIX])
98 undefine([Name])
99 undefine([NAME])
100])
101
102dnl Determine the platform dependent parameters needed to use rpath:
103dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
104dnl hardcode_direct, hardcode_minus_L.
105AC_DEFUN([AC_LIB_RPATH],
106[
107 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
108 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
109 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
110 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
111 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
112 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
113 AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
114 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
115 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
116 . ./conftest.sh
117 rm -f ./conftest.sh
118 acl_cv_rpath=done
119 ])
120 wl="$acl_cv_wl"
121 libext="$acl_cv_libext"
122 shlibext="$acl_cv_shlibext"
123 hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
124 hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
125 hardcode_direct="$acl_cv_hardcode_direct"
126 hardcode_minus_L="$acl_cv_hardcode_minus_L"
127 dnl Determine whether the user wants rpath handling at all.
128 AC_ARG_ENABLE(rpath,
129 [ --disable-rpath do not hardcode runtime library paths],
130 :, enable_rpath=yes)
131])
132
133dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
134dnl the libraries corresponding to explicit and implicit dependencies.
135dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
136dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
137dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
138AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
139[
140 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
141 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
142 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
143 dnl Autoconf >= 2.61 supports dots in --with options.
144 define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
145 dnl By default, look in $includedir and $libdir.
146 use_additional=yes
147 AC_LIB_WITH_FINAL_PREFIX([
148 eval additional_includedir=\"$includedir\"
149 eval additional_libdir=\"$libdir\"
150 ])
151 AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
152[ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
153 --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
154[
155 if test "X$withval" = "Xno"; then
156 use_additional=no
157 else
158 if test "X$withval" = "X"; then
159 AC_LIB_WITH_FINAL_PREFIX([
160 eval additional_includedir=\"$includedir\"
161 eval additional_libdir=\"$libdir\"
162 ])
163 else
164 additional_includedir="$withval/include"
165 additional_libdir="$withval/$acl_libdirstem"
166 fi
167 fi
168])
169 dnl Search the library and its dependencies in $additional_libdir and
170 dnl $LDFLAGS. Using breadth-first-seach.
171 LIB[]NAME=
172 LTLIB[]NAME=
173 INC[]NAME=
174 LIB[]NAME[]_PREFIX=
175 rpathdirs=
176 ltrpathdirs=
177 names_already_handled=
178 names_next_round='$1 $2'
179 while test -n "$names_next_round"; do
180 names_this_round="$names_next_round"
181 names_next_round=
182 for name in $names_this_round; do
183 already_handled=
184 for n in $names_already_handled; do
185 if test "$n" = "$name"; then
186 already_handled=yes
187 break
188 fi
189 done
190 if test -z "$already_handled"; then
191 names_already_handled="$names_already_handled $name"
192 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
193 dnl or AC_LIB_HAVE_LINKFLAGS call.
194 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
195 eval value=\"\$HAVE_LIB$uppername\"
196 if test -n "$value"; then
197 if test "$value" = yes; then
198 eval value=\"\$LIB$uppername\"
199 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
200 eval value=\"\$LTLIB$uppername\"
201 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
202 else
203 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
204 dnl that this library doesn't exist. So just drop it.
205 :
206 fi
207 else
208 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
209 dnl and the already constructed $LIBNAME/$LTLIBNAME.
210 found_dir=
211 found_la=
212 found_so=
213 found_a=
214 if test $use_additional = yes; then
215 if test -n "$shlibext" \
216 && { test -f "$additional_libdir/lib$name.$shlibext" \
217 || { test "$shlibext" = dll \
218 && test -f "$additional_libdir/lib$name.dll.a"; }; }; then
219 found_dir="$additional_libdir"
220 if test -f "$additional_libdir/lib$name.$shlibext"; then
221 found_so="$additional_libdir/lib$name.$shlibext"
222 else
223 found_so="$additional_libdir/lib$name.dll.a"
224 fi
225 if test -f "$additional_libdir/lib$name.la"; then
226 found_la="$additional_libdir/lib$name.la"
227 fi
228 else
229 if test -f "$additional_libdir/lib$name.$libext"; then
230 found_dir="$additional_libdir"
231 found_a="$additional_libdir/lib$name.$libext"
232 if test -f "$additional_libdir/lib$name.la"; then
233 found_la="$additional_libdir/lib$name.la"
234 fi
235 fi
236 fi
237 fi
238 if test "X$found_dir" = "X"; then
239 for x in $LDFLAGS $LTLIB[]NAME; do
240 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
241 case "$x" in
242 -L*)
243 dir=`echo "X$x" | sed -e 's/^X-L//'`
244 if test -n "$shlibext" \
245 && { test -f "$dir/lib$name.$shlibext" \
246 || { test "$shlibext" = dll \
247 && test -f "$dir/lib$name.dll.a"; }; }; then
248 found_dir="$dir"
249 if test -f "$dir/lib$name.$shlibext"; then
250 found_so="$dir/lib$name.$shlibext"
251 else
252 found_so="$dir/lib$name.dll.a"
253 fi
254 if test -f "$dir/lib$name.la"; then
255 found_la="$dir/lib$name.la"
256 fi
257 else
258 if test -f "$dir/lib$name.$libext"; then
259 found_dir="$dir"
260 found_a="$dir/lib$name.$libext"
261 if test -f "$dir/lib$name.la"; then
262 found_la="$dir/lib$name.la"
263 fi
264 fi
265 fi
266 ;;
267 esac
268 if test "X$found_dir" != "X"; then
269 break
270 fi
271 done
272 fi
273 if test "X$found_dir" != "X"; then
274 dnl Found the library.
275 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
276 if test "X$found_so" != "X"; then
277 dnl Linking with a shared library. We attempt to hardcode its
278 dnl directory into the executable's runpath, unless it's the
279 dnl standard /usr/lib.
280 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
281 dnl No hardcoding is needed.
282 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
283 else
284 dnl Use an explicit option to hardcode DIR into the resulting
285 dnl binary.
286 dnl Potentially add DIR to ltrpathdirs.
287 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
288 haveit=
289 for x in $ltrpathdirs; do
290 if test "X$x" = "X$found_dir"; then
291 haveit=yes
292 break
293 fi
294 done
295 if test -z "$haveit"; then
296 ltrpathdirs="$ltrpathdirs $found_dir"
297 fi
298 dnl The hardcoding into $LIBNAME is system dependent.
299 if test "$hardcode_direct" = yes; then
300 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
301 dnl resulting binary.
302 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
303 else
304 if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
305 dnl Use an explicit option to hardcode DIR into the resulting
306 dnl binary.
307 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
308 dnl Potentially add DIR to rpathdirs.
309 dnl The rpathdirs will be appended to $LIBNAME at the end.
310 haveit=
311 for x in $rpathdirs; do
312 if test "X$x" = "X$found_dir"; then
313 haveit=yes
314 break
315 fi
316 done
317 if test -z "$haveit"; then
318 rpathdirs="$rpathdirs $found_dir"
319 fi
320 else
321 dnl Rely on "-L$found_dir".
322 dnl But don't add it if it's already contained in the LDFLAGS
323 dnl or the already constructed $LIBNAME
324 haveit=
325 for x in $LDFLAGS $LIB[]NAME; do
326 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
327 if test "X$x" = "X-L$found_dir"; then
328 haveit=yes
329 break
330 fi
331 done
332 if test -z "$haveit"; then
333 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
334 fi
335 if test "$hardcode_minus_L" != no; then
336 dnl FIXME: Not sure whether we should use
337 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
338 dnl here.
339 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
340 else
341 dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
342 dnl here, because this doesn't fit in flags passed to the
343 dnl compiler. So give up. No hardcoding. This affects only
344 dnl very old systems.
345 dnl FIXME: Not sure whether we should use
346 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
347 dnl here.
348 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
349 fi
350 fi
351 fi
352 fi
353 else
354 if test "X$found_a" != "X"; then
355 dnl Linking with a static library.
356 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
357 else
358 dnl We shouldn't come here, but anyway it's good to have a
359 dnl fallback.
360 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
361 fi
362 fi
363 dnl Assume the include files are nearby.
364 additional_includedir=
365 case "$found_dir" in
366 */$acl_libdirstem | */$acl_libdirstem/)
367 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
368 LIB[]NAME[]_PREFIX="$basedir"
369 additional_includedir="$basedir/include"
370 ;;
371 esac
372 if test "X$additional_includedir" != "X"; then
373 dnl Potentially add $additional_includedir to $INCNAME.
374 dnl But don't add it
375 dnl 1. if it's the standard /usr/include,
376 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
377 dnl 3. if it's already present in $CPPFLAGS or the already
378 dnl constructed $INCNAME,
379 dnl 4. if it doesn't exist as a directory.
380 if test "X$additional_includedir" != "X/usr/include"; then
381 haveit=
382 if test "X$additional_includedir" = "X/usr/local/include"; then
383 if test -n "$GCC"; then
384 case $host_os in
385 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
386 esac
387 fi
388 fi
389 if test -z "$haveit"; then
390 for x in $CPPFLAGS $INC[]NAME; do
391 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
392 if test "X$x" = "X-I$additional_includedir"; then
393 haveit=yes
394 break
395 fi
396 done
397 if test -z "$haveit"; then
398 if test -d "$additional_includedir"; then
399 dnl Really add $additional_includedir to $INCNAME.
400 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
401 fi
402 fi
403 fi
404 fi
405 fi
406 dnl Look for dependencies.
407 if test -n "$found_la"; then
408 dnl Read the .la file. It defines the variables
409 dnl dlname, library_names, old_library, dependency_libs, current,
410 dnl age, revision, installed, dlopen, dlpreopen, libdir.
411 save_libdir="$libdir"
412 case "$found_la" in
413 */* | *\\*) . "$found_la" ;;
414 *) . "./$found_la" ;;
415 esac
416 libdir="$save_libdir"
417 dnl We use only dependency_libs.
418 for dep in $dependency_libs; do
419 case "$dep" in
420 -L*)
421 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
422 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
423 dnl But don't add it
424 dnl 1. if it's the standard /usr/lib,
425 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
426 dnl 3. if it's already present in $LDFLAGS or the already
427 dnl constructed $LIBNAME,
428 dnl 4. if it doesn't exist as a directory.
429 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
430 haveit=
431 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
432 if test -n "$GCC"; then
433 case $host_os in
434 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
435 esac
436 fi
437 fi
438 if test -z "$haveit"; then
439 haveit=
440 for x in $LDFLAGS $LIB[]NAME; do
441 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
442 if test "X$x" = "X-L$additional_libdir"; then
443 haveit=yes
444 break
445 fi
446 done
447 if test -z "$haveit"; then
448 if test -d "$additional_libdir"; then
449 dnl Really add $additional_libdir to $LIBNAME.
450 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
451 fi
452 fi
453 haveit=
454 for x in $LDFLAGS $LTLIB[]NAME; do
455 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
456 if test "X$x" = "X-L$additional_libdir"; then
457 haveit=yes
458 break
459 fi
460 done
461 if test -z "$haveit"; then
462 if test -d "$additional_libdir"; then
463 dnl Really add $additional_libdir to $LTLIBNAME.
464 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
465 fi
466 fi
467 fi
468 fi
469 ;;
470 -R*)
471 dir=`echo "X$dep" | sed -e 's/^X-R//'`
472 if test "$enable_rpath" != no; then
473 dnl Potentially add DIR to rpathdirs.
474 dnl The rpathdirs will be appended to $LIBNAME at the end.
475 haveit=
476 for x in $rpathdirs; do
477 if test "X$x" = "X$dir"; then
478 haveit=yes
479 break
480 fi
481 done
482 if test -z "$haveit"; then
483 rpathdirs="$rpathdirs $dir"
484 fi
485 dnl Potentially add DIR to ltrpathdirs.
486 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
487 haveit=
488 for x in $ltrpathdirs; do
489 if test "X$x" = "X$dir"; then
490 haveit=yes
491 break
492 fi
493 done
494 if test -z "$haveit"; then
495 ltrpathdirs="$ltrpathdirs $dir"
496 fi
497 fi
498 ;;
499 -l*)
500 dnl Handle this in the next round.
501 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
502 ;;
503 *.la)
504 dnl Handle this in the next round. Throw away the .la's
505 dnl directory; it is already contained in a preceding -L
506 dnl option.
507 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
508 ;;
509 *)
510 dnl Most likely an immediate library name.
511 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
512 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
513 ;;
514 esac
515 done
516 fi
517 else
518 dnl Didn't find the library; assume it is in the system directories
519 dnl known to the linker and runtime loader. (All the system
520 dnl directories known to the linker should also be known to the
521 dnl runtime loader, otherwise the system is severely misconfigured.)
522 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
523 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
524 fi
525 fi
526 fi
527 done
528 done
529 if test "X$rpathdirs" != "X"; then
530 if test -n "$hardcode_libdir_separator"; then
531 dnl Weird platform: only the last -rpath option counts, the user must
532 dnl pass all path elements in one option. We can arrange that for a
533 dnl single library, but not when more than one $LIBNAMEs are used.
534 alldirs=
535 for found_dir in $rpathdirs; do
536 alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
537 done
538 dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
539 acl_save_libdir="$libdir"
540 libdir="$alldirs"
541 eval flag=\"$hardcode_libdir_flag_spec\"
542 libdir="$acl_save_libdir"
543 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
544 else
545 dnl The -rpath options are cumulative.
546 for found_dir in $rpathdirs; do
547 acl_save_libdir="$libdir"
548 libdir="$found_dir"
549 eval flag=\"$hardcode_libdir_flag_spec\"
550 libdir="$acl_save_libdir"
551 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
552 done
553 fi
554 fi
555 if test "X$ltrpathdirs" != "X"; then
556 dnl When using libtool, the option that works for both libraries and
557 dnl executables is -R. The -R options are cumulative.
558 for found_dir in $ltrpathdirs; do
559 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
560 done
561 fi
562])
563
564dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
565dnl unless already present in VAR.
566dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
567dnl contains two or three consecutive elements that belong together.
568AC_DEFUN([AC_LIB_APPENDTOVAR],
569[
570 for element in [$2]; do
571 haveit=
572 for x in $[$1]; do
573 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
574 if test "X$x" = "X$element"; then
575 haveit=yes
576 break
577 fi
578 done
579 if test -z "$haveit"; then
580 [$1]="${[$1]}${[$1]:+ }$element"
581 fi
582 done
583])
584
585dnl For those cases where a variable contains several -L and -l options
586dnl referring to unknown libraries and directories, this macro determines the
587dnl necessary additional linker options for the runtime path.
588dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
589dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
590dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
591dnl otherwise linking without libtool is assumed.
592AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
593[
594 AC_REQUIRE([AC_LIB_RPATH])
595 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
596 $1=
597 if test "$enable_rpath" != no; then
598 if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
599 dnl Use an explicit option to hardcode directories into the resulting
600 dnl binary.
601 rpathdirs=
602 next=
603 for opt in $2; do
604 if test -n "$next"; then
605 dir="$next"
606 dnl No need to hardcode the standard /usr/lib.
607 if test "X$dir" != "X/usr/$acl_libdirstem"; then
608 rpathdirs="$rpathdirs $dir"
609 fi
610 next=
611 else
612 case $opt in
613 -L) next=yes ;;
614 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
615 dnl No need to hardcode the standard /usr/lib.
616 if test "X$dir" != "X/usr/$acl_libdirstem"; then
617 rpathdirs="$rpathdirs $dir"
618 fi
619 next= ;;
620 *) next= ;;
621 esac
622 fi
623 done
624 if test "X$rpathdirs" != "X"; then
625 if test -n ""$3""; then
626 dnl libtool is used for linking. Use -R options.
627 for dir in $rpathdirs; do
628 $1="${$1}${$1:+ }-R$dir"
629 done
630 else
631 dnl The linker is used for linking directly.
632 if test -n "$hardcode_libdir_separator"; then
633 dnl Weird platform: only the last -rpath option counts, the user
634 dnl must pass all path elements in one option.
635 alldirs=
636 for dir in $rpathdirs; do
637 alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$dir"
638 done
639 acl_save_libdir="$libdir"
640 libdir="$alldirs"
641 eval flag=\"$hardcode_libdir_flag_spec\"
642 libdir="$acl_save_libdir"
643 $1="$flag"
644 else
645 dnl The -rpath options are cumulative.
646 for dir in $rpathdirs; do
647 acl_save_libdir="$libdir"
648 libdir="$dir"
649 eval flag=\"$hardcode_libdir_flag_spec\"
650 libdir="$acl_save_libdir"
651 $1="${$1}${$1:+ }$flag"
652 done
653 fi
654 fi
655 fi
656 fi
657 fi
658 AC_SUBST([$1])
659])
Note: See TracBrowser for help on using the repository browser.