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, 19 insertions, 112 deletions
diff --git a/m4/lib-link.m4 b/m4/lib-link.m4
index f95b7ba8..eeb200d2 100644
--- a/m4/lib-link.m4
+++ b/m4/lib-link.m4
@@ -1,13 +1,13 @@
1# lib-link.m4 serial 9 (gettext-0.16) 1# lib-link.m4 serial 4 (gettext-0.12)
2dnl Copyright (C) 2001-2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software, distributed under the terms of the GNU
4dnl gives unlimited permission to copy and/or distribute it, 4dnl General Public License. As a special exception to the GNU General
5dnl with or without modifications, as long as this notice is preserved. 5dnl Public License, this file may be distributed as part of a program
6dnl that contains a configuration script generated by Autoconf, under
7dnl the same distribution terms as the rest of that program.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
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,8 +95,6 @@ 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])])
100 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS 98 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
101 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld 99 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
102 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 100 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
@@ -126,7 +124,6 @@ dnl the libraries corresponding to explicit and implicit dependencies.
126dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. 124dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
127AC_DEFUN([AC_LIB_LINKFLAGS_BODY], 125AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
128[ 126[
129 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
130 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 127 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
131 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 128 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
132 dnl By default, look in $includedir and $libdir. 129 dnl By default, look in $includedir and $libdir.
@@ -149,7 +146,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
149 ]) 146 ])
150 else 147 else
151 additional_includedir="$withval/include" 148 additional_includedir="$withval/include"
152 additional_libdir="$withval/$acl_libdirstem" 149 additional_libdir="$withval/lib"
153 fi 150 fi
154 fi 151 fi
155]) 152])
@@ -198,16 +195,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
198 found_so= 195 found_so=
199 found_a= 196 found_a=
200 if test $use_additional = yes; then 197 if test $use_additional = yes; then
201 if test -n "$shlibext" \ 198 if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
202 && { test -f "$additional_libdir/lib$name.$shlibext" \
203 || { test "$shlibext" = dll \
204 && test -f "$additional_libdir/lib$name.dll.a"; }; }; then
205 found_dir="$additional_libdir" 199 found_dir="$additional_libdir"
206 if test -f "$additional_libdir/lib$name.$shlibext"; then 200 found_so="$additional_libdir/lib$name.$shlibext"
207 found_so="$additional_libdir/lib$name.$shlibext"
208 else
209 found_so="$additional_libdir/lib$name.dll.a"
210 fi
211 if test -f "$additional_libdir/lib$name.la"; then 201 if test -f "$additional_libdir/lib$name.la"; then
212 found_la="$additional_libdir/lib$name.la" 202 found_la="$additional_libdir/lib$name.la"
213 fi 203 fi
@@ -227,16 +217,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
227 case "$x" in 217 case "$x" in
228 -L*) 218 -L*)
229 dir=`echo "X$x" | sed -e 's/^X-L//'` 219 dir=`echo "X$x" | sed -e 's/^X-L//'`
230 if test -n "$shlibext" \ 220 if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
231 && { test -f "$dir/lib$name.$shlibext" \
232 || { test "$shlibext" = dll \
233 && test -f "$dir/lib$name.dll.a"; }; }; then
234 found_dir="$dir" 221 found_dir="$dir"
235 if test -f "$dir/lib$name.$shlibext"; then 222 found_so="$dir/lib$name.$shlibext"
236 found_so="$dir/lib$name.$shlibext"
237 else
238 found_so="$dir/lib$name.dll.a"
239 fi
240 if test -f "$dir/lib$name.la"; then 223 if test -f "$dir/lib$name.la"; then
241 found_la="$dir/lib$name.la" 224 found_la="$dir/lib$name.la"
242 fi 225 fi
@@ -263,7 +246,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
263 dnl Linking with a shared library. We attempt to hardcode its 246 dnl Linking with a shared library. We attempt to hardcode its
264 dnl directory into the executable's runpath, unless it's the 247 dnl directory into the executable's runpath, unless it's the
265 dnl standard /usr/lib. 248 dnl standard /usr/lib.
266 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then 249 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
267 dnl No hardcoding is needed. 250 dnl No hardcoding is needed.
268 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 251 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
269 else 252 else
@@ -349,8 +332,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
349 dnl Assume the include files are nearby. 332 dnl Assume the include files are nearby.
350 additional_includedir= 333 additional_includedir=
351 case "$found_dir" in 334 case "$found_dir" in
352 */$acl_libdirstem | */$acl_libdirstem/) 335 */lib | */lib/)
353 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` 336 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
354 additional_includedir="$basedir/include" 337 additional_includedir="$basedir/include"
355 ;; 338 ;;
356 esac 339 esac
@@ -367,7 +350,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
367 if test "X$additional_includedir" = "X/usr/local/include"; then 350 if test "X$additional_includedir" = "X/usr/local/include"; then
368 if test -n "$GCC"; then 351 if test -n "$GCC"; then
369 case $host_os in 352 case $host_os in
370 linux* | gnu* | k*bsd*-gnu) haveit=yes;; 353 linux*) haveit=yes;;
371 esac 354 esac
372 fi 355 fi
373 fi 356 fi
@@ -411,12 +394,12 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
411 dnl 3. if it's already present in $LDFLAGS or the already 394 dnl 3. if it's already present in $LDFLAGS or the already
412 dnl constructed $LIBNAME, 395 dnl constructed $LIBNAME,
413 dnl 4. if it doesn't exist as a directory. 396 dnl 4. if it doesn't exist as a directory.
414 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then 397 if test "X$additional_libdir" != "X/usr/lib"; then
415 haveit= 398 haveit=
416 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then 399 if test "X$additional_libdir" = "X/usr/local/lib"; then
417 if test -n "$GCC"; then 400 if test -n "$GCC"; then
418 case $host_os in 401 case $host_os in
419 linux* | gnu* | k*bsd*-gnu) haveit=yes;; 402 linux*) haveit=yes;;
420 esac 403 esac
421 fi 404 fi
422 fi 405 fi
@@ -566,79 +549,3 @@ AC_DEFUN([AC_LIB_APPENDTOVAR],
566 fi 549 fi
567 done 550 done
568]) 551])
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])