xref: /PHP-5.6/ext/gd/config.m4 (revision faba2301)
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  PHP_CHECK_LIBRARY(gd, gdVersionString,        [AC_DEFINE(HAVE_GD_LIBVERSION,       1, [ ])], [], [ $GD_SHARED_LIBADD ])
255])
256
257dnl
258dnl Main GD configure
259dnl
260
261dnl
262dnl Common for both builtin and external GD
263dnl
264if test "$PHP_GD" != "no"; then
265
266dnl PNG is required by GD library
267  test "$PHP_PNG_DIR" = "no" && PHP_PNG_DIR=yes
268
269dnl Various checks for GD features
270  PHP_GD_ZLIB
271  PHP_GD_TTSTR
272  PHP_GD_VPX
273  PHP_GD_JPEG
274  PHP_GD_PNG
275  PHP_GD_XPM
276  PHP_GD_FREETYPE2
277  PHP_GD_T1LIB
278  PHP_GD_JISX0208
279fi
280
281if test "$PHP_GD" = "yes"; then
282  GD_MODULE_TYPE=builtin
283  extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
284                 libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/webpimg.c libgd/gd_webp.c \
285                 libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \
286                 libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \
287                 libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \
288                 libgd/gd_topal.c libgd/gd_gif_in.c libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c \
289                 libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c libgd/gd_color.c \
290                 libgd/gd_transform.c libgd/gd_crop.c libgd/gd_interpolation.c libgd/gd_matrix.c"
291
292dnl check for fabsf and floorf which are available since C99
293  AC_CHECK_FUNCS(fabsf floorf)
294
295dnl These are always available with bundled library
296  AC_DEFINE(HAVE_GD_BUNDLED,          1, [ ])
297  AC_DEFINE(HAVE_GD_PNG,              1, [ ])
298  AC_DEFINE(HAVE_GD_CACHE_CREATE,     1, [ ])
299
300dnl Make sure the libgd/ is first in the include path
301  GDLIB_CFLAGS="-DHAVE_LIBPNG"
302
303dnl Depending which libraries were included to PHP configure,
304dnl enable the support in bundled GD library
305
306  if test -n "$GD_VPX_DIR"; then
307    AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
308    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBVPX"
309  fi
310
311  if test -n "$GD_JPEG_DIR"; then
312    AC_DEFINE(HAVE_GD_JPG, 1, [ ])
313    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBJPEG"
314  fi
315
316  if test -n "$GD_XPM_DIR"; then
317    AC_DEFINE(HAVE_GD_XPM, 1, [ ])
318    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM"
319  fi
320
321  if test -n "$FREETYPE2_DIR"; then
322    AC_DEFINE(HAVE_GD_FREETYPE,   1, [ ])
323    AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
324    GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF"
325  fi
326
327  if test -n "$USE_GD_JIS_CONV"; then
328    AC_DEFINE(USE_GD_JISX0208, 1, [ ])
329    GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208"
330  fi
331
332else
333
334 if test "$PHP_GD" != "no"; then
335  GD_MODULE_TYPE=external
336  extra_sources="gd_compat.c"
337
338dnl Various checks for GD features
339  PHP_GD_ZLIB
340  PHP_GD_TTSTR
341  PHP_GD_VPX
342  PHP_GD_JPEG
343  PHP_GD_PNG
344  PHP_GD_XPM
345  PHP_GD_FREETYPE2
346  PHP_GD_T1LIB
347
348dnl Header path
349  for i in include/gd include gd ""; do
350    test -f "$PHP_GD/$i/gd.h" && GD_INCLUDE="$PHP_GD/$i"
351  done
352
353  if test -z "$GD_INCLUDE"; then
354    AC_MSG_ERROR([Unable to find gd.h anywhere under $PHP_GD])
355  fi
356
357dnl Library path
358
359  PHP_CHECK_LIBRARY(gd, gdSetErrorMethod,
360  [
361    PHP_ADD_LIBRARY_WITH_PATH(gd, $PHP_GD/$PHP_LIBDIR, GD_SHARED_LIBADD)
362    AC_DEFINE(HAVE_LIBGD, 1, [ ])
363  ],[
364    AC_MSG_ERROR([Unable to find libgd.(a|so) >= 2.1.0 anywhere under $PHP_GD])
365  ],[
366    -L$PHP_GD/$PHP_LIBDIR
367  ])
368  PHP_GD_CHECK_VERSION
369
370  PHP_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE)
371 fi
372fi
373
374dnl
375dnl Common for both builtin and external GD
376dnl
377if test "$PHP_GD" != "no"; then
378  PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS))
379
380  if test "$GD_MODULE_TYPE" = "builtin"; then
381    PHP_ADD_BUILD_DIR($ext_builddir/libgd)
382    GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
383    GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
384
385    PHP_TEST_BUILD(foobar, [], [
386      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
387    ], [ $GD_SHARED_LIBADD ], [char foobar () {}])
388  else
389    GD_HEADER_DIRS="ext/gd/"
390    GDLIB_CFLAGS="-I$GD_INCLUDE $GDLIB_CFLAGS"
391    PHP_ADD_INCLUDE($GD_INCLUDE)
392    PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
393      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
394    ], [ $GD_SHARED_LIBADD ])
395  fi
396
397  PHP_INSTALL_HEADERS([$GD_HEADER_DIRS])
398  PHP_SUBST(GDLIB_CFLAGS)
399  PHP_SUBST(GD_SHARED_LIBADD)
400fi
401