1dnl config.m4 for extension gd 2 3dnl 4dnl Configure options 5dnl 6 7PHP_ARG_WITH(gd, for GD support, 8[ --with-gd[=DIR] Include GD support. DIR is the GD library base 9 install directory [BUNDLED]]) 10if 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) 13fi 14 15if 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) 18fi 19 20if 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) 23fi 24 25if 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) 28fi 29 30PHP_ARG_WITH(xpm-dir, for the location of libXpm, 31[ --with-xpm-dir[=DIR] GD: Set the path to libXpm install prefix], no, no) 32 33PHP_ARG_WITH(freetype-dir, for FreeType 2, 34[ --with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix], no, no) 35 36PHP_ARG_ENABLE(gd-jis-conv, whether to enable JIS-mapped Japanese font support in GD, 37[ --enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support], no, no) 38 39dnl 40dnl Checks for the configure options 41dnl 42 43AC_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 65]) 66 67AC_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 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(HAVE_LIBFREETYPE,1,[ ]) 205 AC_DEFINE(ENABLE_GD_TTF,1,[ ]) 206 else 207 AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>]) 208 fi 209]) 210 211AC_DEFUN([PHP_GD_JISX0208],[ 212 if test "$PHP_GD_JIS_CONV" = "yes"; then 213 USE_GD_JIS_CONV=1 214 fi 215]) 216 217AC_DEFUN([PHP_GD_CHECK_VERSION],[ 218 PHP_CHECK_LIBRARY(gd, gdImageCreateFromPng, [AC_DEFINE(HAVE_GD_PNG, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 219 PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp, [AC_DEFINE(HAVE_GD_WEBP, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 220 PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg, [AC_DEFINE(HAVE_GD_JPG, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 221 PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm, [AC_DEFINE(HAVE_GD_XPM, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 222 PHP_CHECK_LIBRARY(gd, gdImageCreateFromBmp, [AC_DEFINE(HAVE_GD_BMP, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 223 PHP_CHECK_LIBRARY(gd, gdImageStringFT, [AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 224 PHP_CHECK_LIBRARY(gd, gdVersionString, [AC_DEFINE(HAVE_GD_LIBVERSION, 1, [ ])], [], [ $GD_SHARED_LIBADD ]) 225]) 226 227dnl 228dnl Main GD configure 229dnl 230 231dnl 232dnl Common for both builtin and external GD 233dnl 234if test "$PHP_GD" != "no"; then 235 236dnl PNG is required by GD library 237 test "$PHP_PNG_DIR" = "no" && PHP_PNG_DIR=yes 238 239dnl Various checks for GD features 240 PHP_GD_ZLIB 241 PHP_GD_WEBP 242 PHP_GD_JPEG 243 PHP_GD_PNG 244 PHP_GD_XPM 245 PHP_GD_FREETYPE2 246 PHP_GD_JISX0208 247fi 248 249if test "$PHP_GD" = "yes"; then 250 GD_MODULE_TYPE=builtin 251 extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \ 252 libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \ 253 libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \ 254 libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \ 255 libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \ 256 libgd/gd_topal.c libgd/gd_gif_in.c libgd/gd_xbm.c libgd/gd_gif_out.c libgd/gd_security.c \ 257 libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_rotate.c libgd/gd_color_match.c \ 258 libgd/gd_transform.c libgd/gd_crop.c libgd/gd_interpolation.c libgd/gd_matrix.c \ 259 libgd/gd_bmp.c" 260 261dnl check for fabsf and floorf which are available since C99 262 AC_CHECK_FUNCS(fabsf floorf) 263 264dnl These are always available with bundled library 265 AC_DEFINE(HAVE_GD_BUNDLED, 1, [ ]) 266 AC_DEFINE(HAVE_GD_PNG, 1, [ ]) 267 AC_DEFINE(HAVE_GD_BMP, 1, [ ]) 268 AC_DEFINE(HAVE_GD_CACHE_CREATE, 1, [ ]) 269 270dnl Make sure the libgd/ is first in the include path 271 GDLIB_CFLAGS="-DHAVE_LIBPNG" 272 273dnl Depending which libraries were included to PHP configure, 274dnl enable the support in bundled GD library 275 276 if test -n "$GD_WEBP_DIR"; then 277 AC_DEFINE(HAVE_GD_WEBP, 1, [ ]) 278 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBWEBP" 279 fi 280 281 if test -n "$GD_JPEG_DIR"; then 282 AC_DEFINE(HAVE_GD_JPG, 1, [ ]) 283 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBJPEG" 284 fi 285 286 if test -n "$GD_XPM_DIR"; then 287 AC_DEFINE(HAVE_GD_XPM, 1, [ ]) 288 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM" 289 fi 290 291 if test -n "$FREETYPE2_DIR"; then 292 AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ]) 293 AC_DEFINE(ENABLE_GD_TTF, 1, [ ]) 294 GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF" 295 fi 296 297 if test -n "$USE_GD_JIS_CONV"; then 298 AC_DEFINE(USE_GD_JISX0208, 1, [ ]) 299 GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208" 300 fi 301 302else 303 304 if test "$PHP_GD" != "no"; then 305 GD_MODULE_TYPE=external 306 extra_sources="gd_compat.c" 307 308dnl Various checks for GD features 309 PHP_GD_ZLIB 310 PHP_GD_WEBP 311 PHP_GD_JPEG 312 PHP_GD_PNG 313 PHP_GD_XPM 314 PHP_GD_FREETYPE2 315 316dnl Header path 317 for i in include/gd include/gd2 include gd ""; do 318 test -f "$PHP_GD/$i/gd.h" && GD_INCLUDE="$PHP_GD/$i" 319 done 320 321 if test -z "$GD_INCLUDE"; then 322 AC_MSG_ERROR([Unable to find gd.h anywhere under $PHP_GD]) 323 fi 324 325dnl Library path 326 327 PHP_CHECK_LIBRARY(gd, gdSetErrorMethod, 328 [ 329 PHP_ADD_LIBRARY_WITH_PATH(gd, $PHP_GD/$PHP_LIBDIR, GD_SHARED_LIBADD) 330 AC_DEFINE(HAVE_LIBGD, 1, [ ]) 331 ],[ 332 AC_MSG_ERROR([Unable to find libgd.(a|so) >= 2.1.0 anywhere under $PHP_GD]) 333 ],[ 334 -L$PHP_GD/$PHP_LIBDIR 335 ]) 336 PHP_GD_CHECK_VERSION 337 338 PHP_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE) 339 fi 340fi 341 342dnl 343dnl Common for both builtin and external GD 344dnl 345if test "$PHP_GD" != "no"; then 346 PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS)) 347 348 if test "$GD_MODULE_TYPE" = "builtin"; then 349 PHP_ADD_BUILD_DIR($ext_builddir/libgd) 350 GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS" 351 GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/" 352 353 PHP_TEST_BUILD(foobar, [], [ 354 AC_MSG_ERROR([GD build test failed. Please check the config.log for details.]) 355 ], [ $GD_SHARED_LIBADD ], [char foobar () {}]) 356 else 357 GD_HEADER_DIRS="ext/gd/" 358 GDLIB_CFLAGS="-I$GD_INCLUDE $GDLIB_CFLAGS" 359 PHP_ADD_INCLUDE($GD_INCLUDE) 360 PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [ 361 AC_MSG_ERROR([GD build test failed. Please check the config.log for details.]) 362 ], [ $GD_SHARED_LIBADD ]) 363 fi 364 365 PHP_INSTALL_HEADERS([$GD_HEADER_DIRS]) 366 PHP_SUBST(GDLIB_CFLAGS) 367 PHP_SUBST(GD_SHARED_LIBADD) 368fi 369