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.

278 lines
8.3KB

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