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.

290 lines
9.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_lib_xerces.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_LIB_XERCES([MINIMUM-VERSION])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro provides tests of availability of Apache Xerces C++ Parser of
  12. # particular version or newer. This macros checks for Apache Xerces C++
  13. # Parser headers and libraries and defines compilation flags
  14. #
  15. # Macro supports following options and their values:
  16. #
  17. # 1) Single-option usage:
  18. #
  19. # --with-xerces - yes, no or path to Xerces installation prefix
  20. #
  21. # 2) Three-options usage (all options are required):
  22. #
  23. # --with-xerces=yes
  24. # --with-xerces-inc - path to base directory with Xerces headers
  25. # --with-xerces-lib - linker flags for Xerces
  26. #
  27. # This macro calls:
  28. #
  29. # AC_SUBST(XERCES_CFLAGS)
  30. # AC_SUBST(XERCES_LDFLAGS)
  31. # AC_SUBST(XERCES_VERSION) - only if version requirement is used
  32. #
  33. # And sets:
  34. #
  35. # HAVE_XERCES
  36. #
  37. # LICENSE
  38. #
  39. # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
  40. #
  41. # Copying and distribution of this file, with or without modification, are
  42. # permitted in any medium without royalty provided the copyright notice
  43. # and this notice are preserved. This file is offered as-is, without any
  44. # warranty.
  45. #serial 11
  46. AC_DEFUN([AX_LIB_XERCES],
  47. [
  48. AC_REQUIRE([AX_PTHREAD])
  49. AC_ARG_WITH([xerces],
  50. AS_HELP_STRING([--with-xerces=@<:@ARG@:>@],
  51. [use Xerces C++ Parser from given prefix (ARG=path); check standard prefixes (ARG=yes); disable (ARG=no)]
  52. ),
  53. [
  54. if test "$withval" = "yes"; then
  55. if test -d /usr/local/include/xercesc ; then
  56. xerces_prefix=/usr/local
  57. elif test -d /usr/include/xercesc ; then
  58. xerces_prefix=/usr
  59. else
  60. xerces_prefix=""
  61. fi
  62. xerces_requested="yes"
  63. elif test -d "$withval"; then
  64. xerces_prefix="$withval"
  65. xerces_requested="yes"
  66. else
  67. xerces_prefix=""
  68. xerces_requested="no"
  69. fi
  70. ],
  71. [
  72. dnl Default behavior is implicit yes
  73. if test -d /usr/local/include/xercesc ; then
  74. xerces_prefix=/usr/local
  75. elif test -d /usr/include/xercesc ; then
  76. xerces_prefix=/usr
  77. else
  78. xerces_prefix=""
  79. fi
  80. ]
  81. )
  82. AC_ARG_WITH([xerces-inc],
  83. AS_HELP_STRING([--with-xerces-inc=@<:@DIR@:>@],
  84. [path to Xerces C++ Parser headers]
  85. ),
  86. [xerces_include_dir="$withval"],
  87. [xerces_include_dir=""]
  88. )
  89. AC_ARG_WITH([xerces-lib],
  90. AS_HELP_STRING([--with-xerces-lib=@<:@ARG@:>@],
  91. [link options for Xerces C++ Parser libraries]
  92. ),
  93. [xerces_ldflags="$withval"],
  94. [xerces_ldflags=""]
  95. )
  96. XERCES_CPPFLAGS=""
  97. XERCES_LDFLAGS=""
  98. XERCES_VERSION=""
  99. dnl
  100. dnl Collect include/lib paths and flags
  101. dnl
  102. run_xerces_test="no"
  103. if test -n "$xerces_prefix"; then
  104. xerces_include_dir="$xerces_prefix/include"
  105. xerces_include_dir2="$xerces_prefix/include/xercesc"
  106. xerces_ldflags="-L$xerces_prefix/lib"
  107. run_xerces_test="yes"
  108. elif test "$xerces_requested" = "yes"; then
  109. if test -n "$xerces_include_dir" -a -n "$xerces_lib_flags"; then
  110. xerces_include_dir2="$xerces_include_dir/xercesc"
  111. run_xerces_test="yes"
  112. fi
  113. else
  114. run_xerces_test="no"
  115. fi
  116. xerces_libs="-lxerces-c"
  117. dnl
  118. dnl Check Xerces C++ Parser files
  119. dnl
  120. if test "$run_xerces_test" = "yes"; then
  121. saved_CPPFLAGS="$CPPFLAGS"
  122. CPPFLAGS="$CPPFLAGS -I$xerces_include_dir -I$xerces_include_dir2"
  123. saved_LDFLAGS="$LDFLAGS"
  124. LDFLAGS="$LDFLAGS $xerces_ldflags $PTHREAD_LDFLAGS"
  125. saved_LIBS="$LIBS"
  126. LIBS="$xerces_libs $PTHREAD_LIBS $LIBS"
  127. dnl
  128. dnl Check Xerces headers
  129. dnl
  130. AC_MSG_CHECKING([for Xerces C++ Parser headers in $xerces_include_dir and $xerces_include_dir2])
  131. AC_LANG_PUSH([C++])
  132. AC_COMPILE_IFELSE([
  133. AC_LANG_PROGRAM(
  134. [[
  135. @%:@include <xercesc/util/XercesDefs.hpp>
  136. @%:@include <xercesc/util/PlatformUtils.hpp>
  137. ]],
  138. [[]]
  139. )],
  140. [
  141. XERCES_CPPFLAGS="-I$xerces_include_dir -I$xerces_include_dir2"
  142. xerces_header_found="yes"
  143. AC_MSG_RESULT([found])
  144. ],
  145. [
  146. xerces_header_found="no"
  147. AC_MSG_RESULT([not found])
  148. ]
  149. )
  150. AC_LANG_POP([C++])
  151. dnl
  152. dnl Check Xerces libraries
  153. dnl
  154. if test "$xerces_header_found" = "yes"; then
  155. AC_MSG_CHECKING([for Xerces C++ Parser libraries])
  156. AC_LANG_PUSH([C++])
  157. AC_LINK_IFELSE([
  158. AC_LANG_PROGRAM(
  159. [[
  160. @%:@include <xercesc/util/XercesDefs.hpp>
  161. @%:@include <xercesc/util/PlatformUtils.hpp>
  162. #if (_XERCES_VERSION >= 20200)
  163. XERCES_CPP_NAMESPACE_USE
  164. #endif
  165. ]],
  166. [[
  167. XMLPlatformUtils::Initialize();
  168. ]]
  169. )],
  170. [
  171. XERCES_LDFLAGS="$xerces_ldflags $PTHREAD_LDFLAGS"
  172. XERCES_LIBS="$xerces_libs $PTHREAD_LIBS"
  173. xerces_lib_found="yes"
  174. AC_MSG_RESULT([found])
  175. ],
  176. [
  177. xerces_lib_found="no"
  178. AC_MSG_RESULT([not found])
  179. ]
  180. )
  181. AC_LANG_POP([C++])
  182. fi
  183. CPPFLAGS="$saved_CPPFLAGS"
  184. LDFLAGS="$saved_LDFLAGS"
  185. LIBS="$saved_LIBS"
  186. fi
  187. AC_MSG_CHECKING([for Xerces C++ Parser])
  188. if test "$run_xerces_test" = "yes"; then
  189. if test "$xerces_header_found" = "yes" -a "$xerces_lib_found" = "yes"; then
  190. AC_SUBST([XERCES_CPPFLAGS])
  191. AC_SUBST([XERCES_LDFLAGS])
  192. AC_SUBST([XERCES_LIBS])
  193. HAVE_XERCES="yes"
  194. else
  195. HAVE_XERCES="no"
  196. fi
  197. AC_MSG_RESULT([$HAVE_XERCES])
  198. dnl
  199. dnl Check Xerces version
  200. dnl
  201. if test "$HAVE_XERCES" = "yes"; then
  202. xerces_version_req=ifelse([$1], [], [], [$1])
  203. if test -n "$xerces_version_req"; then
  204. AC_MSG_CHECKING([if Xerces C++ Parser version is >= $xerces_version_req])
  205. if test -f "$xerces_include_dir2/util/XercesVersion.hpp"; then
  206. xerces_major=`cat $xerces_include_dir2/util/XercesVersion.hpp | \
  207. grep '^#define.*XERCES_VERSION_MAJOR.*[0-9]$' | \
  208. sed -e 's/#define XERCES_VERSION_MAJOR.//'`
  209. xerces_minor=`cat $xerces_include_dir2/util/XercesVersion.hpp | \
  210. grep '^#define.*XERCES_VERSION_MINOR.*[0-9]$' | \
  211. sed -e 's/#define XERCES_VERSION_MINOR.//'`
  212. xerces_revision=`cat $xerces_include_dir2/util/XercesVersion.hpp | \
  213. grep '^#define.*XERCES_VERSION_REVISION.*[0-9]$' | \
  214. sed -e 's/#define XERCES_VERSION_REVISION.//'`
  215. XERCES_VERSION="$xerces_major.$xerces_minor.$xerces_revision"
  216. AC_SUBST([XERCES_VERSION])
  217. dnl Decompose required version string and calculate numerical representation
  218. xerces_version_req_major=`expr $xerces_version_req : '\([[0-9]]*\)'`
  219. xerces_version_req_minor=`expr $xerces_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
  220. xerces_version_req_revision=`expr $xerces_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  221. if test "x$xerces_version_req_revision" = "x"; then
  222. xerces_version_req_revision="0"
  223. fi
  224. xerces_version_req_number=`expr $xerces_version_req_major \* 10000 \
  225. \+ $xerces_version_req_minor \* 100 \
  226. \+ $xerces_version_req_revision`
  227. dnl Calculate numerical representation of detected version
  228. xerces_version_number=`expr $xerces_major \* 10000 \
  229. \+ $xerces_minor \* 100 \
  230. \+ $xerces_revision`
  231. xerces_version_check=`expr $xerces_version_number \>\= $xerces_version_req_number`
  232. if test "$xerces_version_check" = "1"; then
  233. AC_MSG_RESULT([yes])
  234. else
  235. AC_MSG_RESULT([no])
  236. AC_MSG_WARN([Found Xerces C++ Parser $XERCES_VERSION, which is older than required. Possible compilation failure.])
  237. fi
  238. else
  239. AC_MSG_RESULT([no])
  240. AC_MSG_WARN([Missing header XercesVersion.hpp. Unable to determine Xerces version.])
  241. fi
  242. fi
  243. fi
  244. else
  245. HAVE_XERCES="no"
  246. AC_MSG_RESULT([$HAVE_XERCES])
  247. if test "$xerces_requested" = "yes"; then
  248. AC_MSG_WARN([Xerces C++ Parser support requested but headers or library not found. Specify valid prefix of Xerces C++ using --with-xerces=@<:@DIR@:>@ or provide include directory and linker flags using --with-xerces-inc and --with-xerces-lib])
  249. fi
  250. fi
  251. ])