1*75f6d617Schristos# lib-link.m4 serial 1 (gettext-0.11) 2*75f6d617Schristosdnl Copyright (C) 2001-2002 Free Software Foundation, Inc. 3*75f6d617Schristosdnl This file is free software, distributed under the terms of the GNU 4*75f6d617Schristosdnl General Public License. As a special exception to the GNU General 5*75f6d617Schristosdnl Public License, this file may be distributed as part of a program 6*75f6d617Schristosdnl that contains a configuration script generated by Autoconf, under 7*75f6d617Schristosdnl the same distribution terms as the rest of that program. 8*75f6d617Schristos 9*75f6d617Schristosdnl From Bruno Haible. 10*75f6d617Schristos 11*75f6d617Schristosdnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and 12*75f6d617Schristosdnl the libraries corresponding to explicit and implicit dependencies. 13*75f6d617Schristosdnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and 14*75f6d617Schristosdnl augments the CPPFLAGS variable. 15*75f6d617SchristosAC_DEFUN([AC_LIB_LINKFLAGS], 16*75f6d617Schristos[ 17*75f6d617Schristos AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 18*75f6d617Schristos AC_REQUIRE([AC_LIB_RPATH]) 19*75f6d617Schristos define([Name],[translit([$1],[./-], [___])]) 20*75f6d617Schristos define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 21*75f6d617Schristos [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 22*75f6d617Schristos AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ 23*75f6d617Schristos AC_LIB_LINKFLAGS_BODY([$1], [$2]) 24*75f6d617Schristos ac_cv_lib[]Name[]_libs="$LIB[]NAME" 25*75f6d617Schristos ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" 26*75f6d617Schristos ac_cv_lib[]Name[]_cppflags="$INC[]NAME" 27*75f6d617Schristos ]) 28*75f6d617Schristos LIB[]NAME="$ac_cv_lib[]Name[]_libs" 29*75f6d617Schristos LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" 30*75f6d617Schristos INC[]NAME="$ac_cv_lib[]Name[]_cppflags" 31*75f6d617Schristos AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) 32*75f6d617Schristos AC_SUBST([LIB]NAME) 33*75f6d617Schristos AC_SUBST([LTLIB]NAME) 34*75f6d617Schristos dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the 35*75f6d617Schristos dnl results of this search when this library appears as a dependency. 36*75f6d617Schristos HAVE_LIB[]NAME=yes 37*75f6d617Schristos undefine([Name]) 38*75f6d617Schristos undefine([NAME]) 39*75f6d617Schristos]) 40*75f6d617Schristos 41*75f6d617Schristosdnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) 42*75f6d617Schristosdnl searches for libname and the libraries corresponding to explicit and 43*75f6d617Schristosdnl implicit dependencies, together with the specified include files and 44*75f6d617Schristosdnl the ability to compile and link the specified testcode. If found, it 45*75f6d617Schristosdnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and 46*75f6d617Schristosdnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and 47*75f6d617Schristosdnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs 48*75f6d617Schristosdnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. 49*75f6d617SchristosAC_DEFUN([AC_LIB_HAVE_LINKFLAGS], 50*75f6d617Schristos[ 51*75f6d617Schristos AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 52*75f6d617Schristos AC_REQUIRE([AC_LIB_RPATH]) 53*75f6d617Schristos define([Name],[translit([$1],[./-], [___])]) 54*75f6d617Schristos define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 55*75f6d617Schristos [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 56*75f6d617Schristos 57*75f6d617Schristos dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME 58*75f6d617Schristos dnl accordingly. 59*75f6d617Schristos AC_LIB_LINKFLAGS_BODY([$1], [$2]) 60*75f6d617Schristos 61*75f6d617Schristos dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, 62*75f6d617Schristos dnl because if the user has installed lib[]Name and not disabled its use 63*75f6d617Schristos dnl via --without-lib[]Name-prefix, he wants to use it. 64*75f6d617Schristos ac_save_CPPFLAGS="$CPPFLAGS" 65*75f6d617Schristos AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) 66*75f6d617Schristos 67*75f6d617Schristos AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ 68*75f6d617Schristos ac_save_LIBS="$LIBS" 69*75f6d617Schristos LIBS="$LIBS $LIB[]NAME" 70*75f6d617Schristos AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) 71*75f6d617Schristos LIBS="$ac_save_LIBS" 72*75f6d617Schristos ]) 73*75f6d617Schristos if test "$ac_cv_lib[]Name" = yes; then 74*75f6d617Schristos HAVE_LIB[]NAME=yes 75*75f6d617Schristos AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) 76*75f6d617Schristos AC_MSG_CHECKING([how to link with lib[]$1]) 77*75f6d617Schristos AC_MSG_RESULT([$LIB[]NAME]) 78*75f6d617Schristos else 79*75f6d617Schristos HAVE_LIB[]NAME=no 80*75f6d617Schristos dnl If $LIB[]NAME didn't lead to a usable library, we don't need 81*75f6d617Schristos dnl $INC[]NAME either. 82*75f6d617Schristos CPPFLAGS="$ac_save_CPPFLAGS" 83*75f6d617Schristos LIB[]NAME= 84*75f6d617Schristos LTLIB[]NAME= 85*75f6d617Schristos fi 86*75f6d617Schristos AC_SUBST([HAVE_LIB]NAME) 87*75f6d617Schristos AC_SUBST([LIB]NAME) 88*75f6d617Schristos AC_SUBST([LTLIB]NAME) 89*75f6d617Schristos undefine([Name]) 90*75f6d617Schristos undefine([NAME]) 91*75f6d617Schristos]) 92*75f6d617Schristos 93*75f6d617Schristosdnl Determine the platform dependent parameters needed to use rpath: 94*75f6d617Schristosdnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, 95*75f6d617Schristosdnl hardcode_direct, hardcode_minus_L, 96*75f6d617Schristosdnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec. 97*75f6d617SchristosAC_DEFUN([AC_LIB_RPATH], 98*75f6d617Schristos[ 99*75f6d617Schristos AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS 100*75f6d617Schristos AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld 101*75f6d617Schristos AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 102*75f6d617Schristos AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir 103*75f6d617Schristos AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ 104*75f6d617Schristos CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ 105*75f6d617Schristos ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh 106*75f6d617Schristos . ./conftest.sh 107*75f6d617Schristos rm -f ./conftest.sh 108*75f6d617Schristos acl_cv_rpath=done 109*75f6d617Schristos ]) 110*75f6d617Schristos wl="$acl_cv_wl" 111*75f6d617Schristos libext="$acl_cv_libext" 112*75f6d617Schristos shlibext="$acl_cv_shlibext" 113*75f6d617Schristos hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" 114*75f6d617Schristos hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" 115*75f6d617Schristos hardcode_direct="$acl_cv_hardcode_direct" 116*75f6d617Schristos hardcode_minus_L="$acl_cv_hardcode_minus_L" 117*75f6d617Schristos sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec" 118*75f6d617Schristos sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec" 119*75f6d617Schristos]) 120*75f6d617Schristos 121*75f6d617Schristosdnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and 122*75f6d617Schristosdnl the libraries corresponding to explicit and implicit dependencies. 123*75f6d617Schristosdnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. 124*75f6d617SchristosAC_DEFUN([AC_LIB_LINKFLAGS_BODY], 125*75f6d617Schristos[ 126*75f6d617Schristos define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 127*75f6d617Schristos [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 128*75f6d617Schristos dnl By default, look in $includedir and $libdir. 129*75f6d617Schristos use_additional=yes 130*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([ 131*75f6d617Schristos eval additional_includedir=\"$includedir\" 132*75f6d617Schristos eval additional_libdir=\"$libdir\" 133*75f6d617Schristos ]) 134*75f6d617Schristos AC_ARG_WITH([lib$1-prefix], 135*75f6d617Schristos[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib 136*75f6d617Schristos --without-lib$1-prefix don't search for lib$1 in includedir and libdir], 137*75f6d617Schristos[ 138*75f6d617Schristos if test "X$withval" = "Xno"; then 139*75f6d617Schristos use_additional=no 140*75f6d617Schristos else 141*75f6d617Schristos if test "X$withval" = "X"; then 142*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([ 143*75f6d617Schristos eval additional_includedir=\"$includedir\" 144*75f6d617Schristos eval additional_libdir=\"$libdir\" 145*75f6d617Schristos ]) 146*75f6d617Schristos else 147*75f6d617Schristos additional_includedir="$withval/include" 148*75f6d617Schristos additional_libdir="$withval/lib" 149*75f6d617Schristos fi 150*75f6d617Schristos fi 151*75f6d617Schristos]) 152*75f6d617Schristos dnl Search the library and its dependencies in $additional_libdir and 153*75f6d617Schristos dnl $LDFLAGS. Using breadth-first-seach. 154*75f6d617Schristos LIB[]NAME= 155*75f6d617Schristos LTLIB[]NAME= 156*75f6d617Schristos INC[]NAME= 157*75f6d617Schristos rpathdirs= 158*75f6d617Schristos ltrpathdirs= 159*75f6d617Schristos names_already_handled= 160*75f6d617Schristos names_next_round='$1 $2' 161*75f6d617Schristos while test -n "$names_next_round"; do 162*75f6d617Schristos names_this_round="$names_next_round" 163*75f6d617Schristos names_next_round= 164*75f6d617Schristos for name in $names_this_round; do 165*75f6d617Schristos already_handled= 166*75f6d617Schristos for n in $names_already_handled; do 167*75f6d617Schristos if test "$n" = "$name"; then 168*75f6d617Schristos already_handled=yes 169*75f6d617Schristos break 170*75f6d617Schristos fi 171*75f6d617Schristos done 172*75f6d617Schristos if test -z "$already_handled"; then 173*75f6d617Schristos names_already_handled="$names_already_handled $name" 174*75f6d617Schristos dnl See if it was already located by an earlier AC_LIB_LINKFLAGS 175*75f6d617Schristos dnl or AC_LIB_HAVE_LINKFLAGS call. 176*75f6d617Schristos uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` 177*75f6d617Schristos eval value=\"\$HAVE_LIB$uppername\" 178*75f6d617Schristos if test -n "$value"; then 179*75f6d617Schristos if test "$value" = yes; then 180*75f6d617Schristos eval value=\"\$LIB$uppername\" 181*75f6d617Schristos test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" 182*75f6d617Schristos eval value=\"\$LTLIB$uppername\" 183*75f6d617Schristos test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" 184*75f6d617Schristos else 185*75f6d617Schristos dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined 186*75f6d617Schristos dnl that this library doesn't exist. So just drop it. 187*75f6d617Schristos : 188*75f6d617Schristos fi 189*75f6d617Schristos else 190*75f6d617Schristos dnl Search the library lib$name in $additional_libdir and $LDFLAGS 191*75f6d617Schristos dnl and the already constructed $LIBNAME/$LTLIBNAME. 192*75f6d617Schristos found_dir= 193*75f6d617Schristos found_la= 194*75f6d617Schristos found_so= 195*75f6d617Schristos found_a= 196*75f6d617Schristos if test $use_additional = yes; then 197*75f6d617Schristos if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then 198*75f6d617Schristos found_dir="$additional_libdir" 199*75f6d617Schristos found_so="$additional_libdir/lib$name.$shlibext" 200*75f6d617Schristos if test -f "$additional_libdir/lib$name.la"; then 201*75f6d617Schristos found_la="$additional_libdir/lib$name.la" 202*75f6d617Schristos fi 203*75f6d617Schristos else 204*75f6d617Schristos if test -f "$additional_libdir/lib$name.$libext"; then 205*75f6d617Schristos found_dir="$additional_libdir" 206*75f6d617Schristos found_a="$additional_libdir/lib$name.$libext" 207*75f6d617Schristos if test -f "$additional_libdir/lib$name.la"; then 208*75f6d617Schristos found_la="$additional_libdir/lib$name.la" 209*75f6d617Schristos fi 210*75f6d617Schristos fi 211*75f6d617Schristos fi 212*75f6d617Schristos fi 213*75f6d617Schristos if test "X$found_dir" = "X"; then 214*75f6d617Schristos for x in $LDFLAGS $LTLIB[]NAME; do 215*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 216*75f6d617Schristos case "$x" in 217*75f6d617Schristos -L*) 218*75f6d617Schristos dir=`echo "X$x" | sed -e 's/^X-L//'` 219*75f6d617Schristos if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then 220*75f6d617Schristos found_dir="$dir" 221*75f6d617Schristos found_so="$dir/lib$name.$shlibext" 222*75f6d617Schristos if test -f "$dir/lib$name.la"; then 223*75f6d617Schristos found_la="$dir/lib$name.la" 224*75f6d617Schristos fi 225*75f6d617Schristos else 226*75f6d617Schristos if test -f "$dir/lib$name.$libext"; then 227*75f6d617Schristos found_dir="$dir" 228*75f6d617Schristos found_a="$dir/lib$name.$libext" 229*75f6d617Schristos if test -f "$dir/lib$name.la"; then 230*75f6d617Schristos found_la="$dir/lib$name.la" 231*75f6d617Schristos fi 232*75f6d617Schristos fi 233*75f6d617Schristos fi 234*75f6d617Schristos ;; 235*75f6d617Schristos esac 236*75f6d617Schristos if test "X$found_dir" != "X"; then 237*75f6d617Schristos break 238*75f6d617Schristos fi 239*75f6d617Schristos done 240*75f6d617Schristos fi 241*75f6d617Schristos if test "X$found_dir" != "X"; then 242*75f6d617Schristos dnl Found the library. 243*75f6d617Schristos LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" 244*75f6d617Schristos if test "X$found_so" != "X"; then 245*75f6d617Schristos dnl Linking with a shared library. We attempt to hardcode its 246*75f6d617Schristos dnl directory into the executable's runpath, unless it's the 247*75f6d617Schristos dnl standard /usr/lib. 248*75f6d617Schristos if test "X$found_dir" = "X/usr/lib"; then 249*75f6d617Schristos dnl No hardcoding is needed. 250*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 251*75f6d617Schristos else 252*75f6d617Schristos dnl Use an explicit option to hardcode DIR into the resulting 253*75f6d617Schristos dnl binary. 254*75f6d617Schristos dnl Potentially add DIR to ltrpathdirs. 255*75f6d617Schristos dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. 256*75f6d617Schristos haveit= 257*75f6d617Schristos for x in $ltrpathdirs; do 258*75f6d617Schristos if test "X$x" = "X$found_dir"; then 259*75f6d617Schristos haveit=yes 260*75f6d617Schristos break 261*75f6d617Schristos fi 262*75f6d617Schristos done 263*75f6d617Schristos if test -z "$haveit"; then 264*75f6d617Schristos ltrpathdirs="$ltrpathdirs $found_dir" 265*75f6d617Schristos fi 266*75f6d617Schristos dnl The hardcoding into $LIBNAME is system dependent. 267*75f6d617Schristos if test "$hardcode_direct" = yes; then 268*75f6d617Schristos dnl Using DIR/libNAME.so during linking hardcodes DIR into the 269*75f6d617Schristos dnl resulting binary. 270*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 271*75f6d617Schristos else 272*75f6d617Schristos if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then 273*75f6d617Schristos dnl Use an explicit option to hardcode DIR into the resulting 274*75f6d617Schristos dnl binary. 275*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 276*75f6d617Schristos dnl Potentially add DIR to rpathdirs. 277*75f6d617Schristos dnl The rpathdirs will be appended to $LIBNAME at the end. 278*75f6d617Schristos haveit= 279*75f6d617Schristos for x in $rpathdirs; do 280*75f6d617Schristos if test "X$x" = "X$found_dir"; then 281*75f6d617Schristos haveit=yes 282*75f6d617Schristos break 283*75f6d617Schristos fi 284*75f6d617Schristos done 285*75f6d617Schristos if test -z "$haveit"; then 286*75f6d617Schristos rpathdirs="$rpathdirs $found_dir" 287*75f6d617Schristos fi 288*75f6d617Schristos else 289*75f6d617Schristos dnl Rely on "-L$found_dir". 290*75f6d617Schristos dnl But don't add it if it's already contained in the LDFLAGS 291*75f6d617Schristos dnl or the already constructed $LIBNAME 292*75f6d617Schristos haveit= 293*75f6d617Schristos for x in $LDFLAGS $LIB[]NAME; do 294*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 295*75f6d617Schristos if test "X$x" = "X-L$found_dir"; then 296*75f6d617Schristos haveit=yes 297*75f6d617Schristos break 298*75f6d617Schristos fi 299*75f6d617Schristos done 300*75f6d617Schristos if test -z "$haveit"; then 301*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" 302*75f6d617Schristos fi 303*75f6d617Schristos if test "$hardcode_minus_L" != no; then 304*75f6d617Schristos dnl FIXME: Not sure whether we should use 305*75f6d617Schristos dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" 306*75f6d617Schristos dnl here. 307*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 308*75f6d617Schristos else 309*75f6d617Schristos dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH 310*75f6d617Schristos dnl here, because this doesn't fit in flags passed to the 311*75f6d617Schristos dnl compiler. So give up. No hardcoding. This affects only 312*75f6d617Schristos dnl very old systems. 313*75f6d617Schristos dnl FIXME: Not sure whether we should use 314*75f6d617Schristos dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" 315*75f6d617Schristos dnl here. 316*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" 317*75f6d617Schristos fi 318*75f6d617Schristos fi 319*75f6d617Schristos fi 320*75f6d617Schristos fi 321*75f6d617Schristos else 322*75f6d617Schristos if test "X$found_a" != "X"; then 323*75f6d617Schristos dnl Linking with a static library. 324*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" 325*75f6d617Schristos else 326*75f6d617Schristos dnl We shouldn't come here, but anyway it's good to have a 327*75f6d617Schristos dnl fallback. 328*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" 329*75f6d617Schristos fi 330*75f6d617Schristos fi 331*75f6d617Schristos dnl Assume the include files are nearby. 332*75f6d617Schristos additional_includedir= 333*75f6d617Schristos case "$found_dir" in 334*75f6d617Schristos */lib | */lib/) 335*75f6d617Schristos basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` 336*75f6d617Schristos additional_includedir="$basedir/include" 337*75f6d617Schristos ;; 338*75f6d617Schristos esac 339*75f6d617Schristos if test "X$additional_includedir" != "X"; then 340*75f6d617Schristos dnl Potentially add $additional_includedir to $INCNAME. 341*75f6d617Schristos dnl But don't add it 342*75f6d617Schristos dnl 1. if it's the standard /usr/include, 343*75f6d617Schristos dnl 2. if it's /usr/local/include and we are using GCC on Linux, 344*75f6d617Schristos dnl 3. if it's already present in $CPPFLAGS or the already 345*75f6d617Schristos dnl constructed $INCNAME, 346*75f6d617Schristos dnl 4. if it doesn't exist as a directory. 347*75f6d617Schristos if test "X$additional_includedir" != "X/usr/include"; then 348*75f6d617Schristos haveit= 349*75f6d617Schristos if test "X$additional_includedir" = "X/usr/local/include"; then 350*75f6d617Schristos if test -n "$GCC"; then 351*75f6d617Schristos case $host_os in 352*75f6d617Schristos linux*) haveit=yes;; 353*75f6d617Schristos esac 354*75f6d617Schristos fi 355*75f6d617Schristos fi 356*75f6d617Schristos if test -z "$haveit"; then 357*75f6d617Schristos for x in $CPPFLAGS $INC[]NAME; do 358*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 359*75f6d617Schristos if test "X$x" = "X-I$additional_includedir"; then 360*75f6d617Schristos haveit=yes 361*75f6d617Schristos break 362*75f6d617Schristos fi 363*75f6d617Schristos done 364*75f6d617Schristos if test -z "$haveit"; then 365*75f6d617Schristos if test -d "$additional_includedir"; then 366*75f6d617Schristos dnl Really add $additional_includedir to $INCNAME. 367*75f6d617Schristos INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" 368*75f6d617Schristos fi 369*75f6d617Schristos fi 370*75f6d617Schristos fi 371*75f6d617Schristos fi 372*75f6d617Schristos fi 373*75f6d617Schristos dnl Look for dependencies. 374*75f6d617Schristos if test -n "$found_la"; then 375*75f6d617Schristos dnl Read the .la file. It defines the variables 376*75f6d617Schristos dnl dlname, library_names, old_library, dependency_libs, current, 377*75f6d617Schristos dnl age, revision, installed, dlopen, dlpreopen, libdir. 378*75f6d617Schristos save_libdir="$libdir" 379*75f6d617Schristos case "$found_la" in 380*75f6d617Schristos */* | *\\*) . "$found_la" ;; 381*75f6d617Schristos *) . "./$found_la" ;; 382*75f6d617Schristos esac 383*75f6d617Schristos libdir="$save_libdir" 384*75f6d617Schristos dnl We use only dependency_libs. 385*75f6d617Schristos for dep in $dependency_libs; do 386*75f6d617Schristos case "$dep" in 387*75f6d617Schristos -L*) 388*75f6d617Schristos additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` 389*75f6d617Schristos dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. 390*75f6d617Schristos dnl But don't add it 391*75f6d617Schristos dnl 1. if it's the standard /usr/lib, 392*75f6d617Schristos dnl 2. if it's /usr/local/lib and we are using GCC on Linux, 393*75f6d617Schristos dnl 3. if it's already present in $LDFLAGS or the already 394*75f6d617Schristos dnl constructed $LIBNAME, 395*75f6d617Schristos dnl 4. if it doesn't exist as a directory. 396*75f6d617Schristos if test "X$additional_libdir" != "X/usr/lib"; then 397*75f6d617Schristos haveit= 398*75f6d617Schristos if test "X$additional_libdir" = "X/usr/local/lib"; then 399*75f6d617Schristos if test -n "$GCC"; then 400*75f6d617Schristos case $host_os in 401*75f6d617Schristos linux*) haveit=yes;; 402*75f6d617Schristos esac 403*75f6d617Schristos fi 404*75f6d617Schristos fi 405*75f6d617Schristos if test -z "$haveit"; then 406*75f6d617Schristos haveit= 407*75f6d617Schristos for x in $LDFLAGS $LIB[]NAME; do 408*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 409*75f6d617Schristos if test "X$x" = "X-L$additional_libdir"; then 410*75f6d617Schristos haveit=yes 411*75f6d617Schristos break 412*75f6d617Schristos fi 413*75f6d617Schristos done 414*75f6d617Schristos if test -z "$haveit"; then 415*75f6d617Schristos if test -d "$additional_libdir"; then 416*75f6d617Schristos dnl Really add $additional_libdir to $LIBNAME. 417*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" 418*75f6d617Schristos fi 419*75f6d617Schristos fi 420*75f6d617Schristos haveit= 421*75f6d617Schristos for x in $LDFLAGS $LTLIB[]NAME; do 422*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 423*75f6d617Schristos if test "X$x" = "X-L$additional_libdir"; then 424*75f6d617Schristos haveit=yes 425*75f6d617Schristos break 426*75f6d617Schristos fi 427*75f6d617Schristos done 428*75f6d617Schristos if test -z "$haveit"; then 429*75f6d617Schristos if test -d "$additional_libdir"; then 430*75f6d617Schristos dnl Really add $additional_libdir to $LTLIBNAME. 431*75f6d617Schristos LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" 432*75f6d617Schristos fi 433*75f6d617Schristos fi 434*75f6d617Schristos fi 435*75f6d617Schristos fi 436*75f6d617Schristos ;; 437*75f6d617Schristos -l*) 438*75f6d617Schristos dnl Handle this in the next round. 439*75f6d617Schristos names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` 440*75f6d617Schristos ;; 441*75f6d617Schristos *.la) 442*75f6d617Schristos dnl Handle this in the next round. Throw away the .la's 443*75f6d617Schristos dnl directory; it is already contained in a preceding -L 444*75f6d617Schristos dnl option. 445*75f6d617Schristos names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` 446*75f6d617Schristos ;; 447*75f6d617Schristos *) 448*75f6d617Schristos dnl Most likely an immediate library name. 449*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" 450*75f6d617Schristos LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" 451*75f6d617Schristos ;; 452*75f6d617Schristos esac 453*75f6d617Schristos done 454*75f6d617Schristos fi 455*75f6d617Schristos else 456*75f6d617Schristos dnl Didn't find the library; assume it is in the system directories 457*75f6d617Schristos dnl known to the linker and runtime loader. (All the system 458*75f6d617Schristos dnl directories known to the linker should also be known to the 459*75f6d617Schristos dnl runtime loader, otherwise the system is severely misconfigured.) 460*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" 461*75f6d617Schristos LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" 462*75f6d617Schristos fi 463*75f6d617Schristos fi 464*75f6d617Schristos fi 465*75f6d617Schristos done 466*75f6d617Schristos done 467*75f6d617Schristos if test "X$rpathdirs" != "X"; then 468*75f6d617Schristos if test -n "$hardcode_libdir_separator"; then 469*75f6d617Schristos dnl Weird platform: only the last -rpath option counts, the user must 470*75f6d617Schristos dnl pass all path elements in one option. We can arrange that for a 471*75f6d617Schristos dnl single library, but not when more than one $LIBNAMEs are used. 472*75f6d617Schristos alldirs= 473*75f6d617Schristos for found_dir in $rpathdirs; do 474*75f6d617Schristos alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" 475*75f6d617Schristos done 476*75f6d617Schristos dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. 477*75f6d617Schristos acl_save_libdir="$libdir" 478*75f6d617Schristos libdir="$alldirs" 479*75f6d617Schristos eval flag=\"$hardcode_libdir_flag_spec\" 480*75f6d617Schristos libdir="$acl_save_libdir" 481*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" 482*75f6d617Schristos else 483*75f6d617Schristos dnl The -rpath options are cumulative. 484*75f6d617Schristos for found_dir in $rpathdirs; do 485*75f6d617Schristos acl_save_libdir="$libdir" 486*75f6d617Schristos libdir="$found_dir" 487*75f6d617Schristos eval flag=\"$hardcode_libdir_flag_spec\" 488*75f6d617Schristos libdir="$acl_save_libdir" 489*75f6d617Schristos LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" 490*75f6d617Schristos done 491*75f6d617Schristos fi 492*75f6d617Schristos fi 493*75f6d617Schristos if test "X$ltrpathdirs" != "X"; then 494*75f6d617Schristos dnl When using libtool, the option that works for both libraries and 495*75f6d617Schristos dnl executables is -R. The -R options are cumulative. 496*75f6d617Schristos for found_dir in $ltrpathdirs; do 497*75f6d617Schristos LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" 498*75f6d617Schristos done 499*75f6d617Schristos fi 500*75f6d617Schristos]) 501*75f6d617Schristos 502*75f6d617Schristosdnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, 503*75f6d617Schristosdnl unless already present in VAR. 504*75f6d617Schristosdnl Works only for CPPFLAGS, not for LIB* variables because that sometimes 505*75f6d617Schristosdnl contains two or three consecutive elements that belong together. 506*75f6d617SchristosAC_DEFUN([AC_LIB_APPENDTOVAR], 507*75f6d617Schristos[ 508*75f6d617Schristos for element in [$2]; do 509*75f6d617Schristos haveit= 510*75f6d617Schristos for x in $[$1]; do 511*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 512*75f6d617Schristos if test "X$x" = "X$element"; then 513*75f6d617Schristos haveit=yes 514*75f6d617Schristos break 515*75f6d617Schristos fi 516*75f6d617Schristos done 517*75f6d617Schristos if test -z "$haveit"; then 518*75f6d617Schristos [$1]="${[$1]}${[$1]:+ }$element" 519*75f6d617Schristos fi 520*75f6d617Schristos done 521*75f6d617Schristos]) 522