Skip to content

Commit f819fa8

Browse files
henderkesCopilotmatyhtf
authored
add SWOOLE_ODBC_LIBS variable to config.m4 (#5847)
* add SWOOLE_ODBC_LIBC variable if the odbc library needs more than to link against a single library * unify spaces Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix variable naming with mixed case --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Tianfeng.Han <rango@swoole.com>
1 parent 6184d5c commit f819fa8

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

config.m4

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -642,31 +642,62 @@ EOF
642642
AC_MSG_ERROR([Cannot find header file(s) for pdo_odbc])
643643
fi
644644

645+
if test -n "$SWOOLE_ODBC_LIBS"; then
646+
ODBC_LIBS="$SWOOLE_ODBC_LIBS"
647+
else
648+
ODBC_LIBS="-l$pdo_odbc_def_lib"
649+
fi
650+
645651
PDO_ODBC_INCLUDE="$pdo_odbc_def_cflags -I$PDO_ODBC_INCDIR -DPDO_ODBC_TYPE=\\\"$pdo_odbc_flavour\\\""
646-
PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR -l$pdo_odbc_def_lib"
652+
PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR $ODBC_LIBS"
647653

648654
PHP_EVAL_LIBLINE([$PDO_ODBC_LDFLAGS], [SWOOLE_SHARED_LIBADD])
649655

650656
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$pdo_cv_inc_path $PDO_ODBC_INCLUDE"
651657

652658
dnl Check first for an ODBC 1.0 function to assert that the libraries work
653-
PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLBindCol,
654-
[
655-
dnl And now check for an ODBC 3.0 function to assert that they are *good*
656-
dnl libraries.
657-
PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLAllocHandle,
658-
[], [
659-
AC_MSG_ERROR([
659+
SAVE_LIBS="$LIBS"
660+
LIBS="$LIBS $PDO_ODBC_LDFLAGS"
661+
662+
AC_LINK_IFELSE(
663+
[AC_LANG_PROGRAM(
664+
[[#include <sql.h>
665+
#include <sqlext.h>]],
666+
[[
667+
SQLLEN ind = 0;
668+
char buf[1];
669+
SQLBindCol((SQLHSTMT)0, (SQLUSMALLINT)1, (SQLSMALLINT)SQL_C_CHAR,
670+
(SQLPOINTER)buf, (SQLLEN)sizeof(buf), &ind);
671+
return 0;
672+
]])],
673+
[
674+
dnl And now check for an ODBC 3.0 function to assert that they are *good*
675+
dnl libraries.
676+
AC_LINK_IFELSE(
677+
[AC_LANG_PROGRAM(
678+
[[#include <sql.h>
679+
#include <sqlext.h>]],
680+
[[
681+
SQLHANDLE out = SQL_NULL_HANDLE;
682+
SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_ENV,
683+
(SQLHANDLE)SQL_NULL_HANDLE, &out);
684+
return 0;
685+
]])],
686+
[],
687+
[AC_MSG_ERROR([
660688
Your ODBC library does not appear to be ODBC 3 compatible.
661689
You should consider using iODBC or unixODBC instead, and loading your
662690
libraries as a driver in that environment; it will emulate the
663691
functions required for PDO support.
664-
])], $PDO_ODBC_LDFLAGS)
665-
],[
666-
AC_MSG_ERROR([Your ODBC library does not exist or there was an error. Check config.log for more information])
667-
], $PDO_ODBC_LDFLAGS)
692+
])]
693+
)
694+
],
695+
[AC_MSG_ERROR([Your ODBC library does not exist or there was an error. Check config.log for more information])]
696+
)
697+
698+
LIBS="$SAVE_LIBS"
668699

669-
AC_DEFINE(SW_USE_ODBC, 1, [do we enable swoole-odbc coro support])
700+
AC_DEFINE(SW_USE_ODBC, 1, [do we enable swoole-odbc coro support])
670701
fi
671702

672703
dnl odbc end

0 commit comments

Comments
 (0)