lib-link.m4 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. AC_LIB_ARG_WITH([lib$1-type],
  146. [ --with-lib$1-type=TYPE type of library to search for (auto/static/shared) ],
  147. [ with_lib$1_type=$withval ], [ with_lib$1_type=auto ])
  148. lib_type=`eval echo \$with_lib$1_type`
  149. dnl Search the library and its dependencies in $additional_libdir and
  150. dnl $LDFLAGS. Using breadth-first-seach.
  151. LIB[]NAME=
  152. LTLIB[]NAME=
  153. INC[]NAME=
  154. rpathdirs=
  155. ltrpathdirs=
  156. names_already_handled=
  157. names_next_round='$1 $2'
  158. while test -n "$names_next_round"; do
  159. names_this_round="$names_next_round"
  160. names_next_round=
  161. for name in $names_this_round; do
  162. already_handled=
  163. for n in $names_already_handled; do
  164. if test "$n" = "$name"; then
  165. already_handled=yes
  166. break
  167. fi
  168. done
  169. if test -z "$already_handled"; then
  170. names_already_handled="$names_already_handled $name"
  171. dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
  172. dnl or AC_LIB_HAVE_LINKFLAGS call.
  173. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
  174. eval value=\"\$HAVE_LIB$uppername\"
  175. if test -n "$value"; then
  176. if test "$value" = yes; then
  177. eval value=\"\$LIB$uppername\"
  178. test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
  179. eval value=\"\$LTLIB$uppername\"
  180. test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
  181. else
  182. dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
  183. dnl that this library doesn't exist. So just drop it.
  184. :
  185. fi
  186. else
  187. dnl Search the library lib$name in $additional_libdir and $LDFLAGS
  188. dnl and the already constructed $LIBNAME/$LTLIBNAME.
  189. found_dir=
  190. found_la=
  191. found_so=
  192. found_a=
  193. if test $use_additional = yes; then
  194. if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext" && test x$lib_type != xstatic; then
  195. found_dir="$additional_libdir"
  196. found_so="$additional_libdir/lib$name.$shlibext"
  197. if test -f "$additional_libdir/lib$name.la"; then
  198. found_la="$additional_libdir/lib$name.la"
  199. fi
  200. elif test x$lib_type != xshared; then
  201. if test -f "$additional_libdir/lib$name.$libext"; then
  202. found_dir="$additional_libdir"
  203. found_a="$additional_libdir/lib$name.$libext"
  204. if test -f "$additional_libdir/lib$name.la"; then
  205. found_la="$additional_libdir/lib$name.la"
  206. fi
  207. fi
  208. fi
  209. fi
  210. if test "X$found_dir" = "X"; then
  211. for x in $LDFLAGS $LTLIB[]NAME; do
  212. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  213. case "$x" in
  214. -L*)
  215. dir=`echo "X$x" | sed -e 's/^X-L//'`
  216. if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext" && test x$lib_type != xstatic; then
  217. found_dir="$dir"
  218. found_so="$dir/lib$name.$shlibext"
  219. if test -f "$dir/lib$name.la"; then
  220. found_la="$dir/lib$name.la"
  221. fi
  222. elif test x$lib_type != xshared; then
  223. if test -f "$dir/lib$name.$libext"; then
  224. found_dir="$dir"
  225. found_a="$dir/lib$name.$libext"
  226. if test -f "$dir/lib$name.la"; then
  227. found_la="$dir/lib$name.la"
  228. fi
  229. fi
  230. fi
  231. ;;
  232. esac
  233. if test "X$found_dir" != "X"; then
  234. break
  235. fi
  236. done
  237. fi
  238. if test "X$found_dir" != "X"; then
  239. dnl Found the library.
  240. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
  241. if test "X$found_so" != "X"; then
  242. dnl Linking with a shared library. We attempt to hardcode its
  243. dnl directory into the executable's runpath, unless it's the
  244. dnl standard /usr/lib.
  245. if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
  246. dnl No hardcoding is needed.
  247. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  248. else
  249. dnl Use an explicit option to hardcode DIR into the resulting
  250. dnl binary.
  251. dnl Potentially add DIR to ltrpathdirs.
  252. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
  253. haveit=
  254. for x in $ltrpathdirs; do
  255. if test "X$x" = "X$found_dir"; then
  256. haveit=yes
  257. break
  258. fi
  259. done
  260. if test -z "$haveit"; then
  261. ltrpathdirs="$ltrpathdirs $found_dir"
  262. fi
  263. dnl The hardcoding into $LIBNAME is system dependent.
  264. if test "$hardcode_direct" = yes; then
  265. dnl Using DIR/libNAME.so during linking hardcodes DIR into the
  266. dnl resulting binary.
  267. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  268. else
  269. if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
  270. dnl Use an explicit option to hardcode DIR into the resulting
  271. dnl binary.
  272. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  273. dnl Potentially add DIR to rpathdirs.
  274. dnl The rpathdirs will be appended to $LIBNAME at the end.
  275. haveit=
  276. for x in $rpathdirs; do
  277. if test "X$x" = "X$found_dir"; then
  278. haveit=yes
  279. break
  280. fi
  281. done
  282. if test -z "$haveit"; then
  283. rpathdirs="$rpathdirs $found_dir"
  284. fi
  285. else
  286. dnl Rely on "-L$found_dir".
  287. dnl But don't add it if it's already contained in the LDFLAGS
  288. dnl or the already constructed $LIBNAME
  289. haveit=
  290. for x in $LDFLAGS $LIB[]NAME; do
  291. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  292. if test "X$x" = "X-L$found_dir"; then
  293. haveit=yes
  294. break
  295. fi
  296. done
  297. if test -z "$haveit"; then
  298. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
  299. fi
  300. if test "$hardcode_minus_L" != no; then
  301. dnl FIXME: Not sure whether we should use
  302. dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  303. dnl here.
  304. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  305. else
  306. dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
  307. dnl here, because this doesn't fit in flags passed to the
  308. dnl compiler. So give up. No hardcoding. This affects only
  309. dnl very old systems.
  310. dnl FIXME: Not sure whether we should use
  311. dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  312. dnl here.
  313. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
  314. fi
  315. fi
  316. fi
  317. fi
  318. else
  319. if test "X$found_a" != "X"; then
  320. dnl Linking with a static library.
  321. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
  322. else
  323. dnl We shouldn't come here, but anyway it's good to have a
  324. dnl fallback.
  325. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
  326. fi
  327. fi
  328. dnl Assume the include files are nearby.
  329. additional_includedir=
  330. case "$found_dir" in
  331. */lib | */lib/)
  332. basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
  333. additional_includedir="$basedir/include"
  334. ;;
  335. esac
  336. if test "X$additional_includedir" != "X"; then
  337. dnl Potentially add $additional_includedir to $INCNAME.
  338. dnl But don't add it
  339. dnl 1. if it's the standard /usr/include,
  340. dnl 2. if it's /usr/local/include and we are using GCC on Linux,
  341. dnl 3. if it's already present in $CPPFLAGS or the already
  342. dnl constructed $INCNAME,
  343. dnl 4. if it doesn't exist as a directory.
  344. if test "X$additional_includedir" != "X/usr/include"; then
  345. haveit=
  346. if test "X$additional_includedir" = "X/usr/local/include"; then
  347. if test -n "$GCC"; then
  348. case $host_os in
  349. linux*) haveit=yes;;
  350. esac
  351. fi
  352. fi
  353. if test -z "$haveit"; then
  354. for x in $CPPFLAGS $INC[]NAME; do
  355. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  356. if test "X$x" = "X-I$additional_includedir"; then
  357. haveit=yes
  358. break
  359. fi
  360. done
  361. if test -z "$haveit"; then
  362. if test -d "$additional_includedir"; then
  363. dnl Really add $additional_includedir to $INCNAME.
  364. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
  365. fi
  366. fi
  367. fi
  368. fi
  369. fi
  370. dnl Look for dependencies.
  371. if test -n "$found_la"; then
  372. dnl Read the .la file. It defines the variables
  373. dnl dlname, library_names, old_library, dependency_libs, current,
  374. dnl age, revision, installed, dlopen, dlpreopen, libdir.
  375. save_libdir="$libdir"
  376. case "$found_la" in
  377. */* | *\\*) . "$found_la" ;;
  378. *) . "./$found_la" ;;
  379. esac
  380. libdir="$save_libdir"
  381. dnl We use only dependency_libs.
  382. for dep in $dependency_libs; do
  383. case "$dep" in
  384. -L*)
  385. additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
  386. dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
  387. dnl But don't add it
  388. dnl 1. if it's the standard /usr/lib,
  389. dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
  390. dnl 3. if it's already present in $LDFLAGS or the already
  391. dnl constructed $LIBNAME,
  392. dnl 4. if it doesn't exist as a directory.
  393. if test "X$additional_libdir" != "X/usr/lib"; then
  394. haveit=
  395. if test "X$additional_libdir" = "X/usr/local/lib"; then
  396. if test -n "$GCC"; then
  397. case $host_os in
  398. linux*) haveit=yes;;
  399. esac
  400. fi
  401. fi
  402. if test -z "$haveit"; then
  403. haveit=
  404. for x in $LDFLAGS $LIB[]NAME; do
  405. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  406. if test "X$x" = "X-L$additional_libdir"; then
  407. haveit=yes
  408. break
  409. fi
  410. done
  411. if test -z "$haveit"; then
  412. if test -d "$additional_libdir"; then
  413. dnl Really add $additional_libdir to $LIBNAME.
  414. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
  415. fi
  416. fi
  417. haveit=
  418. for x in $LDFLAGS $LTLIB[]NAME; do
  419. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  420. if test "X$x" = "X-L$additional_libdir"; then
  421. haveit=yes
  422. break
  423. fi
  424. done
  425. if test -z "$haveit"; then
  426. if test -d "$additional_libdir"; then
  427. dnl Really add $additional_libdir to $LTLIBNAME.
  428. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
  429. fi
  430. fi
  431. fi
  432. fi
  433. ;;
  434. -R*)
  435. dir=`echo "X$dep" | sed -e 's/^X-R//'`
  436. if test "$enable_rpath" != no; then
  437. dnl Potentially add DIR to rpathdirs.
  438. dnl The rpathdirs will be appended to $LIBNAME at the end.
  439. haveit=
  440. for x in $rpathdirs; do
  441. if test "X$x" = "X$dir"; then
  442. haveit=yes
  443. break
  444. fi
  445. done
  446. if test -z "$haveit"; then
  447. rpathdirs="$rpathdirs $dir"
  448. fi
  449. dnl Potentially add DIR to ltrpathdirs.
  450. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
  451. haveit=
  452. for x in $ltrpathdirs; do
  453. if test "X$x" = "X$dir"; then
  454. haveit=yes
  455. break
  456. fi
  457. done
  458. if test -z "$haveit"; then
  459. ltrpathdirs="$ltrpathdirs $dir"
  460. fi
  461. fi
  462. ;;
  463. -l*)
  464. dnl Handle this in the next round.
  465. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
  466. ;;
  467. *.la)
  468. dnl Handle this in the next round. Throw away the .la's
  469. dnl directory; it is already contained in a preceding -L
  470. dnl option.
  471. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
  472. ;;
  473. *)
  474. dnl Most likely an immediate library name.
  475. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
  476. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
  477. ;;
  478. esac
  479. done
  480. fi
  481. else
  482. dnl Didn't find the library; assume it is in the system directories
  483. dnl known to the linker and runtime loader. (All the system
  484. dnl directories known to the linker should also be known to the
  485. dnl runtime loader, otherwise the system is severely misconfigured.)
  486. if test "x$lib_type" = "xauto" || test "x$lib_type" = "xshared"; then
  487. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
  488. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
  489. else
  490. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l:lib$name.$libext"
  491. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l:lib$name.$libext"
  492. fi
  493. fi
  494. fi
  495. fi
  496. done
  497. done
  498. if test "X$rpathdirs" != "X"; then
  499. if test -n "$hardcode_libdir_separator"; then
  500. dnl Weird platform: only the last -rpath option counts, the user must
  501. dnl pass all path elements in one option. We can arrange that for a
  502. dnl single library, but not when more than one $LIBNAMEs are used.
  503. alldirs=
  504. for found_dir in $rpathdirs; do
  505. alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
  506. done
  507. dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
  508. acl_save_libdir="$libdir"
  509. libdir="$alldirs"
  510. eval flag=\"$hardcode_libdir_flag_spec\"
  511. libdir="$acl_save_libdir"
  512. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
  513. else
  514. dnl The -rpath options are cumulative.
  515. for found_dir in $rpathdirs; do
  516. acl_save_libdir="$libdir"
  517. libdir="$found_dir"
  518. eval flag=\"$hardcode_libdir_flag_spec\"
  519. libdir="$acl_save_libdir"
  520. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
  521. done
  522. fi
  523. fi
  524. if test "X$ltrpathdirs" != "X"; then
  525. dnl When using libtool, the option that works for both libraries and
  526. dnl executables is -R. The -R options are cumulative.
  527. for found_dir in $ltrpathdirs; do
  528. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
  529. done
  530. fi
  531. ])
  532. dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
  533. dnl unless already present in VAR.
  534. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
  535. dnl contains two or three consecutive elements that belong together.
  536. AC_DEFUN([AC_LIB_APPENDTOVAR],
  537. [
  538. for element in [$2]; do
  539. haveit=
  540. for x in $[$1]; do
  541. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  542. if test "X$x" = "X$element"; then
  543. haveit=yes
  544. break
  545. fi
  546. done
  547. if test -z "$haveit"; then
  548. [$1]="${[$1]}${[$1]:+ }$element"
  549. fi
  550. done
  551. ])