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