oops, use usWinDescent for CellDescent if the OS/2 table exists
[libgdiplus.git] / configure.in
blob8a78e8c8392e3a04a009e3733b38e43099aa4686
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(libgdiplus,2.5)
6 AM_MAINTAINER_MODE
7 AM_PROG_LIBTOOL
9 AC_C_BIGENDIAN
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")
50         fi
51 else
52         CAIRO_DIR=""
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"
65         fi
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`"
79         fi
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`"
91         fi
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])
104 case "$host" in
105         *-*-mingw*|*-*-cygwin*)
106                 AC_DEFINE_UNQUOTED(CYGWIN,1,[Win32])
107                 AC_CHECK_LIB(intl, gettext)
108                 ;;
110         *-*-*netbsd*)
111                 AC_DEFINE_UNQUOTED(BSDOS,1,[NetBSD])
112                 ;;
114         *-*-*freebsd*)
115                 AC_DEFINE_UNQUOTED(BSDOS,1,[FreeBSD])
116                 CFLAGS="-D_THREAD_SAFE $CFLAGS"
117                 ;;
119         *-*-*openbsd*)
120                 AC_DEFINE_UNQUOTED(BSDOS,1,[OpenBSD])
121                 CFLAGS="$CFLAGS"
122                 LIBS="$LIBS"
123                 ;;
125         *-*-linux*)
126                 AC_DEFINE_UNQUOTED(LINUX,1,[Linux])
127                 AC_CHECK_LIB(pthread, pthread_create)
128                 ;;
130         *-*-solaris*)
131                 AC_DEFINE_UNQUOTED(SOLARIS,1,[Solaris])
132                 AC_DEFINE_UNQUOTED(_REENTRANT,1,[For libc reentrancy])
133                 CFLAGS="-pthreads $CFLAGS"
134                 ;;
136         *-*-darwin*)
137                 AC_DEFINE_UNQUOTED(OSX,1,[OS X])
138                 CFLAGS="-no-cpp-precomp $CFLAGS"
139                 LDFLAGS="-flat_namespace -undefined suppress $LDFLAGS"
140                 ;;
142         *)
143                 AC_MSG_RESULT(Unrecognized host $host)
144                 AC_DEFINE_UNQUOTED(OTHEROS,1,[Unknown])
145                 ;;
146 esac
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>
151 AC_CACHE_CHECK(
152   [if compiler recognizes -pthread],
153    myapp_cv_gcc_pthread,
154    ac_save_CFLAGS=$CFLAGS
155    CFLAGS="$CFLAGS -pthread"
156    AC_LANG_SAVE
157    AC_LANG_C
158    AC_TRY_LINK([#include <pthread.h>],
159                [void *p = pthread_create;],
160                 myapp_cv_gcc_pthread=yes,
161                 myapp_cv_gcc_pthread=no)
162    AC_LANG_RESTORE
163    CFLAGS=$ac_save_CFLAGS
165 if test $myapp_cv_gcc_pthread = yes
166 then
167    myapp_threads=""
168    CFLAGS="$CFLAGS -pthread"
169 else
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>], [
178 sigjmp_buf env;
179 sigsetjmp(env, 0);
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__)
189 AC_TRY_COMPILE([], [
190    void __attribute__ ((visibility ("hidden"))) doit (void) {}
191    void main () { doit (); }
192 ], [
193    have_visibility_hidden=yes
194    AC_MSG_RESULT(yes)
195 ], [
196    have_visibility_hidden=no
197    AC_MSG_RESULT(no)
200 case "$host" in
201         i*86-*-*)
202                 case $host_os in
203                   solaris*)
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
206                 esac
207                 ;;
208 esac
210 if test "x$have_visibility_hidden" = "xyes"; then
211    AC_DEFINE(HAVE_VISIBILITY_HIDDEN, 1, [Support for the visibility ("hidden") attribute])
215 AC_ARG_WITH(libjpeg,
216         [AC_HELP_STRING([--without-libjpeg], [disable JPEG file IO])])
217 AC_ARG_WITH(libtiff,
218         [AC_HELP_STRING([--without-libtiff], [disable TIFF file IO])])
219 AC_ARG_WITH(libgif,
220         [AC_HELP_STRING([--without-libgif], [disable GIF file IO])])
221 AC_ARG_WITH(libexif,
222         [AC_HELP_STRING([--without-libexif], [disable EXIF support])])
224 dnl Test for libtiff
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)
239   fi
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)
246 dnl Test for libjpeg
247   if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
248     AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
249       jpeg_ok=yes,
250       jpeg_ok=no
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])
254       AC_TRY_CPP(
255 [#include <stdio.h>
256 #undef PACKAGE
257 #undef VERSION
258 #undef HAVE_STDLIB_H
259 #include <jpeglib.h>],
260         jpeg_ok=yes,
261         jpeg_ok=no)
262       AC_MSG_RESULT($jpeg_ok)
263       if test "$jpeg_ok" = yes; then
264         JPEG='jpeg'; LIBJPEG='-ljpeg'
265       else
266         AC_MSG_WARN(*** JPEG loader will not be built (JPEG header file not found) ***)
267       fi
268     fi
269   fi
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) ***))
289   fi
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)
296 dnl Test for libpng
297     AC_MSG_CHECKING(for libpng12)
298     if $PKG_CONFIG --exists libpng12 ; then
299         AC_MSG_RESULT(yes)
300         PNG='png'
301         PNG_DEP_CFLAGS_PACKAGES=libpng12
302         LIBPNG=`$PKG_CONFIG --libs libpng12`
303     else
304       AC_MSG_RESULT(no)
305       AC_CHECK_LIB(png, png_read_info,
306         [AC_CHECK_HEADER(png.h,
307           png_ok=yes,
308           png_ok=no)],
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;],
314           png_ok=yes,
315           png_ok=no)
316         AC_MSG_RESULT($png_ok)
317         if test "$png_ok" = yes; then
318           PNG='png'; LIBPNG='-lpng -lz'
319         else
320           AC_MSG_ERROR(*** libpng12 found, but it is too old. See http://www.libpng.org/pub/png/libpng.html.)
321         fi
322       else
323           AC_MSG_ERROR(*** libpng12 not found. See http://www.libpng.org/pub/png/libpng.html.)
324       fi
325     fi
328 GDIPLUS_LIBS="$GDIPLUS_LIBS $LIBPNG"
329 AC_DEFINE(HAVE_LIBPNG, 1, Define if png support is available. Always defined.)
331 dnl Test for libexif
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.)
338   else
339         libexif_pkgconfig="No. Get it from http://libexif.sourceforge.net/"
340   fi
341 else
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])
351 if $x11_failed; then
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)
363 AC_SUBST(CAIRO_DIR)
365 AC_OUTPUT([
366 Makefile
367 libgdiplus.pc
368 libgdiplus0.spec
369 src/Makefile
370 tests/Makefile])
372 echo "---"
373 echo "Configuration summary"
374 echo ""
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:"
380 echo ""
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"
388 echo ""
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."
392 echo ""
393 echo "---"