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