File 1522-lib-odbc-respect-with-odbc-PATH.patch of Package erlang

From bef3a2e7345c5b9a2e004693ef3d8cc9cca10607 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Tue, 19 Nov 2024 13:27:48 +0100
Subject: [PATCH 2/2] lib/odbc: respect --with-odbc=PATH

---
 lib/odbc/configure.ac | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/lib/odbc/configure.ac b/lib/odbc/configure.ac
index eaee31e5f6..1fc71f8b28 100644
--- a/lib/odbc/configure.ac
+++ b/lib/odbc/configure.ac
@@ -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
@@ -161,10 +156,13 @@ AS_CASE([$host_os],
 		    ODBC_INCLUDE="-I$with_odbc/include"
 		fi
 
+               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*],
@@ -173,10 +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],
@@ -190,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"
         ],
 
         [
@@ -233,23 +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
-- 
2.43.0

openSUSE Build Service is sponsored by