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_WEBP_DIR"; then 13 PHP_ARG_WITH(webp-dir, for the location of libwebp, 14 [ --with-webp-dir[=DIR] GD: Set the path to libwebp 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_ENABLE(gd-native-ttf, whether to enable truetype string function in GD, 39[ --enable-gd-native-ttf GD: Enable TrueType string function], no, no) 40 41PHP_ARG_ENABLE(gd-jis-conv, whether to enable JIS-mapped Japanese font support in GD, 42[ --enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support], no, no) 43 44dnl 45dnl Checks for the configure options 46dnl 47 48AC_DEFUN([PHP_GD_ZLIB],[ 49 if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then 50 if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then 51 PHP_ZLIB_DIR="$PHP_ZLIB_DIR" 52 PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib" 53 elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then 54 PHP_ZLIB_DIR="$PHP_ZLIB_DIR" 55 PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include" 56 else 57 AC_MSG_ERROR([Can't find zlib headers under "$PHP_ZLIB_DIR"]) 58 fi 59 else 60 for i in /usr/local /usr; do 61 if test -f "$i/include/zlib/zlib.h"; then 62 PHP_ZLIB_DIR="$i" 63 PHP_ZLIB_INCDIR="$i/include/zlib" 64 elif test -f "$i/include/zlib.h"; then 65 PHP_ZLIB_DIR="$i" 66 PHP_ZLIB_INCDIR="$i/include" 67 fi 68 done 69 fi 70]) 71 72AC_DEFUN([PHP_GD_WEBP],[ 73 if test "$PHP_WEBP_DIR" != "no"; then 74 75 for i in $PHP_WEBP_DIR /usr/local /usr; do 76 test -f $i/include/webp/decode.h && GD_WEBP_DIR=$i && break 77 done 78 79 if test -z "$GD_WEBP_DIR"; then 80 AC_MSG_ERROR([webp/decode.h not found.]) 81 fi 82 83 for i in $PHP_WEBP_DIR /usr/local /usr; do 84 test -f $i/include/webp/encode.h && GD_WEBP_DIR=$i && break 85 done 86 87 if test -z "$GD_WEBP_DIR"; then 88 AC_MSG_ERROR([webp/encode.h not found.]) 89 fi 90 91 PHP_CHECK_LIBRARY(webp,WebPGetInfo, 92 [ 93 PHP_ADD_INCLUDE($GD_WEBP_DIR/include) 94 PHP_ADD_LIBRARY(pthread) 95 PHP_ADD_LIBRARY_WITH_PATH(webp, $GD_WEBP_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD) 96 ],[ 97 AC_MSG_ERROR([Problem with libwebp.(a|so). Please check config.log for more information.]) 98 ],[ 99 -L$GD_WEBP_DIR/$PHP_LIBDIR 100 ]) 101 else 102 AC_MSG_RESULT([If configure fails try --with-webp-dir=<DIR>]) 103 fi 104]) 105 106AC_DEFUN([PHP_GD_JPEG],[ 107 if test "$PHP_JPEG_DIR" != "no"; then 108 109 for i in $PHP_JPEG_DIR /usr/local /usr; do 110 test -f $i/include/jpeglib.h && GD_JPEG_DIR=$i && break 111 done 112 113 if test -z "$GD_JPEG_DIR"; then 114 AC_MSG_ERROR([jpeglib.h not found.]) 115 fi 116 117 PHP_CHECK_LIBRARY(jpeg,jpeg_read_header, 118 [ 119 PHP_ADD_INCLUDE($GD_JPEG_DIR/include) 120 PHP_ADD_LIBRARY_WITH_PATH(jpeg, $GD_JPEG_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD) 121 ],[ 122 AC_MSG_ERROR([Problem with libjpeg.(a|so). Please check config.log for more information.]) 123 ],[ 124 -L$GD_JPEG_DIR/$PHP_LIBDIR 125 ]) 126 else 127 AC_MSG_RESULT([If configure fails try --with-jpeg-dir=<DIR>]) 128 fi 129]) 130 131AC_DEFUN([PHP_GD_PNG],[ 132 if test "$PHP_PNG_DIR" != "no"; then 133 134 for i in $PHP_PNG_DIR /usr/local /usr; do 135 test -f $i/include/png.h && GD_PNG_DIR=$i && break 136 done 137 138 if test -z "$GD_PNG_DIR"; then 139 AC_MSG_ERROR([png.h not found.]) 140 fi 141 142 if test "$PHP_ZLIB_DIR" = "no"; then 143 AC_MSG_ERROR([PNG support requires ZLIB. Use --with-zlib-dir=<DIR>]) 144 fi 145 146 PHP_CHECK_LIBRARY(png,png_write_image, 147 [ 148 PHP_ADD_INCLUDE($GD_PNG_DIR/include) 149 PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD) 150 PHP_ADD_LIBRARY_WITH_PATH(png, $GD_PNG_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD) 151 ],[ 152 AC_MSG_ERROR([Problem with libpng.(a|so) or libz.(a|so). Please check config.log for more information.]) 153 ],[ 154 -L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz -L$GD_PNG_DIR/$PHP_LIBDIR 155 ]) 156 157 else 158 AC_MSG_RESULT([If configure fails try --with-png-dir=<DIR> and --with-zlib-dir=<DIR>]) 159 fi 160]) 161 162AC_DEFUN([PHP_GD_XPM],[ 163 if test "$PHP_XPM_DIR" != "no"; then 164 165 for i in $PHP_XPM_DIR /usr/local /usr/X11R6 /usr; do 166 test -f $i/include/xpm.h && GD_XPM_DIR=$i && GD_XPM_INC=$i && break 167 test -f $i/include/X11/xpm.h && GD_XPM_DIR=$i && GD_XPM_INC=$i/X11 && break 168 done 169 170 if test -z "$GD_XPM_DIR"; then 171 AC_MSG_ERROR([xpm.h not found.]) 172 fi 173 174 PHP_CHECK_LIBRARY(Xpm,XpmFreeXpmImage, 175 [ 176 PHP_ADD_INCLUDE($GD_XPM_INC) 177 PHP_ADD_LIBRARY_WITH_PATH(Xpm, $GD_XPM_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD) 178 PHP_ADD_LIBRARY_WITH_PATH(X11, $GD_XPM_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD) 179 ],[ 180 AC_MSG_ERROR([Problem with libXpm.(a|so) or libX11.(a|so). Please check config.log for more information.]) 181 ],[ 182 -L$GD_XPM_DIR/$PHP_LIBDIR -lX11 183 ]) 184 else 185 AC_MSG_RESULT(If configure fails try --with-xpm-dir=<DIR>) 186 fi 187]) 188 189AC_DEFUN([PHP_GD_FREETYPE2],[ 190 if test "$PHP_FREETYPE_DIR" != "no"; then 191 192 for i in $PHP_FREETYPE_DIR /usr/local /usr; do 193 if test -f "$i/bin/freetype-config"; then 194 FREETYPE2_DIR=$i 195 FREETYPE2_CONFIG="$i/bin/freetype-config" 196 break 197 fi 198 done 199 200 if test -z "$FREETYPE2_DIR"; then 201 AC_MSG_ERROR([freetype-config not found.]) 202 fi 203 204 FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` 205 FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` 206 207 PHP_EVAL_INCLINE($FREETYPE2_CFLAGS) 208 PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD) 209 AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ]) 210 AC_DEFINE(HAVE_LIBFREETYPE,1,[ ]) 211 AC_DEFINE(ENABLE_GD_TTF,1,[ ]) 212 else 213 AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>]) 214 fi 215]) 216 217AC_DEFUN([PHP_GD_TTSTR],[ 218 if test "$PHP_GD_NATIVE_TTF" = "yes"; then 219 AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ]) 220 fi 221]) 222 223AC_DEFUN([PHP_GD_JISX0208],[ 224 if test "$PHP_GD_JIS_CONV" = "yes"; then 225 USE_GD_JIS_CONV=1 226 fi 227]) 228 229AC_DEFUN([PHP_GD_CHECK_VERSION],[ 230 PHP_CHECK_LIBRARY(gd, gdImageCreateFromPng, [AC_DEFINE(HAVE_GD_PNG, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 231 PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp, [AC_DEFINE(HAVE_GD_WEBP, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 232 PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg, [AC_DEFINE(HAVE_GD_JPG, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 233 PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm, [AC_DEFINE(HAVE_GD_XPM, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 234 PHP_CHECK_LIBRARY(gd, gdImageStringFT, [AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 235 PHP_CHECK_LIBRARY(gd, gdVersionString, [AC_DEFINE(HAVE_GD_LIBVERSION, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 236]) 237 238dnl 239dnl Main GD configure 240dnl 241 242dnl 243dnl Common for both builtin and external GD 244dnl 245if test "$PHP_GD" != "no"; then 246 247dnl PNG is required by GD library 248 test "$PHP_PNG_DIR" = "no" && PHP_PNG_DIR=yes 249 250dnl Various checks for GD features 251 PHP_GD_ZLIB 252 PHP_GD_TTSTR 253 PHP_GD_WEBP 254 PHP_GD_JPEG 255 PHP_GD_PNG 256 PHP_GD_XPM 257 PHP_GD_FREETYPE2 258 PHP_GD_JISX0208 259fi 260 261if test "$PHP_GD" = "yes"; then 262 GD_MODULE_TYPE=builtin 263 extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \ 264 libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \ 265 libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \ 266 libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \ 267 libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \ 268 libgd/gd_topal.c libgd/gd_gif_in.c libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c \ 269 libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c libgd/gd_color.c \ 270 libgd/gd_transform.c libgd/gd_crop.c libgd/gd_interpolation.c libgd/gd_matrix.c" 271 272dnl check for fabsf and floorf which are available since C99 273 AC_CHECK_FUNCS(fabsf floorf) 274 275dnl These are always available with bundled library 276 AC_DEFINE(HAVE_GD_BUNDLED, 1, [ ]) 277 AC_DEFINE(HAVE_GD_PNG, 1, [ ]) 278 AC_DEFINE(HAVE_GD_CACHE_CREATE, 1, [ ]) 279 280dnl Make sure the libgd/ is first in the include path 281 GDLIB_CFLAGS="-DHAVE_LIBPNG" 282 283dnl Depending which libraries were included to PHP configure, 284dnl enable the support in bundled GD library 285 286 if test -n "$GD_WEBP_DIR"; then 287 AC_DEFINE(HAVE_GD_WEBP, 1, [ ]) 288 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBWEBP" 289 fi 290 291 if test -n "$GD_JPEG_DIR"; then 292 AC_DEFINE(HAVE_GD_JPG, 1, [ ]) 293 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBJPEG" 294 fi 295 296 if test -n "$GD_XPM_DIR"; then 297 AC_DEFINE(HAVE_GD_XPM, 1, [ ]) 298 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM" 299 fi 300 301 if test -n "$FREETYPE2_DIR"; then 302 AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ]) 303 AC_DEFINE(ENABLE_GD_TTF, 1, [ ]) 304 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF" 305 fi 306 307 if test -n "$USE_GD_JIS_CONV"; then 308 AC_DEFINE(USE_GD_JISX0208, 1, [ ]) 309 GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208" 310 fi 311 312else 313 314 if test "$PHP_GD" != "no"; then 315 GD_MODULE_TYPE=external 316 extra_sources="gd_compat.c" 317 318dnl Various checks for GD features 319 PHP_GD_ZLIB 320 PHP_GD_TTSTR 321 PHP_GD_WEBP 322 PHP_GD_JPEG 323 PHP_GD_PNG 324 PHP_GD_XPM 325 PHP_GD_FREETYPE2 326 327dnl Header path 328 for i in include/gd include/gd2 include gd ""; do 329 test -f "$PHP_GD/$i/gd.h" && GD_INCLUDE="$PHP_GD/$i" 330 done 331 332 if test -z "$GD_INCLUDE"; then 333 AC_MSG_ERROR([Unable to find gd.h anywhere under $PHP_GD]) 334 fi 335 336dnl Library path 337 338 PHP_CHECK_LIBRARY(gd, gdSetErrorMethod, 339 [ 340 PHP_ADD_LIBRARY_WITH_PATH(gd, $PHP_GD/$PHP_LIBDIR, GD_SHARED_LIBADD) 341 AC_DEFINE(HAVE_LIBGD, 1, [ ]) 342 ],[ 343 AC_MSG_ERROR([Unable to find libgd.(a|so) >= 2.1.0 anywhere under $PHP_GD]) 344 ],[ 345 -L$PHP_GD/$PHP_LIBDIR 346 ]) 347 PHP_GD_CHECK_VERSION 348 349 PHP_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE) 350 fi 351fi 352 353dnl 354dnl Common for both builtin and external GD 355dnl 356if test "$PHP_GD" != "no"; then 357 PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS)) 358 359 if test "$GD_MODULE_TYPE" = "builtin"; then 360 PHP_ADD_BUILD_DIR($ext_builddir/libgd) 361 GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS" 362 GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/" 363 364 PHP_TEST_BUILD(foobar, [], [ 365 AC_MSG_ERROR([GD build test failed. Please check the config.log for details.]) 366 ], [ $GD_SHARED_LIBADD ], [char foobar () {}]) 367 else 368 GD_HEADER_DIRS="ext/gd/" 369 GDLIB_CFLAGS="-I$GD_INCLUDE $GDLIB_CFLAGS" 370 PHP_ADD_INCLUDE($GD_INCLUDE) 371 PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [ 372 AC_MSG_ERROR([GD build test failed. Please check the config.log for details.]) 373 ], [ $GD_SHARED_LIBADD ]) 374 fi 375 376 PHP_INSTALL_HEADERS([$GD_HEADER_DIRS]) 377 PHP_SUBST(GDLIB_CFLAGS) 378 PHP_SUBST(GD_SHARED_LIBADD) 379fi 380