aboutsummaryrefslogtreecommitdiff
path: root/m4/oracle.m4
blob: 5da75caf22dce4988d52955caf956aebf010142d (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
dnl file      : m4/oracle.m4
dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
dnl license   : GNU GPL v2; see accompanying LICENSE file
dnl
dnl ORACLE
dnl
AC_DEFUN([ORACLE], [

# Client.
#
AC_MSG_CHECKING([for oracle client program])
AC_ARG_WITH(
  [oracle-client],
  [AC_HELP_STRING([--with-oracle-client=PATH], [Oracle client program path (sqlplus by default)])],
  [case $withval in
     yes)
       oracle_client=sqlplus
       ;;
     no)
       AC_MSG_RESULT([])
       AC_MSG_ERROR([need oracle client to run the tests])
       ;;
     *)
       oracle_client=$withval
       ;;
   esac],
  [oracle_client=sqlplus])

$oracle_client -V 2>/dev/null 1>&2

if test x"$?" = x0; then
  AC_MSG_RESULT([$oracle_client])
else
  AC_MSG_RESULT([no])
  AC_MSG_ERROR([oracle client is not found; consider using --with-oracle-client=PATH])
fi

# User.
#
AC_MSG_CHECKING([for oracle database user])
AC_ARG_WITH(
  [oracle-user],
  [AC_HELP_STRING([--with-oracle-user=NAME], [Oracle database user (odb_test by default)])],
  [case $withval in
     yes)
       oracle_user=odb_test
       oracle_user_set=yes
       ;;
     no)
       oracle_user_set=no
       ;;
     *)
       oracle_user=$withval
       oracle_user_set=yes
       ;;
   esac],
  [oracle_user=odb_test
   oracle_user_set=yes])

if test x$oracle_user_set = xyes; then
  AC_MSG_RESULT(['$oracle_user'])
else
  AC_MSG_RESULT([none])
fi

# Password.
#
AC_MSG_CHECKING([for oracle database password])
AC_ARG_WITH(
  [oracle-password],
  [AC_HELP_STRING([--with-oracle-password=PASS], [Oracle database password (odb_test by default)])],
  [case $withval in
     yes)
       oracle_password=odb_test
       oracle_password_set=yes
       ;;
     no)
       oracle_password_set=no
       ;;
     *)
       oracle_password=$withval
       oracle_password_set=yes
       ;;
   esac],
  [oracle_password_set=no])

if test x$oracle_password_set = xyes; then
  AC_MSG_RESULT(['$oracle_password'])
elif test x$oracle_user = xodb_test; then
  oracle_password=odb_test
  oracle_password_set=yes
  AC_MSG_RESULT(['$oracle_password'])
elif test x$oracle_user != x/; then
  AC_MSG_RESULT([none])
  AC_MSG_ERROR([password not specified; Oracle requires a password (--with-oracle-password=PASS)])
fi

# Service name.
#
AC_MSG_CHECKING([for oracle service name])
AC_ARG_WITH(
  [oracle-service],
  [AC_HELP_STRING([--with-oracle-service=NAME], [Oracle service name (default service if left empty). Note that all data associated with this user on this service WILL BE LOST!])],
  [case $withval in
     yes)
       oracle_service=
       oracle_service_set=yes
       ;;
     no)
       oracle_service_set=no
       ;;
     *)
       oracle_service=$withval
       oracle_service_set=yes
       ;;
   esac],
  [oracle_service_set=no])

if test x$oracle_service_set = xyes; then
  AC_MSG_RESULT(['$oracle_service'])
else
  AC_MSG_RESULT([default])
fi

# Host.
#
AC_MSG_CHECKING([for oracle database host])
AC_ARG_WITH(
  [oracle-host],
  [AC_HELP_STRING([--with-oracle-host=HOST], [Oracle database host (localhost by default)])],
  [case $withval in
     yes)
       oracle_host=localhost
       oracle_host_set=yes
       ;;
     no)
       oracle_host_set=no
       ;;
     *)
       oracle_host=$withval
       oracle_host_set=yes
       ;;
   esac],
  [oracle_host_set=no])

if test x$oracle_host_set = xyes; then
  AC_MSG_RESULT(['$oracle_host'])
else
  AC_MSG_RESULT([localhost])
fi

# Port.
#
AC_MSG_CHECKING([for oracle database port])
AC_ARG_WITH(
  [oracle-port],
  [AC_HELP_STRING([--with-oracle-port=PORT], [Oracle database port (standard Oracle port by default)])],
  [case $withval in
     yes)
       oracle_port=1521
       oracle_port_set=yes
       ;;
     no)
       oracle_port_set=no
       ;;
     *)
       oracle_port=$withval
       oracle_port_set=yes
       ;;
   esac],
  [oracle_port_set=no])

if test x$oracle_port_set = xyes; then
  AC_MSG_RESULT(['$oracle_port'])
else
  AC_MSG_RESULT([default])
fi

# Create options file.
#
AC_CONFIG_COMMANDS([oracle.options],
 [
   rm -f oracle.options
   echo '#! /bin/sh' >oracle-driver

   echo 'conn_str=' >>oracle-driver

   if test x$oracle_user_set = xyes; then
     echo "--user '$oracle_user'" >>oracle.options
     echo 'conn_str="'"$oracle_user"'"' >>oracle-driver
   fi

   if test x$oracle_password_set = xyes; then
     echo "--password '$oracle_password'" >>oracle.options
     echo 'conn_str="$conn_str/'"$oracle_password"'"' >>oracle-driver
   fi

   if test x$oracle_host_set = xyes; then
     echo "--host '$oracle_host'" >>oracle.options
     echo 'conn_str="$conn_str@//'"$oracle_host"'"' >>oracle-driver

     if test x$oracle_port_set = xyes; then
       echo "--port '$oracle_port'" >>oracle.options
       echo 'conn_str="$conn_str:'"$oracle_port"'"' >>oracle-driver
     fi
   fi

   if test x$oracle_service != x; then
     if test x$oracle_host_set = xno; then
       echo 'conn_str="$conn_str@"' >>oracle-driver
     fi

     echo "--service '$oracle_service'" >>oracle.options
     echo 'conn_str="$conn_str/'"$oracle_service"'"' >>oracle-driver
   fi

   echo 'if test x$[]1 != x; then' >>oracle-driver
   echo "  exec $oracle_client -L -S "'$conn_str @$[]1' >>oracle-driver
   echo "else" >>oracle-driver
   echo "  exec $oracle_client -L -S "'$conn_str' >>oracle-driver
   echo "fi" >>oracle-driver

   chmod +x oracle-driver
 ],
 [
  oracle_client="$oracle_client"

  oracle_user="$oracle_user"
  oracle_user_set="$oracle_user_set"

  oracle_password="$oracle_password"
  oracle_password_set="$oracle_password_set"

  oracle_service="$oracle_service"
  oracle_service_set="$oracle_service_set"

  oracle_host="$oracle_host"
  oracle_host_set="$oracle_host_set"

  oracle_port="$oracle_port"
  oracle_port_set="$oracle_port_set"
 ])

])dnl