1
# lib-link.m4 serial 25 (gettext-0.18.2)
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],[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_hardcode_libdir_flag_spec,
120
dnl acl_hardcode_libdir_separator,
121
dnl acl_hardcode_direct,
122
dnl acl_hardcode_minus_L.
123
AC_DEFUN([AC_LIB_RPATH],
125
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
126
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
127
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
128
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
129
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
130
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
131
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
132
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
133
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
139
acl_libext="$acl_cv_libext"
140
acl_shlibext="$acl_cv_shlibext"
141
acl_libname_spec="$acl_cv_libname_spec"
142
acl_library_names_spec="$acl_cv_library_names_spec"
143
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
144
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
145
acl_hardcode_direct="$acl_cv_hardcode_direct"
146
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
147
dnl Determine whether the user wants rpath handling at all.
148
AC_ARG_ENABLE([rpath],
149
[ --disable-rpath do not hardcode runtime library paths],
153
dnl AC_LIB_FROMPACKAGE(name, package)
154
dnl declares that libname comes from the given package. The configure file
155
dnl will then not have a --with-libname-prefix option but a
156
dnl --with-package-prefix option. Several libraries can come from the same
157
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
158
dnl macro call that searches for libname.
159
AC_DEFUN([AC_LIB_FROMPACKAGE],
161
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
162
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
163
define([acl_frompackage_]NAME, [$2])
166
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
167
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
168
define([acl_libsinpackage_]PACKUP,
169
m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
174
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
175
dnl the libraries corresponding to explicit and implicit dependencies.
176
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
177
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
178
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
179
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
181
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
182
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
183
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
184
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
185
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
186
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
187
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
188
dnl Autoconf >= 2.61 supports dots in --with options.
189
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
190
dnl By default, look in $includedir and $libdir.
192
AC_LIB_WITH_FINAL_PREFIX([
193
eval additional_includedir=\"$includedir\"
194
eval additional_libdir=\"$libdir\"
196
AC_ARG_WITH(P_A_C_K[-prefix],
197
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
198
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
200
if test "X$withval" = "Xno"; then
203
if test "X$withval" = "X"; then
204
AC_LIB_WITH_FINAL_PREFIX([
205
eval additional_includedir=\"$includedir\"
206
eval additional_libdir=\"$libdir\"
209
additional_includedir="$withval/include"
210
additional_libdir="$withval/$acl_libdirstem"
211
if test "$acl_libdirstem2" != "$acl_libdirstem" \
212
&& ! test -d "$withval/$acl_libdirstem"; then
213
additional_libdir="$withval/$acl_libdirstem2"
218
dnl Search the library and its dependencies in $additional_libdir and
219
dnl $LDFLAGS. Using breadth-first-seach.
224
dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
225
dnl computed. So it has to be reset here.
229
names_already_handled=
230
names_next_round='$1 $2'
231
while test -n "$names_next_round"; do
232
names_this_round="$names_next_round"
234
for name in $names_this_round; do
236
for n in $names_already_handled; do
237
if test "$n" = "$name"; then
242
if test -z "$already_handled"; then
243
names_already_handled="$names_already_handled $name"
244
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
245
dnl or AC_LIB_HAVE_LINKFLAGS call.
246
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
247
eval value=\"\$HAVE_LIB$uppername\"
248
if test -n "$value"; then
249
if test "$value" = yes; then
250
eval value=\"\$LIB$uppername\"
251
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
252
eval value=\"\$LTLIB$uppername\"
253
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
255
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
256
dnl that this library doesn't exist. So just drop it.
260
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
261
dnl and the already constructed $LIBNAME/$LTLIBNAME.
266
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
267
if test -n "$acl_shlibext"; then
268
shrext=".$acl_shlibext" # typically: shrext=.so
272
if test $use_additional = yes; then
273
dir="$additional_libdir"
274
dnl The same code as in the loop below:
275
dnl First look for a shared library.
276
if test -n "$acl_shlibext"; then
277
if test -f "$dir/$libname$shrext"; then
279
found_so="$dir/$libname$shrext"
281
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
283
for f in "$libname$shrext".*; do echo "$f"; done \
284
| sed -e "s,^$libname$shrext\\\\.,," \
285
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
286
| sed 1q ) 2>/dev/null`
287
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
289
found_so="$dir/$libname$shrext.$ver"
292
eval library_names=\"$acl_library_names_spec\"
293
for f in $library_names; do
294
if test -f "$dir/$f"; then
303
dnl Then look for a static library.
304
if test "X$found_dir" = "X"; then
305
if test -f "$dir/$libname.$acl_libext"; then
307
found_a="$dir/$libname.$acl_libext"
310
if test "X$found_dir" != "X"; then
311
if test -f "$dir/$libname.la"; then
312
found_la="$dir/$libname.la"
316
if test "X$found_dir" = "X"; then
317
for x in $LDFLAGS $LTLIB[]NAME; do
318
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
321
dir=`echo "X$x" | sed -e 's/^X-L//'`
322
dnl First look for a shared library.
323
if test -n "$acl_shlibext"; then
324
if test -f "$dir/$libname$shrext"; then
326
found_so="$dir/$libname$shrext"
328
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
330
for f in "$libname$shrext".*; do echo "$f"; done \
331
| sed -e "s,^$libname$shrext\\\\.,," \
332
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
333
| sed 1q ) 2>/dev/null`
334
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
336
found_so="$dir/$libname$shrext.$ver"
339
eval library_names=\"$acl_library_names_spec\"
340
for f in $library_names; do
341
if test -f "$dir/$f"; then
350
dnl Then look for a static library.
351
if test "X$found_dir" = "X"; then
352
if test -f "$dir/$libname.$acl_libext"; then
354
found_a="$dir/$libname.$acl_libext"
357
if test "X$found_dir" != "X"; then
358
if test -f "$dir/$libname.la"; then
359
found_la="$dir/$libname.la"
364
if test "X$found_dir" != "X"; then
369
if test "X$found_dir" != "X"; then
370
dnl Found the library.
371
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
372
if test "X$found_so" != "X"; then
373
dnl Linking with a shared library. We attempt to hardcode its
374
dnl directory into the executable's runpath, unless it's the
375
dnl standard /usr/lib.
376
if test "$enable_rpath" = no \
377
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
378
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
379
dnl No hardcoding is needed.
380
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
382
dnl Use an explicit option to hardcode DIR into the resulting
384
dnl Potentially add DIR to ltrpathdirs.
385
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
387
for x in $ltrpathdirs; do
388
if test "X$x" = "X$found_dir"; then
393
if test -z "$haveit"; then
394
ltrpathdirs="$ltrpathdirs $found_dir"
396
dnl The hardcoding into $LIBNAME is system dependent.
397
if test "$acl_hardcode_direct" = yes; then
398
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
399
dnl resulting binary.
400
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
402
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
403
dnl Use an explicit option to hardcode DIR into the resulting
405
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
406
dnl Potentially add DIR to rpathdirs.
407
dnl The rpathdirs will be appended to $LIBNAME at the end.
409
for x in $rpathdirs; do
410
if test "X$x" = "X$found_dir"; then
415
if test -z "$haveit"; then
416
rpathdirs="$rpathdirs $found_dir"
419
dnl Rely on "-L$found_dir".
420
dnl But don't add it if it's already contained in the LDFLAGS
421
dnl or the already constructed $LIBNAME
423
for x in $LDFLAGS $LIB[]NAME; do
424
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
425
if test "X$x" = "X-L$found_dir"; then
430
if test -z "$haveit"; then
431
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
433
if test "$acl_hardcode_minus_L" != no; then
434
dnl FIXME: Not sure whether we should use
435
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
437
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
439
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
440
dnl here, because this doesn't fit in flags passed to the
441
dnl compiler. So give up. No hardcoding. This affects only
442
dnl very old systems.
443
dnl FIXME: Not sure whether we should use
444
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
446
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
452
if test "X$found_a" != "X"; then
453
dnl Linking with a static library.
454
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
456
dnl We shouldn't come here, but anyway it's good to have a
458
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
461
dnl Assume the include files are nearby.
462
additional_includedir=
464
*/$acl_libdirstem | */$acl_libdirstem/)
465
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
466
if test "$name" = '$1'; then
467
LIB[]NAME[]_PREFIX="$basedir"
469
additional_includedir="$basedir/include"
471
*/$acl_libdirstem2 | */$acl_libdirstem2/)
472
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
473
if test "$name" = '$1'; then
474
LIB[]NAME[]_PREFIX="$basedir"
476
additional_includedir="$basedir/include"
479
if test "X$additional_includedir" != "X"; then
480
dnl Potentially add $additional_includedir to $INCNAME.
482
dnl 1. if it's the standard /usr/include,
483
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
484
dnl 3. if it's already present in $CPPFLAGS or the already
485
dnl constructed $INCNAME,
486
dnl 4. if it doesn't exist as a directory.
487
if test "X$additional_includedir" != "X/usr/include"; then
489
if test "X$additional_includedir" = "X/usr/local/include"; then
490
if test -n "$GCC"; then
492
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
496
if test -z "$haveit"; then
497
for x in $CPPFLAGS $INC[]NAME; do
498
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
499
if test "X$x" = "X-I$additional_includedir"; then
504
if test -z "$haveit"; then
505
if test -d "$additional_includedir"; then
506
dnl Really add $additional_includedir to $INCNAME.
507
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
513
dnl Look for dependencies.
514
if test -n "$found_la"; then
515
dnl Read the .la file. It defines the variables
516
dnl dlname, library_names, old_library, dependency_libs, current,
517
dnl age, revision, installed, dlopen, dlpreopen, libdir.
518
save_libdir="$libdir"
520
*/* | *\\*) . "$found_la" ;;
521
*) . "./$found_la" ;;
523
libdir="$save_libdir"
524
dnl We use only dependency_libs.
525
for dep in $dependency_libs; do
528
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
529
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
531
dnl 1. if it's the standard /usr/lib,
532
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
533
dnl 3. if it's already present in $LDFLAGS or the already
534
dnl constructed $LIBNAME,
535
dnl 4. if it doesn't exist as a directory.
536
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
537
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
539
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
540
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
541
if test -n "$GCC"; then
543
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
547
if test -z "$haveit"; then
549
for x in $LDFLAGS $LIB[]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 $LIBNAME.
559
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
563
for x in $LDFLAGS $LTLIB[]NAME; do
564
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
565
if test "X$x" = "X-L$additional_libdir"; then
570
if test -z "$haveit"; then
571
if test -d "$additional_libdir"; then
572
dnl Really add $additional_libdir to $LTLIBNAME.
573
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
580
dir=`echo "X$dep" | sed -e 's/^X-R//'`
581
if test "$enable_rpath" != no; then
582
dnl Potentially add DIR to rpathdirs.
583
dnl The rpathdirs will be appended to $LIBNAME at the end.
585
for x in $rpathdirs; do
586
if test "X$x" = "X$dir"; then
591
if test -z "$haveit"; then
592
rpathdirs="$rpathdirs $dir"
594
dnl Potentially add DIR to ltrpathdirs.
595
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
597
for x in $ltrpathdirs; do
598
if test "X$x" = "X$dir"; then
603
if test -z "$haveit"; then
604
ltrpathdirs="$ltrpathdirs $dir"
609
dnl Handle this in the next round.
610
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
613
dnl Handle this in the next round. Throw away the .la's
614
dnl directory; it is already contained in a preceding -L
616
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
619
dnl Most likely an immediate library name.
620
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
621
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
627
dnl Didn't find the library; assume it is in the system directories
628
dnl known to the linker and runtime loader. (All the system
629
dnl directories known to the linker should also be known to the
630
dnl runtime loader, otherwise the system is severely misconfigured.)
631
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
632
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
638
if test "X$rpathdirs" != "X"; then
639
if test -n "$acl_hardcode_libdir_separator"; then
640
dnl Weird platform: only the last -rpath option counts, the user must
641
dnl pass all path elements in one option. We can arrange that for a
642
dnl single library, but not when more than one $LIBNAMEs are used.
644
for found_dir in $rpathdirs; do
645
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
647
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
648
acl_save_libdir="$libdir"
650
eval flag=\"$acl_hardcode_libdir_flag_spec\"
651
libdir="$acl_save_libdir"
652
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
654
dnl The -rpath options are cumulative.
655
for found_dir in $rpathdirs; do
656
acl_save_libdir="$libdir"
658
eval flag=\"$acl_hardcode_libdir_flag_spec\"
659
libdir="$acl_save_libdir"
660
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
664
if test "X$ltrpathdirs" != "X"; then
665
dnl When using libtool, the option that works for both libraries and
666
dnl executables is -R. The -R options are cumulative.
667
for found_dir in $ltrpathdirs; do
668
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
678
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
679
dnl unless already present in VAR.
680
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
681
dnl contains two or three consecutive elements that belong together.
682
AC_DEFUN([AC_LIB_APPENDTOVAR],
684
for element in [$2]; do
687
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
688
if test "X$x" = "X$element"; then
693
if test -z "$haveit"; then
694
[$1]="${[$1]}${[$1]:+ }$element"
699
dnl For those cases where a variable contains several -L and -l options
700
dnl referring to unknown libraries and directories, this macro determines the
701
dnl necessary additional linker options for the runtime path.
702
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
703
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
704
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
705
dnl otherwise linking without libtool is assumed.
706
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
708
AC_REQUIRE([AC_LIB_RPATH])
709
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
711
if test "$enable_rpath" != no; then
712
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
713
dnl Use an explicit option to hardcode directories into the resulting
718
if test -n "$next"; then
720
dnl No need to hardcode the standard /usr/lib.
721
if test "X$dir" != "X/usr/$acl_libdirstem" \
722
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
723
rpathdirs="$rpathdirs $dir"
729
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
730
dnl No need to hardcode the standard /usr/lib.
731
if test "X$dir" != "X/usr/$acl_libdirstem" \
732
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
733
rpathdirs="$rpathdirs $dir"
740
if test "X$rpathdirs" != "X"; then
741
if test -n ""$3""; then
742
dnl libtool is used for linking. Use -R options.
743
for dir in $rpathdirs; do
744
$1="${$1}${$1:+ }-R$dir"
747
dnl The linker is used for linking directly.
748
if test -n "$acl_hardcode_libdir_separator"; then
749
dnl Weird platform: only the last -rpath option counts, the user
750
dnl must pass all path elements in one option.
752
for dir in $rpathdirs; do
753
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
755
acl_save_libdir="$libdir"
757
eval flag=\"$acl_hardcode_libdir_flag_spec\"
758
libdir="$acl_save_libdir"
761
dnl The -rpath options are cumulative.
762
for dir in $rpathdirs; do
763
acl_save_libdir="$libdir"
765
eval flag=\"$acl_hardcode_libdir_flag_spec\"
766
libdir="$acl_save_libdir"
767
$1="${$1}${$1:+ }$flag"