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