From c61150f6d09b4266073baa5ee301dfd8161003df Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Jan 2023 12:43:19 -0400 Subject: [PATCH 1/4] Cleanup autotools script This massively simplifies the logic, removes spurious messages, and adds support for Seiden Group's libdb400 shim. --- config.m4 | 127 +++++++++++++++++++++++------------------------------- 1 file changed, 53 insertions(+), 74 deletions(-) diff --git a/config.m4 b/config.m4 index db9c189..87f2660 100755 --- a/config.m4 +++ b/config.m4 @@ -9,96 +9,75 @@ PHP_ARG_WITH(pdo-ibm, for DB2 driver for PDO, if test "$PHP_PDO_IBM" != "no"; then SEARCH_PATH="$PHP_PDO_IBM_LIB $PHP_PDO_IBM $DB2PATH $DB2DIR" - AC_MSG_CHECKING(Looking for DB2 CLI libraries) + dnl Scan the library path for LUW, clidriver, and libdb400 in the usual + dnl places, also assuming include/ is in the directory too. for i in $SEARCH_PATH ; do - AC_MSG_CHECKING([ in $i]) - if test -r $i/libdb2.so || test -r $i/libdb2.a || test -r $i/libdb400.a || test -r $i/libdb2.dylib; then - LIB_DIR="$i/" - AC_MSG_RESULT(found) + dnl XXX: The messages kinda suck and don't indicate which path + dnl (combined with AC_MSG_* spew from AC_CHECK_LIB) + dnl XXX: Macros for this? Can these be merged? + + dnl LUW ships its client libraries in lib64/32 (at least on amd64 linux) + PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ + PHP_ADD_LIBPATH($i/lib64, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE($i/include) + break + ], [ + ], "-L$i/lib64" ) + PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ + PHP_ADD_LIBPATH($i/lib32, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE($i/include) break - else - AC_MSG_RESULT() - fi - AC_MSG_CHECKING([ in $i/lib64]) - if test -r $i/lib64/libdb2.so || test -r $i/lib64/libdb2.a || test -r $i/lib64/libdb400.a || test -r $i/lib64/libdb2.dylib ; then - LIB_DIR="$i/lib64/" - AC_MSG_RESULT(found) + ], [ + ], "-L$i/lib32" ) + dnl The standalone clidriver package uses lib/ + PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ + PHP_ADD_LIBPATH($i/lib, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE($i/include) break - else - AC_MSG_RESULT() - fi - AC_MSG_CHECKING([ in $i/lib32]) - if test -r $i/lib32/libdb2.so || test -r $i/lib32/libdb2.a || test -r $i/lib32/libdb400.a || test -r $i/lib32/libdb2.dylib ; then - LIB_DIR="$i/lib32/" - AC_MSG_RESULT(found) + ], [ + ], "-L$i/lib" ) + dnl Special cases for PASE + dnl SG ships a custom libdb400 (with renamed funcs to co-exist w/ ODBC) + dnl it requires some special handling for headers too + PHP_CHECK_LIBRARY(db400sg, LDBDriverConnect, [ + PDO_IBM_PASE=yes + dnl from RPMs libdb400sg-devel and sqlcli-devel + dnl as IBM i doesn't ship SQL/CLI headers w/ PASE (and RPM's in subdir) + PHP_ADD_LIBPATH($i/lib, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db400sg, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli-sg) + PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli) break - else - AC_MSG_RESULT() - fi - AC_MSG_CHECKING([ in $i/lib]) - if test -r $i/lib/libdb2.so || test -r $i/lib/libdb2.a || test -r $i/lib/libdb400.a || test -r $i/lib/libdb2.dylib ; then - LIB_DIR="$i/lib/" - AC_MSG_RESULT(found) + ], [ + ], "-L$i/lib" ) + dnl Probably vanilla libdb400 + dnl XXX: For PASE, libdb400 is likely on the default path + PHP_CHECK_LIBRARY(db400, SQLDriverConnect, [ + PDO_IBM_PASE=yes + dnl from RPM sqlcli-devel + PHP_ADD_LIBPATH($i/lib, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db400, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli) break - else - AC_MSG_RESULT() - fi + ], [ + ], "-L$i/lib" ) done - AC_MSG_CHECKING([for DB2 CLI include files in default path]) - if test -r $LIB_DIR/libdb400.a ; then - dnl PASE doesn't need that, we'll use the sqlcli-devel package. - PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli) - AC_MSG_RESULT([found PASE headers]) - else - dnl but LUW/Connect will - for i in $SEARCH_PATH ; do - AC_MSG_CHECKING([in $i]) - if test -r "$i/include/sqlcli1.h" ; then - PDO_IBM_DIR=$i - AC_MSG_RESULT(found in $i) - break - fi - done - fi - - ifdef([PHP_CHECK_PDO_INCLUDES], - [ - PHP_CHECK_PDO_INCLUDES - ],[ - AC_MSG_CHECKING([for PDO includes]) - if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then - pdo_cv_inc_path=$abs_srcdir/ext - elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then - pdo_cv_inc_path=$abs_srcdir/ext - elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then - pdo_cv_inc_path=$phpincludedir/ext - else - AC_MSG_ERROR([Cannot find php_pdo_driver.h.]) - fi - AC_MSG_RESULT($pdo_cv_inc_path) - ]) + PHP_CHECK_PDO_INCLUDES dnl Don't forget to add additional source files here php_pdo_ibm_sources_core="pdo_ibm.c ibm_driver.c ibm_statement.c" - PHP_ADD_INCLUDE($PDO_IBM_DIR/include) - PHP_ADD_LIBPATH($LIB_DIR, PDO_IBM_SHARED_LIBADD) - AC_MSG_CHECKING(["$LIB_DIR/libdb400.a"]) - if test -r "$LIB_DIR/libdb400.a" ; then - PHP_ADD_LIBRARY(db400, 1, PDO_IBM_SHARED_LIBADD) - AC_MSG_RESULT(found) - else - PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) - AC_MSG_RESULT() - fi - case "$host_alias" in *aix*) CPPFLAGS="$CPPFLAGS -D__H_LOCALEDEF";; esac - if test -r $LIB_DIR/libdb400.a ; then + dnl Convert the includes to __PASE__ (for IBM-shipped GCC) or use AC_DEFINE + if test "$PDO_IBM_PASE" = "yes" ; then PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path -DPASE) else PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path) From f062a3958b13d51611b8bb4ea407a665d1bb443e Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Jan 2023 12:53:55 -0400 Subject: [PATCH 2/4] Also around since 2005 is this function --- config.m4 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.m4 b/config.m4 index 87f2660..d24e862 100755 --- a/config.m4 +++ b/config.m4 @@ -83,10 +83,7 @@ if test "$PHP_PDO_IBM" != "no"; then PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path) fi - ifdef([PHP_ADD_EXTENSION_DEP], - [ - PHP_ADD_EXTENSION_DEP(pdo_ibm, pdo) - ]) + PHP_ADD_EXTENSION_DEP(pdo_ibm, pdo) PHP_SUBST(PDO_IBM_SHARED_LIBADD) From 1f7df432a4851c12b1a87e0886640c2db0918319 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Jan 2023 13:35:50 -0400 Subject: [PATCH 3/4] Remove probably unneeded spurious define kadler points out this wouldn't have triggered on PASE, which should have in theory the same issues as AIX. We'll have to see if this breaks AIX LUW. --- config.m4 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config.m4 b/config.m4 index d24e862..d44d877 100755 --- a/config.m4 +++ b/config.m4 @@ -71,11 +71,6 @@ if test "$PHP_PDO_IBM" != "no"; then dnl Don't forget to add additional source files here php_pdo_ibm_sources_core="pdo_ibm.c ibm_driver.c ibm_statement.c" - case "$host_alias" in - *aix*) - CPPFLAGS="$CPPFLAGS -D__H_LOCALEDEF";; - esac - dnl Convert the includes to __PASE__ (for IBM-shipped GCC) or use AC_DEFINE if test "$PDO_IBM_PASE" = "yes" ; then PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path -DPASE) From ecef0d20b082f9a83b22bd3a5f41fb3dd4ff3e47 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Jan 2023 13:51:18 -0400 Subject: [PATCH 4/4] Skip other bitness libraries for LUW --- config.m4 | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/config.m4 b/config.m4 index d44d877..33fb895 100755 --- a/config.m4 +++ b/config.m4 @@ -17,20 +17,25 @@ if test "$PHP_PDO_IBM" != "no"; then dnl XXX: Macros for this? Can these be merged? dnl LUW ships its client libraries in lib64/32 (at least on amd64 linux) - PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ - PHP_ADD_LIBPATH($i/lib64, PDO_IBM_SHARED_LIBADD) - PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) - PHP_ADD_INCLUDE($i/include) - break - ], [ - ], "-L$i/lib64" ) - PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ - PHP_ADD_LIBPATH($i/lib32, PDO_IBM_SHARED_LIBADD) - PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) - PHP_ADD_INCLUDE($i/include) - break - ], [ - ], "-L$i/lib32" ) + AC_CHECK_SIZEOF([long]) + AC_MSG_CHECKING([if we're on a 64-bit platform]) + AS_IF([test "$ac_cv_sizeof_long" -eq 4],[ + AC_MSG_RESULT([no]) + PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ + PHP_ADD_LIBPATH($i/lib32, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE($i/include) + break + ], [], "-L$i/lib32" ) + ],[ + AC_MSG_RESULT([yes]) + PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ + PHP_ADD_LIBPATH($i/lib64, PDO_IBM_SHARED_LIBADD) + PHP_ADD_LIBRARY(db2, 1, PDO_IBM_SHARED_LIBADD) + PHP_ADD_INCLUDE($i/include) + break + ], [], "-L$i/lib64" ) + ]) dnl The standalone clidriver package uses lib/ PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [ PHP_ADD_LIBPATH($i/lib, PDO_IBM_SHARED_LIBADD)