1
# lib-link.m4 serial 21 (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
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" ;;
88
AC_TRY_LINK([$3], [$4],
89
[ac_cv_lib[]Name=yes],
90
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
93
if test "$ac_cv_lib[]Name" = yes; then
95
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
96
AC_MSG_CHECKING([how to link with lib[]$1])
97
AC_MSG_RESULT([$LIB[]NAME])
100
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
101
dnl $INC[]NAME either.
102
CPPFLAGS="$ac_save_CPPFLAGS"
107
AC_SUBST([HAVE_LIB]NAME)
109
AC_SUBST([LTLIB]NAME)
110
AC_SUBST([LIB]NAME[_PREFIX])
115
dnl Determine the platform dependent parameters needed to use rpath:
118
dnl acl_hardcode_libdir_flag_spec,
119
dnl acl_hardcode_libdir_separator,
120
dnl acl_hardcode_direct,
121
dnl acl_hardcode_minus_L.
122
AC_DEFUN([AC_LIB_RPATH],
124
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
125
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
126
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
127
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
128
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
129
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
130
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
131
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
132
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
138
acl_libext="$acl_cv_libext"
139
acl_shlibext="$acl_cv_shlibext"
140
acl_libname_spec="$acl_cv_libname_spec"
141
acl_library_names_spec="$acl_cv_library_names_spec"
142
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
143
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
144
acl_hardcode_direct="$acl_cv_hardcode_direct"
145
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
146
dnl Determine whether the user wants rpath handling at all.
147
AC_ARG_ENABLE([rpath],
148
[ --disable-rpath do not hardcode runtime library paths],
152
dnl AC_LIB_FROMPACKAGE(name, package)
153
dnl declares that libname comes from the given package. The configure file
154
dnl will then not have a --with-libname-prefix option but a
155
dnl --with-package-prefix option. Several libraries can come from the same
156
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
157
dnl macro call that searches for libname.
158
AC_DEFUN([AC_LIB_FROMPACKAGE],
160
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
161
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
162
define([acl_frompackage_]NAME, [$2])
165
pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
166
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
167
define([acl_libsinpackage_]PACKUP,
168
m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
173
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
174
dnl the libraries corresponding to explicit and implicit dependencies.
175
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
176
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
177
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
178
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
180
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
181
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
182
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
183
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
184
pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
185
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
186
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
187
dnl Autoconf >= 2.61 supports dots in --with options.
188
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
189
dnl By default, look in $includedir and $libdir.
191
AC_LIB_WITH_FINAL_PREFIX([
192
eval additional_includedir=\"$includedir\"
193
eval additional_libdir=\"$libdir\"
195
AC_ARG_WITH(P_A_C_K[-prefix],
196
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
197
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
199
if test "X$withval" = "Xno"; then
202
if test "X$withval" = "X"; then
203
AC_LIB_WITH_FINAL_PREFIX([
204
eval additional_includedir=\"$includedir\"
205
eval additional_libdir=\"$libdir\"
208
additional_includedir="$withval/include"
209
additional_libdir="$withval/$acl_libdirstem"
210
if test "$acl_libdirstem2" != "$acl_libdirstem" \
211
&& ! test -d "$withval/$acl_libdirstem"; then
212
additional_libdir="$withval/$acl_libdirstem2"
217
dnl Search the library and its dependencies in $additional_libdir and
218
dnl $LDFLAGS. Using breadth-first-seach.
223
dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
224
dnl computed. So it has to be reset here.
228
names_already_handled=
229
names_next_round='$1 $2'
230
while test -n "$names_next_round"; do
231
names_this_round="$names_next_round"
233
for name in $names_this_round; do
235
for n in $names_already_handled; do
236
if test "$n" = "$name"; then
241
if test -z "$already_handled"; then
242
names_already_handled="$names_already_handled $name"
243
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
244
dnl or AC_LIB_HAVE_LINKFLAGS call.
245
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
246
eval value=\"\$HAVE_LIB$uppername\"
247
if test -n "$value"; then
248
if test "$value" = yes; then
249
eval value=\"\$LIB$uppername\"
250
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
251
eval value=\"\$LTLIB$uppername\"
252
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
254
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
255
dnl that this library doesn't exist. So just drop it.
259
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
260
dnl and the already constructed $LIBNAME/$LTLIBNAME.
265
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
266
if test -n "$acl_shlibext"; then
267
shrext=".$acl_shlibext" # typically: shrext=.so
271
if test $use_additional = yes; then
272
dir="$additional_libdir"
273
dnl The same code as in the loop below:
274
dnl First look for a shared library.
275
if test -n "$acl_shlibext"; then
276
if test -f "$dir/$libname$shrext"; then
278
found_so="$dir/$libname$shrext"
280
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
282
for f in "$libname$shrext".*; do echo "$f"; done \
283
| sed -e "s,^$libname$shrext\\\\.,," \
284
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
285
| sed 1q ) 2>/dev/null`
286
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
288
found_so="$dir/$libname$shrext.$ver"
291
eval library_names=\"$acl_library_names_spec\"
292
for f in $library_names; do
293
if test -f "$dir/$f"; then
302
dnl Then look for a static library.
303
if test "X$found_dir" = "X"; then
304
if test -f "$dir/$libname.$acl_libext"; then
306
found_a="$dir/$libname.$acl_libext"
309
if test "X$found_dir" != "X"; then
310
if test -f "$dir/$libname.la"; then
311
found_la="$dir/$libname.la"
315
if test "X$found_dir" = "X"; then
316
for x in $LDFLAGS $LTLIB[]NAME; do
317
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
320
dir=`echo "X$x" | sed -e 's/^X-L//'`
321
dnl First look for a shared library.
322
if test -n "$acl_shlibext"; then
323
if test -f "$dir/$libname$shrext"; then
325
found_so="$dir/$libname$shrext"
327
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
329
for f in "$libname$shrext".*; do echo "$f"; done \
330
| sed -e "s,^$libname$shrext\\\\.,," \
331
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
332
| sed 1q ) 2>/dev/null`
333
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
335
found_so="$dir/$libname$shrext.$ver"
338
eval library_names=\"$acl_library_names_spec\"
339
for f in $library_names; do
340
if test -f "$dir/$f"; then
349
dnl Then look for a static library.
350
if test "X$found_dir" = "X"; then
351
if test -f "$dir/$libname.$acl_libext"; then
353
found_a="$dir/$libname.$acl_libext"
356
if test "X$found_dir" != "X"; then
357
if test -f "$dir/$libname.la"; then
358
found_la="$dir/$libname.la"
363
if test "X$found_dir" != "X"; then
368
if test "X$found_dir" != "X"; then
369
dnl Found the library.
370
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
371
if test "X$found_so" != "X"; then
372
dnl Linking with a shared library. We attempt to hardcode its
373
dnl directory into the executable's runpath, unless it's the
374
dnl standard /usr/lib.
375
if test "$enable_rpath" = no \
376
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
377
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
378
dnl No hardcoding is needed.
379
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
381
dnl Use an explicit option to hardcode DIR into the resulting
383
dnl Potentially add DIR to ltrpathdirs.
384
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
386
for x in $ltrpathdirs; do
387
if test "X$x" = "X$found_dir"; then
392
if test -z "$haveit"; then
393
ltrpathdirs="$ltrpathdirs $found_dir"
395
dnl The hardcoding into $LIBNAME is system dependent.
396
if test "$acl_hardcode_direct" = yes; then
397
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
398
dnl resulting binary.
399
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
401
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
402
dnl Use an explicit option to hardcode DIR into the resulting
404
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
405
dnl Potentially add DIR to rpathdirs.
406
dnl The rpathdirs will be appended to $LIBNAME at the end.
408
for x in $rpathdirs; do
409
if test "X$x" = "X$found_dir"; then
414
if test -z "$haveit"; then
415
rpathdirs="$rpathdirs $found_dir"
418
dnl Rely on "-L$found_dir".
419
dnl But don't add it if it's already contained in the LDFLAGS
420
dnl or the already constructed $LIBNAME
422
for x in $LDFLAGS $LIB[]NAME; do
423
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
424
if test "X$x" = "X-L$found_dir"; then
429
if test -z "$haveit"; then
430
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
432
if test "$acl_hardcode_minus_L" != no; then
433
dnl FIXME: Not sure whether we should use
434
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
436
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
438
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
439
dnl here, because this doesn't fit in flags passed to the
440
dnl compiler. So give up. No hardcoding. This affects only
441
dnl very old systems.
442
dnl FIXME: Not sure whether we should use
443
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
445
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
451
if test "X$found_a" != "X"; then
452
dnl Linking with a static library.
453
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
455
dnl We shouldn't come here, but anyway it's good to have a
457
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
460
dnl Assume the include files are nearby.
461
additional_includedir=
463
*/$acl_libdirstem | */$acl_libdirstem/)
464
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
465
if test "$name" = '$1'; then
466
LIB[]NAME[]_PREFIX="$basedir"
468
additional_includedir="$basedir/include"
470
*/$acl_libdirstem2 | */$acl_libdirstem2/)
471
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
472
if test "$name" = '$1'; then
473
LIB[]NAME[]_PREFIX="$basedir"
475
additional_includedir="$basedir/include"
478
if test "X$additional_includedir" != "X"; then
479
dnl Potentially add $additional_includedir to $INCNAME.
481
dnl 1. if it's the standard /usr/include,
482
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
483
dnl 3. if it's already present in $CPPFLAGS or the already
484
dnl constructed $INCNAME,
485
dnl 4. if it doesn't exist as a directory.
486
if test "X$additional_includedir" != "X/usr/include"; then
488
if test "X$additional_includedir" = "X/usr/local/include"; then
489
if test -n "$GCC"; then
491
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
495
if test -z "$haveit"; then
496
for x in $CPPFLAGS $INC[]NAME; do
497
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
498
if test "X$x" = "X-I$additional_includedir"; then
503
if test -z "$haveit"; then
504
if test -d "$additional_includedir"; then
505
dnl Really add $additional_includedir to $INCNAME.
506
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
512
dnl Look for dependencies.
513
if test -n "$found_la"; then
514
dnl Read the .la file. It defines the variables
515
dnl dlname, library_names, old_library, dependency_libs, current,
516
dnl age, revision, installed, dlopen, dlpreopen, libdir.
517
save_libdir="$libdir"
519
*/* | *\\*) . "$found_la" ;;
520
*) . "./$found_la" ;;
522
libdir="$save_libdir"
523
dnl We use only dependency_libs.
524
for dep in $dependency_libs; do
527
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
528
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
530
dnl 1. if it's the standard /usr/lib,
531
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
532
dnl 3. if it's already present in $LDFLAGS or the already
533
dnl constructed $LIBNAME,
534
dnl 4. if it doesn't exist as a directory.
535
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
536
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
538
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
539
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
540
if test -n "$GCC"; then
542
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
546
if test -z "$haveit"; then
548
for x in $LDFLAGS $LIB[]NAME; do
549
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
550
if test "X$x" = "X-L$additional_libdir"; then
555
if test -z "$haveit"; then
556
if test -d "$additional_libdir"; then
557
dnl Really add $additional_libdir to $LIBNAME.
558
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
562
for x in $LDFLAGS $LTLIB[]NAME; do
563
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
564
if test "X$x" = "X-L$additional_libdir"; then
569
if test -z "$haveit"; then
570
if test -d "$additional_libdir"; then
571
dnl Really add $additional_libdir to $LTLIBNAME.
572
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
579
dir=`echo "X$dep" | sed -e 's/^X-R//'`
580
if test "$enable_rpath" != no; then
581
dnl Potentially add DIR to rpathdirs.
582
dnl The rpathdirs will be appended to $LIBNAME at the end.
584
for x in $rpathdirs; do
585
if test "X$x" = "X$dir"; then
590
if test -z "$haveit"; then
591
rpathdirs="$rpathdirs $dir"
593
dnl Potentially add DIR to ltrpathdirs.
594
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
596
for x in $ltrpathdirs; do
597
if test "X$x" = "X$dir"; then
602
if test -z "$haveit"; then
603
ltrpathdirs="$ltrpathdirs $dir"
608
dnl Handle this in the next round.
609
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
612
dnl Handle this in the next round. Throw away the .la's
613
dnl directory; it is already contained in a preceding -L
615
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
618
dnl Most likely an immediate library name.
619
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
620
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
626
dnl Didn't find the library; assume it is in the system directories
627
dnl known to the linker and runtime loader. (All the system
628
dnl directories known to the linker should also be known to the
629
dnl runtime loader, otherwise the system is severely misconfigured.)
630
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
631
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
637
if test "X$rpathdirs" != "X"; then
638
if test -n "$acl_hardcode_libdir_separator"; then
639
dnl Weird platform: only the last -rpath option counts, the user must
640
dnl pass all path elements in one option. We can arrange that for a
641
dnl single library, but not when more than one $LIBNAMEs are used.
643
for found_dir in $rpathdirs; do
644
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
646
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
647
acl_save_libdir="$libdir"
649
eval flag=\"$acl_hardcode_libdir_flag_spec\"
650
libdir="$acl_save_libdir"
651
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
653
dnl The -rpath options are cumulative.
654
for found_dir in $rpathdirs; do
655
acl_save_libdir="$libdir"
657
eval flag=\"$acl_hardcode_libdir_flag_spec\"
658
libdir="$acl_save_libdir"
659
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
663
if test "X$ltrpathdirs" != "X"; then
664
dnl When using libtool, the option that works for both libraries and
665
dnl executables is -R. The -R options are cumulative.
666
for found_dir in $ltrpathdirs; do
667
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
677
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
678
dnl unless already present in VAR.
679
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
680
dnl contains two or three consecutive elements that belong together.
681
AC_DEFUN([AC_LIB_APPENDTOVAR],
683
for element in [$2]; do
686
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
687
if test "X$x" = "X$element"; then
692
if test -z "$haveit"; then
693
[$1]="${[$1]}${[$1]:+ }$element"
698
dnl For those cases where a variable contains several -L and -l options
699
dnl referring to unknown libraries and directories, this macro determines the
700
dnl necessary additional linker options for the runtime path.
701
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
702
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
703
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
704
dnl otherwise linking without libtool is assumed.
705
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
707
AC_REQUIRE([AC_LIB_RPATH])
708
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
710
if test "$enable_rpath" != no; then
711
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
712
dnl Use an explicit option to hardcode directories into the resulting
717
if test -n "$next"; then
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"
728
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
729
dnl No need to hardcode the standard /usr/lib.
730
if test "X$dir" != "X/usr/$acl_libdirstem" \
731
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
732
rpathdirs="$rpathdirs $dir"
739
if test "X$rpathdirs" != "X"; then
740
if test -n ""$3""; then
741
dnl libtool is used for linking. Use -R options.
742
for dir in $rpathdirs; do
743
$1="${$1}${$1:+ }-R$dir"
746
dnl The linker is used for linking directly.
747
if test -n "$acl_hardcode_libdir_separator"; then
748
dnl Weird platform: only the last -rpath option counts, the user
749
dnl must pass all path elements in one option.
751
for dir in $rpathdirs; do
752
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
754
acl_save_libdir="$libdir"
756
eval flag=\"$acl_hardcode_libdir_flag_spec\"
757
libdir="$acl_save_libdir"
760
dnl The -rpath options are cumulative.
761
for dir in $rpathdirs; do
762
acl_save_libdir="$libdir"
764
eval flag=\"$acl_hardcode_libdir_flag_spec\"
765
libdir="$acl_save_libdir"
766
$1="${$1}${$1:+ }$flag"