Skip to content

Commit 75b16f6

Browse files
authored
Merge pull request #29 from php/cleanup-m4
Cleanup autotools scripts
2 parents ad6334e + 0a9c66f commit 75b16f6

File tree

1 file changed

+59
-102
lines changed

1 file changed

+59
-102
lines changed

config.m4

Lines changed: 59 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,82 @@
1-
dnl $Id$
2-
dnl config.m4 for extension ibm_db2
3-
4-
dnl Comments in this file start with the string 'dnl'.
5-
dnl Remove where necessary. This file will not work
6-
dnl without editing.
7-
8-
dnl If your extension references something external, use with:
9-
101
PHP_ARG_WITH(IBM_DB2, for IBM_DB2 support,
112
[ --with-IBM_DB2=[DIR] Include IBM DB2 Universal Database and Cloudscape support.
123
DIR is the location of the DB2 application development
134
headers and libraries. Set the PHP_IBM_DB2_LIB
145
environment variable to set the specific location of
156
the DB2 libraries])
167

17-
dnl PHP_ARG_ENABLE(IBM_DB2, whether to enable IBM_DB2 support,
18-
dnl Make sure that the comment is aligned:
19-
dnl [ --enable-IBM_DB2 Enable IBM_DB2 support])
208
if test "$PHP_IBM_DB2" != "no"; then
21-
dnl # checking php 32/64 bit php
22-
AC_MSG_CHECKING(PHP)
23-
if test `php -r 'echo PHP_INT_SIZE;'` = 8; then
24-
machine_bits=64
25-
libDir=lib64
26-
AC_MSG_RESULT(Detected 64-bit PHP)
27-
else
28-
machine_bits=32
29-
libDir=lib32
30-
AC_MSG_RESULT(Detected 32-bit PHP)
31-
fi
32-
AC_MSG_CHECKING(IBM_DB_HOME location)
33-
if test $IBM_DB_HOME ; then
34-
SEARCH_PATH=$IBM_DB_HOME
35-
AC_MSG_RESULT($IBM_DB_HOME)
36-
else
37-
AC_MSG_RESULT(not found)
38-
fi
399
dnl # --with-IBM_DB2 -> check with-path
40-
SEARCH_PATH="$PHP_IBM_DB2_LIB $SEARCH_PATH $PHP_IBM_DB2 $DB2PATH $DB2DIR"
10+
SEARCH_PATH="$PHP_IBM_DB2_LIB $SEARCH_PATH $PHP_IBM_DB2 $IBM_DB_HOME $DB2PATH $DB2DIR"
4111

42-
AC_MSG_CHECKING(Looking for DB2 CLI libraries)
12+
dnl Scan the library path for LUW, clidriver, and libdb400 in the usual
13+
dnl places, also assuming include/ is in the directory too.
4314
for i in $SEARCH_PATH ; do
44-
AC_MSG_CHECKING([ in $i])
45-
if test -r $i/libdb2.so || test -r $i/libdb2.a || test -r $i/libdb400.a || test -r $i/libdb2.dylib ; then
46-
LIB_DIR="$i/"
47-
AC_MSG_RESULT(found)
15+
dnl XXX: The messages kinda suck and don't indicate which path
16+
dnl (combined with AC_MSG_* spew from AC_CHECK_LIB)
17+
dnl XXX: Macros for this? Can these be merged?
18+
19+
dnl LUW ships its client libraries in lib64/32 (at least on amd64 linux)
20+
AC_CHECK_SIZEOF([long])
21+
AC_MSG_CHECKING([if we're on a 64-bit platform])
22+
AS_IF([test "$ac_cv_sizeof_long" -eq 4],[
23+
AC_MSG_RESULT([no])
24+
PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [
25+
PHP_ADD_LIBPATH($i/lib32, IBM_DB2_SHARED_LIBADD)
26+
PHP_ADD_LIBRARY(db2, 1, IBM_DB2_SHARED_LIBADD)
27+
PHP_ADD_INCLUDE($i/include)
28+
break
29+
], [], "-L$i/lib32" )
30+
],[
31+
AC_MSG_RESULT([yes])
32+
PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [
33+
PHP_ADD_LIBPATH($i/lib64, IBM_DB2_SHARED_LIBADD)
34+
PHP_ADD_LIBRARY(db2, 1, IBM_DB2_SHARED_LIBADD)
35+
PHP_ADD_INCLUDE($i/include)
36+
break
37+
], [], "-L$i/lib64" )
38+
])
39+
dnl The standalone clidriver package uses lib/
40+
PHP_CHECK_LIBRARY(db2, SQLDriverConnect, [
41+
PHP_ADD_LIBPATH($i/lib, IBM_DB2_SHARED_LIBADD)
42+
PHP_ADD_LIBRARY(db2, 1, IBM_DB2_SHARED_LIBADD)
43+
PHP_ADD_INCLUDE($i/include)
4844
break
49-
else
50-
AC_MSG_RESULT()
51-
fi
52-
AC_MSG_CHECKING([ in $i/$libDir])
53-
if test -r $i/$libDir/libdb2.so || test -r $i/$libDir/libdb2.a || test -r $i/$libDir/libdb400.a || test -r $i/$libDir/libdb2.dylib ; then
54-
LIB_DIR="$i/$libDir/"
55-
AC_MSG_RESULT(found)
45+
], [
46+
], "-L$i/lib" )
47+
dnl Special cases for PASE
48+
dnl SG ships a custom libdb400 (with renamed funcs to co-exist w/ ODBC)
49+
dnl it requires some special handling for headers too
50+
PHP_CHECK_LIBRARY(db400sg, LDBDriverConnect, [
51+
IBM_DB2_PASE=yes
52+
dnl from RPMs libdb400sg-devel and sqlcli-devel
53+
dnl as IBM i doesn't ship SQL/CLI headers w/ PASE (and RPM's in subdir)
54+
PHP_ADD_LIBPATH($i/lib, IBM_DB2_SHARED_LIBADD)
55+
PHP_ADD_LIBRARY(db400sg, 1, IBM_DB2_SHARED_LIBADD)
56+
PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli-sg)
57+
PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli)
5658
break
57-
else
58-
AC_MSG_RESULT()
59-
fi
60-
AC_MSG_CHECKING([ in $i/lib])
61-
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
62-
LIB_DIR="$i/lib/"
63-
AC_MSG_RESULT(found)
59+
], [
60+
], "-L$i/lib" )
61+
dnl Probably vanilla libdb400
62+
dnl XXX: For PASE, libdb400 is likely on the default path
63+
PHP_CHECK_LIBRARY(db400, SQLDriverConnect, [
64+
IBM_DB2_PASE=yes
65+
dnl from RPM sqlcli-devel
66+
PHP_ADD_LIBPATH($i/lib, IBM_DB2_SHARED_LIBADD)
67+
PHP_ADD_LIBRARY(db400, 1, IBM_DB2_SHARED_LIBADD)
68+
PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli)
6469
break
65-
else
66-
AC_MSG_RESULT()
67-
fi
70+
], [
71+
], "-L$i/lib" )
6872
done
6973

70-
if test -z "$LIB_DIR"; then
71-
AC_MSG_RESULT([not found])
72-
if test $IBM_DB_HOME ; then
73-
AC_MSG_ERROR([Cannot find DB2 CLI libraries. Check if you have set the IBM_DB_HOME environment variable's value correctly])
74-
else
75-
AC_MSG_ERROR([Environment variable IBM_DB_HOME is not set. Set it to your DB2/IBM_Data_Server_Driver installation directory and retry ibm_db2 module install])
76-
fi
77-
fi
78-
79-
if test -r $LIB_DIR/libdb400.a ; then
80-
dnl PASE doesn't need that, we'll use the sqlcli-devel package.
81-
PHP_ADD_INCLUDE(/QOpenSys/pkgs/include/cli)
82-
else
83-
dnl but LUW/Connect will
84-
AC_MSG_CHECKING([for DB2 CLI include files in default path])
85-
for i in $SEARCH_PATH ; do
86-
AC_MSG_CHECKING([in $i])
87-
dnl this is for V8.1 and previous
88-
if test -r "$i/include/sqlcli1.h" ; then
89-
IBM_DB2_DIR=$i
90-
AC_MSG_RESULT(found in $i)
91-
break
92-
fi
93-
done
94-
95-
if test -z "$IBM_DB2_DIR"; then
96-
AC_MSG_RESULT([not found])
97-
AC_MSG_ERROR([Please reinstall the DB2 CLI distribution])
98-
fi
99-
100-
dnl # --with-IBM_DB2 -> add include path
101-
PHP_ADD_INCLUDE($IBM_DB2_DIR/include)
102-
fi
103-
104-
dnl # --with-IBM_DB2 -> check for lib and symbol presence
105-
if test -r $LIB_DIR/libdb400.a ; then
106-
LIBNAME=db400
74+
dnl XXX: Should convert defines from PASE to __PASE__, in line with IBM GCC
75+
if test "$IBM_DB2_PASE" = "yes" ; then
10776
PHP_NEW_EXTENSION(ibm_db2, ibm_db2.c, $ext_shared,,-DPASE)
10877
else
109-
LIBNAME=db2
11078
PHP_NEW_EXTENSION(ibm_db2, ibm_db2.c, $ext_shared)
11179
fi
112-
LIBSYMBOL=SQLConnect
113-
114-
dnl # PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
115-
dnl # [
116-
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIB_DIR , IBM_DB2_SHARED_LIBADD)
117-
AC_DEFINE(HAVE_DB2CLILIB,1,[ ])
118-
dnl # ],[
119-
dnl # AC_MSG_ERROR([wrong DB2 CLI lib version or lib not found])
120-
dnl # ],[
121-
dnl # -L$IBM_DB2_DIR/lib -lm -ldl
122-
dnl # ])
12380

12481
PHP_SUBST(IBM_DB2_SHARED_LIBADD)
12582
fi

0 commit comments

Comments
 (0)