Delete trailing whitespace.
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_unixodbc / configure.in
1 AC_INIT(sql_unixodbc.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_unixodbc])
4
5 AC_PROG_CC
6 AC_PROG_CPP
7
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" ]
11 )
12
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" ]
16 )
17
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"
22 ]
23 )
24
25 if test x$with_[]modname != xno; then
26
27         targetname=modname   # we might change this later.
28
29         AC_MSG_CHECKING([for sql.h])
30
31         AC_TRY_COMPILE([#include <sql.h>], [int a = 1;],
32                 UNIXODBC_INCLUDE=" ",
33                 UNIXODBC_INCLUDE=
34         )
35
36         if test "x$UNIXODBC_INCLUDE" = "x"; then
37                 old_CFLAGS="$CFLAGS"
38
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",
43                                 UNIXODBC_INCLUDE=
44                         )
45                         if test "x$UNIXODBC_INCLUDE" != "x"; then
46                                 break;
47                         fi
48                 done
49                 CFLAGS="$old_CFLAGS"
50         fi
51
52         if test "x$UNIXODBC_INCLUDE" = "x"; then
53                 AC_MSG_RESULT(no)
54                 AC_MSG_WARN([unixODBC headers not found.  Use --with-unixodbc-include-dir=<path>.])
55                 targetname=   # disabled module
56         else
57                 sql_unixodbc_cflags="${sql_unixodbc_cflags} ${UNIXODBC_INCLUDE}"
58                 AC_MSG_RESULT(yes)
59
60                 AC_MSG_CHECKING([for SQLConnect in -lodbc])
61
62                 old_LIBS="$LIBS"
63
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",
68                                 UNIXODBC_LIBS=
69                         )
70                         if test "x$UNIXODBC_LIBS" != "x"; then
71                                 break;
72                         fi
73                 done
74                 LIBS="$old_LIBS"
75
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
79                         AC_MSG_RESULT(no)
80                         UNIXODBC_INCLUDE=
81                         AC_MSG_WARN([unixODBC libraries not found.  Use --with-unixODBC-lib-dir=<path>.])
82                         targetname=   # disabled module
83                 else
84                         AC_MSG_RESULT(yes)
85                         sql_unixodbc_ldflags="$sql_unixodbc_ldflags $UNIXODBC_LIBS"
86                 fi
87         fi
88
89         sql_unixodbc_ldflags="$sql_unixodbc_ldflags $LIBS"
90
91         if test "x$targetname" = "x"; then
92                 AC_MSG_WARN([sql submodule 'unixodbc' disabled])
93         fi
94
95 else
96         targetname=
97         echo \*\*\* module modname is disabled.
98 fi
99
100 AC_SUBST(sql_unixodbc_ldflags)
101 AC_SUBST(sql_unixodbc_cflags)
102 AC_SUBST(targetname)
103 AC_OUTPUT(Makefile)