aboutsummaryrefslogtreecommitdiff
path: root/m4/lib-link.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/lib-link.m4')
-rw-r--r--m4/lib-link.m4131
1 files changed, 112 insertions, 19 deletions
diff --git a/m4/lib-link.m4 b/m4/lib-link.m4
index eeb200d2..f95b7ba8 100644
--- a/m4/lib-link.m4
+++ b/m4/lib-link.m4
@@ -1,13 +1,13 @@
1# lib-link.m4 serial 4 (gettext-0.12) 1# lib-link.m4 serial 9 (gettext-0.16)
2dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2006 Free Software Foundation, Inc.
3dnl This file is free software, distributed under the terms of the GNU 3dnl This file is free software; the Free Software Foundation
4dnl General Public License. As a special exception to the GNU General 4dnl gives unlimited permission to copy and/or distribute it,
5dnl Public License, this file may be distributed as part of a program 5dnl with or without modifications, as long as this notice is preserved.
6dnl that contains a configuration script generated by Autoconf, under
7dnl the same distribution terms as the rest of that program.
8 6
9dnl From Bruno Haible. 7dnl From Bruno Haible.
10 8
9AC_PREREQ(2.50)
10
11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and 11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12dnl the libraries corresponding to explicit and implicit dependencies. 12dnl the libraries corresponding to explicit and implicit dependencies.
13dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and 13dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
@@ -95,6 +95,8 @@ dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
95dnl hardcode_direct, hardcode_minus_L. 95dnl hardcode_direct, hardcode_minus_L.
96AC_DEFUN([AC_LIB_RPATH], 96AC_DEFUN([AC_LIB_RPATH],
97[ 97[
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 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS 100 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
99 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld 101 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
100 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 102 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
@@ -124,6 +126,7 @@ dnl the libraries corresponding to explicit and implicit dependencies.
124dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. 126dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
125AC_DEFUN([AC_LIB_LINKFLAGS_BODY], 127AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
126[ 128[
129 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
127 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 130 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
128 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 131 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
129 dnl By default, look in $includedir and $libdir. 132 dnl By default, look in $includedir and $libdir.
@@ -146,7 +149,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
146 ]) 149 ])
147 else 150 else
148 additional_includedir="$withval/include" 151 additional_includedir="$withval/include"
149 additional_libdir="$withval/lib" 152 additional_libdir="$withval/$acl_libdirstem"
150 fi 153 fi
151 fi 154 fi
152]) 155])
@@ -195,9 +198,16 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
195 found_so= 198 found_so=
196 found_a= 199 found_a=
197 if test $use_additional = yes; then 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 found_dir="$additional_libdir" 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"
208 else
209 found_so="$additional_libdir/lib$name.dll.a"
210 fi
201 if test -f "$additional_libdir/lib$name.la"; then 211 if test -f "$additional_libdir/lib$name.la"; then
202 found_la="$additional_libdir/lib$name.la" 212 found_la="$additional_libdir/lib$name.la"
203 fi 213 fi
@@ -217,9 +227,16 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
217 case "$x" in 227 case "$x" in
218 -L*) 228 -L*)
219 dir=`echo "X$x" | sed -e 's/^X-L//'` 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
221 found_dir="$dir" 234 found_dir="$dir"
222 found_so="$dir/lib$name.$shlibext" 235 if test -f "$dir/lib$name.$shlibext"; then
236 found_so="$dir/lib$name.$shlibext"
237 else
238 found_so="$dir/lib$name.dll.a"
239 fi
223 if test -f "$dir/lib$name.la"; then 240 if test -f "$dir/lib$name.la"; then
224 found_la="$dir/lib$name.la" 241 found_la="$dir/lib$name.la"
225 fi 242 fi
@@ -246,7 +263,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
246 dnl Linking with a shared library. We attempt to hardcode its 263 dnl Linking with a shared library. We attempt to hardcode its
247 dnl directory into the executable's runpath, unless it's the 264 dnl directory into the executable's runpath, unless it's the
248 dnl standard /usr/lib. 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 dnl No hardcoding is needed. 267 dnl No hardcoding is needed.
251 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 268 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
252 else 269 else
@@ -332,8 +349,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
332 dnl Assume the include files are nearby. 349 dnl Assume the include files are nearby.
333 additional_includedir= 350 additional_includedir=
334 case "$found_dir" in 351 case "$found_dir" in
335 */lib | */lib/) 352 */$acl_libdirstem | */$acl_libdirstem/)
336 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` 353 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
337 additional_includedir="$basedir/include" 354 additional_includedir="$basedir/include"
338 ;; 355 ;;
339 esac 356 esac
@@ -350,7 +367,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
350 if test "X$additional_includedir" = "X/usr/local/include"; then 367 if test "X$additional_includedir" = "X/usr/local/include"; then
351 if test -n "$GCC"; then 368 if test -n "$GCC"; then
352 case $host_os in 369 case $host_os in
353 linux*) haveit=yes;; 370 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
354 esac 371 esac
355 fi 372 fi
356 fi 373 fi
@@ -394,12 +411,12 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
394 dnl 3. if it's already present in $LDFLAGS or the already 411 dnl 3. if it's already present in $LDFLAGS or the already
395 dnl constructed $LIBNAME, 412 dnl constructed $LIBNAME,
396 dnl 4. if it doesn't exist as a directory. 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
398 haveit= 415 haveit=
399 if test "X$additional_libdir" = "X/usr/local/lib"; then 416 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
400 if test -n "$GCC"; then 417 if test -n "$GCC"; then
401 case $host_os in 418 case $host_os in
402 linux*) haveit=yes;; 419 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
403 esac 420 esac
404 fi 421 fi
405 fi 422 fi
@@ -549,3 +566,79 @@ AC_DEFUN([AC_LIB_APPENDTOVAR],
549 fi 566 fi
550 done 567 done
551]) 568])
569
570dnl For those cases where a variable contains several -L and -l options
571dnl referring to unknown libraries and directories, this macro determines the
572dnl necessary additional linker options for the runtime path.
573dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
574dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
575dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
576dnl otherwise linking without libtool is assumed.
577AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
578[
579 AC_REQUIRE([AC_LIB_RPATH])
580 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
581 $1=
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
585 dnl binary.
586 rpathdirs=
587 next=
588 for opt in $2; do
589 if test -n "$next"; then
590 dir="$next"
591 dnl No need to hardcode the standard /usr/lib.
592 if test "X$dir" != "X/usr/$acl_libdirstem"; then
593 rpathdirs="$rpathdirs $dir"
594 fi
595 next=
596 else
597 case $opt in
598 -L) next=yes ;;
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"
603 fi
604 next= ;;
605 *) next= ;;
606 esac
607 fi
608 done
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"
614 done
615 else
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.
620 alldirs=
621 for dir in $rpathdirs; do
622 alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$dir"
623 done
624 acl_save_libdir="$libdir"
625 libdir="$alldirs"
626 eval flag=\"$hardcode_libdir_flag_spec\"
627 libdir="$acl_save_libdir"
628 $1="$flag"
629 else
630 dnl The -rpath options are cumulative.
631 for dir in $rpathdirs; do
632 acl_save_libdir="$libdir"
633 libdir="$dir"
634 eval flag=\"$hardcode_libdir_flag_spec\"
635 libdir="$acl_save_libdir"
636 $1="${$1}${$1:+ }$flag"
637 done
638 fi
639 fi
640 fi
641 fi
642 fi
643 AC_SUBST([$1])
644])