config.m4 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. dnl config.m4 for extension pdo_odbc
  2. dnl vim:et:sw=2:ts=2:
  3. define([PDO_ODBC_HELP_TEXT],[[
  4. include and lib dirs are looked for under 'dir'.
  5. 'flavour' can be one of: ibm-db2, iODBC, unixODBC, generic
  6. If ',dir' part is omitted, default for the flavour
  7. you have selected will be used. e.g.:
  8. --with-pdo-odbc=unixODBC
  9. will check for unixODBC under /usr/local. You may attempt
  10. to use an otherwise unsupported driver using the 'generic'
  11. flavour. The syntax for generic ODBC support is:
  12. --with-pdo-odbc=generic,dir,libname,ldflags,cflags
  13. When built as 'shared' the extension filename is always pdo_odbc.so]])
  14. PHP_ARG_WITH(pdo-odbc, for ODBC v3 support for PDO,
  15. [ --with-pdo-odbc=flavour,dir
  16. PDO: Support for 'flavour' ODBC driver.]PDO_ODBC_HELP_TEXT)
  17. AC_DEFUN([PDO_ODBC_CHECK_HEADER],[
  18. AC_MSG_CHECKING([for $1 in $PDO_ODBC_INCDIR])
  19. if test -f "$PDO_ODBC_INCDIR/$1"; then
  20. php_pdo_have_header=yes
  21. PHP_DEF_HAVE(translit($1,.,_))
  22. AC_MSG_RESULT(yes)
  23. else
  24. AC_MSG_RESULT(no)
  25. fi
  26. ])
  27. if test "$PHP_PDO_ODBC" != "no"; then
  28. if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
  29. AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
  30. fi
  31. ifdef([PHP_CHECK_PDO_INCLUDES],
  32. [
  33. PHP_CHECK_PDO_INCLUDES
  34. ],[
  35. AC_MSG_CHECKING([for PDO includes])
  36. if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
  37. pdo_cv_inc_path=$abs_srcdir/ext
  38. elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
  39. pdo_cv_inc_path=$abs_srcdir/ext
  40. elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
  41. pdo_cv_inc_path=$phpincludedir/ext
  42. else
  43. AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
  44. fi
  45. AC_MSG_RESULT($pdo_cv_inc_path)
  46. ])
  47. AC_MSG_CHECKING([for selected PDO ODBC flavour])
  48. pdo_odbc_flavour="`echo $PHP_PDO_ODBC | cut -d, -f1`"
  49. pdo_odbc_dir="`echo $PHP_PDO_ODBC | cut -d, -f2`"
  50. if test "$pdo_odbc_dir" = "$PHP_PDO_ODBC" ; then
  51. pdo_odbc_dir=
  52. fi
  53. case $pdo_odbc_flavour in
  54. ibm-db2)
  55. pdo_odbc_def_libdir=/home/db2inst1/sqllib/lib
  56. pdo_odbc_def_incdir=/home/db2inst1/sqllib/include
  57. pdo_odbc_def_lib=db2
  58. ;;
  59. iODBC|iodbc)
  60. pdo_odbc_def_libdir=/usr/local/$PHP_LIBDIR
  61. pdo_odbc_def_incdir=/usr/local/include
  62. pdo_odbc_def_lib=iodbc
  63. ;;
  64. unixODBC|unixodbc)
  65. pdo_odbc_def_libdir=/usr/local/$PHP_LIBDIR
  66. pdo_odbc_def_incdir=/usr/local/include
  67. pdo_odbc_def_lib=odbc
  68. ;;
  69. ODBCRouter|odbcrouter)
  70. pdo_odbc_def_libdir=/usr/$PHP_LIBDIR
  71. pdo_odbc_def_incdir=/usr/include
  72. pdo_odbc_def_lib=odbcsdk
  73. ;;
  74. generic)
  75. pdo_odbc_def_lib="`echo $PHP_PDO_ODBC | cut -d, -f3`"
  76. pdo_odbc_def_ldflags="`echo $PHP_PDO_ODBC | cut -d, -f4`"
  77. pdo_odbc_def_cflags="`echo $PHP_PDO_ODBC | cut -d, -f5`"
  78. pdo_odbc_flavour="generic-$pdo_odbc_def_lib"
  79. ;;
  80. *)
  81. AC_MSG_ERROR([Unknown ODBC flavour $pdo_odbc_flavour]PDO_ODBC_HELP_TEXT)
  82. ;;
  83. esac
  84. if test -n "$pdo_odbc_dir"; then
  85. PDO_ODBC_INCDIR="$pdo_odbc_dir/include"
  86. PDO_ODBC_LIBDIR="$pdo_odbc_dir/$PHP_LIBDIR"
  87. else
  88. PDO_ODBC_INCDIR="$pdo_odbc_def_incdir"
  89. PDO_ODBC_LIBDIR="$pdo_odbc_def_libdir"
  90. fi
  91. AC_MSG_RESULT([$pdo_odbc_flavour
  92. libs $PDO_ODBC_LIBDIR,
  93. headers $PDO_ODBC_INCDIR])
  94. if test ! -d "$PDO_ODBC_LIBDIR" ; then
  95. AC_MSG_WARN([library dir $PDO_ODBC_LIBDIR does not exist])
  96. fi
  97. PDO_ODBC_CHECK_HEADER(odbc.h)
  98. PDO_ODBC_CHECK_HEADER(odbcsdk.h)
  99. PDO_ODBC_CHECK_HEADER(iodbc.h)
  100. PDO_ODBC_CHECK_HEADER(sqlunix.h)
  101. PDO_ODBC_CHECK_HEADER(sqltypes.h)
  102. PDO_ODBC_CHECK_HEADER(sqlucode.h)
  103. PDO_ODBC_CHECK_HEADER(sql.h)
  104. PDO_ODBC_CHECK_HEADER(isql.h)
  105. PDO_ODBC_CHECK_HEADER(sqlext.h)
  106. PDO_ODBC_CHECK_HEADER(isqlext.h)
  107. PDO_ODBC_CHECK_HEADER(udbcext.h)
  108. PDO_ODBC_CHECK_HEADER(sqlcli1.h)
  109. PDO_ODBC_CHECK_HEADER(LibraryManager.h)
  110. PDO_ODBC_CHECK_HEADER(cli0core.h)
  111. PDO_ODBC_CHECK_HEADER(cli0ext.h)
  112. PDO_ODBC_CHECK_HEADER(cli0cli.h)
  113. PDO_ODBC_CHECK_HEADER(cli0defs.h)
  114. PDO_ODBC_CHECK_HEADER(cli0env.h)
  115. if test "$php_pdo_have_header" != "yes"; then
  116. AC_MSG_ERROR([Cannot find header file(s) for pdo_odbc])
  117. fi
  118. PDO_ODBC_INCLUDE="$pdo_odbc_def_cflags -I$PDO_ODBC_INCDIR -DPDO_ODBC_TYPE=\\\"$pdo_odbc_flavour\\\""
  119. PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR -l$pdo_odbc_def_lib"
  120. PHP_EVAL_LIBLINE([$PDO_ODBC_LDFLAGS], [PDO_ODBC_SHARED_LIBADD])
  121. dnl Check first for an ODBC 1.0 function to assert that the libraries work
  122. PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLBindCol,
  123. [
  124. dnl And now check for an ODBC 3.0 function to assert that they're
  125. dnl *good* libraries.
  126. PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLAllocHandle,
  127. [], [
  128. AC_MSG_ERROR([
  129. Your ODBC library does not appear to be ODBC 3 compatible.
  130. You should consider using iODBC or unixODBC instead, and loading your
  131. libraries as a driver in that environment; it will emulate the
  132. functions required for PDO support.
  133. ])], $PDO_ODBC_LDFLAGS)
  134. ],[
  135. AC_MSG_ERROR([Your ODBC library does not exist or there was an error. Check config.log for more information])
  136. ], $PDO_ODBC_LDFLAGS)
  137. PHP_NEW_EXTENSION(pdo_odbc, pdo_odbc.c odbc_driver.c odbc_stmt.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_ODBC_INCLUDE)
  138. PHP_SUBST(PDO_ODBC_SHARED_LIBADD)
  139. ifdef([PHP_ADD_EXTENSION_DEP],
  140. [
  141. PHP_ADD_EXTENSION_DEP(pdo_odbc, pdo)
  142. ])
  143. fi