From 5eb3f884118a9bcac4fcb609b264ac858ea0e5f0 Mon Sep 17 00:00:00 2001 From: "Kirill A. Korinsky" 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 | 201 +++++++++++++++++++++++++++++++++++++++++- lib/odbc/configure.ac | 14 ++- 2 files changed, 213 insertions(+), 2 deletions(-) diff --git a/lib/odbc/configure b/lib/odbc/configure index aad3e087067c..b5d1ad644586 100755 --- a/lib/odbc/configure +++ b/lib/odbc/configure @@ -5683,10 +5683,60 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iodbc_SQLAllocHandle" >&5 printf "%s\n" "$ac_cv_lib_iodbc_SQLAllocHandle" >&6; } if test "x$ac_cv_lib_iodbc_SQLAllocHandle" = xyes +then : + ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes +fi + + if test $odbc_lib_link_success = no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -lodbc" >&5 +printf %s "checking for SQLAllocHandle in -lodbc... " >&6; } +if test ${ac_cv_lib_odbc_SQLAllocHandle+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lodbc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char SQLAllocHandle (void); +int +main (void) +{ +return SQLAllocHandle (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_odbc_SQLAllocHandle=yes +else case e in #( + e) ac_cv_lib_odbc_SQLAllocHandle=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_odbc_SQLAllocHandle" >&5 +printf "%s\n" "$ac_cv_lib_odbc_SQLAllocHandle" >&6; } +if test "x$ac_cv_lib_odbc_SQLAllocHandle" = xyes then : ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes fi + fi ;; #( haiku*) : @@ -5741,6 +5791,56 @@ then : ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes fi + if test $odbc_lib_link_success = no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -liodbc" >&5 +printf %s "checking for SQLAllocHandle in -liodbc... " >&6; } +if test ${ac_cv_lib_iodbc_SQLAllocHandle+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-liodbc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char SQLAllocHandle (void); +int +main (void) +{ +return SQLAllocHandle (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_iodbc_SQLAllocHandle=yes +else case e in #( + e) ac_cv_lib_iodbc_SQLAllocHandle=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iodbc_SQLAllocHandle" >&5 +printf "%s\n" "$ac_cv_lib_iodbc_SQLAllocHandle" >&6; } +if test "x$ac_cv_lib_iodbc_SQLAllocHandle" = xyes +then : + ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes +fi + + fi ;; #( win32|cygwin) : @@ -5959,6 +6059,56 @@ then : ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes fi + if test $odbc_lib_link_success = no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -liodbc" >&5 +printf %s "checking for SQLAllocHandle in -liodbc... " >&6; } +if test ${ac_cv_lib_iodbc_SQLAllocHandle+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-liodbc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char SQLAllocHandle (void); +int +main (void) +{ +return SQLAllocHandle (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_iodbc_SQLAllocHandle=yes +else case e in #( + e) ac_cv_lib_iodbc_SQLAllocHandle=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iodbc_SQLAllocHandle" >&5 +printf "%s\n" "$ac_cv_lib_iodbc_SQLAllocHandle" >&6; } +if test "x$ac_cv_lib_iodbc_SQLAllocHandle" = xyes +then : + ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes +fi + + fi fi ;; #( *) : @@ -6013,6 +6163,56 @@ then : ODBC_LIB="$ODBC_LIB -lodbc"; odbc_lib_link_success=yes fi + if test $odbc_lib_link_success = no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -liodbc" >&5 +printf %s "checking for SQLAllocHandle in -liodbc... " >&6; } +if test ${ac_cv_lib_iodbc_SQLAllocHandle+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-liodbc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char SQLAllocHandle (void); +int +main (void) +{ +return SQLAllocHandle (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_iodbc_SQLAllocHandle=yes +else case e in #( + e) ac_cv_lib_iodbc_SQLAllocHandle=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iodbc_SQLAllocHandle" >&5 +printf "%s\n" "$ac_cv_lib_iodbc_SQLAllocHandle" >&6; } +if test "x$ac_cv_lib_iodbc_SQLAllocHandle" = xyes +then : + ODBC_LIB="$ODBC_LIB -liodbc"; odbc_lib_link_success=yes +fi + + fi ;; esac ;; @@ -7265,4 +7465,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi - diff --git a/lib/odbc/configure.ac b/lib/odbc/configure.ac index 75cd3b3148b4..eaee31e5f6bf 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 ]) ]) From baa987515ca2e42e635082c9f0661e182a99bc63 Mon Sep 17 00:00:00 2001 From: "Kirill A. Korinsky" Date: Tue, 19 Nov 2024 13:27:48 +0100 Subject: [PATCH 2/2] lib/odbc: respect --with-odbc=PATH --- lib/odbc/configure | 61 ++++++++++++++++++++++++++++--------------- lib/odbc/configure.ac | 29 ++++++++++++++++---- 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/lib/odbc/configure b/lib/odbc/configure index b5d1ad644586..f8f6160f28c3 100755 --- a/lib/odbc/configure +++ b/lib/odbc/configure @@ -4944,26 +4944,6 @@ then : fi - for ac_header in sql.h sqlext.h -do : - as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | sed "$as_sed_sh"` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_WINDOWS_H - # include - #endif - -" -if eval test \"x\$"$as_ac_Header"\" = x"yes" -then : - cat >>confdefs.h <<_ACEOF -#define `printf "%s\n" "HAVE_$ac_header" | sed "$as_sed_cpp"` 1 -_ACEOF - odbc_required_headers=yes -else case e in #( - e) odbc_required_headers=no ;; -esac -fi - -done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 printf %s "checking for an ANSI C-conforming const... " >&6; } @@ -5639,6 +5619,8 @@ case $host_os in #( ODBC_INCLUDE="-I$with_odbc/include" fi + save_LIBS="$LIBS" + LIBS="$LIBS $ODBC_LIB" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -liodbc" >&5 printf %s "checking for SQLAllocHandle in -liodbc... " >&6; } if test ${ac_cv_lib_iodbc_SQLAllocHandle+y} @@ -5737,13 +5719,16 @@ then : fi fi + LIBS="$save_LIBS" ;; #( haiku*) : TARGET_FLAGS="-DUNIX" ODBC_LIB= -L"/system/lib" ODBC_INCLUDE="-I/system/develop/headers" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -lodbc" >&5 + save_LIBS="$LIBS" + LIBS="$LIBS $ODBC_LIB" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -lodbc" >&5 printf %s "checking for SQLAllocHandle in -lodbc... " >&6; } if test ${ac_cv_lib_odbc_SQLAllocHandle+y} then : @@ -5841,6 +5826,7 @@ then : fi fi + LIBS="$save_LIBS" ;; #( win32|cygwin) : @@ -5894,6 +5880,8 @@ fi ODBC_LIB=-L"$with_odbc/lib" ODBC_INCLUDE="-I$with_odbc/include" fi + save_LIBS="$LIBS" + LIBS="$LIBS $ODBC_LIB" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for main in -lodbc32" >&5 printf %s "checking for main in -lodbc32... " >&6; } if test ${ac_cv_lib_odbc32_main+y} @@ -5933,6 +5921,7 @@ then : ODBC_LIB="$ODBC_LIB -lodbc32"; odbc_lib_link_success=yes fi + LIBS="$save_LIBS" ;; #( *) : @@ -6011,6 +6000,8 @@ printf "%s\n" "$as_me: WARNING: No odbc library found skipping odbc" >&2;} else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ODBC_LIB" >&5 printf "%s\n" "$ODBC_LIB" >&6; } + save_LIBS="$LIBS" + LIBS="$LIBS $ODBC_LIB" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -lodbc" >&5 printf %s "checking for SQLAllocHandle in -lodbc... " >&6; } if test ${ac_cv_lib_odbc_SQLAllocHandle+y} @@ -6109,12 +6100,15 @@ then : fi fi + LIBS="$save_LIBS" fi ;; #( *) : ODBC_LIB=-L"$with_odbc/lib" ODBC_INCLUDE="-I$with_odbc/include" + save_LIBS="$LIBS" + LIBS="$LIBS $ODBC_LIB" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SQLAllocHandle in -lodbc" >&5 printf %s "checking for SQLAllocHandle in -lodbc... " >&6; } if test ${ac_cv_lib_odbc_SQLAllocHandle+y} @@ -6213,11 +6207,36 @@ then : fi fi + LIBS="$save_LIBS" ;; esac ;; esac +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $ODBC_INCLUDE" + for ac_header in sql.h sqlext.h +do : + as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | sed "$as_sed_sh"` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_WINDOWS_H + # include + #endif + +" +if eval test \"x\$"$as_ac_Header"\" = x"yes" +then : + cat >>confdefs.h <<_ACEOF +#define `printf "%s\n" "HAVE_$ac_header" | sed "$as_sed_cpp"` 1 +_ACEOF + odbc_required_headers=yes +else case e in #( + e) odbc_required_headers=no ;; +esac +fi + +done +CFLAGS="$save_CFLAGS" + if test $odbc_required_headers = no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: \"ODBC library - header check failed\"" >&5 printf "%s\n" "$as_me: WARNING: \"ODBC library - header check failed\"" >&2;} diff --git a/lib/odbc/configure.ac b/lib/odbc/configure.ac index eaee31e5f6bf..1fc71f8b28fc 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 - #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 + #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