lib-link.m4 23 KB

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