xref: /PHP-8.0/ext/gd/config.m4 (revision 03bd4333)
1dnl
2dnl Configure options
3dnl
4PHP_ARG_ENABLE([gd],
5  [for GD support],
6  [AS_HELP_STRING([--enable-gd],
7    [Include GD support])])
8
9PHP_ARG_WITH([external-gd],
10  [for external libgd],
11  [AS_HELP_STRING([--with-external-gd],
12    [Use external libgd])],
13  [no],
14  [no])
15
16if test -z "$PHP_WEBP"; then
17  PHP_ARG_WITH([webp],
18    [for libwebp],
19    [AS_HELP_STRING([--with-webp],
20      [GD: Enable WEBP support (only for bundled libgd)])],
21    [no],
22    [no])
23fi
24
25if test -z "$PHP_JPEG"; then
26  PHP_ARG_WITH([jpeg],
27    [for libjpeg],
28    [AS_HELP_STRING([--with-jpeg],
29      [GD: Enable JPEG support (only for bundled libgd)])],
30    [no],
31    [no])
32fi
33
34PHP_ARG_WITH([xpm],
35  [for libXpm],
36  [AS_HELP_STRING([--with-xpm],
37    [GD: Enable XPM support  (only for bundled libgd)])],
38  [no],
39  [no])
40
41PHP_ARG_WITH([freetype],
42  [for FreeType 2],
43  [AS_HELP_STRING([--with-freetype],
44    [GD: Enable FreeType 2 support (only for bundled libgd)])],
45  [no],
46  [no])
47
48PHP_ARG_ENABLE([gd-jis-conv],
49  [whether to enable JIS-mapped Japanese font support in GD],
50  [AS_HELP_STRING([--enable-gd-jis-conv],
51    [GD: Enable JIS-mapped Japanese font support (only for bundled libgd)])],
52  [no],
53  [no])
54
55dnl
56dnl Checks for the configure options
57dnl
58
59dnl zlib is always required
60AC_DEFUN([PHP_GD_ZLIB],[
61  PKG_CHECK_MODULES([ZLIB], [zlib])
62  PHP_EVAL_LIBLINE($ZLIB_LIBS, GD_SHARED_LIBADD)
63  PHP_EVAL_INCLINE($ZLIB_CFLAGS)
64])
65
66dnl libpng is always required
67AC_DEFUN([PHP_GD_PNG],[
68  PKG_CHECK_MODULES([PNG], [libpng])
69  PHP_EVAL_LIBLINE($PNG_LIBS, GD_SHARED_LIBADD)
70  PHP_EVAL_INCLINE($PNG_CFLAGS)
71  AC_DEFINE(HAVE_LIBPNG, 1, [ ])
72])
73
74AC_DEFUN([PHP_GD_WEBP],[
75  if test "$PHP_WEBP" != "no"; then
76    PKG_CHECK_MODULES([WEBP], [libwebp])
77    PHP_EVAL_LIBLINE($WEBP_LIBS, GD_SHARED_LIBADD)
78    PHP_EVAL_INCLINE($WEBP_CFLAGS)
79    AC_DEFINE(HAVE_LIBWEBP, 1, [ ])
80    AC_DEFINE(HAVE_GD_WEBP, 1, [ ])
81  fi
82])
83
84AC_DEFUN([PHP_GD_JPEG],[
85  if test "$PHP_JPEG" != "no"; then
86    PKG_CHECK_MODULES([JPEG], [libjpeg])
87    PHP_EVAL_LIBLINE($JPEG_LIBS, GD_SHARED_LIBADD)
88    PHP_EVAL_INCLINE($JPEG_CFLAGS)
89    AC_DEFINE(HAVE_LIBJPEG, 1, [ ])
90    AC_DEFINE(HAVE_GD_JPG, 1, [ ])
91  fi
92])
93
94AC_DEFUN([PHP_GD_XPM],[
95  if test "$PHP_XPM" != "no"; then
96    PKG_CHECK_MODULES([XPM], [xpm])
97    PHP_EVAL_LIBLINE($XPM_LIBS, GD_SHARED_LIBADD)
98    PHP_EVAL_INCLINE($XPM_CFLAGS)
99    AC_DEFINE(HAVE_XPM, 1, [ ])
100    AC_DEFINE(HAVE_GD_XPM, 1, [ ])
101  fi
102])
103
104AC_DEFUN([PHP_GD_FREETYPE2],[
105  if test "$PHP_FREETYPE" != "no"; then
106    PKG_CHECK_MODULES([FREETYPE2], [freetype2], [FREETYPE2_FOUND=true])
107
108    PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
109    PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
110    AC_DEFINE(HAVE_LIBFREETYPE, 1, [ ])
111    AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])
112  fi
113])
114
115AC_DEFUN([PHP_GD_JISX0208],[
116  if test "$PHP_GD_JIS_CONV" = "yes"; then
117    AC_DEFINE(USE_GD_JISX0208, 1, [ ])
118    AC_DEFINE(JISX0208, 1, [ ])
119  fi
120])
121
122AC_DEFUN([PHP_GD_CHECK_VERSION],[
123  PHP_CHECK_LIBRARY(gd, gdImageCreateFromPng,          [AC_DEFINE(HAVE_GD_PNG,               1, [ ])], [], [ $GD_SHARED_LIBADD ])
124  PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp,         [AC_DEFINE(HAVE_GD_WEBP,              1, [ ])], [], [ $GD_SHARED_LIBADD ])
125  PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg,         [AC_DEFINE(HAVE_GD_JPG,               1, [ ])], [], [ $GD_SHARED_LIBADD ])
126  PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm,          [AC_DEFINE(HAVE_GD_XPM,               1, [ ])], [], [ $GD_SHARED_LIBADD ])
127  PHP_CHECK_LIBRARY(gd, gdImageCreateFromBmp,          [AC_DEFINE(HAVE_GD_BMP,               1, [ ])], [], [ $GD_SHARED_LIBADD ])
128  PHP_CHECK_LIBRARY(gd, gdImageCreateFromTga,          [AC_DEFINE(HAVE_GD_TGA,               1, [ ])], [], [ $GD_SHARED_LIBADD ])
129  PHP_CHECK_LIBRARY(gd, gdImageStringFT,               [AC_DEFINE(HAVE_GD_FREETYPE,          1, [ ])], [], [ $GD_SHARED_LIBADD ])
130  PHP_CHECK_LIBRARY(gd, gdVersionString,               [AC_DEFINE(HAVE_GD_LIBVERSION,        1, [ ])], [], [ $GD_SHARED_LIBADD ])
131  PHP_CHECK_LIBRARY(gd, gdImageGetInterpolationMethod, [AC_DEFINE(HAVE_GD_GET_INTERPOLATION, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
132])
133
134dnl
135dnl Main GD configure
136dnl
137
138if test "$PHP_GD" != "no"; then
139
140  if test "$PHP_EXTERNAL_GD" = "no"; then
141    GD_CFLAGS=""
142    extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
143                  libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \
144                  libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \
145                  libgd/gdfontmb.c libgd/gdfontl.c libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c \
146                  libgd/gdcache.c libgd/gdkanji.c libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c \
147                  libgd/gd_topal.c libgd/gd_gif_in.c libgd/gd_xbm.c libgd/gd_gif_out.c libgd/gd_security.c \
148                  libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_rotate.c libgd/gd_color_match.c \
149                  libgd/gd_transform.c libgd/gd_crop.c libgd/gd_interpolation.c libgd/gd_matrix.c \
150                  libgd/gd_bmp.c libgd/gd_tga.c"
151
152dnl check for fabsf and floorf which are available since C99
153    AC_CHECK_FUNCS(fabsf floorf)
154
155dnl These are always available with bundled library
156    AC_DEFINE(HAVE_GD_BUNDLED,          1, [ ])
157    AC_DEFINE(HAVE_GD_PNG,              1, [ ])
158    AC_DEFINE(HAVE_GD_BMP,              1, [ ])
159    AC_DEFINE(HAVE_GD_TGA,              1, [ ])
160
161dnl Various checks for GD features
162    PHP_GD_ZLIB
163    PHP_GD_PNG
164    PHP_GD_WEBP
165    PHP_GD_JPEG
166    PHP_GD_XPM
167    PHP_GD_FREETYPE2
168    PHP_GD_JISX0208
169
170    PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GD_CFLAGS))
171    PHP_ADD_BUILD_DIR($ext_builddir/libgd)
172    GD_CFLAGS="-I$ext_srcdir/libgd $GD_CFLAGS"
173    GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
174
175    PHP_TEST_BUILD(foobar, [], [
176      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
177    ], [ $GD_SHARED_LIBADD ], [char foobar () {}])
178
179  else
180    extra_sources="gd_compat.c"
181    PKG_CHECK_MODULES([GDLIB], [gdlib >= 2.1.0])
182    PHP_EVAL_LIBLINE($GDLIB_LIBS, GD_SHARED_LIBADD)
183    PHP_EVAL_INCLINE($GDLIB_CFLAGS)
184    AC_DEFINE(HAVE_LIBGD, 1, [ ])
185    PHP_GD_CHECK_VERSION
186
187    PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared)
188    GD_HEADER_DIRS="ext/gd/"
189    PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
190      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
191    ], [ $GD_SHARED_LIBADD ])
192  fi
193
194  PHP_INSTALL_HEADERS([$GD_HEADER_DIRS])
195  PHP_SUBST(GD_CFLAGS)
196  PHP_SUBST(GDLIB_CFLAGS)
197  PHP_SUBST(GDLIB_LIBS)
198  PHP_SUBST(GD_SHARED_LIBADD)
199fi
200