PageRenderTime 31ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/gsm-receiver/config/ax_boost_base.m4

https://gitlab.com/Red54/airprobe-hopping
m4 | 334 lines | 261 code | 28 blank | 45 comment | 0 complexity | 75c14b92bbc0a354c0b05e1919a6cfb8 MD5 | raw file
  1. # ===========================================================================
  2. # http://autoconf-archive.cryp.to/ax_boost_base.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_BASE([MINIMUM-VERSION])
  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. # LAST MODIFICATION
  27. #
  28. # 2008-04-12
  29. #
  30. # COPYLEFT
  31. #
  32. # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
  33. # Copyright (c) 2008 Free Software Foundation, Inc.
  34. #
  35. # Copying and distribution of this file, with or without modification, are
  36. # permitted in any medium without royalty provided the copyright notice
  37. # and this notice are preserved.
  38. AC_DEFUN([AX_BOOST_BASE],
  39. [
  40. AC_REQUIRE([GR_LIB64])
  41. AC_ARG_WITH([boost],
  42. AS_HELP_STRING([--with-boost@<:@=DIR@:>@],
  43. [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
  44. [
  45. if test "$withval" = "no"; then
  46. want_boost="no"
  47. elif test "$withval" = "yes"; then
  48. want_boost="yes"
  49. ac_boost_path=""
  50. else
  51. want_boost="yes"
  52. ac_boost_path="$withval"
  53. fi
  54. ],
  55. [want_boost="yes"])
  56. AC_ARG_WITH([boost-libdir],
  57. AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
  58. [Force given directory for boost libraries. Note that this
  59. will overwrite library path detection, so use this parameter
  60. only if default library detection fails and you know exactly
  61. where your boost libraries are located.]),
  62. [
  63. if test -d $withval
  64. then
  65. ac_boost_lib_path="$withval"
  66. else
  67. AC_MSG_ERROR(--with-boost-libdir expected directory name)
  68. fi
  69. ],
  70. [ac_boost_lib_path=""]
  71. )
  72. if test "x$want_boost" = "xyes"; then
  73. boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
  74. boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
  75. boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
  76. boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
  77. boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  78. if test "x$boost_lib_version_req_sub_minor" = "x" ; then
  79. boost_lib_version_req_sub_minor="0"
  80. fi
  81. WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
  82. AC_MSG_CHECKING(for boost >= $boost_lib_version_req)
  83. succeeded=no
  84. dnl first we check the system location for boost libraries
  85. dnl this location ist chosen if boost libraries are installed with the --layout=system option
  86. dnl or if you install boost with RPM
  87. if test "$ac_boost_path" != ""; then
  88. dnl Look first where we think they ought to be, accounting for a possible "64" suffix on lib.
  89. dnl If that directory doesn't exist, fall back to the default behavior
  90. if test -d "$ac_boost_path/lib${gr_libdir_suffix}"; then
  91. BOOST_LDFLAGS="-L$ac_boost_path/lib${gr_libdir_suffix}"
  92. else
  93. BOOST_LDFLAGS="-L$ac_boost_path/lib"
  94. fi
  95. BOOST_CPPFLAGS="-I$ac_boost_path/include"
  96. else
  97. for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
  98. if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
  99. dnl Look first where we think they ought to be, accounting for a possible "64" suffix on lib.
  100. dnl If that directory doesn't exist, fall back to the default behavior
  101. if test -d "$ac_boost_path_tmp/lib${gr_libdir_suffix}"; then
  102. BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib${gr_libdir_suffix}"
  103. else
  104. BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
  105. fi
  106. BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
  107. break;
  108. fi
  109. done
  110. fi
  111. dnl overwrite ld flags if we have required special directory with
  112. dnl --with-boost-libdir parameter
  113. if test "$ac_boost_lib_path" != ""; then
  114. BOOST_LDFLAGS="-L$ac_boost_lib_path"
  115. fi
  116. CPPFLAGS_SAVED="$CPPFLAGS"
  117. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  118. export CPPFLAGS
  119. LDFLAGS_SAVED="$LDFLAGS"
  120. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  121. export LDFLAGS
  122. AC_LANG_PUSH(C++)
  123. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  124. @%:@include <boost/version.hpp>
  125. ]], [[
  126. #if BOOST_VERSION >= $WANT_BOOST_VERSION
  127. // Everything is okay
  128. #else
  129. # error Boost version is too old
  130. #endif
  131. ]])],[AC_MSG_RESULT(yes)
  132. succeeded=yes
  133. found_system=yes
  134. ],
  135. [])
  136. AC_LANG_POP([C++])
  137. CPPFLAGS="$CPPFLAGS_SAVED"
  138. LDFLAGS="$LDFLAGS_SAVED"
  139. dnl if we found no boost with system layout we search for boost libraries
  140. dnl built and installed without the --layout=system option
  141. if test "$succeeded" != "yes"; then
  142. _version=0
  143. if test "$ac_boost_path" != ""; then
  144. path_list="$ac_boost_path"
  145. else
  146. path_list="/usr /usr/local /opt /opt/local"
  147. fi
  148. for ac_boost_path in $path_list ; do
  149. if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
  150. for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
  151. _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's,/include/boost-,,; s,_,.,'`
  152. V_CHECK=`expr $_version_tmp \> $_version`
  153. if test "$V_CHECK" = "1" ; then
  154. _version=$_version_tmp
  155. best_path=$ac_boost_path
  156. fi
  157. done
  158. fi
  159. done
  160. VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
  161. BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
  162. if test "$ac_boost_lib_path" = ""; then
  163. dnl Look first where we think they ought to be, accounting for a possible "64" suffix on lib.
  164. dnl If that directory doesn't exist, fall back to the default behavior
  165. if test -d "$best_path/lib${gr_libdir_suffix}"; then
  166. BOOST_LDFLAGS="-L$best_path/lib${gr_libdir_suffix}"
  167. else
  168. BOOST_LDFLAGS="-L$best_path/lib"
  169. fi
  170. fi
  171. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  172. export CPPFLAGS
  173. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  174. export LDFLAGS
  175. AC_LANG_PUSH(C++)
  176. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  177. @%:@include <boost/version.hpp>
  178. ]], [[
  179. #if BOOST_VERSION >= $WANT_BOOST_VERSION
  180. // Everything is okay
  181. #else
  182. # error Boost version is too old
  183. #endif
  184. ]])],[AC_MSG_RESULT(yes)
  185. succeeded=yes
  186. found_system=yes
  187. ],
  188. [])
  189. AC_LANG_POP([C++])
  190. CPPFLAGS="$CPPFLAGS_SAVED"
  191. LDFLAGS="$LDFLAGS_SAVED"
  192. fi
  193. if test "$succeeded" != "yes" ; then
  194. AC_MSG_RESULT([no])
  195. if test "$_version" = "0" ; then
  196. AC_MSG_ERROR([[we could not detect the boost libraries (version $boost_lib_version_req_shorten or higher).
  197. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>.]])
  198. else
  199. AC_MSG_ERROR([your boost libraries seem to old (version $_version).])
  200. fi
  201. else
  202. AC_SUBST(BOOST_CPPFLAGS)
  203. AC_SUBST(BOOST_LDFLAGS)
  204. AC_DEFINE(HAVE_BOOST,1,[Define if the Boost headers are available])
  205. fi
  206. fi
  207. ])
  208. dnl
  209. dnl Macros used by the boost items that need libraries.
  210. dnl
  211. dnl $1 is unit name. E.g., boost_thread
  212. AC_DEFUN([_AX_BOOST_CHECK_LIB],[
  213. _AX_BOOST_CHECK_LIB_($1,HAVE_[]m4_toupper($1),m4_toupper($1)_LIB)
  214. ])
  215. dnl $1 is unit name. E.g., boost_thread
  216. dnl $2 is AC_DEFINE name. E.g., HAVE_BOOST_THREAD
  217. dnl $3 is lib var name. E.g., BOOST_THREAD_LIB
  218. AC_DEFUN([_AX_BOOST_CHECK_LIB_],[
  219. AC_LANG_PUSH([C++])
  220. AC_DEFINE($2,1,[Define if the $1 library is available])
  221. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  222. dnl See if we can find a usable library
  223. link_ok="no"
  224. if test "$ax_boost_user_lib" != ""; then
  225. dnl use what the user supplied
  226. for ax_lib in $ax_boost_user_lib $1-${ax_boost_user_lib}; do
  227. AC_CHECK_LIB($ax_lib, exit,
  228. [$3="-l$ax_lib"; AC_SUBST($3) link_ok="yes"; break])
  229. done
  230. else
  231. dnl Look in BOOSTLIBDIR for possible candidates
  232. head=$BOOSTLIBDIR/lib[]$1
  233. for f in ${head}*.so* ${head}*.a* ${head}*.dll* ${head}*.dylib; do
  234. dnl echo 1: $f
  235. case $f in
  236. *\**) continue;;
  237. esac
  238. f=`echo $f | sed -e 's,.*/,,' -e 's,^lib,,'`
  239. dnl echo 2: $f
  240. f=`echo $f | sed -e 's,\($1.*\)\.so.*$,\1,' -e 's,\($1.*\)\.a.*$,\1,' -e 's,\($1.*\)\.dll.*$,\1,' -e 's,\($1.*\)\.dylib.*$,\1,'`
  241. dnl echo 3: $f
  242. ax_lib=$f
  243. AC_CHECK_LIB($ax_lib, exit,
  244. [$3="-l$ax_lib"; AC_SUBST($3) link_ok="yes"; break])
  245. done
  246. fi
  247. if test "$link_ok" != "yes"; then
  248. AC_MSG_ERROR([Could not link against lib[$1]!])
  249. fi
  250. AC_LANG_POP([C++])
  251. ])
  252. dnl $1 is unit name. E.g., boost_thread
  253. AC_DEFUN([_AX_BOOST_WITH],[
  254. _AX_BOOST_WITH_($1,m4_bpatsubst($1,_,-))
  255. ])
  256. dnl $1 is unit name. E.g., boost_thread
  257. dnl $2 is hyphenated unit name. E.g., boost-thread
  258. AC_DEFUN([_AX_BOOST_WITH_],[
  259. AC_ARG_WITH([$2],
  260. AC_HELP_STRING([--with-$2@<:@=special-lib@:>@],
  261. [Use the m4_substr($1,6) library from boost. It is possible to specify a certain
  262. library to the linker. E.g., --with-$2=$1-gcc41-mt-1_35]),
  263. [
  264. if test "$withval" = "no"; then
  265. want_boost="no"
  266. elif test "$withval" = "yes"; then
  267. want_boost="yes"
  268. ax_boost_user_lib=""
  269. else
  270. want_boost="yes"
  271. ax_boost_user_lib="$withval"
  272. fi
  273. ],
  274. [want_boost="yes"])
  275. ])
  276. dnl $1 is unit name. E.g., boost_thread
  277. dnl $2 is AC_LANG_PROGRAM argument 1
  278. dnl $3 is AC_LANG_PROGRAM argument 2
  279. dnl $4 is cv variable name. E.g., ax_cv_boost_thread
  280. AC_DEFUN([_AX_BOOST_CHECK_],[
  281. _AX_BOOST_WITH($1)
  282. if test "$want_boost" = "yes"; then
  283. AC_REQUIRE([AC_PROG_CC])
  284. AC_REQUIRE([AC_PROG_CXX])
  285. CPPFLAGS_SAVED="$CPPFLAGS"
  286. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  287. LDFLAGS_SAVED="$LDFLAGS"
  288. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  289. AC_CACHE_CHECK([whether the boost::m4_substr([$1],6) includes are available], [$4],
  290. [AC_LANG_PUSH([C++])
  291. AC_COMPILE_IFELSE(AC_LANG_PROGRAM([$2],[$3]),[$4]=yes,[$4]=no)
  292. AC_LANG_POP([C++])
  293. ])
  294. if test "$[$4]" = "yes"; then
  295. _AX_BOOST_CHECK_LIB([$1])
  296. fi
  297. CPPFLAGS="$CPPFLAGS_SAVED"
  298. LDFLAGS="$LDFLAGS_SAVED"
  299. fi
  300. ])
  301. dnl $1 is unit name. E.g., boost_thread
  302. dnl $2 is AC_LANG_PROGRAM argument 1
  303. dnl $3 is AC_LANG_PROGRAM argument 2
  304. AC_DEFUN([_AX_BOOST_CHECK],[
  305. _AX_BOOST_CHECK_($1,$2,$3,ax_cv_$1)
  306. ])