ast_check_osptk.m4 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. dnl
  2. dnl @synopsis AST_CHECK_OSPTK([REQ_VER_MAJOR],[REQ_VER_MINOR],[REQ_VER_BUGFIX])
  3. dnl
  4. dnl @summary check for existence of OSP Toolkit package
  5. dnl
  6. dnl This macro check for existence of OSP Toolkit package by checking osp/osp.h
  7. dnl header file, OSPPInit function and OSP Toolkit version.
  8. dnl
  9. AC_DEFUN([AST_CHECK_OSPTK],
  10. [
  11. # if OSPTK has not been checked and is not excluded
  12. if test "x${PBX_OSPTK}" != "x1" -a "${USE_OSPTK}" != "no"; then
  13. # if --with-osptk=DIR has been specified, use it.
  14. if test "x${OSPTK_DIR}" != "x"; then
  15. osptk_cflags="-I${OSPTK_DIR}/include"
  16. osptk_ldflags="-L${OSPTK_DIR}/lib"
  17. else
  18. osptk_cflags=""
  19. osptk_ldflags=""
  20. fi
  21. # check for the header
  22. osptk_saved_cppflags="${CPPFLAGS}"
  23. CPPFLAGS="${CPPFLAGS} ${osptk_cflags}"
  24. AC_CHECK_HEADER([osp/osp.h], [osptk_header_found=yes], [osptk_header_found=no])
  25. CPPFLAGS="${osptk_saved_cppflags}"
  26. # check for the library
  27. if test "${osptk_header_found}" = "yes"; then
  28. osptk_extralibs="-lssl -lcrypto"
  29. AC_CHECK_LIB([osptk], [OSPPInit], [osptk_library_found=yes], [osptk_library_found=no], ${osptk_ldflags} ${osptk_extralibs})
  30. # check OSP Toolkit version
  31. if test "${osptk_library_found}" = "yes"; then
  32. AC_MSG_CHECKING(if OSP Toolkit version is compatible with app_osplookup)
  33. osptk_saved_cppflags="${CPPFLAGS}"
  34. CPPFLAGS="${CPPFLAGS} ${osptk_cflags}"
  35. AC_RUN_IFELSE(
  36. [AC_LANG_SOURCE([[
  37. #include <osp/osp.h>
  38. int main(void) {
  39. int ver = OSP_CLIENT_TOOLKIT_VERSION_MAJOR * 10000 + OSP_CLIENT_TOOLKIT_VERSION_MINOR * 100 + OSP_CLIENT_TOOLKIT_VERSION_BUGFIX;
  40. int req = $1 * 10000 + $2 * 100 + $3;
  41. return (ver < req) ? 1 : 0;
  42. }
  43. ]])],
  44. [osptk_compatible=yes],
  45. [osptk_compatible=no]
  46. )
  47. CPPFLAGS="${osptk_saved_cppflags}"
  48. if test "${osptk_compatible}" = "yes"; then
  49. AC_MSG_RESULT(yes)
  50. PBX_OSPTK=1
  51. OSPTK_INCLUDE="${osptk_cflags}"
  52. OSPTK_LIB="${osptk_ldflags} -losptk ${osptk_extralibs}"
  53. AC_DEFINE_UNQUOTED([HAVE_OSPTK], 1, [Define this to indicate the ${OSPTK_DESCRIP} library])
  54. else
  55. AC_MSG_RESULT(no)
  56. fi
  57. fi
  58. fi
  59. fi
  60. ])