Skip to content

Commit 91785a7

Browse files
committed
Switch from curl-config to pkg-config for curl extension
First attemp to fix multiarch support (#74125) for curl introduce some debian specificity (dpkg command) so is not suitable for other environmant. This is mostly related to a broken "curl-config" config on debian which doesn't provide the correct build options, while pkg-config works as expected. This new attemp rely on pkg-config output instead. Notice: this make pkg-config a hard dependency. Is there system without pkg-config ?
1 parent debbaba commit 91785a7

File tree

1 file changed

+27
-55
lines changed

1 file changed

+27
-55
lines changed

ext/curl/config.m4

Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,47 @@ PHP_ARG_WITH(curl, for cURL support,
66
[ --with-curl[=DIR] Include cURL support])
77

88
if test "$PHP_CURL" != "no"; then
9-
if test -r $PHP_CURL/include/curl/easy.h; then
10-
CURL_DIR=$PHP_CURL
11-
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
20-
if test -z "$CURL_DIR"; then
21-
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
32-
fi
33-
fi
34-
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/)
9+
if test -z "$PKG_CONFIG"; then
10+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
3811
fi
3912

40-
CURL_CONFIG="curl-config"
41-
AC_MSG_CHECKING(for cURL 7.10.5 or greater)
42-
43-
if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
44-
CURL_CONFIG=${CURL_DIR}/bin/curl-config
13+
AC_MSG_CHECKING(for libcurl.pc)
14+
if test "$PHP_CURL" == "yes"; then
15+
PKNAME=libcurl
16+
AC_MSG_RESULT(using default path)
17+
elif test -r $PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc; then
18+
PKNAME=$PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc
19+
AC_MSG_RESULT(using $PKNAME)
20+
elif test -r $PHP_CURL/lib/pkgconfig/libcurl.pc; then
21+
PKNAME=$PHP_CURL/lib/pkgconfig/libcurl.pc
22+
AC_MSG_RESULT(using $PKNAME)
4523
else
46-
if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then
47-
CURL_CONFIG=${CURL_DIR}/curl-config
48-
fi
24+
AC_MSG_ERROR(Could not find libcurl.pc)
4925
fi
5026

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
27+
AC_MSG_CHECKING(for cURL 7.10.5 or greater)
28+
if test -x "$PKG_CONFIG" && $PKG_CONFIG --atleast-version 7.10.5 $PKNAME; then
29+
curl_version_full=`$PKG_CONFIG --modversion $PKNAME`
5430
AC_MSG_RESULT($curl_version_full)
55-
CURL_LIBS=`$CURL_CONFIG --libs`
5631
else
5732
AC_MSG_ERROR(cURL version 7.10.5 or later is required to compile php with cURL support)
5833
fi
5934

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
35+
CURL_LIBS=`$PKG_CONFIG --libs $PKNAME`
36+
CURL_INCL=`$PKG_CONFIG --cflags $PKNAME`
6537
PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
66-
PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, CURL_SHARED_LIBADD)
38+
PHP_EVAL_INCLINE($CURL_INCL, CURL_SHARED_LIBADD)
6739

6840
AC_MSG_CHECKING([for SSL support in libcurl])
69-
CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
70-
if test "$CURL_SSL" = "SSL"; then
41+
CURL_SSL=`$PKG_CONFIG --variable=supported_features $PKNAME| $EGREP SSL`
42+
if test -n "$CURL_SSL"; then
7143
AC_MSG_RESULT([yes])
7244
AC_DEFINE([HAVE_CURL_SSL], [1], [Have cURL with SSL support])
7345

7446
save_CFLAGS="$CFLAGS"
75-
CFLAGS="`$CURL_CONFIG --cflags`"
76-
save_LDFLAGS="$LDFLAGS"
77-
LDFLAGS="`$CURL_CONFIG --libs`"
47+
CFLAGS=$CURL_INCL
48+
save_LDFLAGS="$CFLAGS"
49+
LDFLAGS=$CURL_LIBS
7850

7951
AC_PROG_CPP
8052
AC_MSG_CHECKING([for openssl support in libcurl])
@@ -145,21 +117,21 @@ int main(int argc, char *argv[])
145117
],[
146118
AC_MSG_ERROR(There is something wrong. Please check config.log for more information.)
147119
],[
148-
$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
120+
$CURL_LIBS
149121
])
150122

151123
PHP_CHECK_LIBRARY(curl,curl_easy_strerror,
152124
[
153125
AC_DEFINE(HAVE_CURL_EASY_STRERROR,1,[ ])
154126
],[],[
155-
$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
127+
$CURL_LIBS
156128
])
157129

158130
PHP_CHECK_LIBRARY(curl,curl_multi_strerror,
159131
[
160132
AC_DEFINE(HAVE_CURL_MULTI_STRERROR,1,[ ])
161133
],[],[
162-
$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
134+
$CURL_LIBS
163135
])
164136

165137
PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)

0 commit comments

Comments
 (0)