xref: /PHP-5.5/ext/gd/config.m4 (revision a0955f35)
1dnl
2dnl $Id$
3dnl
4
5dnl
6dnl Configure options
7dnl
8
9PHP_ARG_WITH(gd, for GD support,
10[  --with-gd[=DIR]           Include GD support.  DIR is the GD library base
11                          install directory [BUNDLED]])
12if test -z "$PHP_VPX_DIR"; then
13  PHP_ARG_WITH(vpx-dir, for the location of libvpx,
14  [  --with-vpx-dir[=DIR]      GD: Set the path to libvpx install prefix], no, no)
15fi
16
17if test -z "$PHP_JPEG_DIR"; then
18  PHP_ARG_WITH(jpeg-dir, for the location of libjpeg,
19  [  --with-jpeg-dir[=DIR]     GD: Set the path to libjpeg install prefix], no, no)
20fi
21
22if test -z "$PHP_PNG_DIR"; then
23  PHP_ARG_WITH(png-dir, for the location of libpng,
24  [  --with-png-dir[=DIR]      GD: Set the path to libpng install prefix], no, no)
25fi
26
27if test -z "$PHP_ZLIB_DIR"; then
28  PHP_ARG_WITH(zlib-dir, for the location of libz,
29  [  --with-zlib-dir[=DIR]     GD: Set the path to libz install prefix], no, no)
30fi
31
32PHP_ARG_WITH(xpm-dir, for the location of libXpm,
33[  --with-xpm-dir[=DIR]      GD: Set the path to libXpm install prefix], no, no)
34
35PHP_ARG_WITH(freetype-dir, for FreeType 2,
36[  --with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix], no, no)
37
38PHP_ARG_WITH(t1lib, for T1lib support,
39[  --with-t1lib[=DIR]        GD: Include T1lib support. T1lib version >= 5.0.0 required], no, no)
40
41PHP_ARG_ENABLE(gd-native-ttf, whether to enable truetype string function in GD,
42[  --enable-gd-native-ttf  GD: Enable TrueType string function], no, no)
43
44PHP_ARG_ENABLE(gd-jis-conv, whether to enable JIS-mapped Japanese font support in GD,
45[  --enable-gd-jis-conv    GD: Enable JIS-mapped Japanese font support], no, no)
46
47dnl
48dnl Checks for the configure options
49dnl
50
51AC_DEFUN([PHP_GD_ZLIB],[
52	if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
53		if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
54			PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
55			PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
56		elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
57			PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
58			PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
59		else
60			AC_MSG_ERROR([Can't find zlib headers under "$PHP_ZLIB_DIR"])
61		fi
62	else
63		for i in /usr/local /usr; do
64			if test -f "$i/include/zlib/zlib.h"; then
65				PHP_ZLIB_DIR="$i"
66				PHP_ZLIB_INCDIR="$i/include/zlib"
67			elif test -f "$i/include/zlib.h"; then
68				PHP_ZLIB_DIR="$i"
69				PHP_ZLIB_INCDIR="$i/include"
70			fi
71		done
72	fi
73])
74
75AC_DEFUN([PHP_GD_VPX],[
76  if test "$PHP_VPX_DIR" != "no"; then
77
78    for i in $PHP_VPX_DIR /usr/local /usr; do
79      test -f $i/include/vpx_codec.h || test -f $i/include/vpx/vpx_codec.h && GD_VPX_DIR=$i && break
80    done
81
82    if test -z "$GD_VPX_DIR"; then
83      AC_MSG_ERROR([vpx_codec.h not found.])
84    fi
85
86    PHP_CHECK_LIBRARY(vpx,vpx_codec_destroy,
87    [
88      PHP_ADD_INCLUDE($GD_VPX_DIR/include)
89      PHP_ADD_LIBRARY(pthread)
90      PHP_ADD_LIBRARY_WITH_PATH(vpx, $GD_VPX_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
91    ],[
92      AC_MSG_ERROR([Problem with libvpx.(a|so). Please check config.log for more information.])
93    ],[
94      -L$GD_VPX_DIR/$PHP_LIBDIR
95    ])
96  else
97    AC_MSG_RESULT([If configure fails try --with-vpx-dir=<DIR>])
98  fi
99])
100
101AC_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>])
123  fi
124])
125
126AC_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>])
154  fi
155])
156
157AC_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>)
181  fi
182])
183
184AC_DEFUN([PHP_GD_FREETYPE2],[
185  if test "$PHP_FREETYPE_DIR" != "no"; then
186
187    for i in $PHP_FREETYPE_DIR /usr/local /usr; do
188      if test -f "$i/bin/freetype-config"; then
189        FREETYPE2_DIR=$i
190        FREETYPE2_CONFIG="$i/bin/freetype-config"
191        break
192      fi
193    done
194
195    if test -z "$FREETYPE2_DIR"; then
196      AC_MSG_ERROR([freetype-config not found.])
197    fi
198
199    FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
200    FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
201
202    PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
203    PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
204    AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
205    AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
206    AC_DEFINE(ENABLE_GD_TTF,1,[ ])
207  else
208    AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>])
209  fi
210])
211
212AC_DEFUN([PHP_GD_T1LIB],[
213  if test "$PHP_T1LIB" != "no"; then
214
215    for i in $PHP_T1LIB /usr/local /usr; do
216      test -f "$i/include/t1lib.h" && GD_T1_DIR=$i && break
217    done
218
219    if test -z "$GD_T1_DIR"; then
220      AC_MSG_ERROR([Your t1lib distribution is not installed correctly. Please reinstall it.])
221    fi
222
223    PHP_CHECK_LIBRARY(t1, T1_StrError,
224    [
225      AC_DEFINE(HAVE_LIBT1,1,[ ])
226      PHP_ADD_INCLUDE($GD_T1_DIR/include)
227      PHP_ADD_LIBRARY_WITH_PATH(t1, $GD_T1_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
228    ],[
229      AC_MSG_ERROR([Problem with libt1.(a|so). Please check config.log for more information.])
230    ],[
231      -L$GD_T1_DIR/$PHP_LIBDIR
232    ])
233  fi
234])
235
236AC_DEFUN([PHP_GD_TTSTR],[
237  if test "$PHP_GD_NATIVE_TTF" = "yes"; then
238    AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
239  fi
240])
241
242AC_DEFUN([PHP_GD_JISX0208],[
243  if test "$PHP_GD_JIS_CONV" = "yes"; then
244    USE_GD_JIS_CONV=1
245  fi
246])
247
248AC_DEFUN([PHP_GD_CHECK_VERSION],[
249  PHP_CHECK_LIBRARY(gd, gdImageCreateFromPng,   [AC_DEFINE(HAVE_GD_PNG,              1, [ ])], [], [ $GD_SHARED_LIBADD ])
250  PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp,  [AC_DEFINE(HAVE_GD_WEBP,             1, [ ])], [], [ $GD_SHARED_LIBADD ])
251  PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg,  [AC_DEFINE(HAVE_GD_JPG,              1, [ ])], [], [ $GD_SHARED_LIBADD ])
252  PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm,   [AC_DEFINE(HAVE_GD_XPM,              1, [ ])], [], [ $GD_SHARED_LIBADD ])
253  PHP_CHECK_LIBRARY(gd, gdImageStringFT,        [AC_DEFINE(HAVE_GD_FREETYPE,         1, [ ])], [], [ $GD_SHARED_LIBADD ])
254])
255
256dnl
257dnl Main GD configure
258dnl
259
260dnl
261dnl Common for both builtin and external GD
262dnl
263if test "$PHP_GD" != "no"; then
264
265dnl PNG is required by GD library
266  test "$PHP_PNG_DIR" = "no" && PHP_PNG_DIR=yes
267
268dnl Various checks for GD features
269  PHP_GD_ZLIB
270  PHP_GD_TTSTR
271  PHP_GD_VPX
272  PHP_GD_JPEG
273  PHP_GD_PNG
274  PHP_GD_XPM
275  PHP_GD_FREETYPE2
276  PHP_GD_T1LIB
277  PHP_GD_JISX0208
278fi
279
280if test "$PHP_GD" = "yes"; then
281  GD_MODULE_TYPE=builtin
282  extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
283                 libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/webpimg.c libgd/gd_webp.c \
284                 libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \
285                 libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \
286                 libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \
287                 libgd/gd_topal.c libgd/gd_gif_in.c libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c \
288                 libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c libgd/gd_color.c \
289                 libgd/gd_transform.c libgd/gd_crop.c libgd/gd_interpolation.c libgd/gd_matrix.c"
290
291dnl check for fabsf and floorf which are available since C99
292  AC_CHECK_FUNCS(fabsf floorf)
293
294dnl These are always available with bundled library
295  AC_DEFINE(HAVE_GD_BUNDLED,          1, [ ])
296  AC_DEFINE(HAVE_GD_PNG,              1, [ ])
297  AC_DEFINE(HAVE_GD_CACHE_CREATE,     1, [ ])
298
299dnl Make sure the libgd/ is first in the include path
300  GDLIB_CFLAGS="-DHAVE_LIBPNG"
301
302dnl Depending which libraries were included to PHP configure,
303dnl enable the support in bundled GD library
304
305  if test -n "$GD_VPX_DIR"; then
306    AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
307    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBVPX"
308  fi
309
310  if test -n "$GD_JPEG_DIR"; then
311    AC_DEFINE(HAVE_GD_JPG, 1, [ ])
312    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBJPEG"
313  fi
314
315  if test -n "$GD_XPM_DIR"; then
316    AC_DEFINE(HAVE_GD_XPM, 1, [ ])
317    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM"
318  fi
319
320  if test -n "$FREETYPE2_DIR"; then
321    AC_DEFINE(HAVE_GD_FREETYPE,   1, [ ])
322    AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
323    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF"
324  fi
325
326  if test -n "$USE_GD_JIS_CONV"; then
327    AC_DEFINE(USE_GD_JISX0208, 1, [ ])
328    GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208"
329  fi
330
331else
332
333 if test "$PHP_GD" != "no"; then
334  GD_MODULE_TYPE=external
335  extra_sources="gd_compat.c"
336
337dnl Various checks for GD features
338  PHP_GD_ZLIB
339  PHP_GD_TTSTR
340  PHP_GD_VPX
341  PHP_GD_JPEG
342  PHP_GD_PNG
343  PHP_GD_XPM
344  PHP_GD_FREETYPE2
345  PHP_GD_T1LIB
346
347dnl Header path
348  for i in include/gd include gd ""; do
349    test -f "$PHP_GD/$i/gd.h" && GD_INCLUDE="$PHP_GD/$i"
350  done
351
352  if test -z "$GD_INCLUDE"; then
353    AC_MSG_ERROR([Unable to find gd.h anywhere under $PHP_GD])
354  fi
355
356dnl Library path
357
358  PHP_CHECK_LIBRARY(gd, gdSetErrorMethod,
359  [
360    PHP_ADD_LIBRARY_WITH_PATH(gd, $PHP_GD/$PHP_LIBDIR, GD_SHARED_LIBADD)
361    AC_DEFINE(HAVE_LIBGD, 1, [ ])
362  ],[
363    AC_MSG_ERROR([Unable to find libgd.(a|so) >= 2.1.0 anywhere under $PHP_GD])
364  ],[
365    -L$PHP_GD/$PHP_LIBDIR
366  ])
367  PHP_GD_CHECK_VERSION
368
369  PHP_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE)
370 fi
371fi
372
373dnl
374dnl Common for both builtin and external GD
375dnl
376if test "$PHP_GD" != "no"; then
377  PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS))
378
379  if test "$GD_MODULE_TYPE" = "builtin"; then
380    PHP_ADD_BUILD_DIR($ext_builddir/libgd)
381    GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
382    GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
383
384    PHP_TEST_BUILD(foobar, [], [
385      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
386    ], [ $GD_SHARED_LIBADD ], [char foobar () {}])
387  else
388    GD_HEADER_DIRS="ext/gd/"
389    GDLIB_CFLAGS="-I$GD_INCLUDE $GDLIB_CFLAGS"
390    PHP_ADD_INCLUDE($GD_INCLUDE)
391    PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
392      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
393    ], [ $GD_SHARED_LIBADD ])
394  fi
395
396  PHP_INSTALL_HEADERS([$GD_HEADER_DIRS])
397  PHP_SUBST(GDLIB_CFLAGS)
398  PHP_SUBST(GD_SHARED_LIBADD)
399fi
400