44680849b1d57fa0ec582c48369355648f03cef9
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_iodbc / configure.in
1 AC_INIT(sql_iodbc.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_iodbc])
4
5 AC_PROG_CC
6 AC_PROG_CPP
7
8 AC_ARG_WITH(iodbc-include-dir,
9 [  --with-iodbc-include-dir=DIR       Directory where the Iodbc includes may be found ],
10 [ iodbc_include_dir="$withval" ]
11 )
12
13 AC_ARG_WITH(iodbc-lib-dir,
14 [  --with-iodbc-lib-dir=DIR       Directory where the Iodbc libraries may be found ],
15 [ iodbc_lib_dir="$withval" ]
16 )
17
18 AC_ARG_WITH(iodbc-dir,
19 [  --with-iodbc-dir=DIR       Base directory where Iodbc is installed ],
20 [ iodbc_lib_dir="$withval/lib/iodbc"
21   iodbc_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 isql.h])
30
31         AC_TRY_COMPILE([#include <isql.h>], [int a = 1;],
32                 IODBC_INCLUDE=" ",
33                 IODBC_INCLUDE=
34         )
35
36         if test "x$IODBC_INCLUDE" = "x"; then
37                 old_CFLAGS="$CFLAGS"
38
39 dnl             FR_LOCATE_DIR(iodbc_include_dir,[isql.h])
40
41                 for try in /usr/local/include /usr/local/iodbc/include $iodbc_include_dir; do
42                         CFLAGS="$old_CFLAGS -I$try"
43                         AC_TRY_COMPILE([#include <isql.h>], [int a = 1;],
44                                 IODBC_INCLUDE="-I$try",
45                                 IODBC_INCLUDE=
46                         )
47                         if test "x$IODBC_INCLUDE" != "x"; then
48                                 break;
49                         fi
50                 done
51                 CFLAGS="$old_CFLAGS"
52         fi
53
54         if test "x$IODBC_INCLUDE" = "x"; then
55                 AC_MSG_RESULT(no)
56                 AC_MSG_WARN([iodbc headers not found.  Use --with-iodbc-include-dir=<path>.])
57                 targetname=   # disabled module
58         else
59                 sql_iodbc_cflags="${sql_iodbc_cflags} ${IODBC_INCLUDE}"
60                 AC_MSG_RESULT(yes)
61                 AC_DEFINE(HAVE_IODBC_H)
62
63   
64                 AC_MSG_CHECKING([for SQLConnect in -liodbc])
65
66                 old_LIBS="$LIBS"
67
68 dnl             FR_LOCATE_DIR(iodbc_lib_dir,[libodbc${libltdl_cv_shlibext}])
69 dnl             FR_LOCATE_DIR(iodbc_lib_dir,[libodbc.a])
70
71                 for try in /usr/lib /usr/lib/iodbc /usr/local/lib/iodbc /usr/local/iodbc/lib/iodbc $iodbc_lib_dir; do
72                         LIBS="$old_LIBS -L$try -liodbc"
73                         AC_TRY_LINK([extern char SQLConnect();], [SQLConnect()],
74                                 IODBC_LIBS="-L$try -liodbc",
75                                 IODBC_LIBS=
76                         )
77                         if test "x$IODBC_LIBS" != "x"; then
78                                 break;
79                         fi
80                 done
81                 LIBS="$old_LIBS"
82
83                 dnl #  If one or the other isn't found, disable them both..
84                 dnl #  If both are found, enable them both.
85                 if test "x$IODBC_LIBS" = "x"; then
86                         AC_MSG_RESULT(no)
87                         IODBC_INCLUDE=
88                         AC_MSG_WARN([iodbc libraries not found.  Use --with-iodbc-lib-dir=<path>.])
89                         targetname=   # disabled module
90                 else
91                         AC_MSG_RESULT(yes) 
92                         sql_iodbc_ldflags="$sql_iodbc_ldflags $IODBC_LIBS"
93                 fi
94         fi
95
96         sql_iodbc_ldflags="$sql_iodbc_ldflags $LIBS"
97
98         if test "x$targetname" = "x"; then
99                 AC_MSG_WARN([sql submodule 'iodbc' disabled])
100         fi
101
102 else
103         targetname=
104         echo \*\*\* module modname is disabled.
105 fi
106
107 AC_SUBST(sql_iodbc_ldflags)
108 AC_SUBST(sql_iodbc_cflags)
109 AC_SUBST(targetname)
110 AC_OUTPUT(Makefile)