In preparation for patching how the oracle detection code works, I moved
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_oracle / configure.in
1 AC_INIT(sql_oracle.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_oracle])
4
5
6 if test x$with_[]modname != xno; then
7
8         targetname=modname   # we might change this later.
9
10         AC_SUBST(ORACLE_LIBS)
11         AC_SUBST(ORACLE_INCLUDE)
12
13         AC_MSG_CHECKING([for oci.h])
14
15         dnl #
16         dnl #  First, see if we can build it WITHOUT using any special includes
17         dnl #
18         AC_TRY_COMPILE([#include <oci.h>],
19                 [ int a = 1;],
20                 ORACLE_INCLUDE=" ",
21                 ORACLE_INCLUDE=
22         )
23
24         dnl #
25         dnl #  If not, look for it in a number of directories.
26         dnl #
27         if test "x$ORACLE_INCLUDE" = "x"; then
28                 old_CFLAGS="$CFLAGS"
29
30                 AC_LOCATE_DIR(oracle_include_dir,oci.h)
31
32                 for try in /usr/local/include/oracle /usr/local/oracle/include $oracle_include_dir; do
33                         CFLAGS="$old_CFLAGS -I$try"
34                         AC_TRY_COMPILE([#include <oci.h>],
35                                 [ int a = 1; ],
36                                 ORACLE_INCLUDE="-I$try",
37                                 ORACLE_INCLUDE=
38                         )
39                         if test "x$ORACLE_INCLUDE" != "x"; then
40                                 break;
41                         fi
42                 done
43                 CFLAGS="$old_CFLAGS"
44         fi
45
46         if test "x$ORACLE_INCLUDE" = "x"; then
47                 AC_MSG_RESULT(no)
48                 AC_MSG_WARN([oracle headers not found.  Use --with-oracle-include-dir=<path>.])
49                 targetname=   # disabled module
50         else
51                 sql_oracle_cflags="${sql_oracle_cflags} ${ORACLE_INCLUDE}"
52                 AC_MSG_RESULT(yes)
53
54                 dnl #
55                 dnl #  Now do the same thing, looking for the Oracle library directory
56                 dnl #
57                 AC_MSG_CHECKING([for oracle_init in -loracleclient])
58
59                 dnl #
60                 dnl #  Look for it in a number of directories.
61                 dnl #
62                 old_LIBS="$LIBS"
63
64                 AC_LOCATE_DIR(oracle_lib_dir,[liboracleclient.so])
65                 AC_LOCATE_DIR(oracle_lib_dir,[liboracleclient.a])
66
67                 for try in /usr/lib/oracle /usr/local/lib/oracle /usr/local/oracle/lib $oracle_lib_dir; do
68                         LIBS="$old_LIBS -L$try -loracleclient"
69                         AC_TRY_LINK([extern char oracle_init();],
70                                 [ oracle_init()],
71                                 ORACLE_LIBS="-L$try -loracleclient",
72                                 ORACLE_LIBS=
73                         )
74                         if test "x$ORACLE_LIBS" != "x"; then
75                                 break;
76                         fi
77                 done
78                 LIBS="$old_LIBS"
79
80                 dnl #
81                 dnl #  If one or the other isn't found, disable them both..
82                 dnl #  If both are found, enable them both.
83                 dnl #
84                 if test "x$ORACLE_LIBS" = "x"; then
85                         AC_MSG_RESULT(no)
86                         ORACLE_INCLUDE=
87                         AC_MSG_WARN([oracle libraries not found.  Use --with-oracle-lib-dir=<path>.])
88                         targetname=   # disabled module
89                 else
90                         sql_oracle_ldflags="$sql_oracle_ldflags $ORACLE_LIBS"
91                         AC_MSG_RESULT(yes)
92                         AC_DEFINE(HAVE_OCI_H)
93                 fi
94         fi
95
96         if test "x$targetname" = "x"; then
97                 AC_MSG_WARN([sql submodule 'oracle' disabled])
98         fi
99
100 else
101         targetname=
102         echo \*\*\* module modname is disabled.
103 fi
104
105 AC_SUBST(sql_oracle_ldflags)
106 AC_SUBST(sql_oracle_cflags)
107 AC_SUBST(targetname)
108 AC_OUTPUT(Makefile)