File 1521-lib-odbc-use-iodbc-when-available.patch of Package erlang

From 4322185fc3ee84e531e54db18d66bb6204cd6f81 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Mon, 18 Nov 2024 18:29:24 +0100
Subject: [PATCH 1/2] lib/odbc: use iodbc when available

iodbc has the same API and it migth be tricky to install both iodbc and
unixodbc on the same machine.

Let allow to build erlang with iodbc as well.
---
 lib/odbc/configure.ac | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/odbc/configure.ac b/lib/odbc/configure.ac
index 75cd3b3148..eaee31e5f6 100644
--- a/lib/odbc/configure.ac
+++ b/lib/odbc/configure.ac
@@ -161,7 +161,10 @@ 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])
+               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
         ],
 
         [haiku*],
@@ -171,6 +174,9 @@ AS_CASE([$host_os],
                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])
+               if test $odbc_lib_link_success = no; then
+                  AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes])
+               fi
         ],
 
         [win32|cygwin],
@@ -228,6 +234,9 @@ AS_CASE([$host_os],
 			else
 			    AC_MSG_RESULT($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
 			fi
                     ],
 
@@ -235,6 +244,9 @@ AS_CASE([$host_os],
 			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_lib_link_success = no; then
+			   AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes])
+			fi
                     ])
         ])
 
-- 
2.43.0

openSUSE Build Service is sponsored by