You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

614 lines
16 KiB

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