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.

171 lines
5.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_lib_firebird.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_LIB_FIREBIRD([MINIMUM-VERSION])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for the Firebird client library of a particular version (or newer).
  12. # This macro takes only one optional argument, the required version of
  13. # Firebird library. If required version is not passed, then 1.5.0 is used
  14. # in test of existence of Firebird client library.
  15. #
  16. # For more information about Firebird API versioning check: API Identifies
  17. # Client Version http://www.firebirdsql.org/rlsnotes20/rnfbtwo-apiods.html
  18. #
  19. # If no installation prefix to the installed Firebird library is given the
  20. # macro searches under /usr, /usr/local, and /opt.
  21. #
  22. # This macro calls:
  23. #
  24. # AC_SUBST(FIREBIRD_CFLAGS)
  25. # AC_SUBST(FIREBIRD_LDFLAGS)
  26. # AC_SUBST(FIREBIRD_VERSION)
  27. #
  28. # And sets:
  29. #
  30. # HAVE_FIREBIRD
  31. #
  32. # LICENSE
  33. #
  34. # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
  35. #
  36. # Copying and distribution of this file, with or without modification, are
  37. # permitted in any medium without royalty provided the copyright notice
  38. # and this notice are preserved. This file is offered as-is, without any
  39. # warranty.
  40. #serial 13
  41. AC_DEFUN([AX_LIB_FIREBIRD],
  42. [
  43. AC_ARG_WITH([firebird],
  44. AS_HELP_STRING(
  45. [--with-firebird=@<:@ARG@:>@],
  46. [use Firebird client library @<:@default=yes@:>@, optionally specify the prefix for firebird library]
  47. ),
  48. [
  49. if test "$withval" = "no"; then
  50. WANT_FIREBIRD="no"
  51. elif test "$withval" = "yes"; then
  52. WANT_FIREBIRD="yes"
  53. ac_firebird_path=""
  54. else
  55. WANT_FIREBIRD="yes"
  56. ac_firebird_path="$withval"
  57. fi
  58. ],
  59. [WANT_FIREBIRD="yes"]
  60. )
  61. FIREBIRD_CFLAGS=""
  62. FIREBIRD_LDFLAGS=""
  63. FIREBIRD_VERSION=""
  64. if test "x$WANT_FIREBIRD" = "xyes"; then
  65. ac_firebird_header="ibase.h"
  66. firebird_version_req=ifelse([$1], [], [3.0.0], [$1])
  67. firebird_version_req_shorten=`expr $firebird_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
  68. firebird_version_req_major=`expr $firebird_version_req : '\([[0-9]]*\)'`
  69. firebird_version_req_minor=`expr $firebird_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
  70. firebird_version_req_micro=`expr $firebird_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  71. if test "x$firebird_version_req_micro" = "x" ; then
  72. firebird_version_req_micro="0"
  73. fi
  74. dnl FB_API_VER represents the version of Firebird as follows:
  75. dnl - Any version of Interbase, or Firebird 1.0.x: 10
  76. dnl - Firebird 1.5.x: 15
  77. dnl - Firebird 2.0.x: 20
  78. firebird_version_req_number=`expr $firebird_version_req_major \+ $firebird_version_req_minor`
  79. AC_MSG_CHECKING([for Firebird client library >= $firebird_version_req])
  80. if test "$ac_firebird_path" != ""; then
  81. ac_firebird_ldflags="-L$ac_firebird_path/lib"
  82. ac_firebird_cppflags="-I$ac_firebird_path/include"
  83. else
  84. for ac_firebird_path_tmp in /usr /usr/local /opt ; do
  85. if test -f "$ac_firebird_path_tmp/include/$ac_firebird_header" \
  86. && test -r "$ac_firebird_path_tmp/include/$ac_firebird_header"; then
  87. ac_firebird_path=$ac_firebird_path_tmp
  88. ac_firebird_cppflags="-I$ac_firebird_path_tmp/include"
  89. ac_firebird_ldflags="-L$ac_firebird_path_tmp/lib"
  90. break;
  91. fi
  92. done
  93. fi
  94. ac_firebird_header_path="$ac_firebird_path/include/$ac_firebird_header"
  95. if test ! -f "$ac_firebird_header_path"; then
  96. AC_MSG_RESULT([no])
  97. success="no"
  98. else
  99. ac_firebird_ldflags="$ac_firebird_ldflags -lfbclient -lpthread"
  100. saved_CPPFLAGS="$CPPFLAGS"
  101. CPPFLAGS="$CPPFLAGS $ac_firebird_cppflags"
  102. AC_LANG_PUSH(C++)
  103. AC_COMPILE_IFELSE(
  104. [
  105. AC_LANG_PROGRAM([[@%:@include <ibase.h>]],
  106. [[
  107. #if (FB_API_VER >= $firebird_version_req_number)
  108. // Everything is okay
  109. #else
  110. # error Firebird version is too old
  111. #endif
  112. ]]
  113. )
  114. ],
  115. [
  116. AC_MSG_RESULT([yes])
  117. success="yes"
  118. ],
  119. [
  120. AC_MSG_RESULT([not found])
  121. success="no"
  122. ]
  123. )
  124. AC_LANG_POP([C++])
  125. CPPFLAGS="$saved_CPPFLAGS"
  126. if test "$success" = "yes"; then
  127. FIREBIRD_CFLAGS="$ac_firebird_cppflags"
  128. FIREBIRD_LDFLAGS="$ac_firebird_ldflags"
  129. dnl Retrieve Firebird release version
  130. ac_firebird_version=`cat $ac_firebird_header_path | \
  131. grep '#define.*FB_API_VER.*' | \
  132. sed -e 's/.* //'`
  133. if test -n "$ac_firebird_version"; then
  134. ac_firebird_version_major=`expr $ac_firebird_version \/ 10`
  135. ac_firebird_version_minor=`expr $ac_firebird_version \% 10`
  136. FIREBIRD_VERSION="$ac_firebird_version_major.$ac_firebird_version_minor.x"
  137. else
  138. AC_MSG_WARN([Could not find FB_API_VER macro in $ac_firebird_header to get Firebird version.])
  139. fi
  140. AC_SUBST(FIREBIRD_CFLAGS)
  141. AC_SUBST(FIREBIRD_LDFLAGS)
  142. AC_SUBST(FIREBIRD_VERSION)
  143. AC_DEFINE(HAVE_FIREBIRD)
  144. fi
  145. fi
  146. fi
  147. ])