Skip to content

Commit de96953

Browse files
committed
ext/curl: port to pkg-config macro and consistently require its use
curl 7.15.1 in December 2006 first added pkg-config support, which is earlier than the minimum supported version for php. This should therefore be uiversally supported.
1 parent 50e7e3a commit de96953

File tree

2 files changed

+18
-86
lines changed

2 files changed

+18
-86
lines changed

ext/curl/config.m4

Lines changed: 18 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,35 @@
11
dnl config.m4 for extension curl
22

33
PHP_ARG_WITH(curl, for cURL support,
4-
[ --with-curl[=DIR] Include cURL support])
4+
[ --with-curl Include cURL support])
55

66
if test "$PHP_CURL" != "no"; then
7-
if test -z "$PKG_CONFIG"; then
8-
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
9-
fi
10-
11-
if test -x "$PKG_CONFIG"; then
12-
dnl using pkg-config output
13-
14-
AC_MSG_CHECKING(for libcurl.pc)
15-
if test "$PHP_CURL" = "yes" -o "$PHP_CURL" = "/usr"; then
16-
PKNAME=libcurl
17-
AC_MSG_RESULT(using default path)
18-
elif test -r $PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc; then
19-
PKNAME=$PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc
20-
AC_MSG_RESULT(using $PKNAME)
21-
elif test -r $PHP_CURL/lib/pkgconfig/libcurl.pc; then
22-
PKNAME=$PHP_CURL/lib/pkgconfig/libcurl.pc
23-
AC_MSG_RESULT(using $PKNAME)
24-
else
25-
AC_MSG_RESULT(not found)
26-
AC_MSG_WARN(Could not find libcurl.pc. Try without $PHP_CURL or set PKG_CONFIG_PATH)
27-
fi
28-
fi
29-
30-
if test -n "$PKNAME"; then
31-
AC_MSG_CHECKING(for cURL 7.15.5 or greater)
32-
if $PKG_CONFIG --atleast-version 7.15.5 $PKNAME; then
33-
curl_version_full=`$PKG_CONFIG --modversion $PKNAME`
34-
AC_MSG_RESULT($curl_version_full)
35-
else
36-
AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support)
37-
fi
38-
39-
CURL_LIBS=`$PKG_CONFIG --libs $PKNAME`
40-
CURL_INCL=`$PKG_CONFIG --cflags $PKNAME`
41-
CURL_SSL=`$PKG_CONFIG --variable=supported_features $PKNAME| $EGREP SSL`
42-
else
43-
dnl fallback to old vay, using curl-config
44-
AC_MSG_WARN(Fallback: search for curl headers and curl-config)
45-
46-
if test -r $PHP_CURL/include/curl/easy.h; then
47-
CURL_DIR=$PHP_CURL
48-
else
49-
AC_MSG_CHECKING(for cURL in default path)
50-
for i in /usr/local /usr; do
51-
if test -r $i/include/curl/easy.h; then
52-
CURL_DIR=$i
53-
AC_MSG_RESULT(found in $i)
54-
break
55-
fi
56-
done
57-
fi
58-
59-
if test -z "$CURL_DIR"; then
60-
AC_MSG_RESULT(not found)
61-
AC_MSG_ERROR(Please reinstall the libcurl distribution -
62-
easy.h should be in <curl-dir>/include/curl/)
63-
fi
64-
65-
CURL_CONFIG="curl-config"
66-
AC_MSG_CHECKING(for cURL 7.15.5 or greater)
67-
68-
if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
69-
CURL_CONFIG=${CURL_DIR}/bin/curl-config
70-
else
71-
if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then
72-
CURL_CONFIG=${CURL_DIR}/curl-config
73-
fi
74-
fi
75-
76-
curl_version_full=`$CURL_CONFIG --version`
77-
curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
78-
if test "$curl_version" -ge 7015005; then
79-
AC_MSG_RESULT($curl_version_full)
80-
CURL_LIBS=`$CURL_CONFIG --libs`
81-
CURL_INCL=`$CURL_CONFIG --cflags`
82-
CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
83-
else
84-
AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support)
85-
fi
86-
fi
7+
PKG_CHECK_MODULES([CURL], [libcurl >= 7.15.5], [CURL_FOUND=true],
8+
AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support))
9+
PKG_CHECK_VAR([CURL_FEATURES], [libcurl], [supported_features])
8710

8811
dnl common stuff (pkg-config / curl-config)
8912

9013
PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
91-
PHP_EVAL_INCLINE($CURL_INCL, CURL_SHARED_LIBADD)
14+
PHP_EVAL_INCLINE($CURL_CFLAGS, CURL_SHARED_LIBADD)
9215

9316
AC_MSG_CHECKING([for SSL support in libcurl])
94-
if test -n "$CURL_SSL"; then
95-
AC_MSG_RESULT([yes])
17+
case "$CURL_FEATURES" in
18+
*SSL*)
19+
CURL_SSL=yes
20+
AC_MSG_RESULT([yes])
21+
;;
22+
*)
23+
CURL_SSL=no
24+
AC_MSG_RESULT([no])
25+
;;
26+
esac
27+
28+
if test "$CURL_SSL" = yes; then
9629
AC_DEFINE([HAVE_CURL_SSL], [1], [Have cURL with SSL support])
9730

9831
save_CFLAGS="$CFLAGS"
99-
CFLAGS=$CURL_INCL
32+
CFLAGS=$CURL_CFLAGS
10033
save_LDFLAGS="$LDFLAGS"
10134
LDFLAGS=$CURL_LIBS
10235

travis/compile.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ $TS \
5050
--enable-soap \
5151
--enable-xmlreader \
5252
--with-xsl \
53-
--with-curl=/usr \
5453
--with-tidy \
5554
--with-xmlrpc \
5655
--enable-sysvsem \

0 commit comments

Comments
 (0)