aboutsummaryrefslogtreecommitdiff
path: root/m4/liboci.m4
blob: 7fc04479586343cda918e8ff66fda82e0a4d4e2f (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
dnl file      : m4/oci.m4
dnl author    : Constantin Michael <constantin@codesynthesis.com>
dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
dnl license   : GNU GPL v2; see accompanying LICENSE file
dnl
dnl LIBOCI([ACTION-IF-FOUND[,
dnl        ACTION-IF-NOT-FOUND]])
dnl
dnl
AC_DEFUN([LIBOCI], [
oci_found=no

AC_ARG_WITH(
  [oci],
  [AC_HELP_STRING([--with-oci=DIR],[location of oci sdk directory])],
  [oci_dir=${withval}],
  [oci_dir=])

AC_MSG_CHECKING([for oci])

save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
save_LIBS="$LIBS"

# If oci_dir was given, add the necessary preprocessor and linker flags.
#
if test x"$oci_dir" != x; then
  # Check whether oci_dir refers to an Oracle server or an Instant Client
  # installation.
  #
  if test -d "$oci_dir/sdk/include"; then
    CPPFLAGS="$CPPFLAGS -I$oci_dir/sdk/include"
    LDFLAGS="$LDFLAGS -L$oci_dir"
    LIBS="-lclntsh $LIBS"

    CXX_LIBTOOL_LINK_IFELSE(
AC_LANG_SOURCE([[
#include <oci.h>

int
main ()
{
  OCIEnv* env (0);
  OCIEnvNlsCreate (&env, OCI_THREADED, 0, 0, 0, 0, 0, 0, 0, 0);
  OCIHandleFree (env, OCI_HTYPE_ENV);
  return 0;
}
]]),
[
oci_found=yes
])

    if test x"$oci_found" = xno; then
      LDFLAGS="$save_LDFLAGS"
      LIBS="$save_LIBS -Wc,`ls $oci_dir/libclntsh.so.* 2>/dev/null`"
    fi
  elif test -d "$oci_dir/rdbms/public"; then
    CPPFLAGS="$CPPFLAGS -I$oci_dir/rdbms/public"
    LDFLAGS="$LDFLAGS -L$oci_dir/lib"
    LIBS="-lclntsh $LIBS"
  fi
fi

CXX_LIBTOOL_LINK_IFELSE(
AC_LANG_SOURCE([[
#include <oci.h>

int
main ()
{
  OCIEnv* env (0);
  OCIEnvNlsCreate (&env, OCI_THREADED, 0, 0, 0, 0, 0, 0, 0, 0);
  OCIHandleFree (env, OCI_HTYPE_ENV);
  return 0;
}
]]),
[
oci_found=yes
])

if test x"$oci_found" = xno; then

  # Try using ORACLE_HOME if it exists.
  #
  if test x"$ORACLE_HOME" != x; then
    CPPFLAGS="$CPPFLAGS -I$ORACLE_HOME/rdbms/public"
    LDFLAGS="$LDFLAGS -L$ORACLE_HOME/lib"
    LIBS="$LIBS -lclntsh"

    CXX_LIBTOOL_LINK_IFELSE(
AC_LANG_SOURCE([[
#include <oci.h>

int
main ()
{
  OCIEnv* env (0);
  OCIEnvNlsCreate (&env, OCI_THREADED, 0, 0, 0, 0, 0, 0, 0, 0);
  OCIHandleFree (env, OCI_HTYPE_ENV);
  return 0;
}
]]),
[
oci_found=yes
])

    if test x"$oci_found" = xno; then
      CPPFLAGS="$save_CPPFLAGS"
      LDFLAGS="$save_LDFLAGS"
      LIBS="$save_LIBS"
    fi

  fi
fi

if test x"$oci_found" = xyes; then
  AC_MSG_RESULT([yes])
  $1
else
  LIBS="$save_LIBS"
  AC_MSG_RESULT([no])
  $2
fi
])dnl