Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/odbc: use iodbc when available #9083

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions lib/odbc/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ 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
Expand Down Expand Up @@ -161,7 +156,13 @@ AS_CASE([$host_os],
ODBC_INCLUDE="-I$with_odbc/include"
fi

AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
save_LIBS="$LIBS"
LIBS="$LIBS $ODBC_LIB"
AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes])
if test $odbc_lib_link_success = no; then
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
fi
LIBS="$save_LIBS"
],

[haiku*],
Expand All @@ -170,7 +171,13 @@ AS_CASE([$host_os],
ODBC_LIB= -L"/system/lib"
ODBC_INCLUDE="-I/system/develop/headers"
dnl Haiku's package manager will deal with this for us
save_LIBS="$LIBS"
LIBS="$LIBS $ODBC_LIB"
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
if test $odbc_lib_link_success = no; then
AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes])
fi
LIBS="$save_LIBS"
],

[win32|cygwin],
Expand All @@ -184,7 +191,10 @@ AS_CASE([$host_os],
ODBC_LIB=-L"$with_odbc/lib"
ODBC_INCLUDE="-I$with_odbc/include"
fi
save_LIBS="$LIBS"
LIBS="$LIBS $ODBC_LIB"
AC_CHECK_LIB(odbc32, main, [ODBC_LIB="$ODBC_LIB -lodbc32"; odbc_lib_link_success=yes])
LIBS="$save_LIBS"
],

[
Expand Down Expand Up @@ -227,17 +237,38 @@ AS_CASE([$host_os],
echo "No odbc library found" > "$ERL_TOP/lib/odbc/SKIP"
else
AC_MSG_RESULT($ODBC_LIB)
save_LIBS="$LIBS"
LIBS="$LIBS $ODBC_LIB"
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
if test $odbc_lib_link_success = no; then
AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes])
fi
LIBS="$save_LIBS"
fi
],

[
ODBC_LIB=-L"$with_odbc/lib"
ODBC_INCLUDE="-I$with_odbc/include"
save_LIBS="$LIBS"
LIBS="$LIBS $ODBC_LIB"
AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes])
if test $odbc_lib_link_success = no; then
AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes])
fi
LIBS="$save_LIBS"
])
])

save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $ODBC_INCLUDE"
AC_CHECK_HEADERS([sql.h sqlext.h], [odbc_required_headers=yes], [odbc_required_headers=no],
[[#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
]])
CFLAGS="$save_CFLAGS"

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
Expand Down
Loading