David Kerry's patch to detect Oracle.
[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 # See if the user passed in the oracle_home_dir option and
17         dnl # use that first.  If not, use $ORACLE_HOME.  If that's
18         dnl # not defined, give up.  There's no point in blindly
19         dnl # hunting around for Oracle - there's no standard place
20         dnl # for it.  Any sane Oracle user/developer should have $ORACLE_HOME
21         dnl # defined anyways.
22         dnl #
23
24         AC_TRY_COMPILE([#include <oci.h>],
25                 [ int a = 1;],
26                 ORACLE_INCLUDE=" ",
27                 ORACLE_INCLUDE=
28         )
29
30         # Look for Oracle8i.
31         if test "x$ORACLE_INCLUDE" = "x"; then
32                 old_CFLAGS="$CFLAGS"
33
34                 AC_LOCATE_DIR(oracle_home_dir,oci.h)
35
36                 for try in $oracle_home_dir $oracle_include_dir; do
37                         CFLAGS="$old_CFLAGS -I${try}/rdbms/demo -I${try}/rdbms/public -I${try}/plsql/public -I${try}/network/public -I${try}/oci/include"
38                         AC_TRY_COMPILE([#include <oci.h>],
39                                 [ int a = 1; ],
40                                 OHOME=$try,
41                                 OHOME=
42                         )
43                         if test "x$OHOME" != "x"; then
44                                 break;
45                         fi
46                 done
47
48                 if test "x$OHOME" = "x" -a "x$ORACLE_HOME" != "x"; then
49                         CFLAGS="$old_CFLAGS -I${ORACLE_HOME}/rdbms/demo -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/plsql/public -I${ORACLE_HOME}/network/public -I${ORACLE_HOME}/oci/include"
50                         AC_TRY_COMPILE([#include <oci.h>],
51                                 [ int a = 1; ],
52                                 OHOME=$ORACLE_HOME,
53                                 OHOME=
54                         )
55                 fi
56
57                 CFLAGS="$old_CFLAGS"
58
59                 if test "x$OHOME" != "x"; then
60                         ORACLE_HOME=$OHOME
61                         ORACLE_INCLUDE="-I${ORACLE_HOME}/rdbms/demo -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/plsql/public -I${ORACLE_HOME}/network/public -I${ORACLE_HOME}/oci/include"
62                 fi
63         fi     ##  this section sets $ORACLE_HOME, if found.
64
65         # not Oracle8i, try older.
66         if test "x$ORACLE_INCLUDE" = "x"; then
67                 old_CFLAGS="$CFLAGS"
68
69                 AC_LOCATE_DIR(oracle_include_dir,oci.h)
70
71                 for try in /usr/local/include/oracle /usr/local/oracle/include $oracle_include_dir; do
72                         CFLAGS="$old_CFLAGS -I$try"
73                         AC_TRY_COMPILE([#include <oci.h>],
74                                 [ int a = 1; ],
75                                 ORACLE_INCLUDE="-I$try",
76                                 ORACLE_INCLUDE=
77                         )
78                         if test "x$ORACLE_INCLUDE" != "x"; then
79                                 break;
80                         fi
81                 done
82                 CFLAGS="$old_CFLAGS"
83         fi
84
85         if test "x$ORACLE_INCLUDE" = "x"; then
86                 AC_MSG_RESULT(no)
87                 AC_MSG_WARN([oracle headers not found.  Use --with-oracle-home-dir=<path>.])
88                 targetname=   # disabled module
89         else
90                 sql_oracle_cflags="${sql_oracle_cflags} ${ORACLE_INCLUDE}"
91                 AC_MSG_RESULT(yes)
92
93
94                 ## is this set, from above?
95                 if test "x$ORACLE_HOME" != "x"; then
96                         ## we must have an Oracle8i tree
97
98                         # FIXME: we might do some checking, just to be nice
99                         ORACLE_LIBS="-L$ORACLE_HOME/lib -lclntsh -lm"
100
101                 else
102                         AC_MSG_CHECKING([for oracle_init in -loracleclient])
103
104                         dnl #
105                         dnl #  Look for it in a number of directories.
106                         dnl #
107                         old_LIBS="$LIBS"
108
109                         AC_LOCATE_DIR(oracle_lib_dir,[oracleclient.so])
110                         AC_LOCATE_DIR(oracle_lib_dir,[oracleclient.a])
111
112                         for try in /usr/lib/oracle /usr/local/lib/oracle /usr/local/oracle/lib $oracle_lib_dir; do
113                                 LIBS="$old_LIBS -L$try -loracleclient"
114                                 AC_TRY_LINK([extern char oracle_init();],
115                                         [ oracle_init()],
116                                         ORACLE_LIBS="-L$try -loracleclient",
117                                         ORACLE_LIBS=
118                                 )
119                                 if test "x$ORACLE_LIBS" != "x"; then
120                                         break;
121                                 fi
122                         done
123                         LIBS="$old_LIBS"
124
125                         dnl #
126                         dnl #  If one or the other isn't found, disable
127                         dnl #  them both..
128                         dnl #  If both are found, enable them both.
129                         dnl #
130                         if test "x$ORACLE_LIBS" = "x"; then
131                                 AC_MSG_RESULT(no)
132                                 ORACLE_INCLUDE=
133                         else
134                                 sql_oracle_ldflags="$sql_oracle_ldflags $ORACLE_LIBS"
135                                 AC_MSG_RESULT(yes)
136                                 break
137                         fi
138                 fi
139
140                 if test "x$ORACLE_LIBS" != "x"; then
141                         AC_MSG_WARN([oracle libraries not found.  Use --with-oracle-lib-dir=<path>.])
142                         targetname=   # disabled module
143                 fi
144         fi
145
146         if test "x$targetname" = "x"; then
147                 AC_MSG_WARN([sql submodule 'oracle' disabled])
148         fi
149
150 else
151         targetname=
152         echo \*\*\* module modname is disabled.
153 fi
154
155 AC_SUBST(sql_oracle_ldflags)
156 AC_SUBST(sql_oracle_cflags)
157 AC_SUBST(targetname)
158 AC_OUTPUT(Makefile)