@@ -6,75 +6,97 @@ PHP_ARG_WITH(curl, for cURL support,
6
6
[ --with-curl[ =DIR] Include cURL support] )
7
7
8
8
if test "$PHP_CURL" != "no"; then
9
- if test -r $PHP_CURL/include/curl/easy.h; then
10
- CURL_DIR=$PHP_CURL
9
+ if test -z "$PKG_CONFIG"; then
10
+ AC_PATH_PROG ( PKG_CONFIG , pkg-config , no )
11
+ fi
12
+
13
+ if test -x "$PKG_CONFIG"; then
14
+ dnl using pkg-config output
15
+
16
+ AC_MSG_CHECKING ( for libcurl.pc )
17
+ if test "$PHP_CURL" == "yes"; then
18
+ PKNAME=libcurl
19
+ AC_MSG_RESULT ( using default path )
20
+ elif test -r $PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc; then
21
+ PKNAME=$PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc
22
+ AC_MSG_RESULT ( using $PKNAME )
23
+ elif test -r $PHP_CURL/lib/pkgconfig/libcurl.pc; then
24
+ PKNAME=$PHP_CURL/lib/pkgconfig/libcurl.pc
25
+ AC_MSG_RESULT ( using $PKNAME )
26
+ else
27
+ AC_MSG_ERROR ( Could not find libcurl.pc )
28
+ fi
29
+
30
+ AC_MSG_CHECKING ( for cURL 7.10.5 or greater )
31
+ if $PKG_CONFIG --atleast-version 7.10.5 $PKNAME; then
32
+ curl_version_full=`$PKG_CONFIG --modversion $PKNAME`
33
+ AC_MSG_RESULT ( $curl_version_full )
34
+ else
35
+ AC_MSG_ERROR ( cURL version 7.10.5 or later is required to compile php with cURL support )
36
+ fi
37
+
38
+ CURL_LIBS=`$PKG_CONFIG --libs $PKNAME`
39
+ CURL_INCL=`$PKG_CONFIG --cflags $PKNAME`
40
+ CURL_SSL=`$PKG_CONFIG --variable=supported_features $PKNAME| $EGREP SSL`
11
41
else
12
- AC_MSG_CHECKING ( for cURL in default path )
13
- for i in /usr/local /usr; do
14
- if test -r $i/include/curl/easy.h; then
15
- CURL_DIR=$i
16
- AC_MSG_RESULT ( found in $i )
17
- break
18
- fi
19
- done
42
+ dnl fallback to old vay, using curl-config
43
+
44
+ if test -r $PHP_CURL/include/curl/easy.h; then
45
+ CURL_DIR=$PHP_CURL
46
+ else
47
+ AC_MSG_CHECKING ( for cURL in default path )
48
+ for i in /usr/local /usr; do
49
+ if test -r $i/include/curl/easy.h; then
50
+ CURL_DIR=$i
51
+ AC_MSG_RESULT ( found in $i )
52
+ break
53
+ fi
54
+ done
55
+ fi
56
+
20
57
if test -z "$CURL_DIR"; then
21
58
AC_MSG_RESULT ( not found )
22
- if which dpkg-architecture>/dev/null; then
23
- AC_MSG_CHECKING ( for cURL in multiarch path )
24
- CURL_MULTIARCH_INCLUDE=/usr/include/$(dpkg-architecture -qDEB_HOST_MULTIARCH)
25
- if test -r $CURL_MULTIARCH_INCLUDE/curl/easy.h; then
26
- CURL_DIR=/usr
27
- AC_MSG_RESULT ( found in $CURL_MULTIARCH_INCLUDE )
28
- else
29
- AC_MSG_RESULT ( not found )
30
- fi
31
- fi
59
+ AC_MSG_ERROR ( Please reinstall the libcurl distribution -
60
+ easy.h should be in <curl-dir>/include/curl/ )
32
61
fi
33
- fi
34
62
35
- if test -z "$CURL_DIR"; then
36
- AC_MSG_ERROR ( Could not find cURL , please reinstall the libcurl distribution -
37
- easy.h should be in <curl-dir>/include/curl/ )
38
- fi
63
+ CURL_CONFIG="curl-config"
64
+ AC_MSG_CHECKING ( for cURL 7.10.5 or greater )
39
65
40
- CURL_CONFIG="curl-config"
41
- AC_MSG_CHECKING ( for cURL 7.10.5 or greater )
66
+ if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
67
+ CURL_CONFIG=${CURL_DIR}/bin/curl-config
68
+ else
69
+ if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then
70
+ CURL_CONFIG=${CURL_DIR}/curl-config
71
+ fi
72
+ fi
42
73
43
- if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
44
- CURL_CONFIG=${CURL_DIR}/bin/curl-config
45
- else
46
- if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then
47
- CURL_CONFIG=${CURL_DIR}/curl-config
74
+ curl_version_full=`$CURL_CONFIG --version`
75
+ curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
76
+ if test "$curl_version" -ge 7010005; then
77
+ AC_MSG_RESULT ( $curl_version_full )
78
+ CURL_LIBS=`$CURL_CONFIG --libs`
79
+ CURL_INCL=`$CURL_CONFIG --cflags`
80
+ CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
81
+ else
82
+ AC_MSG_ERROR ( cURL version 7.10.5 or later is required to compile php with cURL support )
48
83
fi
49
84
fi
50
85
51
- curl_version_full=`$CURL_CONFIG --version`
52
- curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
53
- if test "$curl_version" -ge 7010005; then
54
- AC_MSG_RESULT ( $curl_version_full )
55
- CURL_LIBS=`$CURL_CONFIG --libs`
56
- else
57
- AC_MSG_ERROR ( cURL version 7.10.5 or later is required to compile php with cURL support )
58
- fi
86
+ dnl common stuff (pkg-config / curl-config)
59
87
60
- if test -z "$CURL_MULTIARCH_INCLUDE"; then
61
- PHP_ADD_INCLUDE($CURL_DIR/include)
62
- else
63
- PHP_ADD_INCLUDE($CURL_MULTIARCH_INCLUDE)
64
- fi
65
88
PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
66
- PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR , CURL_SHARED_LIBADD)
89
+ PHP_EVAL_INCLINE($CURL_INCL , CURL_SHARED_LIBADD)
67
90
68
91
AC_MSG_CHECKING ( [ for SSL support in libcurl] )
69
- CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
70
- if test "$CURL_SSL" = "SSL"; then
92
+ if test -n "$CURL_SSL"; then
71
93
AC_MSG_RESULT ( [ yes] )
72
94
AC_DEFINE ( [ HAVE_CURL_SSL] , [ 1] , [ Have cURL with SSL support] )
73
95
74
96
save_CFLAGS="$CFLAGS"
75
- CFLAGS="`$CURL_CONFIG --cflags`"
76
- save_LDFLAGS="$LDFLAGS "
77
- LDFLAGS="`$CURL_CONFIG --libs`"
97
+ CFLAGS=$CURL_INCL
98
+ save_LDFLAGS="$CFLAGS "
99
+ LDFLAGS=$CURL_LIBS
78
100
79
101
AC_PROG_CPP
80
102
AC_MSG_CHECKING ( [ for openssl support in libcurl] )
@@ -145,21 +167,21 @@ int main(int argc, char *argv[])
145
167
] ,[
146
168
AC_MSG_ERROR ( There is something wrong. Please check config.log for more information. )
147
169
] ,[
148
- $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
170
+ $CURL_LIBS
149
171
] )
150
172
151
173
PHP_CHECK_LIBRARY(curl,curl_easy_strerror,
152
174
[
153
175
AC_DEFINE ( HAVE_CURL_EASY_STRERROR ,1 ,[ ] )
154
176
] ,[ ] ,[
155
- $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
177
+ $CURL_LIBS
156
178
] )
157
179
158
180
PHP_CHECK_LIBRARY(curl,curl_multi_strerror,
159
181
[
160
182
AC_DEFINE ( HAVE_CURL_MULTI_STRERROR ,1 ,[ ] )
161
183
] ,[ ] ,[
162
- $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
184
+ $CURL_LIBS
163
185
] )
164
186
165
187
PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
0 commit comments