0844a1e975bb8849f54e952692865d695374becd
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_oracle / configure.ac
1 AC_INIT(rlm_sql_oracle.c)
2 AC_REVISION($Revision: 1.10 $)
3 AC_DEFUN(modname,[rlm_sql_oracle])
4
5 fail=
6 mod_ldflags=
7 mod_cflags=
8 if test x$with_[]modname != xno; then
9
10     dnl ############################################################
11     dnl # Check for command line options
12     dnl ############################################################
13
14     dnl extra argument: --with-oracle-include-dir=DIR
15     oracle_include_dir=
16     AC_ARG_WITH(oracle-include-dir,
17         [AS_HELP_STRING([--with-oracle-include-dir=DIR],
18                 [Directory where the oracle includes may be found])],
19         [case "$withval" in
20             no)
21             AC_MSG_ERROR(Need oracle-include-dir)
22             ;;
23             yes)
24             ;;
25             *)
26             oracle_include_dir="$withval"
27             ;;
28         esac])
29
30     dnl extra argument: --with-oracle-lib-dir=DIR
31     oracle_lib_dir=
32     AC_ARG_WITH(oracle-lib-dir,
33         [AS_HELP_STRING([--with-oracle-lib-dir=DIR],
34                 [Directory where the oracle libraries may be found])],
35         [case "$withval" in
36             no)
37             AC_MSG_ERROR(Need oracle-lib-dir)
38             ;;
39             yes)
40             ;;
41             *)
42             oracle_lib_dir="$withval"
43             ;;
44         esac])
45
46     dnl extra argument: --with-oracle-dir=DIR
47     AC_ARG_WITH(oracle-dir,
48         [AS_HELP_STRING([--with-oracle-dir=DIR],
49                 [Base directory where oracle is installed])],
50         [case "$withval" in
51             no)
52             AC_MSG_ERROR(Need oracle-dir)
53             ;;
54             yes)
55             ;;
56             *)
57             oracle_lib_dir="$withval/lib"
58             oracle_include_dir="$withval/include"
59             ;;
60         esac])
61
62     dnl ############################################################
63     dnl # Check for header files
64     dnl ############################################################
65
66     smart_try_dir="$oracle_include_dir /usr/local/instaclient/include"
67     
68     if test "x$ORACLE_HOME" != "x"; then
69         smart_try_dir+="${ORACLE_HOME}/include"
70     fi
71     
72     FR_SMART_CHECK_INCLUDE(oci.h)
73     if test "x$ac_cv_header_oci_h" != "xyes"; then
74         AC_MSG_WARN([oracle headers not found. Use --with-oracle-include-dir=<path> or set ORACLE_HOME.])
75         fail="$fail oci.h"
76     fi
77
78     dnl ############################################################
79     dnl # Check for libraries
80     dnl ############################################################
81
82     old_LIBS="$LIBS"
83     
84     if test "x$oracle_lib_dir" != "x" ; then
85         lib_path="${oracle_lib_dir} "
86     elif test "x$ORACLE_HOME" != "x" ; then
87         lib_path="${ORACLE_HOME}/lib "
88     fi
89
90     for path in $lib_path "/usr/local/instaclient/lib" "" "/opt/lib"; do
91         for oracle_version in 11 10 9 ""; do
92             if test "$path" != ""; then
93                 AC_MSG_CHECKING([for OCIInitialize in nnz${oracle_version} in $path])
94             else
95                 AC_MSG_CHECKING([for OCIInitialize in nnz${oracle_version}])
96             fi
97             
98             LIBS="$old_LIBS -L$path -lclntsh -lnnz${oracle_version}"
99             AC_TRY_LINK([#include <oci.h>
100
101                 static OCIEnv           *p_env;
102                 static OCIError         *p_err;
103                 static OCISvcCtx        *p_svc;
104                 static OCIStmt          *p_sql;
105                 static OCIDefine        *p_dfn    = (OCIDefine *) 0;
106                 static OCIBind          *p_bnd    = (OCIBind *) 0;
107                 ],
108                 [
109                 int             p_bvi;
110                 char            p_sli[20];
111                 int             rc;
112                 char            errbuf[100];
113                 int             errcode;
114             
115                 rc = OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0,  /* Initialize OCI */
116                                    (dvoid * (*)(dvoid *, size_t)) 0,
117                                    (dvoid * (*)(dvoid *, dvoid *, size_t))0,
118                                    (void (*)(dvoid *, dvoid *)) 0 );
119     
120                 ],
121                 [mod_ldflags="$LIBS"],
122             )
123             if test "x$mod_ldflags" != "x"; then
124                     AC_MSG_RESULT(yes)
125                     break
126             fi
127             AC_MSG_RESULT(no)
128         done
129         
130         if test "x$mod_ldflags" != "x"; then
131                 break
132         fi
133     done
134
135     LIBS="$old_LIBS"
136
137     if test "x$mod_ldflags" = "x"; then
138         AC_MSG_WARN([oracle libraries not found.  Use --with-oracle-lib-dir=<path> or set ORACLE_HOME.])
139         fail=["$fail libclntsh libnnz[9-11]"]
140     fi
141     
142     targetname=modname
143 else
144     targetname=
145     echo \*\*\* module modname is disabled.
146 fi
147
148 dnl Don't change this section.
149 if test "x$fail" != x; then
150         if test "x${enable_strict_dependencies}" = xyes; then
151                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
152         else
153                 AC_MSG_WARN([silently not building ]modname[.])
154                 AC_MSG_WARN([FAILURE: ]modname[ requires:$fail.]);
155                 targetname=
156         fi
157 fi
158
159 mod_cflags="$SMART_CPPFLAGS"
160 AC_SUBST(mod_ldflags)
161 AC_SUBST(mod_cflags)
162 AC_SUBST(targetname)
163 AC_OUTPUT(all.mk)