Skip to content

Commit 19d8a6b

Browse files
committed
Migrate ext/gd to pkg-config
* --with-webp-dir becomes --with-webp * --with-jpeg-dir becomes --with-jpeg * --with-png-dir is removed. libpng is required. * --with-zlib-dir is removed. zlib is required. * --with-xpm-dir becomes --with-xpm. We also enable --with-webp on Travis.
1 parent 61d00c0 commit 19d8a6b

File tree

4 files changed

+59
-211
lines changed

4 files changed

+59
-211
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ addons:
2121
- libxpm-dev
2222
- libzip-dev
2323
- libsqlite3-dev
24+
- libwebp-dev
2425

2526

2627
services:

ext/gd/config.m4

Lines changed: 52 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,18 @@ dnl
77
PHP_ARG_WITH(gd, for GD support,
88
[ --with-gd[=DIR] Include GD support. DIR is the GD library base
99
install directory [BUNDLED]])
10-
if test -z "$PHP_WEBP_DIR"; then
11-
PHP_ARG_WITH(webp-dir, for the location of libwebp,
12-
[ --with-webp-dir[=DIR] GD: Set the path to libwebp install prefix], no, no)
10+
if test -z "$PHP_WEBP"; then
11+
PHP_ARG_WITH(webp, for libwebp,
12+
[ --with-webp GD: Enable WEBP support], no, no)
1313
fi
1414

15-
if test -z "$PHP_JPEG_DIR"; then
16-
PHP_ARG_WITH(jpeg-dir, for the location of libjpeg,
17-
[ --with-jpeg-dir[=DIR] GD: Set the path to libjpeg install prefix], no, no)
15+
if test -z "$PHP_JPEG"; then
16+
PHP_ARG_WITH(jpeg, for libjpeg,
17+
[ --with-jpeg GD: Enable JPEG support], no, no)
1818
fi
1919

20-
if test -z "$PHP_PNG_DIR"; then
21-
PHP_ARG_WITH(png-dir, for the location of libpng,
22-
[ --with-png-dir[=DIR] GD: Set the path to libpng install prefix], no, no)
23-
fi
24-
25-
if test -z "$PHP_ZLIB_DIR"; then
26-
PHP_ARG_WITH(zlib-dir, for the location of libz,
27-
[ --with-zlib-dir[=DIR] GD: Set the path to libz install prefix], no, no)
28-
fi
29-
30-
PHP_ARG_WITH(xpm-dir, for the location of libXpm,
31-
[ --with-xpm-dir[=DIR] GD: Set the path to libXpm install prefix], no, no)
20+
PHP_ARG_WITH(xpm, for libXpm,
21+
[ --with-xpm GD: Enable XPM support], no, no)
3222

3323
PHP_ARG_WITH(freetype, for FreeType 2,
3424
[ --with-freetype GD: Enable FreeType 2 support], no, no)
@@ -40,162 +30,67 @@ dnl
4030
dnl Checks for the configure options
4131
dnl
4232

33+
dnl zlib is always required
4334
AC_DEFUN([PHP_GD_ZLIB],[
44-
if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
45-
if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
46-
PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
47-
PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
48-
elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
49-
PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
50-
PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
51-
else
52-
AC_MSG_ERROR([Can't find zlib headers under "$PHP_ZLIB_DIR"])
53-
fi
54-
else
55-
for i in /usr/local /usr; do
56-
if test -f "$i/include/zlib/zlib.h"; then
57-
PHP_ZLIB_DIR="$i"
58-
PHP_ZLIB_INCDIR="$i/include/zlib"
59-
elif test -f "$i/include/zlib.h"; then
60-
PHP_ZLIB_DIR="$i"
61-
PHP_ZLIB_INCDIR="$i/include"
62-
fi
63-
done
64-
fi
35+
PKG_CHECK_MODULES([ZLIB], [zlib])
36+
PHP_EVAL_LIBLINE($ZLIB_LIBS, GD_SHARED_LIBADD)
37+
PHP_EVAL_INCLINE($ZLIB_CFLAGS)
6538
])
6639

67-
AC_DEFUN([PHP_GD_WEBP],[
68-
if test "$PHP_WEBP_DIR" != "no"; then
69-
70-
for i in $PHP_WEBP_DIR /usr/local /usr; do
71-
test -f $i/include/webp/decode.h && GD_WEBP_DIR=$i && break
72-
done
73-
74-
if test -z "$GD_WEBP_DIR"; then
75-
AC_MSG_ERROR([webp/decode.h not found.])
76-
fi
77-
78-
for i in $PHP_WEBP_DIR /usr/local /usr; do
79-
test -f $i/include/webp/encode.h && GD_WEBP_DIR=$i && break
80-
done
81-
82-
if test -z "$GD_WEBP_DIR"; then
83-
AC_MSG_ERROR([webp/encode.h not found.])
84-
fi
85-
86-
PHP_CHECK_LIBRARY(webp,WebPGetInfo,
87-
[
88-
PHP_ADD_INCLUDE($GD_WEBP_DIR/include)
89-
PHP_ADD_LIBRARY(pthread)
90-
PHP_ADD_LIBRARY_WITH_PATH(webp, $GD_WEBP_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
91-
],[
92-
AC_MSG_ERROR([Problem with libwebp.(a|so). Please check config.log for more information.])
93-
],[
94-
-L$GD_WEBP_DIR/$PHP_LIBDIR
95-
])
96-
else
97-
AC_MSG_RESULT([If configure fails try --with-webp-dir=<DIR>])
98-
fi
40+
dnl libpng is always required
41+
AC_DEFUN([PHP_GD_PNG],[
42+
PKG_CHECK_MODULES([PNG], [libpng])
43+
PHP_EVAL_LIBLINE($PNG_LIBS, GD_SHARED_LIBADD)
44+
PHP_EVAL_INCLINE($PNG_CFLAGS)
45+
AC_DEFINE(HAVE_LIBPNG, 1, [ ])
9946
])
10047

101-
AC_DEFUN([PHP_GD_JPEG],[
102-
if test "$PHP_JPEG_DIR" != "no"; then
103-
104-
for i in $PHP_JPEG_DIR /usr/local /usr; do
105-
test -f $i/include/jpeglib.h && GD_JPEG_DIR=$i && break
106-
done
107-
108-
if test -z "$GD_JPEG_DIR"; then
109-
AC_MSG_ERROR([jpeglib.h not found.])
110-
fi
111-
112-
PHP_CHECK_LIBRARY(jpeg,jpeg_read_header,
113-
[
114-
PHP_ADD_INCLUDE($GD_JPEG_DIR/include)
115-
PHP_ADD_LIBRARY_WITH_PATH(jpeg, $GD_JPEG_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
116-
],[
117-
AC_MSG_ERROR([Problem with libjpeg.(a|so). Please check config.log for more information.])
118-
],[
119-
-L$GD_JPEG_DIR/$PHP_LIBDIR
120-
])
121-
else
122-
AC_MSG_RESULT([If configure fails try --with-jpeg-dir=<DIR>])
48+
AC_DEFUN([PHP_GD_WEBP],[
49+
if test "$PHP_WEBP" != "no"; then
50+
PKG_CHECK_MODULES([WEBP], [libwebp])
51+
PHP_EVAL_LIBLINE($WEBP_LIBS, GD_SHARED_LIBADD)
52+
PHP_EVAL_INCLINE($WEBP_CFLAGS)
53+
AC_DEFINE(HAVE_LIBWEBP, 1, [ ])
54+
AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
12355
fi
12456
])
12557

126-
AC_DEFUN([PHP_GD_PNG],[
127-
if test "$PHP_PNG_DIR" != "no"; then
128-
129-
for i in $PHP_PNG_DIR /usr/local /usr; do
130-
test -f $i/include/png.h && GD_PNG_DIR=$i && break
131-
done
132-
133-
if test -z "$GD_PNG_DIR"; then
134-
AC_MSG_ERROR([png.h not found.])
135-
fi
136-
137-
if test "$PHP_ZLIB_DIR" = "no"; then
138-
AC_MSG_ERROR([PNG support requires ZLIB. Use --with-zlib-dir=<DIR>])
139-
fi
140-
141-
PHP_CHECK_LIBRARY(png,png_write_image,
142-
[
143-
PHP_ADD_INCLUDE($GD_PNG_DIR/include)
144-
PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
145-
PHP_ADD_LIBRARY_WITH_PATH(png, $GD_PNG_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
146-
],[
147-
AC_MSG_ERROR([Problem with libpng.(a|so) or libz.(a|so). Please check config.log for more information.])
148-
],[
149-
-L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz -L$GD_PNG_DIR/$PHP_LIBDIR
150-
])
151-
152-
else
153-
AC_MSG_RESULT([If configure fails try --with-png-dir=<DIR> and --with-zlib-dir=<DIR>])
58+
AC_DEFUN([PHP_GD_JPEG],[
59+
if test "$PHP_JPEG" != "no"; then
60+
PKG_CHECK_MODULES([JPEG], [libjpeg])
61+
PHP_EVAL_LIBLINE($JPEG_LIBS, GD_SHARED_LIBADD)
62+
PHP_EVAL_INCLINE($JPEG_CFLAGS)
63+
AC_DEFINE(HAVE_LIBJPEG, 1, [ ])
64+
AC_DEFINE(HAVE_GD_JPG, 1, [ ])
15465
fi
15566
])
15667

15768
AC_DEFUN([PHP_GD_XPM],[
158-
if test "$PHP_XPM_DIR" != "no"; then
159-
160-
for i in $PHP_XPM_DIR /usr/local /usr/X11R6 /usr; do
161-
test -f $i/include/xpm.h && GD_XPM_DIR=$i && GD_XPM_INC=$i && break
162-
test -f $i/include/X11/xpm.h && GD_XPM_DIR=$i && GD_XPM_INC=$i/X11 && break
163-
done
164-
165-
if test -z "$GD_XPM_DIR"; then
166-
AC_MSG_ERROR([xpm.h not found.])
167-
fi
168-
169-
PHP_CHECK_LIBRARY(Xpm,XpmFreeXpmImage,
170-
[
171-
PHP_ADD_INCLUDE($GD_XPM_INC)
172-
PHP_ADD_LIBRARY_WITH_PATH(Xpm, $GD_XPM_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
173-
PHP_ADD_LIBRARY_WITH_PATH(X11, $GD_XPM_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
174-
],[
175-
AC_MSG_ERROR([Problem with libXpm.(a|so) or libX11.(a|so). Please check config.log for more information.])
176-
],[
177-
-L$GD_XPM_DIR/$PHP_LIBDIR -lX11
178-
])
179-
else
180-
AC_MSG_RESULT(If configure fails try --with-xpm-dir=<DIR>)
69+
if test "$PHP_XPM" != "no"; then
70+
PKG_CHECK_MODULES([XPM], [xpm])
71+
PHP_EVAL_LIBLINE($XPM_LIBS, GD_SHARED_LIBADD)
72+
PHP_EVAL_INCLINE($XPM_CFLAGS)
73+
AC_DEFINE(HAVE_XPM, 1, [ ])
74+
AC_DEFINE(HAVE_GD_XPM, 1, [ ])
18175
fi
18276
])
18377

18478
AC_DEFUN([PHP_GD_FREETYPE2],[
18579
if test "$PHP_FREETYPE" != "no"; then
186-
18780
PKG_CHECK_MODULES([FREETYPE2], [freetype2], [FREETYPE2_FOUND=true])
18881
18982
PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
19083
PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
191-
AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
192-
AC_DEFINE(ENABLE_GD_TTF,1,[ ])
84+
AC_DEFINE(HAVE_LIBFREETYPE, 1, [ ])
85+
AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])
86+
AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
19387
fi
19488
])
19589

19690
AC_DEFUN([PHP_GD_JISX0208],[
19791
if test "$PHP_GD_JIS_CONV" = "yes"; then
198-
USE_GD_JIS_CONV=1
92+
AC_DEFINE(USE_GD_JISX0208, 1, [ ])
93+
AC_DEFINE(JISX0208, 1, [ ])
19994
fi
20095
])
20196

@@ -213,26 +108,9 @@ dnl
213108
dnl Main GD configure
214109
dnl
215110

216-
dnl
217-
dnl Common for both builtin and external GD
218-
dnl
219-
if test "$PHP_GD" != "no"; then
220-
221-
dnl PNG is required by GD library
222-
test "$PHP_PNG_DIR" = "no" && PHP_PNG_DIR=yes
223-
224-
dnl Various checks for GD features
225-
PHP_GD_ZLIB
226-
PHP_GD_WEBP
227-
PHP_GD_JPEG
228-
PHP_GD_PNG
229-
PHP_GD_XPM
230-
PHP_GD_FREETYPE2
231-
PHP_GD_JISX0208
232-
fi
233-
234111
if test "$PHP_GD" = "yes"; then
235112
GD_MODULE_TYPE=builtin
113+
GDLIB_CFLAGS=""
236114
extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
237115
libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \
238116
libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \
@@ -250,53 +128,21 @@ dnl These are always available with bundled library
250128
AC_DEFINE(HAVE_GD_BUNDLED, 1, [ ])
251129
AC_DEFINE(HAVE_GD_PNG, 1, [ ])
252130
AC_DEFINE(HAVE_GD_BMP, 1, [ ])
253-
AC_DEFINE(HAVE_GD_CACHE_CREATE, 1, [ ])
254-
255-
dnl Make sure the libgd/ is first in the include path
256-
GDLIB_CFLAGS="-DHAVE_LIBPNG"
257-
258-
dnl Depending which libraries were included to PHP configure,
259-
dnl enable the support in bundled GD library
260-
261-
if test -n "$GD_WEBP_DIR"; then
262-
AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
263-
GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBWEBP"
264-
fi
265-
266-
if test -n "$GD_JPEG_DIR"; then
267-
AC_DEFINE(HAVE_GD_JPG, 1, [ ])
268-
GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBJPEG"
269-
fi
270-
271-
if test -n "$GD_XPM_DIR"; then
272-
AC_DEFINE(HAVE_GD_XPM, 1, [ ])
273-
GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM"
274-
fi
275-
276-
if test -n "$FREETYPE2_FOUND"; then
277-
AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])
278-
AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
279-
GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF"
280-
fi
281-
282-
if test -n "$USE_GD_JIS_CONV"; then
283-
AC_DEFINE(USE_GD_JISX0208, 1, [ ])
284-
GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208"
285-
fi
286-
287-
else
288-
289-
if test "$PHP_GD" != "no"; then
290-
GD_MODULE_TYPE=external
291-
extra_sources="gd_compat.c"
292131

293132
dnl Various checks for GD features
294133
PHP_GD_ZLIB
134+
PHP_GD_PNG
295135
PHP_GD_WEBP
296136
PHP_GD_JPEG
297-
PHP_GD_PNG
298137
PHP_GD_XPM
299138
PHP_GD_FREETYPE2
139+
PHP_GD_JISX0208
140+
141+
else
142+
143+
if test "$PHP_GD" != "no"; then
144+
GD_MODULE_TYPE=external
145+
extra_sources="gd_compat.c"
300146

301147
dnl Header path
302148
for i in include/gd include/gd2 include gd ""; do

ext/gd/libgd/gd_webp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#ifdef HAVE_LIBWEBP
21
#include <stdio.h>
32
#include <math.h>
43
#include <string.h>
54
#include <stdlib.h>
65
#include "gd.h"
76
#include "gdhelpers.h"
7+
8+
#ifdef HAVE_LIBWEBP
89
#include "webp/decode.h"
910
#include "webp/encode.h"
1011

travis/compile.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ $TS \
4141
--enable-intl \
4242
--without-pear \
4343
--with-gd \
44-
--with-jpeg-dir=/usr \
45-
--with-png-dir=/usr \
44+
--with-jpeg \
45+
--with-webp \
46+
--with-freetype \
47+
--with-xpm \
4648
--enable-exif \
4749
--enable-zip \
4850
--with-zlib \
@@ -70,8 +72,6 @@ $TS \
7072
--with-pspell=/usr \
7173
--with-enchant=/usr \
7274
--enable-wddx \
73-
--with-freetype \
74-
--with-xpm-dir=/usr \
7575
--with-kerberos \
7676
--enable-sysvmsg \
7777
--enable-zend-test \

0 commit comments

Comments
 (0)