1 AC_INIT(sql_unixodbc.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_unixodbc])
8 AC_ARG_WITH(unixodbc-include-dir,
9 [ --with-unixodbc-include-dir=DIR Directory where the unixODBC includes may be found ],
10 [ unixodbc_include_dir="$withval" ]
13 AC_ARG_WITH(unixodbc-lib-dir,
14 [ --with-unixodbc-lib-dir=DIR Directory where the unixODBC libraries may be found ],
15 [ unixodbc_lib_dir="$withval" ]
18 AC_ARG_WITH(unixodbc-dir,
19 [ --with-unixodbc-dir=DIR Base directory where unixODBC is installed ],
20 [ unixodbc_lib_dir="$withval/lib"
21 unixodbc_include_dir="$withval/include"
25 if test x$with_[]modname != xno; then
27 targetname=modname # we might change this later.
29 AC_MSG_CHECKING([for sql.h])
31 AC_TRY_COMPILE([#include <sql.h>], [int a = 1;],
36 if test "x$UNIXODBC_INCLUDE" = "x"; then
39 for try in /usr/local/include $unixodbc_include_dir; do
40 CFLAGS="$old_CFLAGS -I$try"
41 AC_TRY_COMPILE([#include <sql.h>], [int a = 1;],
42 UNIXODBC_INCLUDE="-I$try",
45 if test "x$UNIXODBC_INCLUDE" != "x"; then
52 if test "x$UNIXODBC_INCLUDE" = "x"; then
54 AC_MSG_WARN([unixODBC headers not found. Use --with-unixodbc-include-dir=<path>.])
55 targetname= # disabled module
57 sql_unixodbc_cflags="${sql_unixodbc_cflags} ${UNIXODBC_INCLUDE}"
60 AC_MSG_CHECKING([for SQLConnect in -lodbc])
64 for try in /usr/local/lib $unixodbc_lib_dir; do
65 LIBS="$old_LIBS -L$try -lodbc"
66 AC_TRY_LINK([extern char SQLConnect();], [SQLConnect()],
67 UNIXODBC_LIBS="-L$try -lodbc",
70 if test "x$UNIXODBC_LIBS" != "x"; then
76 dnl # If one or the other isn't found, disable them both..
77 dnl # If both are found, enable them both.
78 if test "x$UNIXODBC_LIBS" = "x"; then
81 AC_MSG_WARN([unixODBC libraries not found. Use --with-unixODBC-lib-dir=<path>.])
82 targetname= # disabled module
85 sql_unixodbc_ldflags="$sql_unixodbc_ldflags $UNIXODBC_LIBS"
89 sql_unixodbc_ldflags="$sql_unixodbc_ldflags $LIBS"
91 if test "x$targetname" = "x"; then
92 AC_MSG_WARN([sql submodule 'unixodbc' disabled])
97 echo \*\*\* module modname is disabled.
100 AC_SUBST(sql_unixodbc_ldflags)
101 AC_SUBST(sql_unixodbc_cflags)