Collection of DPF-based plugins for packaging
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.

500 lines
20KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_xercesc.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_XERCESC
  8. #
  9. # DESCRIPTION
  10. #
  11. # Define $HAVE_LIBXERCES_C, $LIBXERCES_C, and $LTLIBXERCES_C to signify
  12. # whether Xerces is available.
  13. #
  14. # LICENSE
  15. #
  16. # Copyright (c) 2008 Ronald Landheer-Cieslak <blytkerchan@users.sourceforge.net>
  17. #
  18. # This program is free software; you can redistribute it and/or modify it
  19. # under the terms of the GNU General Public License as published by the
  20. # Free Software Foundation; either version 2 of the License, or (at your
  21. # option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful, but
  24. # WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  26. # Public License for more details.
  27. #
  28. # You should have received a copy of the GNU General Public License along
  29. # with this program. If not, see <https://www.gnu.org/licenses/>.
  30. #
  31. # As a special exception, the respective Autoconf Macro's copyright owner
  32. # gives unlimited permission to copy, distribute and modify the configure
  33. # scripts that are the output of Autoconf when processing the Macro. You
  34. # need not follow the terms of the GNU General Public License when using
  35. # or distributing such scripts, even though portions of the text of the
  36. # Macro appear in them. The GNU General Public License (GPL) does govern
  37. # all other use of the material that constitutes the Autoconf Macro.
  38. #
  39. # This special exception to the GPL applies to versions of the Autoconf
  40. # Macro released by the Autoconf Archive. When you make and distribute a
  41. # modified version of the Autoconf Macro, you may extend this special
  42. # exception to the GPL to apply to your modified version as well.
  43. #serial 8
  44. AU_ALIAS([RLC_XERCESC], [AX_XERCESC])
  45. AC_DEFUN([AX_XERCESC],
  46. [
  47. dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
  48. AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  49. AC_REQUIRE([AC_LIB_RPATH])
  50. AC_LANG_PUSH(C++)
  51. AX_XERCESC_BODY()
  52. ac_save_CPPFLAGS="$CPPFLAGS"
  53. AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCXERCES_C])
  54. AC_CACHE_CHECK([for libxerces-c], [ac_cv_libxerces_c], [
  55. ac_save_LIBS="$LIBS"
  56. LIBS="$LIBS $LIBXERCES_C $LIBICONV"
  57. AC_TRY_LINK([
  58. #include <xercesc/util/PlatformUtils.hpp>
  59. #ifdef XERCES_CPP_NAMESPACE_USE
  60. XERCES_CPP_NAMESPACE_USE
  61. #endif
  62. ], [
  63. try
  64. {
  65. XMLPlatformUtils::Initialize();
  66. }
  67. catch (...)
  68. {
  69. // ...
  70. }
  71. XMLPlatformUtils::Terminate();
  72. ], [ac_cv_libxerces_c=yes], [ac_cv_libxerces_c=no])
  73. LIBS="$ac_save_LIBS"
  74. ])
  75. if test "$ac_cv_libxerces_c" = yes; then
  76. HAVE_LIBXERCES_C=yes
  77. AC_DEFINE(HAVE_LIBXERCES_C, 1, [Define if you have the xerces-c library.])
  78. AC_MSG_CHECKING([how to link with libxerces-c])
  79. AC_MSG_RESULT([$LIBXERCES_C])
  80. else
  81. HAVE_LIBXERCES_C=no
  82. CPPFLAGS="$ac_save_CPPFLAGS"
  83. LIBXERCES_C=
  84. LTLIBXERCES_C=
  85. fi
  86. AC_LANG_POP(C++)
  87. AC_SUBST(HAVE_LIBXERCES_C)
  88. AC_SUBST(LIBXERCES_C)
  89. AC_SUBST(LTLIBXERCES_C)
  90. ])
  91. AC_DEFUN([AX_XERCESC_BODY],
  92. [
  93. dnl By default, look in $includedir and $libdir.
  94. use_additional=yes
  95. AC_LIB_WITH_FINAL_PREFIX([
  96. eval additional_includedir=\"$includedir\"
  97. eval additional_libdir=\"$libdir\"
  98. ])
  99. AC_ARG_WITH([libxerces-c-prefix],
  100. [ --with-libxerces-c-prefix[=DIR] search for libxerces-c in DIR/include and DIR/lib
  101. --without-libxerces-c-prefix don't search for libxerces-c in includedir and libdir],
  102. [
  103. if test "X$withval" = "Xno"; then
  104. use_additional=no
  105. else
  106. if test "X$withval" = "X"; then
  107. AC_LIB_WITH_FINAL_PREFIX([
  108. eval additional_includedir=\"$includedir\"
  109. eval additional_libdir=\"$libdir\"
  110. ])
  111. else
  112. additional_includedir="$withval/include"
  113. additional_libdir="$withval/lib"
  114. fi
  115. fi
  116. ])
  117. dnl Search the library and its dependencies in $additional_libdir and
  118. dnl $LDFLAGS. Using breadth-first-search.
  119. LIBXERCES_C=
  120. LTLIBXERCES_C=
  121. INCXERCES_C=
  122. rpathdirs=
  123. ltrpathdirs=
  124. names_already_handled=
  125. names_next_round='xerces-c'
  126. while test -n "$names_next_round"; do
  127. names_this_round="$names_next_round"
  128. names_next_round=
  129. for name in $names_this_round; do
  130. already_handled=
  131. for n in $names_already_handled; do
  132. if test "$n" = "$name"; then
  133. already_handled=yes
  134. break
  135. fi
  136. done
  137. if test -z "$already_handled"; then
  138. names_already_handled="$names_already_handled $name"
  139. dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
  140. dnl or AC_LIB_HAVE_LINKFLAGS call.
  141. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
  142. eval value=\"\$HAVE_LIB$uppername\"
  143. if test -n "$value"; then
  144. if test "$value" = yes; then
  145. eval value=\"\$LIB$uppername\"
  146. test -z "$value" || LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$value"
  147. eval value=\"\$LTLIB$uppername\"
  148. test -z "$value" || LTLIBXERCES_C="${LTLIBXERCES_C}${LTLIBXERCES_C:+ }$value"
  149. else
  150. dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
  151. dnl that this library doesn't exist. So just drop it.
  152. :
  153. fi
  154. else
  155. dnl Search the library lib$name in $additional_libdir and $LDFLAGS
  156. found_dir=
  157. found_la=
  158. found_so=
  159. found_a=
  160. if test $use_additional = yes; then
  161. found_so="$additional_libdir/lib$name.$shlibext*"
  162. for i in $found_so; do
  163. if test -f $i && test -x $i; then
  164. found_so="$i"
  165. break
  166. fi
  167. done
  168. if test -n "$shlibext" && test -f $found_so; then
  169. found_dir="$additional_libdir"
  170. if test -f "$additional_libdir/lib$name.la"; then
  171. found_la="$additional_libdir/lib$name.la"
  172. fi
  173. else
  174. if test -f "$additional_libdir/lib$name.$libext"; then
  175. found_dir="$additional_libdir"
  176. found_a="$additional_libdir/lib$name.$libext"
  177. if test -f "$additional_libdir/lib$name.la"; then
  178. found_la="$additional_libdir/lib$name.la"
  179. fi
  180. fi
  181. fi
  182. fi
  183. if test "X$found_dir" = "X"; then
  184. for x in $LDFLAGS $LTLIBXERCES_C; do
  185. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  186. case "$x" in
  187. -L*)
  188. dir=`echo "X$x" | sed -e 's/^X-L//'`
  189. if test -n "$shlibext"; then
  190. found_dir="$dir"
  191. found_so="$dir/lib$name.$shlibext*"
  192. for i in $found_so; do
  193. if test -f $i && test -x $i; then
  194. found_so="$i"
  195. break
  196. fi
  197. done
  198. if test -f "$dir/lib$name.la"; then
  199. found_la="$dir/lib$name.la"
  200. fi
  201. else
  202. if test -f "$dir/lib$name.$libext"; then
  203. found_dir="$dir"
  204. found_a="$dir/lib$name.$libext"
  205. if test -f "$dir/lib$name.la"; then
  206. found_la="$dir/lib$name.la"
  207. fi
  208. fi
  209. fi
  210. ;;
  211. esac
  212. if test "X$found_dir" != "X"; then
  213. break
  214. fi
  215. done
  216. fi
  217. if test "X$found_dir" != "X"; then
  218. dnl Found the library.
  219. LTLIBXERCES_C="${LTLIBXERCES_C}${LTLIBXERCES_C:+ }-L$found_dir -l$name"
  220. if test "X$found_so" != "X"; then
  221. dnl Linking with a shared library. We attempt to hardcode its
  222. dnl directory into the executable's runpath, unless it's the
  223. dnl standard /usr/lib.
  224. if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
  225. dnl No hardcoding is needed.
  226. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$found_so"
  227. else
  228. dnl Use an explicit option to hardcode DIR into the resulting
  229. dnl binary.
  230. dnl Potentially add DIR to ltrpathdirs.
  231. haveit=
  232. for x in $ltrpathdirs; do
  233. if test "X$x" = "X$found_dir"; then
  234. haveit=yes
  235. break
  236. fi
  237. done
  238. if test -z "$haveit"; then
  239. ltrpathdirs="$ltrpathdirs $found_dir"
  240. fi
  241. if test "$hardcode_direct" = yes; then
  242. dnl resulting binary.
  243. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$found_so"
  244. else
  245. if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
  246. dnl Use an explicit option to hardcode DIR into the resulting
  247. dnl binary.
  248. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$found_so"
  249. dnl Potentially add DIR to rpathdirs.
  250. haveit=
  251. for x in $rpathdirs; do
  252. if test "X$x" = "X$found_dir"; then
  253. haveit=yes
  254. break
  255. fi
  256. done
  257. if test -z "$haveit"; then
  258. rpathdirs="$rpathdirs $found_dir"
  259. fi
  260. else
  261. dnl Rely on "-L$found_dir".
  262. dnl But don't add it if it's already contained in the LDFLAGS
  263. haveit=
  264. for x in $LDFLAGS $LIBXERCES_C; do
  265. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  266. if test "X$x" = "X-L$found_dir"; then
  267. haveit=yes
  268. break
  269. fi
  270. done
  271. if test -z "$haveit"; then
  272. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }-L$found_dir"
  273. fi
  274. if test "$hardcode_minus_L" != no; then
  275. dnl FIXME: Not sure whether we should use
  276. dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  277. dnl here.
  278. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$found_so"
  279. else
  280. dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
  281. dnl here, because this doesn't fit in flags passed to the
  282. dnl compiler. So give up. No hardcoding. This affects only
  283. dnl very old systems.
  284. dnl FIXME: Not sure whether we should use
  285. dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  286. dnl here.
  287. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }-l$name"
  288. fi
  289. fi
  290. fi
  291. fi
  292. else
  293. if test "X$found_a" != "X"; then
  294. dnl Linking with a static library.
  295. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$found_a"
  296. else
  297. dnl We shouldn't come here, but anyway it's good to have a
  298. dnl fallback.
  299. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }-L$found_dir -l$name"
  300. fi
  301. fi
  302. dnl Assume the include files are nearby.
  303. additional_includedir=
  304. case "$found_dir" in
  305. */lib | */lib/)
  306. basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
  307. additional_includedir="$basedir/include"
  308. ;;
  309. esac
  310. if test "X$additional_includedir" != "X"; then
  311. dnl But don't add it
  312. dnl 1. if it's the standard /usr/include,
  313. dnl 2. if it's /usr/local/include and we are using GCC on Linux,
  314. dnl 3. if it's already present in $CPPFLAGS or the already
  315. dnl 4. if it doesn't exist as a directory.
  316. if test "X$additional_includedir" != "X/usr/include"; then
  317. haveit=
  318. if test "X$additional_includedir" = "X/usr/local/include"; then
  319. if test -n "$GCC"; then
  320. case $host_os in
  321. linux*) haveit=yes;;
  322. esac
  323. fi
  324. fi
  325. if test -z "$haveit"; then
  326. for x in $CPPFLAGS $INCXERCES_C; do
  327. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  328. if test "X$x" = "X-I$additional_includedir"; then
  329. haveit=yes
  330. break
  331. fi
  332. done
  333. if test -z "$haveit"; then
  334. if test -d "$additional_includedir"; then
  335. INCXERCES_C="${INCXERCES_C}${INCXERCES_C:+ }-I$additional_includedir"
  336. fi
  337. fi
  338. fi
  339. fi
  340. fi
  341. dnl Look for dependencies.
  342. if test -n "$found_la"; then
  343. dnl Read the .la file. It defines the variables
  344. dnl dlname, library_names, old_library, dependency_libs, current,
  345. dnl age, revision, installed, dlopen, dlpreopen, libdir.
  346. save_libdir="$libdir"
  347. case "$found_la" in
  348. */* | *\\*) . "$found_la" ;;
  349. *) . "./$found_la" ;;
  350. esac
  351. libdir="$save_libdir"
  352. dnl We use only dependency_libs.
  353. for dep in $dependency_libs; do
  354. case "$dep" in
  355. -L*)
  356. additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
  357. dnl But don't add it
  358. dnl 1. if it's the standard /usr/lib,
  359. dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
  360. dnl 3. if it's already present in $LDFLAGS or the already
  361. dnl 4. if it doesn't exist as a directory.
  362. if test "X$additional_libdir" != "X/usr/lib"; then
  363. haveit=
  364. if test "X$additional_libdir" = "X/usr/local/lib"; then
  365. if test -n "$GCC"; then
  366. case $host_os in
  367. linux*) haveit=yes;;
  368. esac
  369. fi
  370. fi
  371. if test -z "$haveit"; then
  372. haveit=
  373. for x in $LDFLAGS $LIBXERCES_C; do
  374. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  375. if test "X$x" = "X-L$additional_libdir"; then
  376. haveit=yes
  377. break
  378. fi
  379. done
  380. if test -z "$haveit"; then
  381. if test -d "$additional_libdir"; then
  382. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }-L$additional_libdir"
  383. fi
  384. fi
  385. haveit=
  386. for x in $LDFLAGS $LTLIBXERCES_C; do
  387. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  388. if test "X$x" = "X-L$additional_libdir"; then
  389. haveit=yes
  390. break
  391. fi
  392. done
  393. if test -z "$haveit"; then
  394. if test -d "$additional_libdir"; then
  395. LTLIBXERCES_C="${LTLIBXERCES_C}${LTLIBXERCES_C:+ }-L$additional_libdir"
  396. fi
  397. fi
  398. fi
  399. fi
  400. ;;
  401. -R*)
  402. dir=`echo "X$dep" | sed -e 's/^X-R//'`
  403. if test "$enable_rpath" != no; then
  404. dnl Potentially add DIR to rpathdirs.
  405. haveit=
  406. for x in $rpathdirs; do
  407. if test "X$x" = "X$dir"; then
  408. haveit=yes
  409. break
  410. fi
  411. done
  412. if test -z "$haveit"; then
  413. rpathdirs="$rpathdirs $dir"
  414. fi
  415. dnl Potentially add DIR to ltrpathdirs.
  416. haveit=
  417. for x in $ltrpathdirs; do
  418. if test "X$x" = "X$dir"; then
  419. haveit=yes
  420. break
  421. fi
  422. done
  423. if test -z "$haveit"; then
  424. ltrpathdirs="$ltrpathdirs $dir"
  425. fi
  426. fi
  427. ;;
  428. -l*)
  429. dnl Handle this in the next round.
  430. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
  431. ;;
  432. *.la)
  433. dnl Handle this in the next round. Throw away the .la's
  434. dnl directory; it is already contained in a preceding -L
  435. dnl option.
  436. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
  437. ;;
  438. *)
  439. dnl Most likely an immediate library name.
  440. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$dep"
  441. LTLIBXERCES_C="${LTLIBXERCES_C}${LTLIBXERCES_C:+ }$dep"
  442. ;;
  443. esac
  444. done
  445. fi
  446. else
  447. dnl Didn't find the library; assume it is in the system directories
  448. dnl known to the linker and runtime loader. (All the system
  449. dnl directories known to the linker should also be known to the
  450. dnl runtime loader, otherwise the system is severely misconfigured.)
  451. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }-l$name"
  452. LTLIBXERCES_C="${LTLIBXERCES_C}${LTLIBXERCES_C:+ }-l$name"
  453. fi
  454. fi
  455. fi
  456. done
  457. done
  458. if test "X$rpathdirs" != "X"; then
  459. if test -n "$hardcode_libdir_separator"; then
  460. dnl Weird platform: only the last -rpath option counts, the user must
  461. dnl pass all path elements in one option. We can arrange that for a
  462. alldirs=
  463. for found_dir in $rpathdirs; do
  464. alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
  465. done
  466. dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
  467. acl_save_libdir="$libdir"
  468. libdir="$alldirs"
  469. eval flag=\"$hardcode_libdir_flag_spec\"
  470. libdir="$acl_save_libdir"
  471. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$flag"
  472. else
  473. dnl The -rpath options are cumulative.
  474. for found_dir in $rpathdirs; do
  475. acl_save_libdir="$libdir"
  476. libdir="$found_dir"
  477. eval flag=\"$hardcode_libdir_flag_spec\"
  478. libdir="$acl_save_libdir"
  479. LIBXERCES_C="${LIBXERCES_C}${LIBXERCES_C:+ }$flag"
  480. done
  481. fi
  482. fi
  483. if test "X$ltrpathdirs" != "X"; then
  484. dnl When using libtool, the option that works for both libraries and
  485. dnl executables is -R. The -R options are cumulative.
  486. for found_dir in $ltrpathdirs; do
  487. LTLIBXERCES_C="${LTLIBXERCES_C}${LTLIBXERCES_C:+ }-R$found_dir"
  488. done
  489. fi
  490. ])