Skip to content

Commit

Permalink
Merge pull request #9083 from catap/iodbc
Browse files Browse the repository at this point in the history
lib/odbc: use iodbc when available

OTP-19456
  • Loading branch information
IngelaAndin authored Jan 29, 2025
2 parents 9233927 + bef3a2e commit 7fe79a1
Showing 1 changed file with 37 additions and 6 deletions.
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

0 comments on commit 7fe79a1

Please sign in to comment.