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
|
dnl file : m4/mssql.m4
dnl copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
dnl MSSQL
dnl
AC_DEFUN([MSSQL], [
# Client.
#
AC_MSG_CHECKING([for mssql client program])
AC_ARG_WITH(
[mssql-client],
[AC_HELP_STRING([--with-mssql-client=PATH], [SQL Server client program path (sqlcmd by default)])],
[case $withval in
yes)
mssql_client=sqlcmd
;;
no)
AC_MSG_RESULT([])
AC_MSG_ERROR([need mssql client to run the tests])
;;
*)
mssql_client=$withval
;;
esac],
[mssql_client=sqlcmd])
$mssql_client -? 2>/dev/null 1>&2
if test x"$?" = x0; then
AC_MSG_RESULT([$mssql_client])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([mssql client is not found; consider using --with-mssql-client=PATH])
fi
# User. If 'no' is specified, then use Windows authentication.
#
AC_MSG_CHECKING([for mssql database user])
AC_ARG_WITH(
[mssql-user],
[AC_HELP_STRING([--with-mssql-user=NAME], [SQL Server database user (odb_test by default)])],
[case $withval in
yes)
mssql_user=odb_test
mssql_user_set=yes
;;
no)
mssql_user_set=no
;;
*)
mssql_user=$withval
mssql_user_set=yes
;;
esac],
[mssql_user=odb_test
mssql_user_set=yes])
if test x$mssql_user_set = xyes; then
AC_MSG_RESULT(['$mssql_user'])
else
AC_MSG_RESULT([none])
fi
# Password. Can be left unspecified if using Windows authentication.
#
AC_MSG_CHECKING([for mssql database password])
AC_ARG_WITH(
[mssql-password],
[AC_HELP_STRING([--with-mssql-password=PASS], [SQL Server database password (odb_test by default)])],
[case $withval in
yes)
mssql_password=odb_test
mssql_password_set=yes
;;
no)
mssql_password_set=no
;;
*)
mssql_password=$withval
mssql_password_set=yes
;;
esac],
[mssql_password_set=no])
if test x$mssql_password_set = xyes; then
AC_MSG_RESULT(['$mssql_password'])
elif test x$mssql_user = xodb_test; then
mssql_password=odb_test
mssql_password_set=yes
AC_MSG_RESULT(['$mssql_password'])
else
AC_MSG_RESULT([none])
if test x$mssql_user_set = xyes; then
AC_MSG_ERROR([password not specified; SQL Server requires a password (--with-mssql-password=PASS)])
fi
fi
# Database. If not specified, use the user's default.
#
AC_MSG_CHECKING([for mssql database name])
AC_ARG_WITH(
[mssql-db],
[AC_HELP_STRING([--with-mssql-db=NAME], [SQL Server database name (odb_test by default). Note that all data in this database WILL BE LOST!])],
[case $withval in
yes)
mssql_db=odb_test
mssql_db_set=yes
;;
no)
mssql_db_set=no
;;
*)
mssql_db=$withval
mssql_db_set=yes
;;
esac],
[mssql_db=odb_test
mssql_db_set=yes])
if test x$mssql_db_set = xyes; then
AC_MSG_RESULT(['$mssql_db'])
else
AC_MSG_RESULT([default])
fi
# Server.
#
AC_MSG_CHECKING([for mssql instance address])
AC_ARG_WITH(
[mssql-server],
[AC_HELP_STRING([--with-mssql-server=ADDR], [SQL Server instance address])],
[case $withval in
yes | no)
mssql_server_set=no
;;
*)
mssql_server=$withval
mssql_server_set=yes
;;
esac],
[mssql_server_set=no])
if test x$mssql_server_set = xyes; then
AC_MSG_RESULT(['$mssql_server'])
else
AC_MSG_RESULT([none])
AC_MSG_ERROR([instance address not specified; SQL Server instance address is required (--with-mssql-server=ADDR)])
fi
# Driver.
#
AC_MSG_CHECKING([for mssql native client odbc driver])
AC_ARG_WITH(
[mssql-driver],
[AC_HELP_STRING([--with-mssql-driver=NAME], [SQL Server Native Client ODBC driver (latest available by default)])],
[case $withval in
yes | no)
mssql_driver_set=no
;;
*)
mssql_driver=$withval
mssql_driver_set=yes
;;
esac],
[mssql_driver_set=no])
if test x$mssql_driver_set = xyes; then
AC_MSG_RESULT(['$mssql_driver'])
else
AC_MSG_RESULT([latest])
fi
# Create options file.
#
AC_CONFIG_COMMANDS([mssql.options],
[
rm -f mssql.options
echo '#! /bin/sh' >mssql-driver
echo 'opt=' >>mssql-driver
if test x$mssql_user_set = xyes; then
echo "--user '$mssql_user'" >>mssql.options
echo 'opt="$opt -U '"$mssql_user"'"' >>mssql-driver
echo "--password '$mssql_password'" >>mssql.options
echo 'opt="$opt -P '"$mssql_password"'"' >>mssql-driver
fi
if test x$mssql_db_set = xyes; then
echo "--database '$mssql_db'" >>mssql.options
echo 'opt="$opt -d '"$mssql_db"'"' >>mssql-driver
fi
echo "--server '$mssql_server'" >>mssql.options
echo 'opt="$opt -S '"$mssql_server"'"' >>mssql-driver
if test x$mssql_driver_set = xyes; then
echo "--driver '$mssql_driver'" >>mssql.options
fi
echo 'opt="$opt -x -r -b"' >>mssql-driver
echo 'if test x$[]1 != x; then' >>mssql-driver
echo " exec $mssql_client "'$opt -i $[]1' >>mssql-driver
echo "else" >>mssql-driver
echo " exec $mssql_client "'$opt' >>mssql-driver
echo "fi" >>mssql-driver
chmod +x mssql-driver
],
[
mssql_client="$mssql_client"
mssql_user="$mssql_user"
mssql_user_set="$mssql_user_set"
mssql_password="$mssql_password"
mssql_db="$mssql_db"
mssql_db_set="$mssql_db_set"
mssql_server="$mssql_server"
mssql_driver="$mssql_driver"
mssql_driver_set="$mssql_driver_set"
])
])dnl
|