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.m4169
1 files changed, 96 insertions, 73 deletions
diff --git a/m4/lib-link.m4 b/m4/lib-link.m4
index 2f51855..eecf70e 100644
--- a/m4/lib-link.m4
+++ b/m4/lib-link.m4
@@ -1,12 +1,12 @@
1# lib-link.m4 serial 26 (gettext-0.18.2) 1# lib-link.m4 serial 31
2dnl Copyright (C) 2001-2016 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.54]) 9AC_PREREQ([2.61])
10 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.
@@ -124,8 +124,8 @@ dnl acl_hardcode_direct,
124dnl acl_hardcode_minus_L. 124dnl acl_hardcode_minus_L.
125AC_DEFUN([AC_LIB_RPATH], 125AC_DEFUN([AC_LIB_RPATH],
126[ 126[
127 dnl Tell automake >= 1.10 to complain if config.rpath is missing. 127 dnl Complain if config.rpath is missing.
128 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) 128 AC_REQUIRE_AUX_FILE([config.rpath])
129 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS 129 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
130 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld 130 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
131 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 131 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
@@ -187,17 +187,17 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
187 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], 187 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
188 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 188 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
189 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) 189 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
190 dnl Autoconf >= 2.61 supports dots in --with options.
191 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
192 dnl By default, look in $includedir and $libdir. 190 dnl By default, look in $includedir and $libdir.
193 use_additional=yes 191 use_additional=yes
194 AC_LIB_WITH_FINAL_PREFIX([ 192 AC_LIB_WITH_FINAL_PREFIX([
195 eval additional_includedir=\"$includedir\" 193 eval additional_includedir=\"$includedir\"
196 eval additional_libdir=\"$libdir\" 194 eval additional_libdir=\"$libdir\"
195 eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
196 eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
197 ]) 197 ])
198 AC_ARG_WITH(P_A_C_K[-prefix], 198 AC_ARG_WITH(PACK[-prefix],
199[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib 199[[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
200 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], 200 --without-]]PACK[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
201[ 201[
202 if test "X$withval" = "Xno"; then 202 if test "X$withval" = "Xno"; then
203 use_additional=no 203 use_additional=no
@@ -206,17 +206,23 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
206 AC_LIB_WITH_FINAL_PREFIX([ 206 AC_LIB_WITH_FINAL_PREFIX([
207 eval additional_includedir=\"$includedir\" 207 eval additional_includedir=\"$includedir\"
208 eval additional_libdir=\"$libdir\" 208 eval additional_libdir=\"$libdir\"
209 eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
210 eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
209 ]) 211 ])
210 else 212 else
211 additional_includedir="$withval/include" 213 additional_includedir="$withval/include"
212 additional_libdir="$withval/$acl_libdirstem" 214 additional_libdir="$withval/$acl_libdirstem"
213 if test "$acl_libdirstem2" != "$acl_libdirstem" \ 215 additional_libdir2="$withval/$acl_libdirstem2"
214 && ! test -d "$withval/$acl_libdirstem"; then 216 additional_libdir3="$withval/$acl_libdirstem3"
215 additional_libdir="$withval/$acl_libdirstem2"
216 fi
217 fi 217 fi
218 fi 218 fi
219]) 219])
220 if test "X$additional_libdir2" = "X$additional_libdir"; then
221 additional_libdir2=
222 fi
223 if test "X$additional_libdir3" = "X$additional_libdir"; then
224 additional_libdir3=
225 fi
220 dnl Search the library and its dependencies in $additional_libdir and 226 dnl Search the library and its dependencies in $additional_libdir and
221 dnl $LDFLAGS. Using breadth-first-seach. 227 dnl $LDFLAGS. Using breadth-first-seach.
222 LIB[]NAME= 228 LIB[]NAME=
@@ -272,48 +278,54 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
272 shrext= 278 shrext=
273 fi 279 fi
274 if test $use_additional = yes; then 280 if test $use_additional = yes; then
275 dir="$additional_libdir" 281 for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do
276 dnl The same code as in the loop below: 282 if test "X$found_dir" = "X"; then
277 dnl First look for a shared library. 283 eval dir=\$$additional_libdir_variable
278 if test -n "$acl_shlibext"; then 284 if test -n "$dir"; then
279 if test -f "$dir/$libname$shrext"; then 285 dnl The same code as in the loop below:
280 found_dir="$dir" 286 dnl First look for a shared library.
281 found_so="$dir/$libname$shrext" 287 if test -n "$acl_shlibext"; then
282 else 288 if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
283 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then 289 found_dir="$dir"
284 ver=`(cd "$dir" && \ 290 found_so="$dir/$libname$shrext"
285 for f in "$libname$shrext".*; do echo "$f"; done \ 291 else
286 | sed -e "s,^$libname$shrext\\\\.,," \ 292 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
287 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ 293 ver=`(cd "$dir" && \
288 | sed 1q ) 2>/dev/null` 294 for f in "$libname$shrext".*; do echo "$f"; done \
289 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then 295 | sed -e "s,^$libname$shrext\\\\.,," \
290 found_dir="$dir" 296 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
291 found_so="$dir/$libname$shrext.$ver" 297 | sed 1q ) 2>/dev/null`
298 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
299 found_dir="$dir"
300 found_so="$dir/$libname$shrext.$ver"
301 fi
302 else
303 eval library_names=\"$acl_library_names_spec\"
304 for f in $library_names; do
305 if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
306 found_dir="$dir"
307 found_so="$dir/$f"
308 break
309 fi
310 done
311 fi
312 fi
292 fi 313 fi
293 else 314 dnl Then look for a static library.
294 eval library_names=\"$acl_library_names_spec\" 315 if test "X$found_dir" = "X"; then
295 for f in $library_names; do 316 if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
296 if test -f "$dir/$f"; then
297 found_dir="$dir" 317 found_dir="$dir"
298 found_so="$dir/$f" 318 found_a="$dir/$libname.$acl_libext"
299 break
300 fi 319 fi
301 done 320 fi
321 if test "X$found_dir" != "X"; then
322 if test -f "$dir/$libname.la"; then
323 found_la="$dir/$libname.la"
324 fi
325 fi
302 fi 326 fi
303 fi 327 fi
304 fi 328 done
305 dnl Then look for a static library.
306 if test "X$found_dir" = "X"; then
307 if test -f "$dir/$libname.$acl_libext"; then
308 found_dir="$dir"
309 found_a="$dir/$libname.$acl_libext"
310 fi
311 fi
312 if test "X$found_dir" != "X"; then
313 if test -f "$dir/$libname.la"; then
314 found_la="$dir/$libname.la"
315 fi
316 fi
317 fi 329 fi
318 if test "X$found_dir" = "X"; then 330 if test "X$found_dir" = "X"; then
319 for x in $LDFLAGS $LTLIB[]NAME; do 331 for x in $LDFLAGS $LTLIB[]NAME; do
@@ -323,7 +335,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
323 dir=`echo "X$x" | sed -e 's/^X-L//'` 335 dir=`echo "X$x" | sed -e 's/^X-L//'`
324 dnl First look for a shared library. 336 dnl First look for a shared library.
325 if test -n "$acl_shlibext"; then 337 if test -n "$acl_shlibext"; then
326 if test -f "$dir/$libname$shrext"; then 338 if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
327 found_dir="$dir" 339 found_dir="$dir"
328 found_so="$dir/$libname$shrext" 340 found_so="$dir/$libname$shrext"
329 else 341 else
@@ -333,14 +345,14 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
333 | sed -e "s,^$libname$shrext\\\\.,," \ 345 | sed -e "s,^$libname$shrext\\\\.,," \
334 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ 346 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
335 | sed 1q ) 2>/dev/null` 347 | sed 1q ) 2>/dev/null`
336 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then 348 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
337 found_dir="$dir" 349 found_dir="$dir"
338 found_so="$dir/$libname$shrext.$ver" 350 found_so="$dir/$libname$shrext.$ver"
339 fi 351 fi
340 else 352 else
341 eval library_names=\"$acl_library_names_spec\" 353 eval library_names=\"$acl_library_names_spec\"
342 for f in $library_names; do 354 for f in $library_names; do
343 if test -f "$dir/$f"; then 355 if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
344 found_dir="$dir" 356 found_dir="$dir"
345 found_so="$dir/$f" 357 found_so="$dir/$f"
346 break 358 break
@@ -351,7 +363,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
351 fi 363 fi
352 dnl Then look for a static library. 364 dnl Then look for a static library.
353 if test "X$found_dir" = "X"; then 365 if test "X$found_dir" = "X"; then
354 if test -f "$dir/$libname.$acl_libext"; then 366 if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
355 found_dir="$dir" 367 found_dir="$dir"
356 found_a="$dir/$libname.$acl_libext" 368 found_a="$dir/$libname.$acl_libext"
357 fi 369 fi
@@ -377,7 +389,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
377 dnl standard /usr/lib. 389 dnl standard /usr/lib.
378 if test "$enable_rpath" = no \ 390 if test "$enable_rpath" = no \
379 || test "X$found_dir" = "X/usr/$acl_libdirstem" \ 391 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
380 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then 392 || test "X$found_dir" = "X/usr/$acl_libdirstem2" \
393 || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then
381 dnl No hardcoding is needed. 394 dnl No hardcoding is needed.
382 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 395 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
383 else 396 else
@@ -477,6 +490,13 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
477 fi 490 fi
478 additional_includedir="$basedir/include" 491 additional_includedir="$basedir/include"
479 ;; 492 ;;
493 */$acl_libdirstem3 | */$acl_libdirstem3/)
494 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`
495 if test "$name" = '$1'; then
496 LIB[]NAME[]_PREFIX="$basedir"
497 fi
498 additional_includedir="$basedir/include"
499 ;;
480 esac 500 esac
481 if test "X$additional_includedir" != "X"; then 501 if test "X$additional_includedir" != "X"; then
482 dnl Potentially add $additional_includedir to $INCNAME. 502 dnl Potentially add $additional_includedir to $INCNAME.
@@ -527,19 +547,21 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
527 for dep in $dependency_libs; do 547 for dep in $dependency_libs; do
528 case "$dep" in 548 case "$dep" in
529 -L*) 549 -L*)
530 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` 550 dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
531 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. 551 dnl Potentially add $dependency_libdir to $LIBNAME and $LTLIBNAME.
532 dnl But don't add it 552 dnl But don't add it
533 dnl 1. if it's the standard /usr/lib, 553 dnl 1. if it's the standard /usr/lib,
534 dnl 2. if it's /usr/local/lib and we are using GCC on Linux, 554 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
535 dnl 3. if it's already present in $LDFLAGS or the already 555 dnl 3. if it's already present in $LDFLAGS or the already
536 dnl constructed $LIBNAME, 556 dnl constructed $LIBNAME,
537 dnl 4. if it doesn't exist as a directory. 557 dnl 4. if it doesn't exist as a directory.
538 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ 558 if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \
539 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then 559 && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \
560 && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then
540 haveit= 561 haveit=
541 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ 562 if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \
542 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then 563 || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \
564 || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then
543 if test -n "$GCC"; then 565 if test -n "$GCC"; then
544 case $host_os in 566 case $host_os in
545 linux* | gnu* | k*bsd*-gnu) haveit=yes;; 567 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
@@ -550,29 +572,29 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
550 haveit= 572 haveit=
551 for x in $LDFLAGS $LIB[]NAME; do 573 for x in $LDFLAGS $LIB[]NAME; do
552 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 574 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
553 if test "X$x" = "X-L$additional_libdir"; then 575 if test "X$x" = "X-L$dependency_libdir"; then
554 haveit=yes 576 haveit=yes
555 break 577 break
556 fi 578 fi
557 done 579 done
558 if test -z "$haveit"; then 580 if test -z "$haveit"; then
559 if test -d "$additional_libdir"; then 581 if test -d "$dependency_libdir"; then
560 dnl Really add $additional_libdir to $LIBNAME. 582 dnl Really add $dependency_libdir to $LIBNAME.
561 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" 583 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$dependency_libdir"
562 fi 584 fi
563 fi 585 fi
564 haveit= 586 haveit=
565 for x in $LDFLAGS $LTLIB[]NAME; do 587 for x in $LDFLAGS $LTLIB[]NAME; do
566 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 588 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
567 if test "X$x" = "X-L$additional_libdir"; then 589 if test "X$x" = "X-L$dependency_libdir"; then
568 haveit=yes 590 haveit=yes
569 break 591 break
570 fi 592 fi
571 done 593 done
572 if test -z "$haveit"; then 594 if test -z "$haveit"; then
573 if test -d "$additional_libdir"; then 595 if test -d "$dependency_libdir"; then
574 dnl Really add $additional_libdir to $LTLIBNAME. 596 dnl Really add $dependency_libdir to $LTLIBNAME.
575 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" 597 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$dependency_libdir"
576 fi 598 fi
577 fi 599 fi
578 fi 600 fi
@@ -670,7 +692,6 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
670 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" 692 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
671 done 693 done
672 fi 694 fi
673 popdef([P_A_C_K])
674 popdef([PACKLIBS]) 695 popdef([PACKLIBS])
675 popdef([PACKUP]) 696 popdef([PACKUP])
676 popdef([PACK]) 697 popdef([PACK])
@@ -721,7 +742,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
721 dir="$next" 742 dir="$next"
722 dnl No need to hardcode the standard /usr/lib. 743 dnl No need to hardcode the standard /usr/lib.
723 if test "X$dir" != "X/usr/$acl_libdirstem" \ 744 if test "X$dir" != "X/usr/$acl_libdirstem" \
724 && test "X$dir" != "X/usr/$acl_libdirstem2"; then 745 && test "X$dir" != "X/usr/$acl_libdirstem2" \
746 && test "X$dir" != "X/usr/$acl_libdirstem3"; then
725 rpathdirs="$rpathdirs $dir" 747 rpathdirs="$rpathdirs $dir"
726 fi 748 fi
727 next= 749 next=
@@ -731,7 +753,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
731 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` 753 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
732 dnl No need to hardcode the standard /usr/lib. 754 dnl No need to hardcode the standard /usr/lib.
733 if test "X$dir" != "X/usr/$acl_libdirstem" \ 755 if test "X$dir" != "X/usr/$acl_libdirstem" \
734 && test "X$dir" != "X/usr/$acl_libdirstem2"; then 756 && test "X$dir" != "X/usr/$acl_libdirstem2" \
757 && test "X$dir" != "X/usr/$acl_libdirstem3"; then
735 rpathdirs="$rpathdirs $dir" 758 rpathdirs="$rpathdirs $dir"
736 fi 759 fi
737 next= ;; 760 next= ;;