lib-link.m4 23 KB

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