config.m4 12 KB

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