Update Oracle Autoconf scripts. Closes bug #57
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_oracle / configure.in
1 AC_INIT(sql_oracle.c)
2 AC_REVISION($Revision: 1.10 $)
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         dnl ############################################################
22         dnl # Check for command line options
23         dnl ############################################################
24
25         dnl extra argument: --with-oracle-include-dir=DIR
26         oracle_include_dir=
27         AC_ARG_WITH(oracle-include-dir,
28                 [AS_HELP_STRING([--with-oracle-include-dir=DIR],
29                             [Directory where the Oracle includes may be found. It should be located under ORACLE_HOME if you have client SDK installed. Use --with-oracle-include-dir=yes if you are sure that your compiler include path includes Oracle include dir. Hint: you might try to do: locate oci.h])],
30                 [case "$withval" in
31                         no)
32                             AC_MSG_ERROR(Need oracle-include-dir)
33                             ;;
34                         yes)
35                             ;;
36                         *)
37                             oracle_include_dir="$withval"
38                             ;;
39                 esac])
40
41         dnl extra argument: --with-oracle-lib-dir=DIR
42         oracle_lib_dir=
43         AC_ARG_WITH(oracle-lib-dir,
44                 [AS_HELP_STRING([--with-oracle-lib-dir=DIR],
45                             [Directory where the oracle libraries may be found. It should be located under ORACLE_HOME. iUse --with-oracle-lib-dir=yes if you are sure that your linker will find the necessary Oracle client libs. Hint: you might try to do: locate libclntsh.so])],
46                 [case "$withval" in
47                         no)
48                             AC_MSG_ERROR(Need oracle-lib-dir)
49                             ;;
50                         yes)
51                             ;;
52                         *)
53                             oracle_lib_dir="$withval"
54                             ;;
55         esac])
56
57
58
59         AC_TRY_COMPILE([#include <oci.h>],
60                 [ int a = 1;],
61                 ORACLE_INCLUDE=" ",
62                 ORACLE_INCLUDE=
63         )
64
65         RLM_SQL_ORA_WORKING_CFLAGS_FOR_LINKING_TEST=
66         if test "x$ORACLE_INCLUDE" = "x" ; then
67                 old_CFLAGS="$CFLAGS"
68                 CFLAGS="$old_CFLAGS -I$oracle_include_dir"
69                 AC_TRY_COMPILE([#include <oci.h>],
70                         [ int a = 1;],
71                         ORACLE_INCLUDE="-I$oracle_include_dir",
72                         ORACLE_INCLUDE=
73                 )
74
75                 RLM_SQL_ORA_WORKING_CFLAGS_FOR_LINKING_TEST="$CFLAGS"
76                 CFLAGS="$old_CFLAGS"
77         fi
78
79         # Proceed to linking makes only sense if include dir is OK.
80         if test "x$ORACLE_INCLUDE" != "x" ; then
81                 old_LIBS="$LIBS"
82                 old_CFLAGS="$CFLAGS"
83                 CFLAGS="$RLM_SQL_ORA_WORKING_CFLAGS_FOR_LINKING_TEST"
84
85                 ORACLE_LIBDIR_SWITCH=
86                 if test "x$oracle_lib_dir" != "x" ; then
87                         ORACLE_LIBDIR_SWITCH="-L${oracle_lib_dir} "
88                 fi
89                 LIBS="$old_LIBS $ORACLE_LIBDIR_SWITCH -lclntsh -lnnz10"
90                 AC_TRY_LINK([#include <oci.h>
91         
92                                 static OCIEnv           *p_env;
93                                 static OCIError         *p_err;
94                                 static OCISvcCtx        *p_svc;
95                                 static OCIStmt          *p_sql;
96                                 static OCIDefine        *p_dfn    = (OCIDefine *) 0;
97                                 static OCIBind          *p_bnd    = (OCIBind *) 0;
98                         ],
99                         [
100                                   int             p_bvi;
101                                   char            p_sli[20];
102                                   int             rc;
103                                   char            errbuf[100];
104                                   int             errcode;
105                                 
106                                   rc = OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0,  /* Initialize OCI */
107                                           (dvoid * (*)(dvoid *, size_t)) 0,
108                                           (dvoid * (*)(dvoid *, dvoid *, size_t))0,
109                                           (void (*)(dvoid *, dvoid *)) 0 );
110
111                         ],
112                         ORACLE_LIBS="$ORACLE_LIBDIR_SWITCH -lclntsh -lnnz10",
113                         ORACLE_LIBS=
114                 )
115
116                 LIBS="$old_LIBS"
117                 CFLAGS="$old_CFLAGS"
118         fi
119
120
121         if test "x$ORACLE_INCLUDE" = "x"; then
122                 AC_MSG_RESULT(no)
123                 AC_MSG_WARN([oracle headers not found.  Use --with-oracle-include-dir=<path>.])
124                 fail="$fail oci.h"
125         else
126                 sql_oracle_cflags="${sql_oracle_cflags} ${ORACLE_INCLUDE}"
127                 AC_MSG_RESULT(yes)
128
129
130                 if test "x$ORACLE_LIBS" = "x"; then
131                         AC_MSG_WARN([oracle libraries not found.  Use --with-oracle-lib-dir=<path>.])
132                         fail="$fail libclntsh libnnz10"
133                 else
134                         sql_oracle_ldflags="${sql_oracle_ldflags} $ORACLE_LIBS"
135                         AC_MSG_RESULT(yes)
136                 fi
137         fi
138
139         targetname=modname
140 else
141         targetname=
142         echo \*\*\* module modname is disabled.
143 fi
144
145 dnl Don't change this section.
146 if test "x$fail" != x; then
147         if test "x${enable_strict_dependencies}" = xyes; then
148                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
149         else
150                 AC_MSG_WARN([silently not building ]modname[.])
151                 AC_MSG_WARN([FAILURE: ]modname[ requires:$fail.]);
152                 targetname=
153         fi
154 fi
155
156 AC_SUBST(sql_oracle_ldflags)
157 AC_SUBST(sql_oracle_cflags)
158 AC_SUBST(targetname)
159 AC_OUTPUT(Makefile)