1a32e9e42Smrg# lib-link.m4 serial 26 (gettext-0.18.2) 2a32e9e42Smrgdnl Copyright (C) 2001-2016 Free Software Foundation, Inc. 3a32e9e42Smrgdnl This file is free software; the Free Software Foundation 4a32e9e42Smrgdnl gives unlimited permission to copy and/or distribute it, 5a32e9e42Smrgdnl with or without modifications, as long as this notice is preserved. 6a32e9e42Smrg 7a32e9e42Smrgdnl From Bruno Haible. 8a32e9e42Smrg 9a32e9e42SmrgAC_PREREQ([2.54]) 10a32e9e42Smrg 11a32e9e42Smrgdnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and 12a32e9e42Smrgdnl the libraries corresponding to explicit and implicit dependencies. 13a32e9e42Smrgdnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and 14a32e9e42Smrgdnl augments the CPPFLAGS variable. 15a32e9e42Smrgdnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname 16a32e9e42Smrgdnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. 17a32e9e42SmrgAC_DEFUN([AC_LIB_LINKFLAGS], 18a32e9e42Smrg[ 19a32e9e42Smrg AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 20a32e9e42Smrg AC_REQUIRE([AC_LIB_RPATH]) 21a32e9e42Smrg pushdef([Name],[m4_translit([$1],[./+-], [____])]) 22a32e9e42Smrg pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], 23a32e9e42Smrg [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 24a32e9e42Smrg AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ 25a32e9e42Smrg AC_LIB_LINKFLAGS_BODY([$1], [$2]) 26a32e9e42Smrg ac_cv_lib[]Name[]_libs="$LIB[]NAME" 27a32e9e42Smrg ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" 28a32e9e42Smrg ac_cv_lib[]Name[]_cppflags="$INC[]NAME" 29a32e9e42Smrg ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" 30a32e9e42Smrg ]) 31a32e9e42Smrg LIB[]NAME="$ac_cv_lib[]Name[]_libs" 32a32e9e42Smrg LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" 33a32e9e42Smrg INC[]NAME="$ac_cv_lib[]Name[]_cppflags" 34a32e9e42Smrg LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" 35a32e9e42Smrg AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) 36a32e9e42Smrg AC_SUBST([LIB]NAME) 37a32e9e42Smrg AC_SUBST([LTLIB]NAME) 38a32e9e42Smrg AC_SUBST([LIB]NAME[_PREFIX]) 39a32e9e42Smrg dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the 40a32e9e42Smrg dnl results of this search when this library appears as a dependency. 41a32e9e42Smrg HAVE_LIB[]NAME=yes 42a32e9e42Smrg popdef([NAME]) 43a32e9e42Smrg popdef([Name]) 44a32e9e42Smrg]) 45a32e9e42Smrg 46a32e9e42Smrgdnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message]) 47a32e9e42Smrgdnl searches for libname and the libraries corresponding to explicit and 48a32e9e42Smrgdnl implicit dependencies, together with the specified include files and 49a32e9e42Smrgdnl the ability to compile and link the specified testcode. The missing-message 50a32e9e42Smrgdnl defaults to 'no' and may contain additional hints for the user. 51a32e9e42Smrgdnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} 52a32e9e42Smrgdnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and 53a32e9e42Smrgdnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs 54a32e9e42Smrgdnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. 55a32e9e42Smrgdnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname 56a32e9e42Smrgdnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. 57a32e9e42SmrgAC_DEFUN([AC_LIB_HAVE_LINKFLAGS], 58a32e9e42Smrg[ 59a32e9e42Smrg AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 60a32e9e42Smrg AC_REQUIRE([AC_LIB_RPATH]) 61a32e9e42Smrg pushdef([Name],[m4_translit([$1],[./+-], [____])]) 62a32e9e42Smrg pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], 63a32e9e42Smrg [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 64a32e9e42Smrg 65a32e9e42Smrg dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME 66a32e9e42Smrg dnl accordingly. 67a32e9e42Smrg AC_LIB_LINKFLAGS_BODY([$1], [$2]) 68a32e9e42Smrg 69a32e9e42Smrg dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, 70a32e9e42Smrg dnl because if the user has installed lib[]Name and not disabled its use 71a32e9e42Smrg dnl via --without-lib[]Name-prefix, he wants to use it. 72a32e9e42Smrg ac_save_CPPFLAGS="$CPPFLAGS" 73a32e9e42Smrg AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) 74a32e9e42Smrg 75a32e9e42Smrg AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ 76a32e9e42Smrg ac_save_LIBS="$LIBS" 77a32e9e42Smrg dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, 78a32e9e42Smrg dnl because these -l options might require -L options that are present in 79a32e9e42Smrg dnl LIBS. -l options benefit only from the -L options listed before it. 80a32e9e42Smrg dnl Otherwise, add it to the front of LIBS, because it may be a static 81a32e9e42Smrg dnl library that depends on another static library that is present in LIBS. 82a32e9e42Smrg dnl Static libraries benefit only from the static libraries listed after 83a32e9e42Smrg dnl it. 84a32e9e42Smrg case " $LIB[]NAME" in 85a32e9e42Smrg *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; 86a32e9e42Smrg *) LIBS="$LIB[]NAME $LIBS" ;; 87a32e9e42Smrg esac 88a32e9e42Smrg AC_LINK_IFELSE( 89a32e9e42Smrg [AC_LANG_PROGRAM([[$3]], [[$4]])], 90a32e9e42Smrg [ac_cv_lib[]Name=yes], 91a32e9e42Smrg [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) 92a32e9e42Smrg LIBS="$ac_save_LIBS" 93a32e9e42Smrg ]) 94a32e9e42Smrg if test "$ac_cv_lib[]Name" = yes; then 95a32e9e42Smrg HAVE_LIB[]NAME=yes 96a32e9e42Smrg AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) 97a32e9e42Smrg AC_MSG_CHECKING([how to link with lib[]$1]) 98a32e9e42Smrg AC_MSG_RESULT([$LIB[]NAME]) 99a32e9e42Smrg else 100a32e9e42Smrg HAVE_LIB[]NAME=no 101a32e9e42Smrg dnl If $LIB[]NAME didn't lead to a usable library, we don't need 102a32e9e42Smrg dnl $INC[]NAME either. 103a32e9e42Smrg CPPFLAGS="$ac_save_CPPFLAGS" 104a32e9e42Smrg LIB[]NAME= 105a32e9e42Smrg LTLIB[]NAME= 106a32e9e42Smrg LIB[]NAME[]_PREFIX= 107a32e9e42Smrg fi 108a32e9e42Smrg AC_SUBST([HAVE_LIB]NAME) 109a32e9e42Smrg AC_SUBST([LIB]NAME) 110a32e9e42Smrg AC_SUBST([LTLIB]NAME) 111a32e9e42Smrg AC_SUBST([LIB]NAME[_PREFIX]) 112a32e9e42Smrg popdef([NAME]) 113a32e9e42Smrg popdef([Name]) 114a32e9e42Smrg]) 115a32e9e42Smrg 116a32e9e42Smrgdnl Determine the platform dependent parameters needed to use rpath: 117a32e9e42Smrgdnl acl_libext, 118a32e9e42Smrgdnl acl_shlibext, 119a32e9e42Smrgdnl acl_libname_spec, 120a32e9e42Smrgdnl acl_library_names_spec, 121a32e9e42Smrgdnl acl_hardcode_libdir_flag_spec, 122a32e9e42Smrgdnl acl_hardcode_libdir_separator, 123a32e9e42Smrgdnl acl_hardcode_direct, 124a32e9e42Smrgdnl acl_hardcode_minus_L. 125a32e9e42SmrgAC_DEFUN([AC_LIB_RPATH], 126a32e9e42Smrg[ 127a32e9e42Smrg dnl Tell automake >= 1.10 to complain if config.rpath is missing. 128a32e9e42Smrg m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) 129a32e9e42Smrg AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS 130a32e9e42Smrg AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld 131a32e9e42Smrg AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 132a32e9e42Smrg AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir 133a32e9e42Smrg AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ 134a32e9e42Smrg CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ 135a32e9e42Smrg ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh 136a32e9e42Smrg . ./conftest.sh 137a32e9e42Smrg rm -f ./conftest.sh 138a32e9e42Smrg acl_cv_rpath=done 139a32e9e42Smrg ]) 140a32e9e42Smrg wl="$acl_cv_wl" 141a32e9e42Smrg acl_libext="$acl_cv_libext" 142a32e9e42Smrg acl_shlibext="$acl_cv_shlibext" 143a32e9e42Smrg acl_libname_spec="$acl_cv_libname_spec" 144a32e9e42Smrg acl_library_names_spec="$acl_cv_library_names_spec" 145a32e9e42Smrg acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" 146a32e9e42Smrg acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" 147a32e9e42Smrg acl_hardcode_direct="$acl_cv_hardcode_direct" 148a32e9e42Smrg acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" 149a32e9e42Smrg dnl Determine whether the user wants rpath handling at all. 150a32e9e42Smrg AC_ARG_ENABLE([rpath], 151a32e9e42Smrg [ --disable-rpath do not hardcode runtime library paths], 152a32e9e42Smrg :, enable_rpath=yes) 153a32e9e42Smrg]) 154a32e9e42Smrg 155a32e9e42Smrgdnl AC_LIB_FROMPACKAGE(name, package) 156a32e9e42Smrgdnl declares that libname comes from the given package. The configure file 157a32e9e42Smrgdnl will then not have a --with-libname-prefix option but a 158a32e9e42Smrgdnl --with-package-prefix option. Several libraries can come from the same 159a32e9e42Smrgdnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar 160a32e9e42Smrgdnl macro call that searches for libname. 161a32e9e42SmrgAC_DEFUN([AC_LIB_FROMPACKAGE], 162a32e9e42Smrg[ 163a32e9e42Smrg pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], 164a32e9e42Smrg [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 165a32e9e42Smrg define([acl_frompackage_]NAME, [$2]) 166a32e9e42Smrg popdef([NAME]) 167a32e9e42Smrg pushdef([PACK],[$2]) 168a32e9e42Smrg pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], 169a32e9e42Smrg [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 170a32e9e42Smrg define([acl_libsinpackage_]PACKUP, 171a32e9e42Smrg m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) 172a32e9e42Smrg popdef([PACKUP]) 173a32e9e42Smrg popdef([PACK]) 174a32e9e42Smrg]) 175a32e9e42Smrg 176a32e9e42Smrgdnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and 177a32e9e42Smrgdnl the libraries corresponding to explicit and implicit dependencies. 178a32e9e42Smrgdnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. 179a32e9e42Smrgdnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found 180a32e9e42Smrgdnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. 181a32e9e42SmrgAC_DEFUN([AC_LIB_LINKFLAGS_BODY], 182a32e9e42Smrg[ 183a32e9e42Smrg AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) 184a32e9e42Smrg pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], 185a32e9e42Smrg [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 186a32e9e42Smrg pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) 187a32e9e42Smrg pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], 188a32e9e42Smrg [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 189a32e9e42Smrg pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) 190a32e9e42Smrg dnl Autoconf >= 2.61 supports dots in --with options. 191a32e9e42Smrg pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) 192a32e9e42Smrg dnl By default, look in $includedir and $libdir. 193a32e9e42Smrg use_additional=yes 194a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([ 195a32e9e42Smrg eval additional_includedir=\"$includedir\" 196a32e9e42Smrg eval additional_libdir=\"$libdir\" 197a32e9e42Smrg ]) 198a32e9e42Smrg AC_ARG_WITH(P_A_C_K[-prefix], 199a32e9e42Smrg[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib 200a32e9e42Smrg --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], 201a32e9e42Smrg[ 202a32e9e42Smrg if test "X$withval" = "Xno"; then 203a32e9e42Smrg use_additional=no 204a32e9e42Smrg else 205a32e9e42Smrg if test "X$withval" = "X"; then 206a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([ 207a32e9e42Smrg eval additional_includedir=\"$includedir\" 208a32e9e42Smrg eval additional_libdir=\"$libdir\" 209a32e9e42Smrg ]) 210a32e9e42Smrg else 211a32e9e42Smrg additional_includedir="$withval/include" 212a32e9e42Smrg additional_libdir="$withval/$acl_libdirstem" 213a32e9e42Smrg if test "$acl_libdirstem2" != "$acl_libdirstem" \ 214a32e9e42Smrg && ! test -d "$withval/$acl_libdirstem"; then 215a32e9e42Smrg additional_libdir="$withval/$acl_libdirstem2" 216a32e9e42Smrg fi 217a32e9e42Smrg fi 218a32e9e42Smrg fi 219a32e9e42Smrg]) 220a32e9e42Smrg dnl Search the library and its dependencies in $additional_libdir and 221a32e9e42Smrg dnl $LDFLAGS. Using breadth-first-seach. 222a32e9e42Smrg LIB[]NAME= 223a32e9e42Smrg LTLIB[]NAME= 224a32e9e42Smrg INC[]NAME= 225a32e9e42Smrg LIB[]NAME[]_PREFIX= 226a32e9e42Smrg dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been 227a32e9e42Smrg dnl computed. So it has to be reset here. 228a32e9e42Smrg HAVE_LIB[]NAME= 229a32e9e42Smrg rpathdirs= 230a32e9e42Smrg ltrpathdirs= 231a32e9e42Smrg names_already_handled= 232a32e9e42Smrg names_next_round='$1 $2' 233a32e9e42Smrg while test -n "$names_next_round"; do 234a32e9e42Smrg names_this_round="$names_next_round" 235a32e9e42Smrg names_next_round= 236a32e9e42Smrg for name in $names_this_round; do 237a32e9e42Smrg already_handled= 238a32e9e42Smrg for n in $names_already_handled; do 239a32e9e42Smrg if test "$n" = "$name"; then 240a32e9e42Smrg already_handled=yes 241a32e9e42Smrg break 242a32e9e42Smrg fi 243a32e9e42Smrg done 244a32e9e42Smrg if test -z "$already_handled"; then 245a32e9e42Smrg names_already_handled="$names_already_handled $name" 246a32e9e42Smrg dnl See if it was already located by an earlier AC_LIB_LINKFLAGS 247a32e9e42Smrg dnl or AC_LIB_HAVE_LINKFLAGS call. 248a32e9e42Smrg uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` 249a32e9e42Smrg eval value=\"\$HAVE_LIB$uppername\" 250a32e9e42Smrg if test -n "$value"; then 251a32e9e42Smrg if test "$value" = yes; then 252a32e9e42Smrg eval value=\"\$LIB$uppername\" 253a32e9e42Smrg test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" 254a32e9e42Smrg eval value=\"\$LTLIB$uppername\" 255a32e9e42Smrg test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" 256a32e9e42Smrg else 257a32e9e42Smrg dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined 258a32e9e42Smrg dnl that this library doesn't exist. So just drop it. 259a32e9e42Smrg : 260a32e9e42Smrg fi 261a32e9e42Smrg else 262a32e9e42Smrg dnl Search the library lib$name in $additional_libdir and $LDFLAGS 263a32e9e42Smrg dnl and the already constructed $LIBNAME/$LTLIBNAME. 264a32e9e42Smrg found_dir= 265a32e9e42Smrg found_la= 266a32e9e42Smrg found_so= 267a32e9e42Smrg found_a= 268a32e9e42Smrg eval libname=\"$acl_libname_spec\" # typically: libname=lib$name 269a32e9e42Smrg if test -n "$acl_shlibext"; then 270a32e9e42Smrg shrext=".$acl_shlibext" # typically: shrext=.so 271a32e9e42Smrg else 272a32e9e42Smrg shrext= 273a32e9e42Smrg fi 274a32e9e42Smrg if test $use_additional = yes; then 275a32e9e42Smrg dir="$additional_libdir" 276a32e9e42Smrg dnl The same code as in the loop below: 277a32e9e42Smrg dnl First look for a shared library. 278a32e9e42Smrg if test -n "$acl_shlibext"; then 279a32e9e42Smrg if test -f "$dir/$libname$shrext"; then 280a32e9e42Smrg found_dir="$dir" 281a32e9e42Smrg found_so="$dir/$libname$shrext" 282a32e9e42Smrg else 283a32e9e42Smrg if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then 284a32e9e42Smrg ver=`(cd "$dir" && \ 285a32e9e42Smrg for f in "$libname$shrext".*; do echo "$f"; done \ 286a32e9e42Smrg | sed -e "s,^$libname$shrext\\\\.,," \ 287a32e9e42Smrg | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ 288a32e9e42Smrg | sed 1q ) 2>/dev/null` 289a32e9e42Smrg if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then 290a32e9e42Smrg found_dir="$dir" 291a32e9e42Smrg found_so="$dir/$libname$shrext.$ver" 292a32e9e42Smrg fi 293a32e9e42Smrg else 294a32e9e42Smrg eval library_names=\"$acl_library_names_spec\" 295a32e9e42Smrg for f in $library_names; do 296a32e9e42Smrg if test -f "$dir/$f"; then 297a32e9e42Smrg found_dir="$dir" 298a32e9e42Smrg found_so="$dir/$f" 299a32e9e42Smrg break 300a32e9e42Smrg fi 301a32e9e42Smrg done 302a32e9e42Smrg fi 303a32e9e42Smrg fi 304a32e9e42Smrg fi 305a32e9e42Smrg dnl Then look for a static library. 306a32e9e42Smrg if test "X$found_dir" = "X"; then 307a32e9e42Smrg if test -f "$dir/$libname.$acl_libext"; then 308a32e9e42Smrg found_dir="$dir" 309a32e9e42Smrg found_a="$dir/$libname.$acl_libext" 310a32e9e42Smrg fi 311a32e9e42Smrg fi 312a32e9e42Smrg if test "X$found_dir" != "X"; then 313a32e9e42Smrg if test -f "$dir/$libname.la"; then 314a32e9e42Smrg found_la="$dir/$libname.la" 315a32e9e42Smrg fi 316a32e9e42Smrg fi 317a32e9e42Smrg fi 318a32e9e42Smrg if test "X$found_dir" = "X"; then 319a32e9e42Smrg for x in $LDFLAGS $LTLIB[]NAME; do 320a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 321a32e9e42Smrg case "$x" in 322a32e9e42Smrg -L*) 323a32e9e42Smrg dir=`echo "X$x" | sed -e 's/^X-L//'` 324a32e9e42Smrg dnl First look for a shared library. 325a32e9e42Smrg if test -n "$acl_shlibext"; then 326a32e9e42Smrg if test -f "$dir/$libname$shrext"; then 327a32e9e42Smrg found_dir="$dir" 328a32e9e42Smrg found_so="$dir/$libname$shrext" 329a32e9e42Smrg else 330a32e9e42Smrg if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then 331a32e9e42Smrg ver=`(cd "$dir" && \ 332a32e9e42Smrg for f in "$libname$shrext".*; do echo "$f"; done \ 333a32e9e42Smrg | sed -e "s,^$libname$shrext\\\\.,," \ 334a32e9e42Smrg | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ 335a32e9e42Smrg | sed 1q ) 2>/dev/null` 336a32e9e42Smrg if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then 337a32e9e42Smrg found_dir="$dir" 338a32e9e42Smrg found_so="$dir/$libname$shrext.$ver" 339a32e9e42Smrg fi 340a32e9e42Smrg else 341a32e9e42Smrg eval library_names=\"$acl_library_names_spec\" 342a32e9e42Smrg for f in $library_names; do 343a32e9e42Smrg if test -f "$dir/$f"; then 344a32e9e42Smrg found_dir="$dir" 345a32e9e42Smrg found_so="$dir/$f" 346a32e9e42Smrg break 347a32e9e42Smrg fi 348a32e9e42Smrg done 349a32e9e42Smrg fi 350a32e9e42Smrg fi 351a32e9e42Smrg fi 352a32e9e42Smrg dnl Then look for a static library. 353a32e9e42Smrg if test "X$found_dir" = "X"; then 354a32e9e42Smrg if test -f "$dir/$libname.$acl_libext"; then 355a32e9e42Smrg found_dir="$dir" 356a32e9e42Smrg found_a="$dir/$libname.$acl_libext" 357a32e9e42Smrg fi 358a32e9e42Smrg fi 359a32e9e42Smrg if test "X$found_dir" != "X"; then 360a32e9e42Smrg if test -f "$dir/$libname.la"; then 361a32e9e42Smrg found_la="$dir/$libname.la" 362a32e9e42Smrg fi 363a32e9e42Smrg fi 364a32e9e42Smrg ;; 365a32e9e42Smrg esac 366a32e9e42Smrg if test "X$found_dir" != "X"; then 367a32e9e42Smrg break 368a32e9e42Smrg fi 369a32e9e42Smrg done 370a32e9e42Smrg fi 371a32e9e42Smrg if test "X$found_dir" != "X"; then 372a32e9e42Smrg dnl Found the library. 373a32e9e42Smrg LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" 374a32e9e42Smrg if test "X$found_so" != "X"; then 375a32e9e42Smrg dnl Linking with a shared library. We attempt to hardcode its 376a32e9e42Smrg dnl directory into the executable's runpath, unless it's the 377a32e9e42Smrg dnl standard /usr/lib. 378a32e9e42Smrg if test "$enable_rpath" = no \ 379a32e9e42Smrg || test "X$found_dir" = "X/usr/$acl_libdirstem" \ 380a32e9e42Smrg || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then 381a32e9e42Smrg dnl No hardcoding is needed. 382a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 383a32e9e42Smrg else 384a32e9e42Smrg dnl Use an explicit option to hardcode DIR into the resulting 385a32e9e42Smrg dnl binary. 386a32e9e42Smrg dnl Potentially add DIR to ltrpathdirs. 387a32e9e42Smrg dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. 388a32e9e42Smrg haveit= 389a32e9e42Smrg for x in $ltrpathdirs; do 390a32e9e42Smrg if test "X$x" = "X$found_dir"; then 391a32e9e42Smrg haveit=yes 392a32e9e42Smrg break 393a32e9e42Smrg fi 394a32e9e42Smrg done 395a32e9e42Smrg if test -z "$haveit"; then 396a32e9e42Smrg ltrpathdirs="$ltrpathdirs $found_dir" 397a32e9e42Smrg fi 398a32e9e42Smrg dnl The hardcoding into $LIBNAME is system dependent. 399a32e9e42Smrg if test "$acl_hardcode_direct" = yes; then 400a32e9e42Smrg dnl Using DIR/libNAME.so during linking hardcodes DIR into the 401a32e9e42Smrg dnl resulting binary. 402a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 403a32e9e42Smrg else 404a32e9e42Smrg if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then 405a32e9e42Smrg dnl Use an explicit option to hardcode DIR into the resulting 406a32e9e42Smrg dnl binary. 407a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 408a32e9e42Smrg dnl Potentially add DIR to rpathdirs. 409a32e9e42Smrg dnl The rpathdirs will be appended to $LIBNAME at the end. 410a32e9e42Smrg haveit= 411a32e9e42Smrg for x in $rpathdirs; do 412a32e9e42Smrg if test "X$x" = "X$found_dir"; then 413a32e9e42Smrg haveit=yes 414a32e9e42Smrg break 415a32e9e42Smrg fi 416a32e9e42Smrg done 417a32e9e42Smrg if test -z "$haveit"; then 418a32e9e42Smrg rpathdirs="$rpathdirs $found_dir" 419a32e9e42Smrg fi 420a32e9e42Smrg else 421a32e9e42Smrg dnl Rely on "-L$found_dir". 422a32e9e42Smrg dnl But don't add it if it's already contained in the LDFLAGS 423a32e9e42Smrg dnl or the already constructed $LIBNAME 424a32e9e42Smrg haveit= 425a32e9e42Smrg for x in $LDFLAGS $LIB[]NAME; do 426a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 427a32e9e42Smrg if test "X$x" = "X-L$found_dir"; then 428a32e9e42Smrg haveit=yes 429a32e9e42Smrg break 430a32e9e42Smrg fi 431a32e9e42Smrg done 432a32e9e42Smrg if test -z "$haveit"; then 433a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" 434a32e9e42Smrg fi 435a32e9e42Smrg if test "$acl_hardcode_minus_L" != no; then 436a32e9e42Smrg dnl FIXME: Not sure whether we should use 437a32e9e42Smrg dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" 438a32e9e42Smrg dnl here. 439a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 440a32e9e42Smrg else 441a32e9e42Smrg dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH 442a32e9e42Smrg dnl here, because this doesn't fit in flags passed to the 443a32e9e42Smrg dnl compiler. So give up. No hardcoding. This affects only 444a32e9e42Smrg dnl very old systems. 445a32e9e42Smrg dnl FIXME: Not sure whether we should use 446a32e9e42Smrg dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" 447a32e9e42Smrg dnl here. 448a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" 449a32e9e42Smrg fi 450a32e9e42Smrg fi 451a32e9e42Smrg fi 452a32e9e42Smrg fi 453a32e9e42Smrg else 454a32e9e42Smrg if test "X$found_a" != "X"; then 455a32e9e42Smrg dnl Linking with a static library. 456a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" 457a32e9e42Smrg else 458a32e9e42Smrg dnl We shouldn't come here, but anyway it's good to have a 459a32e9e42Smrg dnl fallback. 460a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" 461a32e9e42Smrg fi 462a32e9e42Smrg fi 463a32e9e42Smrg dnl Assume the include files are nearby. 464a32e9e42Smrg additional_includedir= 465a32e9e42Smrg case "$found_dir" in 466a32e9e42Smrg */$acl_libdirstem | */$acl_libdirstem/) 467a32e9e42Smrg basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` 468a32e9e42Smrg if test "$name" = '$1'; then 469a32e9e42Smrg LIB[]NAME[]_PREFIX="$basedir" 470a32e9e42Smrg fi 471a32e9e42Smrg additional_includedir="$basedir/include" 472a32e9e42Smrg ;; 473a32e9e42Smrg */$acl_libdirstem2 | */$acl_libdirstem2/) 474a32e9e42Smrg basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` 475a32e9e42Smrg if test "$name" = '$1'; then 476a32e9e42Smrg LIB[]NAME[]_PREFIX="$basedir" 477a32e9e42Smrg fi 478a32e9e42Smrg additional_includedir="$basedir/include" 479a32e9e42Smrg ;; 480a32e9e42Smrg esac 481a32e9e42Smrg if test "X$additional_includedir" != "X"; then 482a32e9e42Smrg dnl Potentially add $additional_includedir to $INCNAME. 483a32e9e42Smrg dnl But don't add it 484a32e9e42Smrg dnl 1. if it's the standard /usr/include, 485a32e9e42Smrg dnl 2. if it's /usr/local/include and we are using GCC on Linux, 486a32e9e42Smrg dnl 3. if it's already present in $CPPFLAGS or the already 487a32e9e42Smrg dnl constructed $INCNAME, 488a32e9e42Smrg dnl 4. if it doesn't exist as a directory. 489a32e9e42Smrg if test "X$additional_includedir" != "X/usr/include"; then 490a32e9e42Smrg haveit= 491a32e9e42Smrg if test "X$additional_includedir" = "X/usr/local/include"; then 492a32e9e42Smrg if test -n "$GCC"; then 493a32e9e42Smrg case $host_os in 494a32e9e42Smrg linux* | gnu* | k*bsd*-gnu) haveit=yes;; 495a32e9e42Smrg esac 496a32e9e42Smrg fi 497a32e9e42Smrg fi 498a32e9e42Smrg if test -z "$haveit"; then 499a32e9e42Smrg for x in $CPPFLAGS $INC[]NAME; do 500a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 501a32e9e42Smrg if test "X$x" = "X-I$additional_includedir"; then 502a32e9e42Smrg haveit=yes 503a32e9e42Smrg break 504a32e9e42Smrg fi 505a32e9e42Smrg done 506a32e9e42Smrg if test -z "$haveit"; then 507a32e9e42Smrg if test -d "$additional_includedir"; then 508a32e9e42Smrg dnl Really add $additional_includedir to $INCNAME. 509a32e9e42Smrg INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" 510a32e9e42Smrg fi 511a32e9e42Smrg fi 512a32e9e42Smrg fi 513a32e9e42Smrg fi 514a32e9e42Smrg fi 515a32e9e42Smrg dnl Look for dependencies. 516a32e9e42Smrg if test -n "$found_la"; then 517a32e9e42Smrg dnl Read the .la file. It defines the variables 518a32e9e42Smrg dnl dlname, library_names, old_library, dependency_libs, current, 519a32e9e42Smrg dnl age, revision, installed, dlopen, dlpreopen, libdir. 520a32e9e42Smrg save_libdir="$libdir" 521a32e9e42Smrg case "$found_la" in 522a32e9e42Smrg */* | *\\*) . "$found_la" ;; 523a32e9e42Smrg *) . "./$found_la" ;; 524a32e9e42Smrg esac 525a32e9e42Smrg libdir="$save_libdir" 526a32e9e42Smrg dnl We use only dependency_libs. 527a32e9e42Smrg for dep in $dependency_libs; do 528a32e9e42Smrg case "$dep" in 529a32e9e42Smrg -L*) 530a32e9e42Smrg additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` 531a32e9e42Smrg dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. 532a32e9e42Smrg dnl But don't add it 533a32e9e42Smrg dnl 1. if it's the standard /usr/lib, 534a32e9e42Smrg dnl 2. if it's /usr/local/lib and we are using GCC on Linux, 535a32e9e42Smrg dnl 3. if it's already present in $LDFLAGS or the already 536a32e9e42Smrg dnl constructed $LIBNAME, 537a32e9e42Smrg dnl 4. if it doesn't exist as a directory. 538a32e9e42Smrg if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ 539a32e9e42Smrg && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then 540a32e9e42Smrg haveit= 541a32e9e42Smrg if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ 542a32e9e42Smrg || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then 543a32e9e42Smrg if test -n "$GCC"; then 544a32e9e42Smrg case $host_os in 545a32e9e42Smrg linux* | gnu* | k*bsd*-gnu) haveit=yes;; 546a32e9e42Smrg esac 547a32e9e42Smrg fi 548a32e9e42Smrg fi 549a32e9e42Smrg if test -z "$haveit"; then 550a32e9e42Smrg haveit= 551a32e9e42Smrg for x in $LDFLAGS $LIB[]NAME; do 552a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 553a32e9e42Smrg if test "X$x" = "X-L$additional_libdir"; then 554a32e9e42Smrg haveit=yes 555a32e9e42Smrg break 556a32e9e42Smrg fi 557a32e9e42Smrg done 558a32e9e42Smrg if test -z "$haveit"; then 559a32e9e42Smrg if test -d "$additional_libdir"; then 560a32e9e42Smrg dnl Really add $additional_libdir to $LIBNAME. 561a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" 562a32e9e42Smrg fi 563a32e9e42Smrg fi 564a32e9e42Smrg haveit= 565a32e9e42Smrg for x in $LDFLAGS $LTLIB[]NAME; do 566a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 567a32e9e42Smrg if test "X$x" = "X-L$additional_libdir"; then 568a32e9e42Smrg haveit=yes 569a32e9e42Smrg break 570a32e9e42Smrg fi 571a32e9e42Smrg done 572a32e9e42Smrg if test -z "$haveit"; then 573a32e9e42Smrg if test -d "$additional_libdir"; then 574a32e9e42Smrg dnl Really add $additional_libdir to $LTLIBNAME. 575a32e9e42Smrg LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" 576a32e9e42Smrg fi 577a32e9e42Smrg fi 578a32e9e42Smrg fi 579a32e9e42Smrg fi 580a32e9e42Smrg ;; 581a32e9e42Smrg -R*) 582a32e9e42Smrg dir=`echo "X$dep" | sed -e 's/^X-R//'` 583a32e9e42Smrg if test "$enable_rpath" != no; then 584a32e9e42Smrg dnl Potentially add DIR to rpathdirs. 585a32e9e42Smrg dnl The rpathdirs will be appended to $LIBNAME at the end. 586a32e9e42Smrg haveit= 587a32e9e42Smrg for x in $rpathdirs; do 588a32e9e42Smrg if test "X$x" = "X$dir"; then 589a32e9e42Smrg haveit=yes 590a32e9e42Smrg break 591a32e9e42Smrg fi 592a32e9e42Smrg done 593a32e9e42Smrg if test -z "$haveit"; then 594a32e9e42Smrg rpathdirs="$rpathdirs $dir" 595a32e9e42Smrg fi 596a32e9e42Smrg dnl Potentially add DIR to ltrpathdirs. 597a32e9e42Smrg dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. 598a32e9e42Smrg haveit= 599a32e9e42Smrg for x in $ltrpathdirs; do 600a32e9e42Smrg if test "X$x" = "X$dir"; then 601a32e9e42Smrg haveit=yes 602a32e9e42Smrg break 603a32e9e42Smrg fi 604a32e9e42Smrg done 605a32e9e42Smrg if test -z "$haveit"; then 606a32e9e42Smrg ltrpathdirs="$ltrpathdirs $dir" 607a32e9e42Smrg fi 608a32e9e42Smrg fi 609a32e9e42Smrg ;; 610a32e9e42Smrg -l*) 611a32e9e42Smrg dnl Handle this in the next round. 612a32e9e42Smrg names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` 613a32e9e42Smrg ;; 614a32e9e42Smrg *.la) 615a32e9e42Smrg dnl Handle this in the next round. Throw away the .la's 616a32e9e42Smrg dnl directory; it is already contained in a preceding -L 617a32e9e42Smrg dnl option. 618a32e9e42Smrg names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` 619a32e9e42Smrg ;; 620a32e9e42Smrg *) 621a32e9e42Smrg dnl Most likely an immediate library name. 622a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" 623a32e9e42Smrg LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" 624a32e9e42Smrg ;; 625a32e9e42Smrg esac 626a32e9e42Smrg done 627a32e9e42Smrg fi 628a32e9e42Smrg else 629a32e9e42Smrg dnl Didn't find the library; assume it is in the system directories 630a32e9e42Smrg dnl known to the linker and runtime loader. (All the system 631a32e9e42Smrg dnl directories known to the linker should also be known to the 632a32e9e42Smrg dnl runtime loader, otherwise the system is severely misconfigured.) 633a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" 634a32e9e42Smrg LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" 635a32e9e42Smrg fi 636a32e9e42Smrg fi 637a32e9e42Smrg fi 638a32e9e42Smrg done 639a32e9e42Smrg done 640a32e9e42Smrg if test "X$rpathdirs" != "X"; then 641a32e9e42Smrg if test -n "$acl_hardcode_libdir_separator"; then 642a32e9e42Smrg dnl Weird platform: only the last -rpath option counts, the user must 643a32e9e42Smrg dnl pass all path elements in one option. We can arrange that for a 644a32e9e42Smrg dnl single library, but not when more than one $LIBNAMEs are used. 645a32e9e42Smrg alldirs= 646a32e9e42Smrg for found_dir in $rpathdirs; do 647a32e9e42Smrg alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" 648a32e9e42Smrg done 649a32e9e42Smrg dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. 650a32e9e42Smrg acl_save_libdir="$libdir" 651a32e9e42Smrg libdir="$alldirs" 652a32e9e42Smrg eval flag=\"$acl_hardcode_libdir_flag_spec\" 653a32e9e42Smrg libdir="$acl_save_libdir" 654a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" 655a32e9e42Smrg else 656a32e9e42Smrg dnl The -rpath options are cumulative. 657a32e9e42Smrg for found_dir in $rpathdirs; do 658a32e9e42Smrg acl_save_libdir="$libdir" 659a32e9e42Smrg libdir="$found_dir" 660a32e9e42Smrg eval flag=\"$acl_hardcode_libdir_flag_spec\" 661a32e9e42Smrg libdir="$acl_save_libdir" 662a32e9e42Smrg LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" 663a32e9e42Smrg done 664a32e9e42Smrg fi 665a32e9e42Smrg fi 666a32e9e42Smrg if test "X$ltrpathdirs" != "X"; then 667a32e9e42Smrg dnl When using libtool, the option that works for both libraries and 668a32e9e42Smrg dnl executables is -R. The -R options are cumulative. 669a32e9e42Smrg for found_dir in $ltrpathdirs; do 670a32e9e42Smrg LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" 671a32e9e42Smrg done 672a32e9e42Smrg fi 673a32e9e42Smrg popdef([P_A_C_K]) 674a32e9e42Smrg popdef([PACKLIBS]) 675a32e9e42Smrg popdef([PACKUP]) 676a32e9e42Smrg popdef([PACK]) 677a32e9e42Smrg popdef([NAME]) 678a32e9e42Smrg]) 679a32e9e42Smrg 680a32e9e42Smrgdnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, 681a32e9e42Smrgdnl unless already present in VAR. 682a32e9e42Smrgdnl Works only for CPPFLAGS, not for LIB* variables because that sometimes 683a32e9e42Smrgdnl contains two or three consecutive elements that belong together. 684a32e9e42SmrgAC_DEFUN([AC_LIB_APPENDTOVAR], 685a32e9e42Smrg[ 686a32e9e42Smrg for element in [$2]; do 687a32e9e42Smrg haveit= 688a32e9e42Smrg for x in $[$1]; do 689a32e9e42Smrg AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 690a32e9e42Smrg if test "X$x" = "X$element"; then 691a32e9e42Smrg haveit=yes 692a32e9e42Smrg break 693a32e9e42Smrg fi 694a32e9e42Smrg done 695a32e9e42Smrg if test -z "$haveit"; then 696a32e9e42Smrg [$1]="${[$1]}${[$1]:+ }$element" 697a32e9e42Smrg fi 698a32e9e42Smrg done 699a32e9e42Smrg]) 700a32e9e42Smrg 701a32e9e42Smrgdnl For those cases where a variable contains several -L and -l options 702a32e9e42Smrgdnl referring to unknown libraries and directories, this macro determines the 703a32e9e42Smrgdnl necessary additional linker options for the runtime path. 704a32e9e42Smrgdnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) 705a32e9e42Smrgdnl sets LDADDVAR to linker options needed together with LIBSVALUE. 706a32e9e42Smrgdnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, 707a32e9e42Smrgdnl otherwise linking without libtool is assumed. 708a32e9e42SmrgAC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], 709a32e9e42Smrg[ 710a32e9e42Smrg AC_REQUIRE([AC_LIB_RPATH]) 711a32e9e42Smrg AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) 712a32e9e42Smrg $1= 713a32e9e42Smrg if test "$enable_rpath" != no; then 714a32e9e42Smrg if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then 715a32e9e42Smrg dnl Use an explicit option to hardcode directories into the resulting 716a32e9e42Smrg dnl binary. 717a32e9e42Smrg rpathdirs= 718a32e9e42Smrg next= 719a32e9e42Smrg for opt in $2; do 720a32e9e42Smrg if test -n "$next"; then 721a32e9e42Smrg dir="$next" 722a32e9e42Smrg dnl No need to hardcode the standard /usr/lib. 723a32e9e42Smrg if test "X$dir" != "X/usr/$acl_libdirstem" \ 724a32e9e42Smrg && test "X$dir" != "X/usr/$acl_libdirstem2"; then 725a32e9e42Smrg rpathdirs="$rpathdirs $dir" 726a32e9e42Smrg fi 727a32e9e42Smrg next= 728a32e9e42Smrg else 729a32e9e42Smrg case $opt in 730a32e9e42Smrg -L) next=yes ;; 731a32e9e42Smrg -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` 732a32e9e42Smrg dnl No need to hardcode the standard /usr/lib. 733a32e9e42Smrg if test "X$dir" != "X/usr/$acl_libdirstem" \ 734a32e9e42Smrg && test "X$dir" != "X/usr/$acl_libdirstem2"; then 735a32e9e42Smrg rpathdirs="$rpathdirs $dir" 736a32e9e42Smrg fi 737a32e9e42Smrg next= ;; 738a32e9e42Smrg *) next= ;; 739a32e9e42Smrg esac 740a32e9e42Smrg fi 741a32e9e42Smrg done 742a32e9e42Smrg if test "X$rpathdirs" != "X"; then 743a32e9e42Smrg if test -n ""$3""; then 744a32e9e42Smrg dnl libtool is used for linking. Use -R options. 745a32e9e42Smrg for dir in $rpathdirs; do 746a32e9e42Smrg $1="${$1}${$1:+ }-R$dir" 747a32e9e42Smrg done 748a32e9e42Smrg else 749a32e9e42Smrg dnl The linker is used for linking directly. 750a32e9e42Smrg if test -n "$acl_hardcode_libdir_separator"; then 751a32e9e42Smrg dnl Weird platform: only the last -rpath option counts, the user 752a32e9e42Smrg dnl must pass all path elements in one option. 753a32e9e42Smrg alldirs= 754a32e9e42Smrg for dir in $rpathdirs; do 755a32e9e42Smrg alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" 756a32e9e42Smrg done 757a32e9e42Smrg acl_save_libdir="$libdir" 758a32e9e42Smrg libdir="$alldirs" 759a32e9e42Smrg eval flag=\"$acl_hardcode_libdir_flag_spec\" 760a32e9e42Smrg libdir="$acl_save_libdir" 761a32e9e42Smrg $1="$flag" 762a32e9e42Smrg else 763a32e9e42Smrg dnl The -rpath options are cumulative. 764a32e9e42Smrg for dir in $rpathdirs; do 765a32e9e42Smrg acl_save_libdir="$libdir" 766a32e9e42Smrg libdir="$dir" 767a32e9e42Smrg eval flag=\"$acl_hardcode_libdir_flag_spec\" 768a32e9e42Smrg libdir="$acl_save_libdir" 769a32e9e42Smrg $1="${$1}${$1:+ }$flag" 770a32e9e42Smrg done 771a32e9e42Smrg fi 772a32e9e42Smrg fi 773a32e9e42Smrg fi 774a32e9e42Smrg fi 775a32e9e42Smrg fi 776a32e9e42Smrg AC_SUBST([$1]) 777a32e9e42Smrg]) 778