summaryrefslogtreecommitdiffstats
path: root/src/modules/rlm_sql/drivers/rlm_sql_oracle/configure.ac
blob: a320b856270d2cc1660a1c1d9ed319c921ebde9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
AC_PREREQ([2.68])
AC_INIT(rlm_sql_oracle.c)
AC_REVISION($Revision: 1.10 $)
FR_INIT_MODULE([rlm_sql_oracle])

oracle_supported_versions="19 18 12 11 10 9"
fail=
mod_ldflags=
mod_cflags=

if test x$with_[]modname != xno; then

    dnl ############################################################
    dnl # Check for command line options
    dnl ############################################################

    dnl extra argument: --with-oracle-include-dir=DIR
    oracle_include_dir=
    AC_ARG_WITH(oracle-include-dir,
	[AS_HELP_STRING([--with-oracle-include-dir=DIR],
		[Directory where the oracle includes may be found])],
	[case "$withval" in
	    no)
	    AC_MSG_ERROR(Need oracle-include-dir)
	    ;;
	    yes)
	    ;;
	    *)
	    oracle_include_dir="$withval"
	    ;;
	esac])

    dnl extra argument: --with-oracle-lib-dir=DIR
    oracle_lib_dir=
    AC_ARG_WITH(oracle-lib-dir,
	[AS_HELP_STRING([--with-oracle-lib-dir=DIR],
		[Directory where the oracle libraries may be found])],
	[case "$withval" in
	    no)
	    AC_MSG_ERROR(Need oracle-lib-dir)
	    ;;
	    yes)
	    ;;
	    *)
	    oracle_lib_dir="$withval"
	    ;;
	esac])

    dnl extra argument: --with-oracle-dir=DIR
    AC_ARG_WITH(oracle-dir,
	[AS_HELP_STRING([--with-oracle-dir=DIR],
		[Base directory where oracle is installed])],
	[case "$withval" in
	    no)
	    AC_MSG_ERROR(Need oracle-dir)
	    ;;
	    yes)
	    ;;
	    *)
	    oracle_lib_dir="$withval/lib"
	    oracle_include_dir="$withval/include"
	    ;;
	esac])

    dnl ############################################################
    dnl # Check for header files
    dnl ############################################################

    smart_try_dir="$oracle_include_dir /usr/local/instaclient/include"

    if test "x$ORACLE_HOME" != "x"; then
	smart_try_dir="${smart_try_dir} ${ORACLE_HOME}/include"
    fi

    FR_SMART_CHECK_INCLUDE(oci.h)
    if test "x$ac_cv_header_oci_h" != "xyes"; then
	AC_MSG_WARN([oracle headers not found. Use --with-oracle-include-dir=<path> or set ORACLE_HOME.])
	fail="$fail oci.h"
    fi

    dnl ############################################################
    dnl # Check for libraries
    dnl ############################################################

    old_LIBS="$LIBS"

    if test "x$oracle_lib_dir" != "x" ; then
	lib_path="${oracle_lib_dir} "
    elif test "x$ORACLE_HOME" != "x" ; then
	lib_path="${ORACLE_HOME}/lib "
    fi

    AC_MSG_WARN([Oracle supported versions: ${oracle_supported_versions}])
    AC_MSG_WARN([Oracle version >= 12 needs -laio])

    for path in $lib_path "/usr/local/instaclient/lib" "" "/opt/lib"; do
	for oracle_version in ${oracle_supported_versions} ""; do
	    if test "$path" != ""; then
		AC_MSG_CHECKING([for OCIInitialize in nnz${oracle_version} in $path])
	    else
		AC_MSG_CHECKING([for OCIInitialize in nnz${oracle_version}])
	    fi

	    LIBS="$old_LIBS -L$path -Wl,-rpath,$path -lclntsh -lnnz${oracle_version}"

	    AC_TRY_LINK([#include <oci.h>

		static OCIEnv           *p_env;
		static OCIError         *p_err;
		static OCISvcCtx        *p_svc;
		static OCIStmt          *p_sql;
		static OCIDefine        *p_dfn    = (OCIDefine *) 0;
		static OCIBind          *p_bnd    = (OCIBind *) 0;
		],
		[
		int             p_bvi;
		char            p_sli[20];
		int             rc;
		char            errbuf[100];
		int             errcode;

		rc = OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0,  /* Initialize OCI */
				   (dvoid * (*)(dvoid *, size_t)) 0,
				   (dvoid * (*)(dvoid *, dvoid *, size_t))0,
				   (void (*)(dvoid *, dvoid *)) 0 );

		],
		[mod_ldflags="$LIBS"],
	    )
	    if test "x$mod_ldflags" != "x"; then
		    AC_MSG_RESULT(yes)
		    break
	    fi
	    AC_MSG_RESULT(no)
	done

	if test "x$mod_ldflags" != "x"; then
		break
	fi
    done

    LIBS="$old_LIBS"

    if test "x$mod_ldflags" = "x"; then
	AC_MSG_WARN([oracle libraries not found.  Use --with-oracle-lib-dir=<path> or set ORACLE_HOME.])
	fail=["$fail libclntsh libnnz[9-12]"]
    fi

    targetname=modname
else
    targetname=
    echo \*\*\* module modname is disabled.
fi

dnl Don't change this section.
if test "x$fail" != x; then
	if test "x${enable_strict_dependencies}" = xyes; then
		AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
	else
		AC_MSG_WARN([silently not building ]modname[.])
		AC_MSG_WARN([FAILURE: ]modname[ requires:$fail.]);
		targetname=
	fi
fi

mod_cflags="$SMART_CPPFLAGS"
AC_SUBST(mod_ldflags)
AC_SUBST(mod_cflags)
AC_SUBST(targetname)
AC_OUTPUT(all.mk)