Skip to content

libwebp support for linux #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions ext/gd/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ dnl
PHP_ARG_WITH(gd, for GD support,
[ --with-gd[=DIR] Include GD support. DIR is the GD library base
install directory [BUNDLED]])
if test -z "$PHP_VPX_DIR"; then
PHP_ARG_WITH(vpx-dir, for the location of libvpx,
[ --with-vpx-dir[=DIR] GD: Set the path to libvpx install prefix], no, no)
if test -z "$PHP_WEBP_DIR"; then
PHP_ARG_WITH(webp-dir, for the location of libwebp,
[ --with-webp-dir[=DIR] GD: Set the path to libwebp install prefix], no, no)
fi

if test -z "$PHP_JPEG_DIR"; then
Expand Down Expand Up @@ -69,29 +69,37 @@ AC_DEFUN([PHP_GD_ZLIB],[
fi
])

AC_DEFUN([PHP_GD_VPX],[
if test "$PHP_VPX_DIR" != "no"; then
AC_DEFUN([PHP_GD_WEBP],[
if test "$PHP_WEBP_DIR" != "no"; then

for i in $PHP_VPX_DIR /usr/local /usr; do
test -f $i/include/vpx_codec.h || test -f $i/include/vpx/vpx_codec.h && GD_VPX_DIR=$i && break
for i in $PHP_WEBP_DIR /usr/local /usr; do
test -f $i/include/webp/decode.h && GD_WEBP_DIR=$i && break
done

if test -z "$GD_VPX_DIR"; then
AC_MSG_ERROR([vpx_codec.h not found.])
if test -z "$GD_WEBP_DIR"; then
AC_MSG_ERROR([webp/decode.h not found.])
fi

PHP_CHECK_LIBRARY(vpx,vpx_codec_destroy,
for i in $PHP_WEBP_DIR /usr/local /usr; do
test -f $i/include/webp/encode.h && GD_WEBP_DIR=$i && break
done

if test -z "$GD_WEBP_DIR"; then
AC_MSG_ERROR([webp/encode.h not found.])
fi

PHP_CHECK_LIBRARY(webp,WebPGetInfo,
[
PHP_ADD_INCLUDE($GD_VPX_DIR/include)
PHP_ADD_INCLUDE($GD_WEBP_DIR/include)
PHP_ADD_LIBRARY(pthread)
PHP_ADD_LIBRARY_WITH_PATH(vpx, $GD_VPX_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(webp, $GD_WEBP_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
],[
AC_MSG_ERROR([Problem with libvpx.(a|so). Please check config.log for more information.])
AC_MSG_ERROR([Problem with libwebp.(a|so). Please check config.log for more information.])
],[
-L$GD_VPX_DIR/$PHP_LIBDIR
-L$GD_WEBP_DIR/$PHP_LIBDIR
])
else
AC_MSG_RESULT([If configure fails try --with-vpx-dir=<DIR>])
AC_MSG_RESULT([If configure fails try --with-webp-dir=<DIR>])
fi
])

Expand Down Expand Up @@ -242,7 +250,7 @@ dnl PNG is required by GD library
dnl Various checks for GD features
PHP_GD_ZLIB
PHP_GD_TTSTR
PHP_GD_VPX
PHP_GD_WEBP
PHP_GD_JPEG
PHP_GD_PNG
PHP_GD_XPM
Expand All @@ -253,7 +261,7 @@ fi
if test "$PHP_GD" = "yes"; then
GD_MODULE_TYPE=builtin
extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/webpimg.c libgd/gd_webp.c \
libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \
libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \
libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \
libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \
Expand All @@ -275,9 +283,9 @@ dnl Make sure the libgd/ is first in the include path
dnl Depending which libraries were included to PHP configure,
dnl enable the support in bundled GD library

if test -n "$GD_VPX_DIR"; then
if test -n "$GD_WEBP_DIR"; then
AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBVPX"
GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBWEBP"
fi

if test -n "$GD_JPEG_DIR"; then
Expand Down Expand Up @@ -310,7 +318,7 @@ else
dnl Various checks for GD features
PHP_GD_ZLIB
PHP_GD_TTSTR
PHP_GD_VPX
PHP_GD_WEBP
PHP_GD_JPEG
PHP_GD_PNG
PHP_GD_XPM
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ PHP_FUNCTION(imagecreatefromwebp)
_php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WEBP, "WEBP", gdImageCreateFromWebp, gdImageCreateFromWebpCtx);
}
/* }}} */
#endif /* HAVE_GD_VPX */
#endif /* HAVE_GD_WEBP */

/* {{{ proto resource imagecreatefromxbm(string filename)
Create a new image from XBM file or URL */
Expand Down