import from HEAD:
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_firebird / configure.in
1 AC_INIT(sql_firebird.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_firebird])
4
5 AC_PROG_CC
6 AC_PROG_CPP
7
8 AC_ARG_WITH(firebird-include-dir,
9 [  --with-firebird-include-dir=DIR       Directory where the firebird includes may be found ],
10 [ firebird_include_dir="$withval" ]
11 )
12
13 AC_ARG_WITH(firebird-lib-dir,
14 [  --with-firebird-lib-dir=DIR       Directory where the firebird libraries may be found ],
15 [ firebird_lib_dir="$withval" ]
16 )
17
18 AC_ARG_WITH(firebird-dir,
19 [  --with-firebird-dir=DIR       Base directory where firebird is installed ],
20 [ firebird_lib_dir="$withval/lib"
21   firebird_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 ibase.h])
30
31         AC_TRY_COMPILE([#include <ibase.h>], [int a = 1;],
32                 FIREBIRD_INCLUDE=" ",
33                 FIREBIRD_INCLUDE=
34         )
35
36         if test "x$FIREBIRD_INCLUDE" = "x"; then
37                 old_CFLAGS="$CFLAGS"
38
39                 for try in /usr/local/include $firebird_include_dir; do
40                         CFLAGS="$old_CFLAGS -I$try"
41                         AC_TRY_COMPILE([#include <ibase.h>], [int a = 1;],
42                                 FIREBIRD_INCLUDE="-I$try",
43                                 FIREBIRD_INCLUDE=
44                         )
45                         if test "x$FIREBIRD_INCLUDE" != "x"; then
46                                 break;
47                         fi
48                 done
49                 CFLAGS="$old_CFLAGS"
50         fi
51
52         if test "x$FIREBIRD_INCLUDE" = "x"; then
53                 AC_MSG_RESULT(no)
54                 AC_MSG_WARN([firebird headers not found.  Use --with-firebird-include-dir=<path>.])
55                 targetname=   # disabled module
56         else
57                 sql_firebird_cflags="${sql_firebird_cflags} ${FIREBIRD_INCLUDE}"
58                 AC_MSG_RESULT(yes)
59   
60                 AC_MSG_CHECKING([for isc_attach_database -l$GDS])
61
62                 old_LIBS="$LIBS"
63
64                 for try in /usr/lib $firebird_lib_dir; do
65                         LIBS="$old_LIBS -L$try -lfbclient"
66                         AC_TRY_LINK([extern char isc_attach_database();], [isc_attach_database()],
67                                 FIREBIRD_LIBS="-L$try -lfbclient",
68                                 FIREBIRD_LIBS=
69                         )
70                         if test "x$FIREBIRD_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$FIREBIRD_LIBS" = "x"; then
79                         AC_MSG_RESULT(no)
80                         FIREBIRD_INCLUDE=
81                         AC_MSG_WARN([firebird libraries not found.  Use --with-firebird-lib-dir=<path>.])
82                         targetname=   # disabled module
83                 else
84                         AC_MSG_RESULT(yes) 
85                         sql_firebird_ldflags="$sql_firebird_ldflags $FIREBIRD_LIBS"
86                 fi
87         fi
88
89         sql_firebird_ldflags="$sql_firebird_ldflags $LIBS"
90
91         if test "x$targetname" = "x"; then
92                 AC_MSG_WARN([sql submodule 'firebird' disabled])
93         fi
94
95 else
96         targetname=
97         echo \*\*\* module modname is disabled.
98 fi
99
100 AC_SUBST(sql_firebird_ldflags)
101 AC_SUBST(sql_firebird_cflags)
102 AC_SUBST(targetname)
103 AC_OUTPUT(Makefile)