1
# lib-link.m4 serial 4 (gettext-0.12)
2
dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3
dnl This file is free software, distributed under the terms of the GNU
4
dnl General Public License. As a special exception to the GNU General
5
dnl Public License, this file may be distributed as part of a program
6
dnl that contains a configuration script generated by Autoconf, under
7
dnl the same distribution terms as the rest of that program.
1
# lib-link.m4 serial 9 (gettext-0.16)
2
dnl Copyright (C) 2001-2006 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.
9
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.
13
13
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
95
95
dnl hardcode_direct, hardcode_minus_L.
96
96
AC_DEFUN([AC_LIB_RPATH],
98
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
99
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
98
100
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
99
101
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
100
102
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
124
126
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
125
127
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
129
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
127
130
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
128
131
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
129
132
dnl By default, look in $includedir and $libdir.
197
200
if test $use_additional = yes; then
198
if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
201
if test -n "$shlibext" \
202
&& { test -f "$additional_libdir/lib$name.$shlibext" \
203
|| { test "$shlibext" = dll \
204
&& test -f "$additional_libdir/lib$name.dll.a"; }; }; then
199
205
found_dir="$additional_libdir"
200
found_so="$additional_libdir/lib$name.$shlibext"
206
if test -f "$additional_libdir/lib$name.$shlibext"; then
207
found_so="$additional_libdir/lib$name.$shlibext"
209
found_so="$additional_libdir/lib$name.dll.a"
201
211
if test -f "$additional_libdir/lib$name.la"; then
202
212
found_la="$additional_libdir/lib$name.la"
219
229
dir=`echo "X$x" | sed -e 's/^X-L//'`
220
if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
230
if test -n "$shlibext" \
231
&& { test -f "$dir/lib$name.$shlibext" \
232
|| { test "$shlibext" = dll \
233
&& test -f "$dir/lib$name.dll.a"; }; }; then
222
found_so="$dir/lib$name.$shlibext"
235
if test -f "$dir/lib$name.$shlibext"; then
236
found_so="$dir/lib$name.$shlibext"
238
found_so="$dir/lib$name.dll.a"
223
240
if test -f "$dir/lib$name.la"; then
224
241
found_la="$dir/lib$name.la"
246
263
dnl Linking with a shared library. We attempt to hardcode its
247
264
dnl directory into the executable's runpath, unless it's the
248
265
dnl standard /usr/lib.
249
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
266
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
250
267
dnl No hardcoding is needed.
251
268
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
332
349
dnl Assume the include files are nearby.
333
350
additional_includedir=
334
351
case "$found_dir" in
336
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
352
*/$acl_libdirstem | */$acl_libdirstem/)
353
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
337
354
additional_includedir="$basedir/include"
394
411
dnl 3. if it's already present in $LDFLAGS or the already
395
412
dnl constructed $LIBNAME,
396
413
dnl 4. if it doesn't exist as a directory.
397
if test "X$additional_libdir" != "X/usr/lib"; then
414
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
399
if test "X$additional_libdir" = "X/usr/local/lib"; then
416
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
400
417
if test -n "$GCC"; then
419
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
570
dnl For those cases where a variable contains several -L and -l options
571
dnl referring to unknown libraries and directories, this macro determines the
572
dnl necessary additional linker options for the runtime path.
573
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
574
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
575
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
576
dnl otherwise linking without libtool is assumed.
577
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
579
AC_REQUIRE([AC_LIB_RPATH])
580
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
582
if test "$enable_rpath" != no; then
583
if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
584
dnl Use an explicit option to hardcode directories into the resulting
589
if test -n "$next"; then
591
dnl No need to hardcode the standard /usr/lib.
592
if test "X$dir" != "X/usr/$acl_libdirstem"; then
593
rpathdirs="$rpathdirs $dir"
599
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
600
dnl No need to hardcode the standard /usr/lib.
601
if test "X$dir" != "X/usr/$acl_libdirstem"; then
602
rpathdirs="$rpathdirs $dir"
609
if test "X$rpathdirs" != "X"; then
610
if test -n ""$3""; then
611
dnl libtool is used for linking. Use -R options.
612
for dir in $rpathdirs; do
613
$1="${$1}${$1:+ }-R$dir"
616
dnl The linker is used for linking directly.
617
if test -n "$hardcode_libdir_separator"; then
618
dnl Weird platform: only the last -rpath option counts, the user
619
dnl must pass all path elements in one option.
621
for dir in $rpathdirs; do
622
alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$dir"
624
acl_save_libdir="$libdir"
626
eval flag=\"$hardcode_libdir_flag_spec\"
627
libdir="$acl_save_libdir"
630
dnl The -rpath options are cumulative.
631
for dir in $rpathdirs; do
632
acl_save_libdir="$libdir"
634
eval flag=\"$hardcode_libdir_flag_spec\"
635
libdir="$acl_save_libdir"
636
$1="${$1}${$1:+ }$flag"