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