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