config.m4 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. dnl config.m4 for extension gd
  2. dnl
  3. dnl Configure options
  4. dnl
  5. PHP_ARG_WITH(gd, for GD support,
  6. [ --with-gd[=DIR] Include GD support. DIR is the GD library base
  7. install directory [BUNDLED]])
  8. if test -z "$PHP_WEBP_DIR"; then
  9. PHP_ARG_WITH(webp-dir, for the location of libwebp,
  10. [ --with-webp-dir[=DIR] GD: Set the path to libwebp install prefix], no, no)
  11. fi
  12. if test -z "$PHP_JPEG_DIR"; then
  13. PHP_ARG_WITH(jpeg-dir, for the location of libjpeg,
  14. [ --with-jpeg-dir[=DIR] GD: Set the path to libjpeg install prefix], no, no)
  15. fi
  16. if test -z "$PHP_PNG_DIR"; then
  17. PHP_ARG_WITH(png-dir, for the location of libpng,
  18. [ --with-png-dir[=DIR] GD: Set the path to libpng install prefix], no, no)
  19. fi
  20. if test -z "$PHP_ZLIB_DIR"; then
  21. PHP_ARG_WITH(zlib-dir, for the location of libz,
  22. [ --with-zlib-dir[=DIR] GD: Set the path to libz install prefix], no, no)
  23. fi
  24. PHP_ARG_WITH(xpm-dir, for the location of libXpm,
  25. [ --with-xpm-dir[=DIR] GD: Set the path to libXpm install prefix], no, no)
  26. PHP_ARG_WITH(freetype-dir, for FreeType 2,
  27. [ --with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix], no, no)
  28. PHP_ARG_ENABLE(gd-jis-conv, whether to enable JIS-mapped Japanese font support in GD,
  29. [ --enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support], no, no)
  30. dnl
  31. dnl Checks for the configure options
  32. dnl
  33. AC_DEFUN([PHP_GD_ZLIB],[
  34. if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
  35. if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
  36. PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
  37. PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
  38. elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
  39. PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
  40. PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
  41. else
  42. AC_MSG_ERROR([Can't find zlib headers under "$PHP_ZLIB_DIR"])
  43. fi
  44. else
  45. for i in /usr/local /usr; do
  46. if test -f "$i/include/zlib/zlib.h"; then
  47. PHP_ZLIB_DIR="$i"
  48. PHP_ZLIB_INCDIR="$i/include/zlib"
  49. elif test -f "$i/include/zlib.h"; then
  50. PHP_ZLIB_DIR="$i"
  51. PHP_ZLIB_INCDIR="$i/include"
  52. fi
  53. done
  54. fi
  55. ])
  56. AC_DEFUN([PHP_GD_WEBP],[
  57. if test "$PHP_WEBP_DIR" != "no"; then
  58. for i in $PHP_WEBP_DIR /usr/local /usr; do
  59. test -f $i/include/webp/decode.h && GD_WEBP_DIR=$i && break
  60. done
  61. if test -z "$GD_WEBP_DIR"; then
  62. AC_MSG_ERROR([webp/decode.h not found.])
  63. fi
  64. for i in $PHP_WEBP_DIR /usr/local /usr; do
  65. test -f $i/include/webp/encode.h && GD_WEBP_DIR=$i && break
  66. done
  67. if test -z "$GD_WEBP_DIR"; then
  68. AC_MSG_ERROR([webp/encode.h not found.])
  69. fi
  70. PHP_CHECK_LIBRARY(webp,WebPGetInfo,
  71. [
  72. PHP_ADD_INCLUDE($GD_WEBP_DIR/include)
  73. PHP_ADD_LIBRARY(pthread)
  74. PHP_ADD_LIBRARY_WITH_PATH(webp, $GD_WEBP_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
  75. ],[
  76. AC_MSG_ERROR([Problem with libwebp.(a|so). Please check config.log for more information.])
  77. ],[
  78. -L$GD_WEBP_DIR/$PHP_LIBDIR
  79. ])
  80. else
  81. AC_MSG_RESULT([If configure fails try --with-webp-dir=<DIR>])
  82. fi
  83. ])
  84. AC_DEFUN([PHP_GD_JPEG],[
  85. if test "$PHP_JPEG_DIR" != "no"; then
  86. for i in $PHP_JPEG_DIR /usr/local /usr; do
  87. test -f $i/include/jpeglib.h && GD_JPEG_DIR=$i && break
  88. done
  89. if test -z "$GD_JPEG_DIR"; then
  90. AC_MSG_ERROR([jpeglib.h not found.])
  91. fi
  92. PHP_CHECK_LIBRARY(jpeg,jpeg_read_header,
  93. [
  94. PHP_ADD_INCLUDE($GD_JPEG_DIR/include)
  95. PHP_ADD_LIBRARY_WITH_PATH(jpeg, $GD_JPEG_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
  96. ],[
  97. AC_MSG_ERROR([Problem with libjpeg.(a|so). Please check config.log for more information.])
  98. ],[
  99. -L$GD_JPEG_DIR/$PHP_LIBDIR
  100. ])
  101. else
  102. AC_MSG_RESULT([If configure fails try --with-jpeg-dir=<DIR>])
  103. fi
  104. ])
  105. AC_DEFUN([PHP_GD_PNG],[
  106. if test "$PHP_PNG_DIR" != "no"; then
  107. for i in $PHP_PNG_DIR /usr/local /usr; do
  108. test -f $i/include/png.h && GD_PNG_DIR=$i && break
  109. done
  110. if test -z "$GD_PNG_DIR"; then
  111. AC_MSG_ERROR([png.h not found.])
  112. fi
  113. if test "$PHP_ZLIB_DIR" = "no"; then
  114. AC_MSG_ERROR([PNG support requires ZLIB. Use --with-zlib-dir=<DIR>])
  115. fi
  116. PHP_CHECK_LIBRARY(png,png_write_image,
  117. [
  118. PHP_ADD_INCLUDE($GD_PNG_DIR/include)
  119. PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
  120. PHP_ADD_LIBRARY_WITH_PATH(png, $GD_PNG_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
  121. ],[
  122. AC_MSG_ERROR([Problem with libpng.(a|so) or libz.(a|so). Please check config.log for more information.])
  123. ],[
  124. -L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz -L$GD_PNG_DIR/$PHP_LIBDIR
  125. ])
  126. else
  127. AC_MSG_RESULT([If configure fails try --with-png-dir=<DIR> and --with-zlib-dir=<DIR>])
  128. fi
  129. ])
  130. AC_DEFUN([PHP_GD_XPM],[
  131. if test "$PHP_XPM_DIR" != "no"; then
  132. for i in $PHP_XPM_DIR /usr/local /usr/X11R6 /usr; do
  133. test -f $i/include/xpm.h && GD_XPM_DIR=$i && GD_XPM_INC=$i && break
  134. test -f $i/include/X11/xpm.h && GD_XPM_DIR=$i && GD_XPM_INC=$i/X11 && break
  135. done
  136. if test -z "$GD_XPM_DIR"; then
  137. AC_MSG_ERROR([xpm.h not found.])
  138. fi
  139. PHP_CHECK_LIBRARY(Xpm,XpmFreeXpmImage,
  140. [
  141. PHP_ADD_INCLUDE($GD_XPM_INC)
  142. PHP_ADD_LIBRARY_WITH_PATH(Xpm, $GD_XPM_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
  143. PHP_ADD_LIBRARY_WITH_PATH(X11, $GD_XPM_DIR/$PHP_LIBDIR, GD_SHARED_LIBADD)
  144. ],[
  145. AC_MSG_ERROR([Problem with libXpm.(a|so) or libX11.(a|so). Please check config.log for more information.])
  146. ],[
  147. -L$GD_XPM_DIR/$PHP_LIBDIR -lX11
  148. ])
  149. else
  150. AC_MSG_RESULT(If configure fails try --with-xpm-dir=<DIR>)
  151. fi
  152. ])
  153. AC_DEFUN([PHP_GD_FREETYPE2],[
  154. if test "$PHP_FREETYPE_DIR" != "no"; then
  155. for i in $PHP_FREETYPE_DIR /usr/local /usr; do
  156. if test -f "$i/bin/freetype-config"; then
  157. FREETYPE2_DIR=$i
  158. FREETYPE2_CONFIG="$i/bin/freetype-config"
  159. break
  160. fi
  161. done
  162. if test -z "$FREETYPE2_DIR"; then
  163. AC_MSG_ERROR([freetype-config not found.])
  164. fi
  165. FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
  166. FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
  167. PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
  168. PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
  169. AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
  170. AC_DEFINE(ENABLE_GD_TTF,1,[ ])
  171. else
  172. AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>])
  173. fi
  174. ])
  175. AC_DEFUN([PHP_GD_JISX0208],[
  176. if test "$PHP_GD_JIS_CONV" = "yes"; then
  177. USE_GD_JIS_CONV=1
  178. fi
  179. ])
  180. AC_DEFUN([PHP_GD_CHECK_VERSION],[
  181. PHP_CHECK_LIBRARY(gd, gdImageCreateFromPng, [AC_DEFINE(HAVE_GD_PNG, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  182. PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp, [AC_DEFINE(HAVE_GD_WEBP, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  183. PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg, [AC_DEFINE(HAVE_GD_JPG, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  184. PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm, [AC_DEFINE(HAVE_GD_XPM, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  185. PHP_CHECK_LIBRARY(gd, gdImageCreateFromBmp, [AC_DEFINE(HAVE_GD_BMP, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  186. PHP_CHECK_LIBRARY(gd, gdImageStringFT, [AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  187. PHP_CHECK_LIBRARY(gd, gdVersionString, [AC_DEFINE(HAVE_GD_LIBVERSION, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
  188. ])
  189. dnl
  190. dnl Main GD configure
  191. dnl
  192. dnl
  193. dnl Common for both builtin and external GD
  194. dnl
  195. if test "$PHP_GD" != "no"; then
  196. dnl PNG is required by GD library
  197. test "$PHP_PNG_DIR" = "no" && PHP_PNG_DIR=yes
  198. dnl Various checks for GD features
  199. PHP_GD_ZLIB
  200. PHP_GD_WEBP
  201. PHP_GD_JPEG
  202. PHP_GD_PNG
  203. PHP_GD_XPM
  204. PHP_GD_FREETYPE2
  205. PHP_GD_JISX0208
  206. fi
  207. if test "$PHP_GD" = "yes"; then
  208. GD_MODULE_TYPE=builtin
  209. extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
  210. libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \
  211. libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \
  212. libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \
  213. libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \
  214. libgd/gd_topal.c libgd/gd_gif_in.c libgd/gd_xbm.c libgd/gd_gif_out.c libgd/gd_security.c \
  215. libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_rotate.c libgd/gd_color_match.c \
  216. libgd/gd_transform.c libgd/gd_crop.c libgd/gd_interpolation.c libgd/gd_matrix.c \
  217. libgd/gd_bmp.c"
  218. dnl check for fabsf and floorf which are available since C99
  219. AC_CHECK_FUNCS(fabsf floorf)
  220. dnl These are always available with bundled library
  221. AC_DEFINE(HAVE_GD_BUNDLED, 1, [ ])
  222. AC_DEFINE(HAVE_GD_PNG, 1, [ ])
  223. AC_DEFINE(HAVE_GD_BMP, 1, [ ])
  224. AC_DEFINE(HAVE_GD_CACHE_CREATE, 1, [ ])
  225. dnl Make sure the libgd/ is first in the include path
  226. GDLIB_CFLAGS="-DHAVE_LIBPNG"
  227. dnl Depending which libraries were included to PHP configure,
  228. dnl enable the support in bundled GD library
  229. if test -n "$GD_WEBP_DIR"; then
  230. AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
  231. GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBWEBP"
  232. fi
  233. if test -n "$GD_JPEG_DIR"; then
  234. AC_DEFINE(HAVE_GD_JPG, 1, [ ])
  235. GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBJPEG"
  236. fi
  237. if test -n "$GD_XPM_DIR"; then
  238. AC_DEFINE(HAVE_GD_XPM, 1, [ ])
  239. GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM"
  240. fi
  241. if test -n "$FREETYPE2_DIR"; then
  242. AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])
  243. AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
  244. GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF"
  245. fi
  246. if test -n "$USE_GD_JIS_CONV"; then
  247. AC_DEFINE(USE_GD_JISX0208, 1, [ ])
  248. GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208"
  249. fi
  250. else
  251. if test "$PHP_GD" != "no"; then
  252. GD_MODULE_TYPE=external
  253. extra_sources="gd_compat.c"
  254. dnl Various checks for GD features
  255. PHP_GD_ZLIB
  256. PHP_GD_WEBP
  257. PHP_GD_JPEG
  258. PHP_GD_PNG
  259. PHP_GD_XPM
  260. PHP_GD_FREETYPE2
  261. dnl Header path
  262. for i in include/gd include/gd2 include gd ""; do
  263. test -f "$PHP_GD/$i/gd.h" && GD_INCLUDE="$PHP_GD/$i"
  264. done
  265. if test -z "$GD_INCLUDE"; then
  266. AC_MSG_ERROR([Unable to find gd.h anywhere under $PHP_GD])
  267. fi
  268. dnl Library path
  269. PHP_CHECK_LIBRARY(gd, gdSetErrorMethod,
  270. [
  271. PHP_ADD_LIBRARY_WITH_PATH(gd, $PHP_GD/$PHP_LIBDIR, GD_SHARED_LIBADD)
  272. AC_DEFINE(HAVE_LIBGD, 1, [ ])
  273. ],[
  274. AC_MSG_ERROR([Unable to find libgd.(a|so) >= 2.1.0 anywhere under $PHP_GD])
  275. ],[
  276. -L$PHP_GD/$PHP_LIBDIR
  277. ])
  278. PHP_GD_CHECK_VERSION
  279. PHP_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE)
  280. fi
  281. fi
  282. dnl
  283. dnl Common for both builtin and external GD
  284. dnl
  285. if test "$PHP_GD" != "no"; then
  286. PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS))
  287. if test "$GD_MODULE_TYPE" = "builtin"; then
  288. PHP_ADD_BUILD_DIR($ext_builddir/libgd)
  289. GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
  290. GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
  291. PHP_TEST_BUILD(foobar, [], [
  292. AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
  293. ], [ $GD_SHARED_LIBADD ], [char foobar () {}])
  294. else
  295. GD_HEADER_DIRS="ext/gd/"
  296. GDLIB_CFLAGS="-I$GD_INCLUDE $GDLIB_CFLAGS"
  297. PHP_ADD_INCLUDE($GD_INCLUDE)
  298. PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
  299. AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
  300. ], [ $GD_SHARED_LIBADD ])
  301. fi
  302. PHP_INSTALL_HEADERS([$GD_HEADER_DIRS])
  303. PHP_SUBST(GDLIB_CFLAGS)
  304. PHP_SUBST(GD_SHARED_LIBADD)
  305. fi