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.

302 lines
13KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_boost_base.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for the Boost C++ libraries of a particular version (or newer)
  12. #
  13. # If no path to the installed boost library is given the macro searchs
  14. # under /usr, /usr/local, /opt and /opt/local and evaluates the
  15. # $BOOST_ROOT environment variable. Further documentation is available at
  16. # <http://randspringer.de/boost/index.html>.
  17. #
  18. # This macro calls:
  19. #
  20. # AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
  21. #
  22. # And sets:
  23. #
  24. # HAVE_BOOST
  25. #
  26. # LICENSE
  27. #
  28. # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
  29. # Copyright (c) 2009 Peter Adolphs
  30. #
  31. # Copying and distribution of this file, with or without modification, are
  32. # permitted in any medium without royalty provided the copyright notice
  33. # and this notice are preserved. This file is offered as-is, without any
  34. # warranty.
  35. #serial 43
  36. # example boost program (need to pass version)
  37. m4_define([_AX_BOOST_BASE_PROGRAM],
  38. [AC_LANG_PROGRAM([[
  39. #include <boost/version.hpp>
  40. ]],[[
  41. (void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))]));
  42. ]])])
  43. AC_DEFUN([AX_BOOST_BASE],
  44. [
  45. AC_ARG_WITH([boost],
  46. [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
  47. [use Boost library from a standard location (ARG=yes),
  48. from the specified location (ARG=<path>),
  49. or disable it (ARG=no)
  50. @<:@ARG=yes@:>@ ])],
  51. [
  52. AS_CASE([$withval],
  53. [no],[want_boost="no";_AX_BOOST_BASE_boost_path=""],
  54. [yes],[want_boost="yes";_AX_BOOST_BASE_boost_path=""],
  55. [want_boost="yes";_AX_BOOST_BASE_boost_path="$withval"])
  56. ],
  57. [want_boost="yes"])
  58. AC_ARG_WITH([boost-libdir],
  59. [AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
  60. [Force given directory for boost libraries.
  61. Note that this will override library path detection,
  62. so use this parameter only if default library detection fails
  63. and you know exactly where your boost libraries are located.])],
  64. [
  65. AS_IF([test -d "$withval"],
  66. [_AX_BOOST_BASE_boost_lib_path="$withval"],
  67. [AC_MSG_ERROR([--with-boost-libdir expected directory name])])
  68. ],
  69. [_AX_BOOST_BASE_boost_lib_path=""])
  70. BOOST_LDFLAGS=""
  71. BOOST_CPPFLAGS=""
  72. AS_IF([test "x$want_boost" = "xyes"],
  73. [_AX_BOOST_BASE_RUNDETECT([$1],[$2],[$3])])
  74. AC_SUBST(BOOST_CPPFLAGS)
  75. AC_SUBST(BOOST_LDFLAGS)
  76. ])
  77. # convert a version string in $2 to numeric and affect to polymorphic var $1
  78. AC_DEFUN([_AX_BOOST_BASE_TONUMERICVERSION],[
  79. AS_IF([test "x$2" = "x"],[_AX_BOOST_BASE_TONUMERICVERSION_req="1.20.0"],[_AX_BOOST_BASE_TONUMERICVERSION_req="$2"])
  80. _AX_BOOST_BASE_TONUMERICVERSION_req_shorten=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\.[[0-9]]*\)'`
  81. _AX_BOOST_BASE_TONUMERICVERSION_req_major=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\)'`
  82. AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_major" = "x"],
  83. [AC_MSG_ERROR([You should at least specify libboost major version])])
  84. _AX_BOOST_BASE_TONUMERICVERSION_req_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.\([[0-9]]*\)'`
  85. AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_minor" = "x"],
  86. [_AX_BOOST_BASE_TONUMERICVERSION_req_minor="0"])
  87. _AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  88. AS_IF([test "X$_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor" = "X"],
  89. [_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor="0"])
  90. _AX_BOOST_BASE_TONUMERICVERSION_RET=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req_major \* 100000 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_minor \* 100 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor`
  91. AS_VAR_SET($1,$_AX_BOOST_BASE_TONUMERICVERSION_RET)
  92. ])
  93. dnl Run the detection of boost should be run only if $want_boost
  94. AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
  95. _AX_BOOST_BASE_TONUMERICVERSION(WANT_BOOST_VERSION,[$1])
  96. succeeded=no
  97. AC_REQUIRE([AC_CANONICAL_HOST])
  98. dnl On 64-bit systems check for system libraries in both lib64 and lib.
  99. dnl The former is specified by FHS, but e.g. Debian does not adhere to
  100. dnl this (as it rises problems for generic multi-arch support).
  101. dnl The last entry in the list is chosen by default when no libraries
  102. dnl are found, e.g. when only header-only libraries are installed!
  103. AS_CASE([${host_cpu}],
  104. [x86_64],[libsubdirs="lib64 libx32 lib lib64"],
  105. [ppc64|s390x|sparc64|aarch64|ppc64le],[libsubdirs="lib64 lib lib64"],
  106. [libsubdirs="lib"]
  107. )
  108. dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give
  109. dnl them priority over the other paths since, if libs are found there, they
  110. dnl are almost assuredly the ones desired.
  111. AS_CASE([${host_cpu}],
  112. [i?86],[multiarch_libsubdir="lib/i386-${host_os}"],
  113. [multiarch_libsubdir="lib/${host_cpu}-${host_os}"]
  114. )
  115. dnl first we check the system location for boost libraries
  116. dnl this location ist chosen if boost libraries are installed with the --layout=system option
  117. dnl or if you install boost with RPM
  118. AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[
  119. AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"])
  120. AS_IF([test -d "$_AX_BOOST_BASE_boost_path/include" && test -r "$_AX_BOOST_BASE_boost_path/include"],[
  121. AC_MSG_RESULT([yes])
  122. BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include"
  123. for _AX_BOOST_BASE_boost_path_tmp in $multiarch_libsubdir $libsubdirs; do
  124. AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) lib path in "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"])
  125. AS_IF([test -d "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" && test -r "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" ],[
  126. AC_MSG_RESULT([yes])
  127. BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp";
  128. break;
  129. ],
  130. [AC_MSG_RESULT([no])])
  131. done],[
  132. AC_MSG_RESULT([no])])
  133. ],[
  134. if test X"$cross_compiling" = Xyes; then
  135. search_libsubdirs=$multiarch_libsubdir
  136. else
  137. search_libsubdirs="$multiarch_libsubdir $libsubdirs"
  138. fi
  139. for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
  140. if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then
  141. for libsubdir in $search_libsubdirs ; do
  142. if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
  143. done
  144. BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path_tmp/$libsubdir"
  145. BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path_tmp/include"
  146. break;
  147. fi
  148. done
  149. ])
  150. dnl overwrite ld flags if we have required special directory with
  151. dnl --with-boost-libdir parameter
  152. AS_IF([test "x$_AX_BOOST_BASE_boost_lib_path" != "x"],
  153. [BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_lib_path"])
  154. AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION)])
  155. CPPFLAGS_SAVED="$CPPFLAGS"
  156. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  157. export CPPFLAGS
  158. LDFLAGS_SAVED="$LDFLAGS"
  159. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  160. export LDFLAGS
  161. AC_REQUIRE([AC_PROG_CXX])
  162. AC_LANG_PUSH(C++)
  163. AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[
  164. AC_MSG_RESULT(yes)
  165. succeeded=yes
  166. found_system=yes
  167. ],[
  168. ])
  169. AC_LANG_POP([C++])
  170. dnl if we found no boost with system layout we search for boost libraries
  171. dnl built and installed without the --layout=system option or for a staged(not installed) version
  172. if test "x$succeeded" != "xyes" ; then
  173. CPPFLAGS="$CPPFLAGS_SAVED"
  174. LDFLAGS="$LDFLAGS_SAVED"
  175. BOOST_CPPFLAGS=
  176. if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
  177. BOOST_LDFLAGS=
  178. fi
  179. _version=0
  180. if test -n "$_AX_BOOST_BASE_boost_path" ; then
  181. if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path"; then
  182. for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
  183. _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
  184. V_CHECK=`expr $_version_tmp \> $_version`
  185. if test "x$V_CHECK" = "x1" ; then
  186. _version=$_version_tmp
  187. fi
  188. VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
  189. BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include/boost-$VERSION_UNDERSCORE"
  190. done
  191. dnl if nothing found search for layout used in Windows distributions
  192. if test -z "$BOOST_CPPFLAGS"; then
  193. if test -d "$_AX_BOOST_BASE_boost_path/boost" && test -r "$_AX_BOOST_BASE_boost_path/boost"; then
  194. BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path"
  195. fi
  196. fi
  197. dnl if we found something and BOOST_LDFLAGS was unset before
  198. dnl (because "$_AX_BOOST_BASE_boost_lib_path" = ""), set it here.
  199. if test -n "$BOOST_CPPFLAGS" && test -z "$BOOST_LDFLAGS"; then
  200. for libsubdir in $libsubdirs ; do
  201. if ls "$_AX_BOOST_BASE_boost_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
  202. done
  203. BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$libsubdir"
  204. fi
  205. fi
  206. else
  207. if test "x$cross_compiling" != "xyes" ; then
  208. for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do
  209. if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then
  210. for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
  211. _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
  212. V_CHECK=`expr $_version_tmp \> $_version`
  213. if test "x$V_CHECK" = "x1" ; then
  214. _version=$_version_tmp
  215. best_path=$_AX_BOOST_BASE_boost_path
  216. fi
  217. done
  218. fi
  219. done
  220. VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
  221. BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
  222. if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
  223. for libsubdir in $libsubdirs ; do
  224. if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
  225. done
  226. BOOST_LDFLAGS="-L$best_path/$libsubdir"
  227. fi
  228. fi
  229. if test -n "$BOOST_ROOT" ; then
  230. for libsubdir in $libsubdirs ; do
  231. if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
  232. done
  233. if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
  234. version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
  235. stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
  236. stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
  237. V_CHECK=`expr $stage_version_shorten \>\= $_version`
  238. if test "x$V_CHECK" = "x1" && test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
  239. AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
  240. BOOST_CPPFLAGS="-I$BOOST_ROOT"
  241. BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
  242. fi
  243. fi
  244. fi
  245. fi
  246. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  247. export CPPFLAGS
  248. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  249. export LDFLAGS
  250. AC_LANG_PUSH(C++)
  251. AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[
  252. AC_MSG_RESULT(yes)
  253. succeeded=yes
  254. found_system=yes
  255. ],[
  256. ])
  257. AC_LANG_POP([C++])
  258. fi
  259. if test "x$succeeded" != "xyes" ; then
  260. if test "x$_version" = "x0" ; then
  261. AC_MSG_NOTICE([[We could not detect the boost libraries (version $1 or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
  262. else
  263. AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
  264. fi
  265. # execute ACTION-IF-NOT-FOUND (if present):
  266. ifelse([$3], , :, [$3])
  267. else
  268. AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
  269. # execute ACTION-IF-FOUND (if present):
  270. ifelse([$2], , :, [$2])
  271. fi
  272. CPPFLAGS="$CPPFLAGS_SAVED"
  273. LDFLAGS="$LDFLAGS_SAVED"
  274. ])