3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(libgdiplus,2.5)
11 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
12 if test "x$PKG_CONFIG" = "xno"; then
13 AC_MSG_ERROR([You need to install pkg-config])
15 GLIB_REQUIRED_VERSION="2.2.3"
16 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
18 GDIPLUS_LIBS="`pkg-config --libs glib-2.0 `"
19 GDIPLUS_CFLAGS="`pkg-config --cflags glib-2.0 `"
21 # libgdiplus bundles its own cairo 1.6.4 but if the system cairo is more recent then we use it instead
22 CAIRO_BUNDLED_VERSION="1.6.4"
23 PKG_CHECK_MODULES(CAIRO, cairo > $CAIRO_BUNDLED_VERSION, [cairo_v=system], [cairo_v=internal])
25 # Optional use (experimental and unsupported) of Pango's text rendering on top of Cairo
26 AC_ARG_WITH(pango, [ --with-pango],[text_v=pango],[text_v=cairo])
28 if test $cairo_v = "internal"; then
29 # force subdirectories (cairo, specifically) to build their static
30 # libraries using position independent code.
31 ac_configure_args="$ac_configure_args --with-pic=yes"
33 # disable the PNG, PDF and SVG surface backends of Cairo (unrequired for GDI+)
34 # cairo 1.6.4 bug - we can't disable PDF and keep PS backend - reported at https://bugs.freedesktop.org/show_bug.cgi?id=15532
35 # ac_configure_args="$ac_configure_args --disable-png --disable-pdf --disable-svg"
36 ac_configure_args="$ac_configure_args --disable-png --disable-svg"
37 # gdiplus mac note; if we have quartz and ft fonts, quartz is the default and gdi+ assumes the latter everywhere, force it out
38 # of the internal build
39 ac_configure_args="$ac_configure_args --disable-quartz-font"
41 AC_CONFIG_SUBDIRS([pixman cairo])
42 CAIRO_DIR="pixman cairo"
43 CAIRO_LIBS='$(top_builddir)/cairo/src/libcairo.la'
44 CAIRO_CFLAGS='-I$(top_builddir)/pixman/pixman -I$(top_srcdir)/pixman/pixman -I$(top_builddir)/cairo/src -I$(top_srcdir)/cairo/src'
45 cairo_info+="$CAIRO_BUNDLED_VERSION (internal)"
46 AC_DEFINE(USE_INCLUDED_CAIRO,1,[Use Cairo/pixman bundled in libgdiplus])
48 if test $text_v = "pango"; then
49 AC_MSG_ERROR("Pango text rendering is only possible with --with-cairo=system")
53 CAIRO_LIBS="`pkg-config --libs cairo `"
54 CAIRO_CFLAGS="`pkg-config --cflags cairo `"
55 cairo_info="`pkg-config --modversion cairo ` (system)"
56 GDIPLUS_PKG_REQ="cairo"
58 if test $text_v = "pango"; then
59 PANGO_REQUIRED_VERSION="1.10"
60 PKG_CHECK_MODULES(PANGO, pango >= $PANGO_REQUIRED_VERSION)
61 PANGO_LIBS="`pkg-config --libs pangocairo `"
62 PANGO_CFLAGS="`pkg-config --cflags pangocairo `"
63 AC_DEFINE(USE_PANGO_RENDERING,1,[Use Pango to measure and draw text (INCOMPLETE and UNSUPPORTED)])
64 GDIPLUS_PKG_REQ="$GDIPLUS_PKG_REQ pangocairo-1.0"
68 GDIPLUS_LIBS="$GDIPLUS_LIBS $CAIRO_LIBS $PANGO_LIBS"
69 GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS $CAIRO_CFLAGS $PANGO_CFLAGS"
71 # Fall back to using fontconfig/freetype-config if their .pc is not found
72 PKG_CHECK_MODULES(FONTCONFIG, fontconfig,
73 [fontconfig_pkgconfig=yes], [fontconfig_pkgconfig=no])
74 if test "x$FONTCONFIG" = "xno"; then
75 AC_PATH_PROG(FONTCONFIG_CONFIG, fontconfig-config, no)
76 if test "x$FONTCONFIG_CONFIG" = "xyes"; then
77 FONTCONFIG_CFLAGS="`fontconfig-config --cflags`"
78 FONTCONFIG_LIBS="`fontconfig-config --libs`"
81 AC_CHECK_LIB(fontconfig, FcInit)
82 AC_CHECK_FUNCS(FcFini)
84 PKG_CHECK_MODULES(FREETYPE2, freetype2,
85 [freetype2_pkgconfig=yes], freetype2_pkgconfig=no])
86 if test "x$FREETYPE2" = "xno"; then
87 AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
88 if test "x$FREETYPE_CONFIG" = "xyes"; then
89 FREETYPE2_CFLAGS="`freetype-config --cflags`"
90 FREETYPE2_LIBS="`freetype-config --libs`"
94 GDIPLUS_LIBS="$GDIPLUS_LIBS $FONTCONFIG_LIBS $FREETYPE2_LIBS"
95 GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS $FONTCONFIG_CFLAGS $FREETYPE2_CFLAGS"
97 # Add xrender here so that we don't fail to find glib if we won't have xrender.pc
98 GDIPLUS_LIBS="$GDIPLUS_LIBS `pkg-config --libs xrender `"
99 GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS `pkg-config --cflags xrender `"
101 AC_CHECK_HEADERS(byteswap.h)
103 AC_MSG_CHECKING([host threading settings])
105 *-*-mingw*|*-*-cygwin*)
106 AC_DEFINE_UNQUOTED(CYGWIN,1,[Win32])
107 AC_CHECK_LIB(intl, gettext)
111 AC_DEFINE_UNQUOTED(BSDOS,1,[NetBSD])
115 AC_DEFINE_UNQUOTED(BSDOS,1,[FreeBSD])
116 CFLAGS="-D_THREAD_SAFE $CFLAGS"
120 AC_DEFINE_UNQUOTED(BSDOS,1,[OpenBSD])
126 AC_DEFINE_UNQUOTED(LINUX,1,[Linux])
127 AC_CHECK_LIB(pthread, pthread_create)
131 AC_DEFINE_UNQUOTED(SOLARIS,1,[Solaris])
132 AC_DEFINE_UNQUOTED(_REENTRANT,1,[For libc reentrancy])
133 CFLAGS="-pthreads $CFLAGS"
137 AC_DEFINE_UNQUOTED(OSX,1,[OS X])
138 CFLAGS="-no-cpp-precomp $CFLAGS"
139 LDFLAGS="-flat_namespace -undefined suppress $LDFLAGS"
143 AC_MSG_RESULT(Unrecognized host $host)
144 AC_DEFINE_UNQUOTED(OTHEROS,1,[Unknown])
148 # Apparently for BSD special handling needs to happen
149 # See http://archives/neohapsis.com/archives/openbsd/2001-11/2142.html
150 # by Miod Vallat <miod@online.fr>
152 [if compiler recognizes -pthread],
153 myapp_cv_gcc_pthread,
154 ac_save_CFLAGS=$CFLAGS
155 CFLAGS="$CFLAGS -pthread"
158 AC_TRY_LINK([#include <pthread.h>],
159 [void *p = pthread_create;],
160 myapp_cv_gcc_pthread=yes,
161 myapp_cv_gcc_pthread=no)
163 CFLAGS=$ac_save_CFLAGS
165 if test $myapp_cv_gcc_pthread = yes
168 CFLAGS="$CFLAGS -pthread"
170 AC_CHECK_LIB(pthread,pthread_create,myapp_threads=-lpthread,
171 [AC_CHECK_LIB(c_r,pthread_create,myapp_threads=-lc_r)])
175 # sigsetjmp is a macro on some platforms, so can't use AC_CHECK_FUNCS
176 AC_MSG_CHECKING(for sigsetjmp)
177 AC_TRY_LINK([#include <setjmp.h>], [
180 ], gdip_ok=yes, gdip_ok=no)
181 AC_MSG_RESULT($gdip_ok)
182 if test "$gdip_ok" = "yes"; then
183 AC_DEFINE(HAVE_SIGSETJMP, 1, sigsetjmp is available)
187 # when possible hide stuff we don't want to export
188 AC_MSG_CHECKING(for visibility __attribute__)
190 void __attribute__ ((visibility ("hidden"))) doit (void) {}
191 void main () { doit (); }
193 have_visibility_hidden=yes
196 have_visibility_hidden=no
204 # On solaris 10 x86, gcc prints a warning saying 'visibility attribute not supported on this configuration; ignored', but linking fails.
205 have_visibility_hidden=no
210 if test "x$have_visibility_hidden" = "xyes"; then
211 AC_DEFINE(HAVE_VISIBILITY_HIDDEN, 1, [Support for the visibility ("hidden") attribute])
216 [AC_HELP_STRING([--without-libjpeg], [disable JPEG file IO])])
218 [AC_HELP_STRING([--without-libtiff], [disable TIFF file IO])])
220 [AC_HELP_STRING([--without-libgif], [disable GIF file IO])])
222 [AC_HELP_STRING([--without-libexif], [disable EXIF support])])
225 if test x$with_libtiff != xno && test -z "$LIBTIFF"; then
226 AC_CHECK_LIB(tiff, TIFFReadScanline,
227 [AC_CHECK_HEADER(tiffio.h,
228 TIFF='tiff'; LIBTIFF='-ltiff',
229 AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
230 [AC_CHECK_LIB(tiff, TIFFWriteScanline,
231 [AC_CHECK_HEADER(tiffio.h,
232 TIFF='tiff'; LIBTIFF='-ltiff -ljpeg -lz',
233 AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
234 [AC_CHECK_LIB(tiff34, TIFFFlushData,
235 [AC_CHECK_HEADER(tiffio.h,
236 TIFF='tiff'; LIBTIFF='-ltiff34 -ljpeg -lz',
237 AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
238 AC_MSG_WARN(*** TIFF plug-in will not be built (TIFF library not found) ***), -lz -lm)], -ljpeg -lz -lm)], -lm)
241 if test x$TIFF != x; then
242 GDIPLUS_LIBS="$GDIPLUS_LIBS $LIBTIFF"
243 AC_DEFINE(HAVE_LIBTIFF, 1, Define if tiff support is available)
247 if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
248 AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
251 AC_MSG_WARN(*** JPEG loader will not be built (JPEG library not found) ***))
252 if test "$jpeg_ok" = yes; then
253 AC_MSG_CHECKING([for jpeglib.h])
259 #include <jpeglib.h>],
262 AC_MSG_RESULT($jpeg_ok)
263 if test "$jpeg_ok" = yes; then
264 JPEG='jpeg'; LIBJPEG='-ljpeg'
266 AC_MSG_WARN(*** JPEG loader will not be built (JPEG header file not found) ***)
271 if test x$JPEG != x; then
272 GDIPLUS_LIBS="$GDIPLUS_LIBS $LIBJPEG"
273 AC_DEFINE(HAVE_LIBJPEG, 1, Define if jpeg support is available)
276 dnl Test for libgif or libungif
277 if test x$with_libgif != xno && test -z "$LIBGIF"; then
278 AC_CHECK_LIB(gif, DGifOpenFileName,
279 [AC_CHECK_HEADER(gif_lib.h,
280 GIF='gif'; LIBGIF='-lgif',
281 AC_MSG_WARN(*** GIF loader will not be built (giflibrary not found) ***))],
282 AC_MSG_WARN(*** GIF loader will not be built (giflibrary not found) ***))
284 AC_CHECK_LIB(ungif, DGifOpenFileName,
285 [AC_CHECK_HEADER(gif_lib.h,
286 GIF='ungif'; LIBGIF='-lungif',
287 AC_MSG_WARN(*** GIF loader will not be built (ungiflibrary not found) ***))],
288 AC_MSG_WARN(*** GIF loader will not be built (ungiflibrary not found) ***))
291 if test x$GIF != x; then
292 GDIPLUS_LIBS="$GDIPLUS_LIBS $LIBGIF"
293 AC_DEFINE(HAVE_LIBGIF, 1, Define if gif support is available)
297 AC_MSG_CHECKING(for libpng12)
298 if $PKG_CONFIG --exists libpng12 ; then
301 PNG_DEP_CFLAGS_PACKAGES=libpng12
302 LIBPNG=`$PKG_CONFIG --libs libpng12`
305 AC_CHECK_LIB(png, png_read_info,
306 [AC_CHECK_HEADER(png.h,
309 AC_MSG_ERROR(*** libpng12 not found. See http://www.libpng.org/pub/png/libpng.html.), -lz -lm)
310 if test "$png_ok" = yes; then
311 AC_MSG_CHECKING([for png_structp in png.h])
312 AC_TRY_COMPILE([#include <png.h>],
313 [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
316 AC_MSG_RESULT($png_ok)
317 if test "$png_ok" = yes; then
318 PNG='png'; LIBPNG='-lpng -lz'
320 AC_MSG_ERROR(*** libpng12 found, but it is too old. See http://www.libpng.org/pub/png/libpng.html.)
323 AC_MSG_ERROR(*** libpng12 not found. See http://www.libpng.org/pub/png/libpng.html.)
328 GDIPLUS_LIBS="$GDIPLUS_LIBS $LIBPNG"
329 AC_DEFINE(HAVE_LIBPNG, 1, Define if png support is available. Always defined.)
332 if test x$with_libexif != xno && test -z "$LIBEXIF"; then
333 PKG_CHECK_MODULES(LIBEXIF, libexif, [libexif_pkgconfig=yes], libexif_pkgconfig=no])
334 if test x$libexif_pkgconfig = xyes ; then
335 GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS $LIBEXIF_CFLAGS"
336 GDIPLUS_LIBS="$GDIPLUS_LIBS $LIBEXIF_LIBS"
337 AC_DEFINE(HAVE_LIBEXIF, 1, Define if libexif is available.)
339 libexif_pkgconfig="No. Get it from http://libexif.sourceforge.net/"
342 libexif_pkgconfig="No. You disabled it."
344 AM_CONDITIONAL(HAVE_LIBEXIF, test x$libexif_pkgconfig = xyes)
347 dnl Produce a diagnostic, to reduce support time
349 AC_TRY_COMPILE([#include <X11/Xlib.h>],
350 [],[x11_failed=false],[x11_failed=true])
352 AC_ERROR("Failed to compile with X11/Xlib.h include. You must fix your compiler paths")
355 GDIPLUS_PKG_LIBS="$GDIPLUS_LIBS"
356 GDIPLUS_PKG_CFLAGS="$GDIPLUS_CFLAGS"
358 AC_SUBST(GDIPLUS_LIBS)
359 AC_SUBST(GDIPLUS_CFLAGS)
360 AC_SUBST(GDIPLUS_PKG_LIBS)
361 AC_SUBST(GDIPLUS_PKG_CFLAGS)
362 AC_SUBST(GDIPLUS_PKG_REQ)
373 echo "Configuration summary"
375 echo " * Installation prefix = $prefix"
376 echo " * Cairo = $cairo_info"
377 echo " * Text = $text_v"
378 echo " * EXIF tags = $libexif_pkgconfig"
379 echo " * Codecs supported:"
381 echo $ECHO_N " - TIFF: "
382 test ! x$TIFF = x && echo yes || echo "no (Get it from http://www.libtiff.org/)"
383 echo $ECHO_N " - JPEG: "
384 test ! x$JPEG = x && echo yes || echo "no (Get it from http://freshmeat.net/projects/libjpeg)"
385 echo $ECHO_N " - GIF: "
386 test ! x$GIF = x && echo yes || echo "no (See http://sourceforge.net/projects/libgif)"
387 echo $ECHO_N " - PNG: yes"
389 echo " NOTE: if any of the above say 'no' you may install the"
390 echo " corresponding development packages for them, rerun"
391 echo " autogen.sh to include them in the build."