2
0

odbc.m4 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. dnl Derrick Brashear
  2. dnl from KTH krb and Arla
  3. AC_DEFUN([ODBC_INC_WHERE1], [
  4. ac_cv_found_odbc_inc=no
  5. if test -f "$1/sql.h" ; then
  6. ac_cv_found_odbc_inc=yes
  7. fi
  8. ])
  9. AC_DEFUN([ODBC_INC_WHERE], [
  10. for i in $1; do
  11. AC_MSG_CHECKING(for odbc header in $i)
  12. ODBC_INC_WHERE1($i)
  13. if test "$ac_cv_found_odbc_inc" = "yes"; then
  14. ac_cv_odbc_where_inc=$i
  15. AC_MSG_RESULT(found)
  16. break
  17. else
  18. AC_MSG_RESULT(no found)
  19. fi
  20. done
  21. ])
  22. AC_DEFUN([ODBC_LIB_WHERE1], [
  23. saved_LIBS=$LIBS
  24. saved_CFLAGS=$CFLAGS
  25. case "$host" in
  26. *darwin*)
  27. LIBS="$saved_LIBS -L$1 -lodbc -framework CoreFoundation"
  28. ;;
  29. *)
  30. LIBS="$saved_LIBS -L$1 -lodbc"
  31. ;;
  32. esac
  33. CFLAGS="$saved_CFLAGS -I$ac_cv_odbc_where_inc"
  34. AC_TRY_LINK(
  35. [#include <sql.h>],
  36. [SQLHDBC con;
  37. SQLDisconnect(con);],
  38. [ac_cv_found_odbc_lib=yes],
  39. ac_cv_found_odbc_lib=no)
  40. LIBS=$saved_LIBS
  41. CFLAGS=$saved_CFLAGS
  42. ])
  43. AC_DEFUN([TEST_LIBPATH], [
  44. changequote(<<, >>)
  45. define(<<AC_CV_FOUND>>, translit(ac_cv_found_$2_lib, <<- *>>, <<__p>>))
  46. changequote([, ])
  47. if test "$AC_CV_FOUND" = "yes"; then
  48. if test \! -r "$1/lib$2.a" -a \! -r "$1/lib$2.so" -a \! -r "$1/lib$2.sl" -a \! -r "$1/lib$2.dylib"; then
  49. AC_CV_FOUND=no
  50. fi
  51. fi
  52. ])
  53. AC_DEFUN([ODBC_LIB_WHERE], [
  54. for i in $1; do
  55. AC_MSG_CHECKING(for odbc library in $i)
  56. ODBC_LIB_WHERE1($i)
  57. TEST_LIBPATH($i, odbc)
  58. if test "$ac_cv_found_odbc_lib" = "yes" ; then
  59. ac_cv_odbc_where_lib=$i
  60. AC_MSG_RESULT(found)
  61. break
  62. else
  63. AC_MSG_RESULT(no found)
  64. fi
  65. done
  66. ])
  67. AC_DEFUN([FIND_LIB_SUBDIR],
  68. [dnl
  69. AC_ARG_WITH([lib-subdir], AC_HELP_STRING([--with-lib-subdir=DIR],[Find libraries in DIR instead of lib]))
  70. AC_CHECK_SIZEOF(long)
  71. AC_CACHE_CHECK([what directory libraries are found in], [ac_cv_cmu_lib_subdir],
  72. [test "X$with_lib_subdir" = "Xyes" && with_lib_subdir=
  73. test "X$with_lib_subdir" = "Xno" && with_lib_subdir=
  74. if test "X$with_lib_subdir" = "X" ; then
  75. ac_cv_cmu_lib_subdir=lib
  76. if test $ac_cv_sizeof_long -eq 4 ; then
  77. test -d /usr/lib32 && ac_cv_cmu_lib_subdir=lib32
  78. fi
  79. if test $ac_cv_sizeof_long -eq 8 ; then
  80. test -d /usr/lib64 && ac_cv_cmu_lib_subdir=lib64
  81. fi
  82. else
  83. ac_cv_cmu_lib_subdir=$with_lib_subdir
  84. fi])
  85. AC_SUBST(LIB_SUBDIR, $ac_cv_cmu_lib_subdir)
  86. ])
  87. AC_DEFUN([AX_LIB_ODBC], [
  88. AC_REQUIRE([FIND_LIB_SUBDIR])
  89. AC_ARG_WITH(odbc,
  90. [ --with-odbc=PREFIX Compile with ODBC support],
  91. [if test "X$with_odbc" = "X"; then
  92. with_odbc=yes
  93. fi])
  94. AC_ARG_WITH(odbc-lib,
  95. [ --with-odbc-lib=dir use odbc libraries in dir],
  96. [if test "$withval" = "yes" -o "$withval" = "no"; then
  97. AC_MSG_ERROR([No argument for --with-odbc-lib])
  98. fi])
  99. AC_ARG_WITH(odbc-include,
  100. [ --with-odbc-include=dir use odbc headers in dir],
  101. [if test "$withval" = "yes" -o "$withval" = "no"; then
  102. AC_MSG_ERROR([No argument for --with-odbc-include])
  103. fi])
  104. if test "X$with_odbc" != "X"; then
  105. if test "$with_odbc" != "yes"; then
  106. ac_cv_odbc_where_lib=$with_odbc
  107. ac_cv_odbc_where_inc=$with_odbc/include
  108. fi
  109. fi
  110. if test "X$with_odbc_include" != "X"; then
  111. ac_cv_odbc_where_inc=$with_odbc_include
  112. fi
  113. if test "X$ac_cv_odbc_where_inc" = "X"; then
  114. ODBC_INC_WHERE(/usr/include /usr/local/include)
  115. fi
  116. if test "X$with_odbc_lib" != "X"; then
  117. ac_cv_odbc_where_lib=$with_odbc_lib
  118. fi
  119. if test "X$ac_cv_odbc_where_lib" = "X"; then
  120. AC_CHECK_LIB([odbc],[SQLDisconnect],[ac_cv_odbc_where_lib="yes"],[
  121. ODBC_LIB_WHERE(/usr/$LIB_SUBDIR /usr/local/$LIB_SUBDIR)
  122. ])
  123. fi
  124. AC_MSG_CHECKING(whether to include odbc)
  125. if test "X$ac_cv_odbc_where_lib" = "X" -o "X$ac_cv_odbc_where_inc" = "X"; then
  126. ac_cv_found_odbc=no
  127. AC_MSG_RESULT(no)
  128. else
  129. ac_cv_found_odbc=yes
  130. AC_MSG_RESULT(yes)
  131. ODBC_INC_DIR=$ac_cv_odbc_where_inc
  132. ODBC_LIB_DIR=$ac_cv_odbc_where_lib
  133. ODBC_INC_FLAGS="-I$ac_cv_odbc_where_inc"
  134. ODBC_LIB_FLAGS="-Wl,-lodbc"
  135. case "$host" in
  136. *darwin*)
  137. ODBC_LIB_FLAGS="$ODBC_LIB_FLAGS -framework CoreFoundation"
  138. ;;
  139. esac
  140. if test "$ac_cv_odbc_where_lib" != "yes"; then
  141. ODBC_LIB_FLAGS="-L$ac_cv_odbc_where_lib $ODBC_LIB_FLAGS"
  142. fi
  143. AC_SUBST(ODBC_INC_DIR)
  144. AC_SUBST(ODBC_LIB_DIR)
  145. AC_SUBST(ODBC_INC_FLAGS)
  146. AC_SUBST(ODBC_LIB_FLAGS)
  147. AC_DEFINE([HAVE_ODBC],[1],[libodbc])
  148. fi
  149. ])