1
1
define ( [ PDO_ODBC_HELP_TEXT] ,[ [
2
- The include and lib dirs are looked for under 'dir'. The 'flavour' can be one
3
- of: ibm-db2, iODBC, unixODBC, generic. If ',dir' part is omitted, default for
4
- the flavour you have selected will be used. e.g.: --with-pdo-odbc=unixODBC
5
- will check for unixODBC under /usr/local. You may attempt to use an otherwise
6
- unsupported driver using the 'generic' flavour. The syntax for generic ODBC
7
- support is: --with-pdo-odbc=generic,dir,libname,ldflags,cflags. When built as
8
- 'shared' the extension filename is always pdo_odbc.so] ] )
2
+ The 'flavour' part determines what driver or driver manager to use; it can be
3
+ either ibm-db2, iODBC, unixODBC, or generic.
4
+
5
+ The include and lib dirs are looked for under 'dir'. You may attempt to use
6
+ an otherwise unsupported driver using the 'generic' flavour. The syntax for
7
+ generic ODBC support is: --with-pdo-odbc=generic,dir,libname,ldflags,cflags.
8
+ When built as 'shared' the extension filename is always 'pdo_odbc.so'.
9
+
10
+ For unixODBC and iODBC, the 'dir' part is ignored and can be omitted, as
11
+ pkg-config will be searched instead. For ibm-db2, it will search for the DB2
12
+ driver at that path.] ] )
9
13
10
14
PHP_ARG_WITH([ pdo-odbc] ,
11
15
[ for ODBC v3 support for PDO] ,
12
16
[ AS_HELP_STRING ( [ --with-pdo-odbc=flavour,dir] ,
13
17
[ PDO: Support for 'flavour' ODBC driver.] PDO_ODBC_HELP_TEXT ) ] )
14
18
15
19
AC_DEFUN ( [ PHP_PDO_ODBC_CHECK_HEADER] ,
16
- [ AC_MSG_CHECKING ( [ for $1 in $PDO_ODBC_INCDIR ] )
17
- AS_IF ( [ test -f "$PDO_ODBC_INCDIR/ $1 " ] , [
20
+ [ AC_MSG_CHECKING ( [ for $1 ] )
21
+ AC_PREPROC_IFELSE ( [ AC_LANG_PROGRAM ( [ #include < $1 > ] , [ ] ) ] , [
18
22
php_pdo_odbc_have_header=yes
19
23
AC_DEFINE_UNQUOTED ( AS_TR_CPP ( [ HAVE_$1 ] ) , [ 1] ,
20
24
[ Define to 1 if you have the <$1 > header file.] )
21
- AC_MSG_RESULT ( [ yes] )
25
+ AC_MSG_RESULT ( [ yes] )
22
26
] ,
23
27
[ AC_MSG_RESULT ( [ no] ) ] )
24
28
] )
@@ -48,15 +52,11 @@ if test "$PHP_PDO_ODBC" != "no"; then
48
52
;;
49
53
50
54
iODBC|iodbc)
51
- pdo_odbc_def_libdir=/usr/local/$PHP_LIBDIR
52
- pdo_odbc_def_incdir=/usr/local/include
53
- pdo_odbc_def_lib=iodbc
55
+ pdo_odbc_pkgconfig_module=libiodbc
54
56
;;
55
57
56
58
unixODBC|unixodbc)
57
- pdo_odbc_def_libdir=/usr/local/$PHP_LIBDIR
58
- pdo_odbc_def_incdir=/usr/local/include
59
- pdo_odbc_def_lib=odbc
59
+ pdo_odbc_pkgconfig_module=odbc
60
60
;;
61
61
62
62
generic)
@@ -71,22 +71,52 @@ if test "$PHP_PDO_ODBC" != "no"; then
71
71
;;
72
72
esac
73
73
74
- if test -n "$pdo_odbc_dir "; then
75
- PDO_ODBC_INCDIR="$pdo_odbc_dir/include"
76
- PDO_ODBC_LIBDIR="$pdo_odbc_dir/$PHP_LIBDIR"
74
+ if test -n "$pdo_odbc_pkgconfig_module "; then
75
+ AC_MSG_RESULT ( [ $pdo_odbc_flavour using pkg-config ] )
76
+ PKG_CHECK_MODULES( [ PDO_ODBC ] , [ $pdo_odbc_pkgconfig_module ] )
77
77
else
78
- PDO_ODBC_INCDIR="$pdo_odbc_def_incdir"
79
- PDO_ODBC_LIBDIR="$pdo_odbc_def_libdir"
78
+ if test -n "$pdo_odbc_dir"; then
79
+ PDO_ODBC_INCDIR="$pdo_odbc_dir/include"
80
+ PDO_ODBC_LIBDIR="$pdo_odbc_dir/$PHP_LIBDIR"
81
+ else
82
+ PDO_ODBC_INCDIR="$pdo_odbc_def_incdir"
83
+ PDO_ODBC_LIBDIR="$pdo_odbc_def_libdir"
84
+ fi
85
+
86
+ AC_MSG_RESULT ( [ $pdo_odbc_flavour
87
+ libs $PDO_ODBC_LIBDIR,
88
+ headers $PDO_ODBC_INCDIR] )
89
+
90
+ if test ! -d "$PDO_ODBC_LIBDIR" ; then
91
+ AC_MSG_WARN ( [ library dir $PDO_ODBC_LIBDIR does not exist] )
92
+ fi
93
+
94
+ PDO_ODBC_CFLAGS="$pdo_odbc_def_cflags -I$PDO_ODBC_INCDIR"
95
+ PDO_ODBC_LIBS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR -l$pdo_odbc_def_lib"
96
+
97
+ dnl Check first for an ODBC 1.0 function to assert that the libraries work
98
+ PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLBindCol,
99
+ [
100
+ dnl And now check for an ODBC 3.0 function to assert that they're *good*
101
+ dnl libraries.
102
+ PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLAllocHandle,
103
+ [ ] , [
104
+ AC_MSG_ERROR ( [
105
+ Your ODBC library does not appear to be ODBC 3 compatible.
106
+ You should consider using iODBC or unixODBC instead, and loading your
107
+ libraries as a driver in that environment; it will emulate the
108
+ functions required for PDO support.
109
+ ] ) ] , $PDO_ODBC_LIBS)
110
+ ] ,[
111
+ AC_MSG_ERROR ( [ Your ODBC library does not exist or there was an error. Check config.log for more information] )
112
+ ] , $PDO_ODBC_LIBS)
80
113
fi
81
114
82
- AC_MSG_RESULT ( [ $pdo_odbc_flavour
83
- libs $PDO_ODBC_LIBDIR,
84
- headers $PDO_ODBC_INCDIR] )
85
-
86
- if test ! -d "$PDO_ODBC_LIBDIR" ; then
87
- AC_MSG_WARN ( [ library dir $PDO_ODBC_LIBDIR does not exist] )
88
- fi
115
+ PHP_EVAL_INCLINE([ $PDO_ODBC_CFLAGS] )
116
+ PHP_EVAL_LIBLINE([ $PDO_ODBC_LIBS] , [ PDO_ODBC_SHARED_LIBADD] )
89
117
118
+ OLD_CPPFLAGS=$CPPFLAGS
119
+ CPPFLAGS="$CPPFLAGS $PDO_ODBC_CFLAGS"
90
120
PHP_PDO_ODBC_CHECK_HEADER([ cli0cli.h] )
91
121
PHP_PDO_ODBC_CHECK_HEADER([ cli0core.h] )
92
122
PHP_PDO_ODBC_CHECK_HEADER([ cli0defs.h] )
@@ -104,33 +134,15 @@ if test "$PHP_PDO_ODBC" != "no"; then
104
134
PHP_PDO_ODBC_CHECK_HEADER([ sqlucode.h] )
105
135
PHP_PDO_ODBC_CHECK_HEADER([ sqlunix.h] )
106
136
PHP_PDO_ODBC_CHECK_HEADER([ udbcext.h] )
137
+ CPPFLAGS=$OLD_CPPFLAGS
107
138
108
139
AS_VAR_IF ( [ php_pdo_odbc_have_header] , [ yes] ,,
109
140
[ AC_MSG_ERROR ( [ Cannot find header file(s) for pdo_odbc.] ) ] )
110
141
111
- PDO_ODBC_INCLUDE="$pdo_odbc_def_cflags -I$PDO_ODBC_INCDIR -DPDO_ODBC_TYPE=\\\"$pdo_odbc_flavour\\\""
112
- PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR -l$pdo_odbc_def_lib"
113
-
114
- PHP_EVAL_LIBLINE([ $PDO_ODBC_LDFLAGS] , [ PDO_ODBC_SHARED_LIBADD] )
115
-
116
- dnl Check first for an ODBC 1.0 function to assert that the libraries work
117
- PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLBindCol,
118
- [
119
- dnl And now check for an ODBC 3.0 function to assert that they're *good*
120
- dnl libraries.
121
- PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLAllocHandle,
122
- [ ] , [
123
- AC_MSG_ERROR ( [
124
- Your ODBC library does not appear to be ODBC 3 compatible.
125
- You should consider using iODBC or unixODBC instead, and loading your
126
- libraries as a driver in that environment; it will emulate the
127
- functions required for PDO support.
128
- ] ) ] , $PDO_ODBC_LDFLAGS)
129
- ] ,[
130
- AC_MSG_ERROR ( [ Your ODBC library does not exist or there was an error. Check config.log for more information] )
131
- ] , $PDO_ODBC_LDFLAGS)
142
+ AC_DEFINE_UNQUOTED ( [ PDO_ODBC_TYPE] , [ "$pdo_odbc_flavour"] ,
143
+ [ Define to the ODBC driver or driver manager value.] )
132
144
133
- PHP_NEW_EXTENSION(pdo_odbc, pdo_odbc.c odbc_driver.c odbc_stmt.c, $ext_shared,, $PDO_ODBC_INCLUDE )
145
+ PHP_NEW_EXTENSION(pdo_odbc, pdo_odbc.c odbc_driver.c odbc_stmt.c, $ext_shared)
134
146
PHP_SUBST([ PDO_ODBC_SHARED_LIBADD] )
135
147
PHP_ADD_EXTENSION_DEP(pdo_odbc, pdo)
136
148
fi
0 commit comments