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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
dnl
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 2005-2021. All Rights Reserved.
dnl
dnl Licensed under the Apache License, Version 2.0 (the "License");
dnl you may not use this file except in compliance with the License.
dnl You may obtain a copy of the License at
dnl
dnl http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing, software
dnl distributed under the License is distributed on an "AS IS" BASIS,
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dnl See the License for the specific language governing permissions and
dnl limitations under the License.
dnl
dnl %CopyrightEnd%
dnl
dnl define([AC_CACHE_LOAD], )dnl
dnl define([AC_CACHE_SAVE], )dnl
dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([c_src/odbcserver.c])
AC_PREREQ([2.71])
m4_include([otp.m4])
AC_CONFIG_AUX_DIR([${ERL_TOP}/make/autoconf])
ERL_CANONICAL_SYSTEM_TYPE
AC_ARG_WITH(odbc,
[ --with-odbc=PATH specify location of ODBC include and lib
--with-odbc use ODBC (default)
--without-odbc don't use ODBC])
ERL_XCOMP_SYSROOT_INIT
dnl Checks for programs.
AC_PROG_CC
dnl ---------------------------------------------------------------------
dnl Special windows stuff regarding CFLAGS and details in the environment...
dnl ---------------------------------------------------------------------
LM_WINDOWS_ENVIRONMENT
AC_PROG_MAKE_SET
AC_CHECK_PROGS(LD, ld.sh)
AC_CHECK_TOOL(LD, ld, '$(CC)')
AC_SUBST(LD)
_search_path=/bin:/usr/bin:/usr/local/bin:$PATH
AC_PATH_PROG(RM, rm, false, $_search_path)
if test "$ac_cv_path_RM" = false; then
AC_MSG_ERROR([No 'rm' command found])
fi
_search_path=
AS_IF([test "$with_odbc" = "no"],
[
rm -f "$ERL_TOP/lib/odbc/SKIP"
],
[
dnl "$with_odbc" != "no"
# Sockets
#--------------------------------------------------------------------
# Check for the existence of the -lsocket and -lnsl libraries.
# The order here is important, so that they end up in the right
# order in the command line generated by make. Here are some
# special considerations:
# 1. Use "connect" and "accept" to check for -lsocket, and
# "gethostbyname" to check for -lnsl.
# 2. Use each function name only once: can't redo a check because
# autoconf caches the results of the last check and won't redo it.
# 3. Use -lnsl and -lsocket only if they supply procedures that
# aren't already present in the normal libraries. This is because
# IRIX 5.2 has libraries, but they aren't needed and they're
# bogus: they goof up name resolution if used.
# 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
# To get around this problem, check for both libraries together
# if -lsocket doesn't work by itself.
#--------------------------------------------------------------------
erl_checkBoth=0
AC_CHECK_FUNC(connect, erl_checkSocket=0, erl_checkSocket=1)
AS_IF([test "$erl_checkSocket" = 1],
[
AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket", erl_checkBoth=1)
])
AS_IF([test "$erl_checkBoth" = 1],
[
tk_oldLibs=$LIBS
LIBS="$LIBS -lsocket -lnsl"
AC_CHECK_FUNC(accept, odbc_erl_checkNsl=0, [LIBS=$tk_oldLibs])
])
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
AS_CASE(["$host_os"],
[haiku*],
[
AC_CHECK_LIB(network, socket)
])
dnl Checks for header files.
AC_CHECK_INCLUDES_DEFAULT
AC_PROG_EGREP
AC_CHECK_HEADERS([fcntl.h netdb.h stdlib.h string.h sys/socket.h winsock2.h])
AC_CHECK_HEADERS([windows.h])
AC_CHECK_HEADERS([sql.h sqlext.h], [odbc_required_headers=yes], [odbc_required_headers=no],
[[#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
]])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_addr], [], [],
[#if HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <netinet/in.h>
#endif])
dnl Checks for library functions.
AC_CHECK_FUNCS([memset socket])
# ODBC
$RM -f "$ERL_TOP/lib/odbc/SKIP"
LM_CHECK_THR_LIB
AC_SUBST(THR_DEFS)
AC_SUBST(THR_LIBS)
odbc_lib_link_success=no
AC_SUBST(TARGET_FLAGS)
AS_CASE([$host_os],
[darwin1[[0-9]].*],
[
TARGET_FLAGS="-DUNIX"
if test ! -d "$with_odbc" || test "$with_odbc" = "yes"; then
ODBC_LIB= -L"/usr/local/lib"
ODBC_INCLUDE="-I/usr/local/include"
else
ODBC_LIB=-L"$with_odbc/lib"
ODBC_INCLUDE="-I$with_odbc/include"
fi
AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
],
[haiku*],
[
TARGET_FLAGS="-DUNIX"
ODBC_LIB= -L"/system/lib"
ODBC_INCLUDE="-I/system/develop/headers"
dnl Haiku's package manager will deal with this for us
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
],
[win32|cygwin],
[
TARGET_FLAGS="-DWIN32"
AC_CHECK_LIB(ws2_32, main)
if test ! -d "$with_odbc" || test "$with_odbc" = "yes"; then
ODBC_LIB=""
ODBC_INCLUDE=""
else
ODBC_LIB=-L"$with_odbc/lib"
ODBC_INCLUDE="-I$with_odbc/include"
fi
AC_CHECK_LIB(odbc32, main, [ODBC_LIB="$ODBC_LIB -lodbc32"; odbc_lib_link_success=yes])
],
[
TARGET_FLAGS="-DUNIX"
AS_CASE(["$erl_xcomp_without_sysroot-$with_odbc"],
[yes-yes | yes-],
[
msg="Dont know where to search for odbc (setting erl_xcomp_sysroot will help)"
AC_MSG_WARN([$msg])
echo "$msg" > "$ERL_TOP/lib/odbc/SKIP"
odbc_lib_link_success=wont_try
],
[no-yes | no-],
[
AC_CHECK_SIZEOF(void *)
AC_MSG_CHECKING([for odbc in standard locations])
for rdir in /usr/local/odbc /usr/local /usr/odbc \
/usr /opt/local/pgm/odbc /usr/local/pgm/odbc \
"$with_odbc"; do
test -f "$erl_xcomp_isysroot$rdir/include/sql.h" || continue
is_odbc_std_location=yes
libdir="$erl_xcomp_sysroot$rdir/lib"
if test "$ac_cv_sizeof_void_p" = "8"; then
dnl "/." in test is important (dir symlinks)
if test -d "${libdir}64/."; then
libdir="${libdir}64"
elif test -d "${libdir}/64/."; then
libdir="${libdir}/64"
fi
fi
ODBC_LIB="-L$libdir"
ODBC_INCLUDE="-I$erl_xcomp_isysroot$rdir/include"
break
done
if test "x$is_odbc_std_location" != "xyes"; then
AC_MSG_RESULT(no)
AC_MSG_WARN([No odbc library found skipping odbc])
echo "No odbc library found" > "$ERL_TOP/lib/odbc/SKIP"
else
AC_MSG_RESULT($ODBC_LIB)
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
fi
],
[
ODBC_LIB=-L"$with_odbc/lib"
ODBC_INCLUDE="-I$with_odbc/include"
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
])
])
if test $odbc_required_headers = no; then
AC_MSG_WARN(["ODBC library - header check failed"])
echo "ODBC library - header check failed" > $ERL_TOP/lib/odbc/SKIP
fi
if test $odbc_lib_link_success = no; then
AC_MSG_WARN(["ODBC library - link check failed"])
echo "ODBC library - link check failed" > $ERL_TOP/lib/odbc/SKIP
fi
AC_SUBST(ODBC_LIB)
AC_SUBST(ODBC_INCLUDE)
]) dnl "$with_odbc" != "no"
AS_IF([test "x$GCC" = xyes],
[
# Treat certain GCC warnings as errors
LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
])
AC_CONFIG_FILES([c_src/$host/Makefile:c_src/Makefile.in])
AC_OUTPUT
|