1#! /bin/sh 2# Output a system dependent set of variables, describing how to set the 3# run time search path of shared libraries in an executable. 4# 5# Copyright 1996-2005 Free Software Foundation, Inc. 6# Taken from GNU libtool, 2001 7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8# 9# This file is free software; the Free Software Foundation gives 10# unlimited permission to copy and/or distribute it, with or without 11# modifications, as long as this notice is preserved. 12# 13# The first argument passed to this file is the canonical host specification, 14# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 15# or 16# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 17# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld 18# should be set by the caller. 19# 20# The set of defined variables is at the end of this script. 21 22# Known limitations: 23# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer 24# than 256 bytes, otherwise the compiler driver will dump core. The only 25# known workaround is to choose shorter directory names for the build 26# directory and/or the installation directory. 27 28# All known linkers require a `.a' archive for static linking (except M$VC, 29# which needs '.lib'). 30libext=a 31shrext=.so 32 33host="$1" 34host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` 35host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` 36host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` 37 38cc_basename=`echo "$CC" | sed -e 's%^.*/%%'` 39 40# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. 41 42wl= 43if test "$GCC" = yes; then 44 wl='-Wl,' 45else 46 case "$host_os" in 47 aix*) 48 wl='-Wl,' 49 ;; 50 darwin*) 51 case "$cc_basename" in 52 xlc*) 53 wl='-Wl,' 54 ;; 55 esac 56 ;; 57 mingw* | pw32* | os2*) 58 ;; 59 hpux9* | hpux10* | hpux11*) 60 wl='-Wl,' 61 ;; 62 irix5* | irix6* | nonstopux*) 63 wl='-Wl,' 64 ;; 65 newsos6) 66 ;; 67 linux*) 68 case $cc_basename in 69 icc* | ecc*) 70 wl='-Wl,' 71 ;; 72 pgcc | pgf77 | pgf90) 73 wl='-Wl,' 74 ;; 75 ccc*) 76 wl='-Wl,' 77 ;; 78 como) 79 wl='-lopt=' 80 ;; 81 esac 82 ;; 83 osf3* | osf4* | osf5*) 84 wl='-Wl,' 85 ;; 86 sco3.2v5*) 87 ;; 88 solaris*) 89 wl='-Wl,' 90 ;; 91 sunos4*) 92 wl='-Qoption ld ' 93 ;; 94 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) 95 wl='-Wl,' 96 ;; 97 sysv4*MP*) 98 ;; 99 unicos*) 100 wl='-Wl,' 101 ;; 102 uts4*) 103 ;; 104 esac 105fi 106 107# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. 108 109hardcode_libdir_flag_spec= 110hardcode_libdir_separator= 111hardcode_direct=no 112hardcode_minus_L=no 113 114case "$host_os" in 115 cygwin* | mingw* | pw32*) 116 # FIXME: the MSVC++ port hasn't been tested in a loooong time 117 # When not using gcc, we currently assume that we are using 118 # Microsoft Visual C++. 119 if test "$GCC" != yes; then 120 with_gnu_ld=no 121 fi 122 ;; 123 openbsd*) 124 with_gnu_ld=no 125 ;; 126esac 127 128ld_shlibs=yes 129if test "$with_gnu_ld" = yes; then 130 case "$host_os" in 131 aix3* | aix4* | aix5*) 132 # On AIX/PPC, the GNU linker is very broken 133 if test "$host_cpu" != ia64; then 134 ld_shlibs=no 135 fi 136 ;; 137 amigaos*) 138 hardcode_libdir_flag_spec='-L$libdir' 139 hardcode_minus_L=yes 140 # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports 141 # that the semantics of dynamic libraries on AmigaOS, at least up 142 # to version 4, is to share data among multiple programs linked 143 # with the same dynamic library. Since this doesn't match the 144 # behavior of shared libraries on other platforms, we cannot use 145 # them. 146 ld_shlibs=no 147 ;; 148 beos*) 149 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 150 : 151 else 152 ld_shlibs=no 153 fi 154 ;; 155 cygwin* | mingw* | pw32*) 156 # hardcode_libdir_flag_spec is actually meaningless, as there is 157 # no search path for DLLs. 158 hardcode_libdir_flag_spec='-L$libdir' 159 if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then 160 : 161 else 162 ld_shlibs=no 163 fi 164 ;; 165 netbsd*) 166 ;; 167 solaris* | sysv5*) 168 if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then 169 ld_shlibs=no 170 elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 171 : 172 else 173 ld_shlibs=no 174 fi 175 ;; 176 sunos4*) 177 hardcode_direct=yes 178 ;; 179 linux*) 180 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 181 : 182 else 183 ld_shlibs=no 184 fi 185 ;; 186 *) 187 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 188 : 189 else 190 ld_shlibs=no 191 fi 192 ;; 193 esac 194 if test "$ld_shlibs" = yes; then 195 # Unlike libtool, we use -rpath here, not --rpath, since the documented 196 # option of GNU ld is called -rpath, not --rpath. 197 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 198 fi 199else 200 case "$host_os" in 201 aix3*) 202 # Note: this linker hardcodes the directories in LIBPATH if there 203 # are no directories specified by -L. 204 hardcode_minus_L=yes 205 if test "$GCC" = yes; then 206 # Neither direct hardcoding nor static linking is supported with a 207 # broken collect2. 208 hardcode_direct=unsupported 209 fi 210 ;; 211 aix4* | aix5*) 212 if test "$host_cpu" = ia64; then 213 # On IA64, the linker does run time linking by default, so we don't 214 # have to do anything special. 215 aix_use_runtimelinking=no 216 else 217 aix_use_runtimelinking=no 218 # Test if we are trying to use run time linking or normal 219 # AIX style linking. If -brtl is somewhere in LDFLAGS, we 220 # need to do runtime linking. 221 case $host_os in aix4.[23]|aix4.[23].*|aix5*) 222 for ld_flag in $LDFLAGS; do 223 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then 224 aix_use_runtimelinking=yes 225 break 226 fi 227 done 228 esac 229 fi 230 hardcode_direct=yes 231 hardcode_libdir_separator=':' 232 if test "$GCC" = yes; then 233 case $host_os in aix4.[012]|aix4.[012].*) 234 collect2name=`${CC} -print-prog-name=collect2` 235 if test -f "$collect2name" && \ 236 strings "$collect2name" | grep resolve_lib_name >/dev/null 237 then 238 # We have reworked collect2 239 hardcode_direct=yes 240 else 241 # We have old collect2 242 hardcode_direct=unsupported 243 hardcode_minus_L=yes 244 hardcode_libdir_flag_spec='-L$libdir' 245 hardcode_libdir_separator= 246 fi 247 esac 248 fi 249 # Begin _LT_AC_SYS_LIBPATH_AIX. 250 echo 'int main () { return 0; }' > conftest.c 251 ${CC} ${LDFLAGS} conftest.c -o conftest 252 aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } 253}'` 254 if test -z "$aix_libpath"; then 255 aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } 256}'` 257 fi 258 if test -z "$aix_libpath"; then 259 aix_libpath="/usr/lib:/lib" 260 fi 261 rm -f conftest.c conftest 262 # End _LT_AC_SYS_LIBPATH_AIX. 263 if test "$aix_use_runtimelinking" = yes; then 264 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" 265 else 266 if test "$host_cpu" = ia64; then 267 hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' 268 else 269 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" 270 fi 271 fi 272 ;; 273 amigaos*) 274 hardcode_libdir_flag_spec='-L$libdir' 275 hardcode_minus_L=yes 276 # see comment about different semantics on the GNU ld section 277 ld_shlibs=no 278 ;; 279 bsdi[45]*) 280 ;; 281 cygwin* | mingw* | pw32*) 282 # When not using gcc, we currently assume that we are using 283 # Microsoft Visual C++. 284 # hardcode_libdir_flag_spec is actually meaningless, as there is 285 # no search path for DLLs. 286 hardcode_libdir_flag_spec=' ' 287 libext=lib 288 ;; 289 darwin* | rhapsody*) 290 hardcode_direct=no 291 if test "$GCC" = yes ; then 292 : 293 else 294 case "$cc_basename" in 295 xlc*) 296 ;; 297 *) 298 ld_shlibs=no 299 ;; 300 esac 301 fi 302 ;; 303 dgux*) 304 hardcode_libdir_flag_spec='-L$libdir' 305 ;; 306 freebsd1*) 307 ld_shlibs=no 308 ;; 309 freebsd2.2*) 310 hardcode_libdir_flag_spec='-R$libdir' 311 hardcode_direct=yes 312 ;; 313 freebsd2*) 314 hardcode_direct=yes 315 hardcode_minus_L=yes 316 ;; 317 freebsd* | kfreebsd*-gnu | dragonfly*) 318 hardcode_libdir_flag_spec='-R$libdir' 319 hardcode_direct=yes 320 ;; 321 hpux9*) 322 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' 323 hardcode_libdir_separator=: 324 hardcode_direct=yes 325 # hardcode_minus_L: Not really in the search PATH, 326 # but as the default location of the library. 327 hardcode_minus_L=yes 328 ;; 329 hpux10* | hpux11*) 330 if test "$with_gnu_ld" = no; then 331 case "$host_cpu" in 332 hppa*64*) 333 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' 334 hardcode_libdir_separator=: 335 hardcode_direct=no 336 ;; 337 ia64*) 338 hardcode_libdir_flag_spec='-L$libdir' 339 hardcode_direct=no 340 # hardcode_minus_L: Not really in the search PATH, 341 # but as the default location of the library. 342 hardcode_minus_L=yes 343 ;; 344 *) 345 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' 346 hardcode_libdir_separator=: 347 hardcode_direct=yes 348 # hardcode_minus_L: Not really in the search PATH, 349 # but as the default location of the library. 350 hardcode_minus_L=yes 351 ;; 352 esac 353 fi 354 ;; 355 irix5* | irix6* | nonstopux*) 356 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 357 hardcode_libdir_separator=: 358 ;; 359 netbsd*) 360 hardcode_libdir_flag_spec='-R$libdir' 361 hardcode_direct=yes 362 ;; 363 newsos6) 364 hardcode_direct=yes 365 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 366 hardcode_libdir_separator=: 367 ;; 368 openbsd*) 369 hardcode_direct=yes 370 if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then 371 hardcode_libdir_flag_spec='${wl}-rpath,$libdir' 372 else 373 case "$host_os" in 374 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) 375 hardcode_libdir_flag_spec='-R$libdir' 376 ;; 377 *) 378 hardcode_libdir_flag_spec='${wl}-rpath,$libdir' 379 ;; 380 esac 381 fi 382 ;; 383 os2*) 384 hardcode_libdir_flag_spec='-L$libdir' 385 hardcode_minus_L=yes 386 ;; 387 osf3*) 388 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 389 hardcode_libdir_separator=: 390 ;; 391 osf4* | osf5*) 392 if test "$GCC" = yes; then 393 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 394 else 395 # Both cc and cxx compiler support -rpath directly 396 hardcode_libdir_flag_spec='-rpath $libdir' 397 fi 398 hardcode_libdir_separator=: 399 ;; 400 sco3.2v5*) 401 ;; 402 solaris*) 403 hardcode_libdir_flag_spec='-R$libdir' 404 ;; 405 sunos4*) 406 hardcode_libdir_flag_spec='-L$libdir' 407 hardcode_direct=yes 408 hardcode_minus_L=yes 409 ;; 410 sysv4) 411 case $host_vendor in 412 sni) 413 hardcode_direct=yes # is this really true??? 414 ;; 415 siemens) 416 hardcode_direct=no 417 ;; 418 motorola) 419 hardcode_direct=no #Motorola manual says yes, but my tests say they lie 420 ;; 421 esac 422 ;; 423 sysv4.3*) 424 ;; 425 sysv4*MP*) 426 if test -d /usr/nec; then 427 ld_shlibs=yes 428 fi 429 ;; 430 sysv4.2uw2*) 431 hardcode_direct=yes 432 hardcode_minus_L=no 433 ;; 434 sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) 435 ;; 436 sysv5*) 437 hardcode_libdir_flag_spec= 438 ;; 439 uts4*) 440 hardcode_libdir_flag_spec='-L$libdir' 441 ;; 442 *) 443 ld_shlibs=no 444 ;; 445 esac 446fi 447 448# Check dynamic linker characteristics 449# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. 450libname_spec='lib$name' 451case "$host_os" in 452 aix3*) 453 ;; 454 aix4* | aix5*) 455 ;; 456 amigaos*) 457 ;; 458 beos*) 459 ;; 460 bsdi[45]*) 461 ;; 462 cygwin* | mingw* | pw32*) 463 shrext=.dll 464 ;; 465 darwin* | rhapsody*) 466 shrext=.dylib 467 ;; 468 dgux*) 469 ;; 470 freebsd1*) 471 ;; 472 kfreebsd*-gnu) 473 ;; 474 freebsd*) 475 ;; 476 gnu*) 477 ;; 478 hpux9* | hpux10* | hpux11*) 479 case "$host_cpu" in 480 ia64*) 481 shrext=.so 482 ;; 483 hppa*64*) 484 shrext=.sl 485 ;; 486 *) 487 shrext=.sl 488 ;; 489 esac 490 ;; 491 irix5* | irix6* | nonstopux*) 492 case "$host_os" in 493 irix5* | nonstopux*) 494 libsuff= shlibsuff= 495 ;; 496 *) 497 case $LD in 498 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; 499 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; 500 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; 501 *) libsuff= shlibsuff= ;; 502 esac 503 ;; 504 esac 505 ;; 506 linux*oldld* | linux*aout* | linux*coff*) 507 ;; 508 linux*) 509 ;; 510 knetbsd*-gnu) 511 ;; 512 netbsd*) 513 ;; 514 newsos6) 515 ;; 516 nto-qnx*) 517 ;; 518 openbsd*) 519 ;; 520 os2*) 521 libname_spec='$name' 522 shrext=.dll 523 ;; 524 osf3* | osf4* | osf5*) 525 ;; 526 sco3.2v5*) 527 ;; 528 solaris*) 529 ;; 530 sunos4*) 531 ;; 532 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) 533 ;; 534 sysv4*MP*) 535 ;; 536 uts4*) 537 ;; 538esac 539 540sed_quote_subst='s/\(["`$\\]\)/\\\1/g' 541escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` 542shlibext=`echo "$shrext" | sed -e 's,^\.,,'` 543escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` 544 545LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF 546 547# How to pass a linker flag through the compiler. 548wl="$escaped_wl" 549 550# Static library suffix (normally "a"). 551libext="$libext" 552 553# Shared library suffix (normally "so"). 554shlibext="$shlibext" 555 556# Flag to hardcode \$libdir into a binary during linking. 557# This must work even if \$libdir does not exist. 558hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" 559 560# Whether we need a single -rpath flag with a separated argument. 561hardcode_libdir_separator="$hardcode_libdir_separator" 562 563# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the 564# resulting binary. 565hardcode_direct="$hardcode_direct" 566 567# Set to yes if using the -LDIR flag during linking hardcodes DIR into the 568# resulting binary. 569hardcode_minus_L="$hardcode_minus_L" 570 571EOF 572