1
# lib-link.m4 serial 13 (gettext-0.17)
2
dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
1
# lib-link.m4 serial 18 (gettext-0.18)
2
dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
7
7
dnl From Bruno Haible.
11
11
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12
12
dnl the libraries corresponding to explicit and implicit dependencies.
19
19
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20
20
AC_REQUIRE([AC_LIB_RPATH])
21
define([Name],[translit([$1],[./-], [___])])
22
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
21
pushdef([Name],[translit([$1],[./-], [___])])
22
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
24
24
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25
25
AC_LIB_LINKFLAGS_BODY([$1], [$2])
26
26
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
39
39
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40
40
dnl results of this search when this library appears as a dependency.
46
46
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [system])
58
58
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
59
59
AC_REQUIRE([AC_LIB_RPATH])
60
define([Name],[translit([$1],[./-], [___])])
61
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
60
pushdef([Name],[translit([$1],[./-], [___])])
61
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
64
64
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
114
114
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
115
115
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
116
116
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
117
AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
117
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
118
118
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
119
119
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
131
131
acl_hardcode_direct="$acl_cv_hardcode_direct"
132
132
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
133
133
dnl Determine whether the user wants rpath handling at all.
134
AC_ARG_ENABLE([rpath],
135
135
[ --disable-rpath do not hardcode runtime library paths],
136
136
:, enable_rpath=yes)
139
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies, system]) searches for
140
dnl libname and the libraries corresponding to explicit and
141
dnl implicit dependencies.
139
dnl AC_LIB_FROMPACKAGE(name, package)
140
dnl declares that libname comes from the given package. The configure file
141
dnl will then not have a --with-libname-prefix option but a
142
dnl --with-package-prefix option. Several libraries can come from the same
143
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
144
dnl macro call that searches for libname.
145
AC_DEFUN([AC_LIB_FROMPACKAGE],
147
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
148
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
149
define([acl_frompackage_]NAME, [$2])
152
pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
153
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
154
define([acl_libsinpackage_]PACKUP,
155
m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
160
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies, system]) searches for
161
dnl libname and the libraries corresponding to explicit and implicit
142
163
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
143
164
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
144
165
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
146
167
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
148
169
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
149
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
150
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
170
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
171
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
172
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
173
pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
174
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
175
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
151
176
dnl Autoconf >= 2.61 supports dots in --with options.
152
define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
177
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
153
178
dnl By default, look in $includedir and $libdir.
154
179
use_additional=yes
155
180
if test "x$GCC" = "xyes" -a "x$3" = "xsystem"
161
187
AC_LIB_WITH_FINAL_PREFIX([
162
188
eval additional_includedir=\"$includedir\"
163
189
eval additional_libdir=\"$libdir\"
165
AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
166
[ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
167
--without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
191
AC_ARG_WITH(P_A_C_K[-prefix],
192
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
193
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
169
195
if test "X$withval" = "Xno"; then
170
196
use_additional=no
178
204
additional_includedir="$withval/include"
179
205
additional_libdir="$withval/$acl_libdirstem"
206
if test "$acl_libdirstem2" != "$acl_libdirstem" \
207
&& ! test -d "$withval/$acl_libdirstem"; then
208
additional_libdir="$withval/$acl_libdirstem2"
335
365
dnl Linking with a shared library. We attempt to hardcode its
336
366
dnl directory into the executable's runpath, unless it's the
337
367
dnl standard /usr/lib.
338
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
368
if test "$enable_rpath" = no \
369
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
370
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
339
371
dnl No hardcoding is needed.
340
372
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
423
455
case "$found_dir" in
424
456
*/$acl_libdirstem | */$acl_libdirstem/)
425
457
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
426
LIB[]NAME[]_PREFIX="$basedir"
458
if test "$name" = '$1'; then
459
LIB[]NAME[]_PREFIX="$basedir"
461
additional_includedir="$basedir/include"
463
*/$acl_libdirstem2 | */$acl_libdirstem2/)
464
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
465
if test "$name" = '$1'; then
466
LIB[]NAME[]_PREFIX="$basedir"
427
468
additional_includedir="$basedir/include"
484
525
dnl 3. if it's already present in $LDFLAGS or the already
485
526
dnl constructed $LIBNAME,
486
527
dnl 4. if it doesn't exist as a directory.
487
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
528
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
529
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
489
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
531
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
532
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
490
533
if test -n "$GCC"; then
492
535
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
662
710
if test -n "$next"; then
664
712
dnl No need to hardcode the standard /usr/lib.
665
if test "X$dir" != "X/usr/$acl_libdirstem"; then
713
if test "X$dir" != "X/usr/$acl_libdirstem" \
714
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
666
715
rpathdirs="$rpathdirs $dir"
672
721
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
673
722
dnl No need to hardcode the standard /usr/lib.
674
if test "X$dir" != "X/usr/$acl_libdirstem"; then
723
if test "X$dir" != "X/usr/$acl_libdirstem" \
724
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
675
725
rpathdirs="$rpathdirs $dir"