1# LIBUNIXODBC_CHECK_CONFIG ([DEFAULT-ACTION]) 2# ---------------------------------------------------------- 3# Eugene Grigorjev <eugene@zabbix.com> June-07-2007 4# 5# Checks for unixodbc. DEFAULT-ACTION is the string yes or no to 6# specify whether to default to --with-unixodbc 7# If not supplied, DEFAULT-ACTION is no. 8# 9# This macro #defines HAVE_UNIXODBC if required header files are 10# found, and sets @UNIXODBC_LDFLAGS@ and @UNIXODBC_CFLAGS@ to the necessary 11# values. 12# 13# Users may override the detected values by doing something like: 14# UNIXODBC_LDFLAGS="-lunixodbc" UNIXODBC_CFLAGS="-I/usr/myinclude" ./configure 15# 16# This macro is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 20AC_DEFUN([LIBUNIXODBC_CHECK_CONFIG], 21[ 22 AC_ARG_WITH(unixodbc, 23 [ 24If you want to use unixODBC library: 25AC_HELP_STRING([--with-unixodbc@<:@=ARG@:>@], 26 [use ODBC driver against unixODBC package @<:@default=no@:>@, optionally specify full path to odbc_config binary.]) 27 ],[ if test "x$withval" = "xno"; then 28 want_unixodbc="no" 29 elif test "x$withval" = "xyes"; then 30 want_unixodbc="yes" 31 else 32 want_unixodbc="yes" 33 specified_unixodbc="yes" 34 ODBC_CONFIG=$withval 35 fi 36 ],[want_unixodbc=ifelse([$1],,[no],[$1])]) 37 38 if test "x$want_unixodbc" != "xno"; then 39 AC_PATH_PROG([ODBC_CONFIG], [odbc_config], []) 40 41 unixodbc_error="" 42 43 UNIXODBC_LIBS="-lodbc" 44 45 if test -x "$ODBC_CONFIG"; then 46 UNIXODBC_CFLAGS="-I`$ODBC_CONFIG --include-prefix`" 47 UNIXODBC_LDFLAGS="-L`$ODBC_CONFIG --lib-prefix`" 48 elif test "x$specified_unixodbc" = "xyes"; then 49 unixodbc_error="file $ODBC_CONFIG not found or not executable" 50 fi 51 52 if test "x$unixodbc_error" = "x"; then 53 _save_unixodbc_cflags="${CFLAGS}" 54 _save_unixodbc_ldflags="${LDFLAGS}" 55 _save_unixodbc_libs="${LIBS}" 56 CFLAGS="${CFLAGS} ${UNIXODBC_CFLAGS}" 57 LDFLAGS="${LDFLAGS} ${UNIXODBC_LDFLAGS}" 58 LIBS="${LIBS} ${UNIXODBC_LIBS}" 59 60 AC_CHECK_LIB(odbc, SQLAllocHandle, ,[unixodbc_error="unixODBC library not found"]) 61 62 if test "x$unixodbc_error" = "x"; then 63 AC_DEFINE(HAVE_UNIXODBC,1,[Define to 1 if unixODBC Driver Manager should be used.]) 64 fi 65 66 CFLAGS="${_save_unixodbc_cflags}" 67 LDFLAGS="${_save_unixodbc_ldflags}" 68 LIBS="${_save_unixodbc_libs}" 69 fi 70 fi 71 72 AC_SUBST(UNIXODBC_LDFLAGS) 73 AC_SUBST(UNIXODBC_CFLAGS) 74 AC_SUBST(UNIXODBC_LIBS) 75 76])dnl 77