diff options
-rw-r--r-- | m4/libiodbc.m4 | 94 | ||||
-rw-r--r-- | m4/libunixodbc.m4 | 101 |
2 files changed, 195 insertions, 0 deletions
diff --git a/m4/libiodbc.m4 b/m4/libiodbc.m4 new file mode 100644 index 00000000..4447a4fd --- /dev/null +++ b/m4/libiodbc.m4 @@ -0,0 +1,94 @@ +# LIBIODBC_CHECK_CONFIG ([DEFAULT-ACTION]) +# ---------------------------------------------------------- +# Eugene Grigorjev <eugene@zabbix.com> June-07-2007 +# +# Checks for iodbc. DEFAULT-ACTION is the string yes or no to +# specify whether to default to --with-iodbc +# If not supplied, DEFAULT-ACTION is no. +# +# This macro #defines HAVE_IODBC if a required header files is +# found, and sets @IODBC_LDFLAGS@ and @IODBC_CFLAGS@ to the necessary +# values. +# +# Users may override the detected values by doing something like: +# IODBC_LDFLAGS="-liodbc" IODBC_CFLAGS="-I/usr/myinclude" ./configure +# +# This macro is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +AC_DEFUN([LIBIODBC_CHECK_CONFIG], +[ + AC_ARG_WITH(iodbc,[ +What ODBC driver do you want to use (please select only one): +AC_HELP_STRING([--with-iodbc@<:@=ARG@:>@], + [use odbc driver against iODBC package @<:@default=no@:>@, default is to search through a number of common places for the IODBC files.]) + ],[ if test "$withval" = "no"; then + want_iodbc="no" + _libiodbc_with="no" + elif test "$withval" = "yes"; then + want_iodbc="yes" + _libiodbc_with="yes" + else + want_iodbc="yes" + _libiodbc_with=$withval + fi + ],[_libiodbc_with=ifelse([$1],,[no],[$1])]) + + if test "x$_libiodbc_with" != x"no"; then + AC_MSG_CHECKING(for iODBC support) + + if test "$_libiodbc_with" = "yes"; then + if test -f /usr/include/sql.h; then + _libiodbc_with="/usr" + else + _libiodbc_with="/usr/local" + fi + else + if echo "$_libiodbc_with" | grep -v '^/'; then + _libiodbc_with="$PWD/$_libiodbc_with" + fi + fi + + if test -f "$_libiodbc_with/include/sql.h"; then + + IODBC_CFLAGS="-I$_libiodbc_with/include" + IODBC_LDFLAGS="$LDFLAGS -L$_libiodbc_with/lib" + + _save_iodbc_libs="${LIBS}" + _save_iodbc_ldflags="${LDFLAGS}" + _save_iodbc_cflags="${CFLAGS}" + LIBS="${LIBS} ${IODBC_LIBS}" + LDFLAGS="${LDFLAGS} ${IODBC_LDFLAGS}" + CFLAGS="${CFLAGS} ${IODBC_CFLAGS}" + + AC_CHECK_LIB(iodbc, main,[ + IODBC_LIBS="-liodbc $IODBC_LIBS" + ],[ + AC_MSG_ERROR([Not found libiodbc library]) + ]) + + LIBS="${_save_iodbc_libs}" + LDFLAGS="${_save_iodbc_ldflags}" + CFLAGS="${_save_iodbc_cflags}" + unset _save_iodbc_libs + unset _save_iodbc_ldflags + unset _save_iodbc_cflags + + AC_DEFINE(HAVE_IODBC,1,[Define to 1 if iODBC Driver Manager should be used.]) + + found_iodbc="yes" + AC_MSG_RESULT(yes) + + else + found_iodbc="no" + AC_MSG_RESULT(no) + fi + fi + + AC_SUBST(IODBC_LDFLAGS) + AC_SUBST(IODBC_CFLAGS) + AC_SUBST(IODBC_LIBS) + + unset _libiodbc_with +])dnl diff --git a/m4/libunixodbc.m4 b/m4/libunixodbc.m4 new file mode 100644 index 00000000..3090bc21 --- /dev/null +++ b/m4/libunixodbc.m4 @@ -0,0 +1,101 @@ +# LIBUNIXODBC_CHECK_CONFIG ([DEFAULT-ACTION]) +# ---------------------------------------------------------- +# Eugene Grigorjev <eugene@zabbix.com> June-07-2007 +# +# Checks for unixodbc. DEFAULT-ACTION is the string yes or no to +# specify whether to default to --with-unixodbc +# If not supplied, DEFAULT-ACTION is no. +# +# This macro #defines HAVE_UNIXODBC if a required header files is +# found, and sets @UNIXODBC_LDFLAGS@ and @UNIXODBC_CFLAGS@ to the necessary +# values. +# +# Users may override the detected values by doing something like: +# UNIXODBC_LDFLAGS="-lunixodbc" UNIXODBC_CFLAGS="-I/usr/myinclude" ./configure +# +# This macro is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +AC_DEFUN([LIBUNIXODBC_CHECK_CONFIG], +[ + AC_ARG_WITH(unixodbc, + [AC_HELP_STRING([--with-unixodbc@<:@=ARG@:>@], + [use odbc driver against unixODBC package @<:@default=no@:>@, optionally specify path to odbc_config.]) + ],[ if test "$withval" = "no"; then + want_unixodbc="no" + elif test "$withval" = "yes"; then + want_unixodbc="yes" + else + want_unixodbc="yes" + _libodbc_config=$withval + fi + ],[want_unixodbc=ifelse([$1],,[no],[$1])]) + + if test "x$want_unixodbc" != x"no"; then + + if test -z "$_libodbc_config" -o test; then + AC_PATH_PROG([_libodbc_config], [odbc_config], [no]) + fi + + if test -f $_libodbc_config; then + UNIXODBC_CFLAGS="-I`${_libodbc_config} --include-prefix`" + UNIXODBC_LDFLAGS="$LDFLAGS -L`${_libodbc_config} --lib-prefix`" + found_unixodbc="yes" + else + found_unixodbc="no" + fi + + if test "$found_unixodbc" = "yes"; then + + _save_unixodbc_libs="${LIBS}" + _save_unixodbc_ldflags="${LDFLAGS}" + _save_unixodbc_cflags="${CFLAGS}" + LIBS="${LIBS} ${UNIXODBC_LIBS}" + LDFLAGS="${LDFLAGS} ${UNIXODBC_LDFLAGS}" + CFLAGS="${CFLAGS} ${UNIXODBC_CFLAGS}" + + AC_CHECK_LIB(odbc, main,[ + UNIXODBC_LIBS="-lodbc $UNIXODBC_LIBS" + ],[ + AC_MSG_ERROR([Not found libodbc library]) + ]) + + LIBS="${LIBS} ${UNIXODBC_LIBS}" + + AC_CACHE_CHECK([whether unixodbc is usable], + [_libunixodbc_usable], + [AC_LINK_IFELSE(AC_LANG_PROGRAM([ + #include <sql.h> + #include <sqlext.h> + #include <sqltypes.h> + ],[ + /* Try and use a few common options to force a failure if we are + missing symbols or can't link. */ + SQLRETURN retcode; + retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, (SQLHENV*)0); + ]),_libunixodbc_usable=yes,_libunixodbc_usable=no) + ]) + + LIBS="${_save_unixodbc_libs}" + LDFLAGS="${_save_unixodbc_ldflags}" + CFLAGS="${_save_unixodbc_cflags}" + unset _save_unixodbc_libs + unset _save_unixodbc_ldflags + unset _save_unixodbc_cflags + + if test "$_libunixodbc_usable" != "yes"; then + AC_MSG_ERROR([Can't use libodbc library]) + fi + + AC_DEFINE(HAVE_UNIXODBC,1,[Define to 1 if unixUNIXODBC Driver Manager should be used.]) + fi + fi + + AC_SUBST(UNIXODBC_LDFLAGS) + AC_SUBST(UNIXODBC_CFLAGS) + AC_SUBST(UNIXODBC_LIBS) + + unset _libunixodbc_with + unset _libunixodbc_usable +])dnl |