Imported Upstream version 1.12.14
[platform/upstream/cairo.git] / configure.ac
1 AC_PREREQ([2.63])
2 CAIRO_PARSE_VERSION
3 AC_INIT([cairo],
4         [cairo_version_major.cairo_version_minor.cairo_version_micro],
5         [http://bugs.freedesktop.org/enter_bug.cgi?product=cairo],
6         [cairo],
7         [http://cairographics.org/])
8 AC_CONFIG_AUX_DIR(build)
9 AC_CONFIG_MACRO_DIR(build)
10 AC_USE_SYSTEM_EXTENSIONS
11 AC_CONFIG_SRCDIR(src/cairo.h)
12 AC_CONFIG_HEADERS(config.h)
13
14 AM_INIT_AUTOMAKE([1.11 foreign -Wall no-define no-dist-gzip dist-xz])
15 AM_SILENT_RULES([yes])
16
17 # Initialize libtool
18 LT_PREREQ([2.2])
19 LT_INIT([win32-dll])
20
21 # Api documentation
22 GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
23
24 AC_SYS_LARGEFILE
25
26 dnl ===========================================================================
27 dnl
28 dnl The order of the includes here is rather important
29 dnl
30 m4_include(build/configure.ac.version)  dnl macros setting up various version declares
31 m4_include(build/configure.ac.tools)    dnl checks for tools we use
32 m4_include(build/configure.ac.features) dnl macros for backend/feature handling
33 m4_include(build/configure.ac.warnings) dnl checks for compiler warning
34 m4_include(build/configure.ac.system)   dnl checks for system functions, headers, libs
35 m4_include(build/configure.ac.analysis) dnl checks for analysis tools (lcov, etc)
36 m4_include(build/configure.ac.noversion) dnl disable builtin libtool versioning
37 m4_include(build/configure.ac.pthread)  dnl checks for pthreads
38 AC_CACHE_SAVE
39
40 dnl ===========================================================================
41
42 AC_CHECK_LIB(z, compress,
43          [AC_CHECK_HEADER(zlib.h, [
44           have_libz=yes
45           AC_DEFINE(HAVE_ZLIB, 1, [Define to 1 if you have zlib available])
46          ],
47          [have_libz="no (requires zlib http://www.gzip.org/zlib/)"])],
48          [have_libz="no (requires zlib http://www.gzip.org/zlib/)"])
49
50 save_LIBS="$LIBS"
51 AC_CHECK_LIB(lzo2, lzo2a_decompress,
52          [AC_CHECK_HEADER(lzo/lzo2a.h, [
53           have_lzo=yes
54           AC_DEFINE(HAVE_LZO, 1, [Define to 1 if you have lzo available])
55           lzo_LIBS="-llzo2"
56          ],
57          [have_lzo="no (requires lzpo http://www.oberhumer.com/opensource/lzo/)"])],
58          [have_lzo="no (requires lzpo http://www.oberhumer.com/opensource/lzo/)"])
59 AC_SUBST(lzo_LIBS)
60 LIBS="$save_LIBS"
61
62 AC_CHECK_LIB(dl, dlsym,
63              [have_dlsym=yes; have_dl=yes],
64              [have_dlsym=no; have_dl=no])
65 if test "x$have_dlsym" = "xno"; then
66    AC_CHECK_FUNC(dlsym, [have_dlsym=yes], [have_dlsym=no])
67 fi
68 AC_CHECK_HEADERS(dlfcn.h, [have_dlsym=yes], [have_dlsym=no])
69 AM_CONDITIONAL(CAIRO_HAS_DL, test "x$have_dl" = "xyes")
70 if test "x$have_dlsym" = "xyes"; then
71   AC_DEFINE([CAIRO_HAS_DLSYM], 1, [Define to 1 if dlsym is available])
72 fi
73 AM_CONDITIONAL(CAIRO_HAS_DLSYM, test "x$have_dlsym" = "xyes")
74
75 dnl ===========================================================================
76
77 CAIRO_ENABLE_SURFACE_BACKEND(xlib, Xlib, auto, [
78   xlib_REQUIRES="x11 xext"
79   PKG_CHECK_MODULES(xlib, $xlib_REQUIRES, ,
80                     [xlib_REQUIRES=""
81                      AC_PATH_XTRA
82                      if test "x$no_x" = xyes; then
83                        use_xlib="no (requires X development libraries)"
84                      else
85                        xlib_NONPKGCONFIG_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
86                        xlib_NONPKGCONFIG_CFLAGS=$X_CFLAGS
87                      fi])
88
89   AC_CHECK_HEADER(sys/ipc.h)
90   AC_CHECK_HEADER(sys/shm.h)
91
92   if test "$ac_cv_header_sys_ipc_h" = "yes" -a "$ac_cv_header_sys_shm_h" = "yes"; then
93       AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
94       AC_TRY_RUN([
95                   #include <sys/types.h>
96                   #include <sys/ipc.h>
97                   #include <sys/shm.h>
98                   int main()
99                   {
100                       char *shmaddr;
101                       int id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0600);
102                       if (id == -1) return 2;
103                       shmaddr = shmat (id, 0, 0);
104                       shmctl (id, IPC_RMID, 0);
105                       if ((char*) shmat (id, 0, 0) == (char*) -1) {
106                           shmdt (shmaddr);
107                           return 1;
108                       }
109                       shmdt (shmaddr);
110                       shmdt (shmaddr);
111                       return 0;
112                   }
113                   ],
114                   AC_DEFINE(IPC_RMID_DEFERRED_RELEASE, 1,
115                             [Define to 1 if shared memory segments are released deferred.])
116                   AC_MSG_RESULT(yes),
117                   AC_MSG_RESULT(no),
118                   AC_MSG_RESULT(assuming no))
119       fi
120
121       AC_CHECK_HEADERS([X11/extensions/XShm.h X11/extensions/shmproto.h X11/extensions/shmstr.h], [], [],
122                        [#include <X11/Xlibint.h>
123                         #include <X11/Xproto.h>])
124 ])
125
126 CAIRO_ENABLE_SURFACE_BACKEND(xlib_xrender, Xlib Xrender, auto, [
127   if test "x$use_xlib" != "xyes"; then
128     use_xlib_xrender="no (requires --enable-xlib)"
129   else
130     dnl Check for Xrender header files if the Xrender package is not installed:
131     xlib_xrender_BASE=cairo-xlib
132     xlib_xrender_REQUIRES="xrender >= 0.6"
133     PKG_CHECK_MODULES(xlib_xrender, $xlib_xrender_REQUIRES, ,
134                       [xlib_xrender_REQUIRES=""
135                        old_CPPFLAGS=$CPPFLAGS
136                        CPPFLAGS="$CPPFLAGS $xlib_CFLAGS $xlib_NONPKGCONFIG_CFLAGS"
137                        AC_CHECK_HEADER(X11/extensions/Xrender.h,
138                                        [xlib_xrender_NONPKGCONFIG_LIBS="-lXrender"],
139                                        [use_xlib_xrender="no (requires $xlib_xrender_REQUIRES http://freedesktop.org/Software/xlibs)"],
140                                        [#include <X11/X.h>])
141                        CPPFLAGS=$old_CPPFLAGS
142                       ])
143
144     old_CFLAGS=$CFLAGS
145     old_LIBS=$LIBS
146     CFLAGS="$CFLAGS $xlib_CFLAGS $xlib_NONPKGCONFIG_CFLAGS $xlib_xrender_CFLAGS $xlib_xrender_NONPKGCONFIG_CFLAGS"
147     LIBS="$LIBS $xlib_LIBS $xlib_NONPKGCONFIG_LIBS $xlib_xrender_LIBS $xlib_xrender_NONPKGCONFIG_LIBS"
148     AC_CHECK_FUNCS([XRenderCreateLinearGradient XRenderCreateRadialGradient XRenderCreateConicalGradient])
149     CFLAGS=$old_CFLAGS
150     LIBS=$old_LIBS
151
152   fi
153 ])
154
155 dnl ===========================================================================
156
157 CAIRO_ENABLE_SURFACE_BACKEND(xcb, XCB, auto, [
158   xcb_REQUIRES="xcb >= 1.6 xcb-render >= 1.6"
159   PKG_CHECK_MODULES(xcb, $xcb_REQUIRES, ,
160                     [use_xcb="no (requires $xcb_REQUIRES http://xcb.freedesktop.org)"])
161 ])
162
163 CAIRO_ENABLE_FUNCTIONS(xlib_xcb, Xlib/XCB, no, [
164   if test "x$use_xcb" = "xyes" -a "x$use_xlib" = "xyes"; then
165     xlib_xcb_REQUIRES="x11-xcb"
166     PKG_CHECK_MODULES(xlib_xcb, $xlib_xcb_REQUIRES, ,
167                       [use_xlib_xcb="no (requires $xlib_xcb_REQUIRES http://xcb.freedesktop.org)"])
168   else
169     use_xlib_xcb="no (requires both --enable-xlib and --enable-xcb)"
170   fi
171 ])
172
173 CAIRO_ENABLE_FUNCTIONS(xcb_shm, XCB/SHM, auto, [
174   if test "x$use_xcb" = "xyes"; then
175       xcb_shm_REQUIRES="xcb-shm"
176       PKG_CHECK_MODULES(xcb_shm, $xcb_shm_REQUIRES, ,
177                         [use_xcb_shm="no (requires $xcb_shm http://xcb.freedesktop.org)"])
178   else
179     use_xcb_shm="no (requires --enable-xcb)"
180   fi
181 ])
182
183 dnl ===========================================================================
184
185 CAIRO_ENABLE_SURFACE_BACKEND(qt, Qt, no, [
186   qt_REQUIRES="QtGui >= 4.4.0"
187   PKG_CHECK_MODULES(qt, $qt_REQUIRES, ,
188                     [qt_REQUIRES=""
189                      use_qt="no (requires Qt4 development libraries)"
190                      ])
191 ])
192
193 dnl ===========================================================================
194
195 CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [
196   dnl There is no pkgconfig for quartz; lets do a header check
197   AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, , [use_quartz="no (requires ApplicationServices framework)"])
198   if test "x$use_quartz" != "xyes" ; then
199     dnl check for CoreGraphics as a separate framework
200     AC_CHECK_HEADER(CoreGraphics/CoreGraphics.h, , [use_quartz="no (requires CoreGraphics framework)"])
201     quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics"
202   else
203     quartz_LIBS="-Xlinker -framework -Xlinker ApplicationServices"
204   fi
205 ])
206
207 CAIRO_ENABLE_FONT_BACKEND(quartz_font, Quartz, auto, [
208   use_quartz_font=$use_quartz
209 ])
210
211 CAIRO_ENABLE_SURFACE_BACKEND(quartz_image, Quartz Image, no, [
212   use_quartz_image=$use_quartz
213 ])
214
215 dnl ===========================================================================
216
217 CAIRO_ENABLE_SURFACE_BACKEND(win32, Microsoft Windows, auto, [
218   if test "x$have_windows" != xyes; then
219     use_win32="no (requires a Win32 platform)"
220   fi
221   win32_LIBS="-lgdi32 -lmsimg32"
222 ])
223
224 CAIRO_ENABLE_FONT_BACKEND(win32_font, Microsoft Windows, auto, [
225   use_win32_font=$use_win32
226 ])
227
228 test_win32_printing=no
229 if test "x$use_win32" = "xyes"; then
230   AC_CHECK_PROG(GS, gs, gs)
231   if test "$GS"; then
232     AC_DEFINE([CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE], 1, [Define to 1 if the Win32 Printing backend can be tested (needs ghostscript)])
233     test_win32_printing="yes"
234   else
235     AC_MSG_WARN([Win32 Printing backend will not be tested since ghostscript is not available])
236     test_win32_printing="no (requires ghostscript)"
237   fi
238 fi
239
240 AM_CONDITIONAL(CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE, test "x$test_win32_printing" = "xyes")
241
242 dnl ===========================================================================
243
244 CAIRO_ENABLE_SURFACE_BACKEND(skia, Skia, no, [
245   AC_ARG_WITH([skia],
246               [AS_HELP_STRING([--with-skia=/path/to/skia],
247                               [directory to find compiled skia sources])],
248               [skia_DIR="$withval"],
249               [skia_DIR="`pwd`/../skia"])
250   AC_ARG_WITH([skia-bulid],
251               [AS_HELP_STRING([--with-skia-build=(Release|Debug)]
252                               [build of skia to link with, default is Release])],
253               [skia_BUILD="$withval"],
254               [skia_BUILD="Release"])
255   skia_NONPKGCONFIG_CFLAGS="-I$skia_DIR/include/config -I$skia_DIR/include/core -I$skia_DIR/include/effects"
256   if test "x$skia_BUILD" = x"Release"; then
257         skia_NONPKGCONFIG_CFLAGS="-DSK_RELEASE -DSK_CAN_USE_FLOAT $skia_NONPKGCONFIG_CFLAGS"
258   fi
259   skia_NONPKGCONFIG_LIBS="--start-group $skia_DIR/out/$skia_BUILD/obj.target/gyp/libeffects.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libimages.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libutils.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libopts.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libcore.a -end-group"
260   AC_SUBST(skia_DIR)
261 ])
262
263 dnl ===========================================================================
264
265 CAIRO_ENABLE_SURFACE_BACKEND(os2, OS/2, no, [
266   case "$host" in
267     *-*-os2*)
268       :
269       ;;
270     *)
271       use_os2="no (requires an OS/2 platform)"
272       ;;
273   esac
274 ])
275
276 dnl ===========================================================================
277
278 CAIRO_ENABLE_SURFACE_BACKEND(beos, BeOS/Zeta, no, [
279   case "$host" in
280     *-*-beos)
281       beos_LIBS=""
282       dnl Add libbe and libzeta if available
283       AC_CHECK_LIB(be,main,beos_LIBS="$beos_LIBS -lbe")
284       AC_CHECK_LIB(zeta,main,beos_LIBS="$beos_LIBS -lzeta")
285       ;;
286     *)
287       use_beos="no (requires a BeOS platform)"
288       ;;
289   esac
290 ])
291
292 dnl ===========================================================================
293
294 CAIRO_ENABLE_SURFACE_BACKEND(drm, DRM, no, [
295   drm_REQUIRES="libudev >= 136"
296   PKG_CHECK_MODULES(drm, $drm_REQUIRES, ,
297    [use_drm="no (requires $drm_REQUIRES, udev is available from git://git.kernel.org/pub/scm/linux/hotplug/udev.git)"])
298 ])
299
300 CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
301   if test "x$use_drm" = "xyes"; then
302       AC_ARG_WITH([gallium],
303                   [AS_HELP_STRING([--with-gallium=/path/to/mesa],
304                                   [directory to find gallium enabled mesa])],
305                   [mesa_DIR="$withval"],
306                   [mesa_DIR="`pwd`/../mesa"])
307       gallium_DIR="$mesa_DIR/src/gallium"
308       gallium_NONPKGCONFIG_CFLAGS="-I$mesa_DIR/include -I$mesa_DIR/src/mesa -I$gallium_DIR/include -I$gallium_DIR/auxiliary"
309       gallium_NONPKGCONFIG_LIBS="-lGL"
310       AC_SUBST(mesa_DIR)
311       AC_SUBST(gallium_DIR)
312   else
313     use_gallium="no (requires --enable-drm)"
314   fi
315 ])
316
317 dnl ===========================================================================
318
319 CAIRO_ENABLE_FUNCTIONS(png, PNG, yes, [
320   use_png=no
321   AC_ARG_VAR([png_REQUIRES], [module name for libpng to search for using pkg-config])
322   if test "x$png_REQUIRES" = x; then
323     # libpng13 is GnuWin32's libpng-1.2.8 :-(
324     for l in libpng libpng14 libpng12 libpng13 libpng10; do
325       if $PKG_CONFIG --exists $l ; then
326         png_REQUIRES=$l
327         use_png=yes
328         break
329       fi
330     done
331   else
332     use_png=yes
333   fi
334
335   if test "x$use_png" = "xyes" ; then 
336     PKG_CHECK_MODULES(png, $png_REQUIRES, , : )
337   else
338     AC_MSG_WARN([Could not find libpng in the pkg-config search path])
339   fi    
340 ])
341
342 dnl ===========================================================================
343 CAIRO_ENABLE_SURFACE_BACKEND(gl, OpenGL, no, [
344   gl_REQUIRES="gl"
345   PKG_CHECK_MODULES(gl, $gl_REQUIRES,, [
346           dnl Fallback to searching for headers
347           AC_CHECK_HEADER(GL/gl.h,, [use_gl="no (gl.pc nor OpenGL headers not found)"])
348           if test "x$use_gl" = "xyes"; then
349               gl_NONPKGCONFIG_CFLAGS=
350               gl_NONPKGCONFIG_LIBS="-lGL"
351           fi])
352
353   if test "x$have_dl" = "xyes" -a "x$have_dlsym" = "xyes"; then
354     gl_LIBS="$gl_LIBS -ldl"
355   fi
356
357   need_glx_functions=yes
358   need_wgl_functions=yes
359   need_egl_functions=yes
360 ])
361
362 dnl ===========================================================================
363 CAIRO_ENABLE_SURFACE_BACKEND(glesv2, OpenGLESv2, no, [
364   glesv2_REQUIRES="glesv2"
365   PKG_CHECK_MODULES(glesv2, $glesv2_REQUIRES,, [
366           dnl Fallback to searching for headers
367           AC_CHECK_HEADER(GLES2/gl2.h,, [use_glesv2="no (glesv2.pc nor OpenGL ES 2.0 headers not found)"])
368           if test "x$use_glesv2" = "xyes"; then
369               glesv2_NONPKGCONFIG_CFLAGS=
370               glesv2_NONPKGCONFIG_LIBS="-lGLESv2"
371           fi])
372
373   if test "x$have_dl" = "xyes" -a "x$have_dlsym" = "xyes"; then
374     glesv2_LIBS="$glesv2_LIBS -ldl"
375   fi
376
377   need_egl_functions=yes
378 ])
379
380 dnl ===========================================================================
381 CAIRO_ENABLE_SURFACE_BACKEND(cogl, Cogl, no, [
382   cogl_REQUIRES="cogl-2.0-experimental"
383   PKG_CHECK_MODULES(cogl, $cogl_REQUIRES,, [use_cogl="no"])
384 ])
385
386 dnl ===========================================================================
387
388 CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [
389   directfb_REQUIRES=directfb
390   PKG_CHECK_MODULES(directfb, $directfb_REQUIRES, ,
391                     [use_directfb="no (requires $directfb_REQUIRES http://www.directfb.org)"])
392 ])
393
394 dnl ===========================================================================
395
396 CAIRO_ENABLE_SURFACE_BACKEND(vg, OpenVG, no, [
397   dnl There is no pkgconfig for OpenVG; lets do a header check
398   AC_CHECK_HEADER(VG/openvg.h,, [use_vg="no (OpenVG headers not found)"])
399   if test "x$use_vg" = "xyes"; then
400       vg_NONPKGCONFIG_CFLAGS=
401       vg_NONPKGCONFIG_LIBS="-lOpenVG"
402       need_egl_functions=yes
403       need_glx_functions=yes
404   fi
405 ])
406
407 CAIRO_ENABLE_FUNCTIONS(egl, EGL, auto, [
408   if test "x$need_egl_functions" = "xyes"; then
409       egl_REQUIRES="egl"
410       PKG_CHECK_MODULES(egl, $egl_REQUIRES, ,
411                     [egl_REQUIRES=""
412                      AC_CHECK_HEADER(EGL/egl.h,, [use_egl="no (EGL headers not found)"])
413                      if test "x$use_egl" = "xyes"; then
414                          egl_NONPKGCONFIG_CFLAGS=
415                          egl_NONPKGCONFIG_LIBS=
416                          save_LIBS="$LIBS"
417                          other_egl_LIBS=""
418                          # Temporary workaround for missing link from egl13
419                          AC_CHECK_LIB(csi, csi_stream_attachresource, other_egl_LIBS="-lcsi")
420                          LIBS="$other_egl_LIBS $LIBS"
421                          for egl_lib in EGL egl13 egl12 egl11; do
422                              if test -z "$egl_NONPKGCONFIG_LIBS"; then
423                                  AC_CHECK_LIB($egl_lib, eglGetError, egl_NONPKGCONFIG_LIBS="-l$egl_lib")
424                              fi
425                          done
426                          if test -z "$egl_NONPKGCONFIG_LIBS"; then
427                              use_egl="no (EGL library not found)"
428                          else
429                              egl_NONPKGCONFIG_LIBS="$egl_NONPKGCONFIG_LIBS $other_egl_LIBS"
430                          fi
431                          LIBS="$save_LIBS"
432                      fi
433         ])
434   else
435       use_egl="no (not required by any backend)"
436   fi
437 ])
438
439 CAIRO_ENABLE_FUNCTIONS(glx, GLX, auto, [
440   if test "x$need_glx_functions" = "xyes"; then
441     save_CFLAGS="$CFLAGS"
442     CFLAGS="$CFLAGS $gl_CFLAGS $gl_NONPKGCONFIG_CFLAGS"
443     AC_CHECK_HEADER(GL/glx.h,, [use_glx="no (GLX headers not found)"])
444     glx_NONPKGCONFIG_CFLAGS=
445     glx_NONPKGCONFIG_LIBS="-lGL"
446     CFLAGS="$save_CFLAGS"
447   else
448       use_glx="no (not required by any backend)"
449   fi
450 ])
451
452 CAIRO_ENABLE_FUNCTIONS(wgl, WGL, auto, [
453   if test "x$need_wgl_functions" = "xyes"; then
454     AC_CHECK_HEADER(windows.h,, [use_wgl="no (WGL headers not found)"])
455   else
456       use_wgl="no (not required by any backend)"
457   fi
458 ])
459
460 dnl ===========================================================================
461
462 any2ppm_cs=no
463 CAIRO_ENABLE_SURFACE_BACKEND(script, script, yes, [
464   any2ppm_cs=yes
465 ])
466
467 dnl ===========================================================================
468
469 # We use pkg-config to look for freetype2, but fall back to
470 # freetype-config if it fails.  We prefer pkg-config, since we can
471 # then just put freetype2 >= $FREETYPE_MIN_VERSION in
472 # Requires.private, but at least up to 2003-06-07, there was no
473 # freetype2.pc in the release.
474 #
475 # FreeType versions come in three forms:
476 #   release (such as 2.1.9)
477 #   libtool (such as 9.7.3) (returned by freetype-config and pkg-config)
478 #   platform-specific/soname (such as 6.3.4)
479 # and they recommend you never use the platform-specific version
480 # (see docs/VERSION.DLL in freetype2 sources)
481 #
482 # Set these as appropriate:
483
484 # release number - for information only
485 FREETYPE_MIN_RELEASE=2.1.9
486 # libtool-specific version - this is what is checked
487 FREETYPE_MIN_VERSION=9.7.3
488
489 CAIRO_ENABLE_FONT_BACKEND(ft, FreeType, auto, [
490
491     PKG_CHECK_MODULES(FREETYPE, freetype2 >= $FREETYPE_MIN_VERSION,
492                       [freetype_pkgconfig=yes],
493                       [freetype_pkgconfig=no])
494   
495     if test "x$freetype_pkgconfig" = "xyes"; then
496       ft_REQUIRES="freetype2 >= $FREETYPE_MIN_VERSION $ft_REQUIRES"
497     else
498   
499       if test -z "$FREETYPE_CONFIG"; then
500         AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
501       fi
502       if test "x$FREETYPE_CONFIG" = "xno" ; then
503         use_ft='no (freetype-config not found in path or $FREETYPE_CONFIG)'
504       else
505         AC_MSG_CHECKING(freetype2 libtool version)
506
507         FREETYPE_VERSION=`$FREETYPE_CONFIG --version`
508         AX_COMPARE_VERSION([$FREETYPE_VERSION], [gt], [$FREETYPE_MIN_VERSION],
509                            [AC_MSG_RESULT($FREETYPE_VERSION - OK)
510                            ft_NONPKGCONFIG_CFLAGS=`$FREETYPE_CONFIG --cflags`
511                            ft_NONPKGCONFIG_LIBS=`$FREETYPE_CONFIG --libs`],
512                            [AC_MSG_RESULT($FREETYPE_VERSION - Too old)
513                            use_ft="no ($FREETYPE_VERSION found; version $FREETYPE_MIN_VERSION from release $FREETYPE_MIN_RELEASE required)"])
514       fi
515     fi
516
517   ft_CFLAGS="$FREETYPE_CFLAGS"
518   ft_LIBS="$FREETYPE_LIBS"
519 ])
520
521 FONTCONFIG_MIN_VERSION=2.2.95
522 CAIRO_ENABLE_FONT_BACKEND(fc, Fontconfig, auto, [
523   use_fc=$use_ft
524   if test "x$use_fc" = "xyes"; then
525     fc_REQUIRES="fontconfig >= $FONTCONFIG_MIN_VERSION"
526     PKG_CHECK_MODULES(FONTCONFIG, $fc_REQUIRES,,
527                       [use_fc="no (requires $fc_REQUIRES)"])
528   fi
529   fc_CFLAGS="$FONTCONFIG_CFLAGS"
530   fc_LIBS="$FONTCONFIG_LIBS"
531 ])
532
533 if test "x$use_ft" = "xyes"; then
534   _save_libs="$LIBS"
535   _save_cflags="$CFLAGS"
536   LIBS="$LIBS $ft_LIBS"
537   CFLAGS="$CFLAGS $ft_CFLAGS"
538
539   AC_CHECK_FUNCS(FT_Get_X11_Font_Format FT_GlyphSlot_Embolden FT_GlyphSlot_Oblique FT_Load_Sfnt_Table FT_Library_SetLcdFilter)
540
541   LIBS="$_save_libs"
542   CFLAGS="$_save_cflags"
543 fi
544
545 if test "x$use_fc" = "xyes"; then
546   CAIRO_CHECK_FUNCS_WITH_FLAGS(FcInit FcFini, [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS])
547 fi
548
549 dnl ===========================================================================
550
551 CAIRO_ENABLE_SURFACE_BACKEND(ps, PostScript, yes, [
552     # The ps backend requires zlib.
553     use_ps=$have_libz
554     ps_NONPKGCONFIG_LIBS=-lz
555 ])
556
557 dnl ===========================================================================
558
559 SPECTRE_VERSION_REQUIRED=0.2.0
560 test_ps=no
561 any2ppm_ps=no
562 if test "x$use_ps" = "xyes"; then
563   AC_CHECK_PROG(GS, gs, gs)
564   if test "$GS"; then
565     AC_DEFINE([CAIRO_CAN_TEST_PS_SURFACE], 1, [Define to 1 if the PS backend can be tested (needs ghostscript)])
566     test_ps="yes"
567   else
568     AC_MSG_WARN([PS backend will not be tested since ghostscript is not available])
569     test_ps="no (requires ghostscript)"
570   fi
571
572   libspectre_DEPENDENCY="libspectre >= $SPECTRE_VERSION_REQUIRED"
573   PKG_CHECK_MODULES(LIBSPECTRE, $libspectre_DEPENDENCY,
574                     [any2ppm_ps=yes],
575                     [test_ps="no (requires libspectre)"])
576 fi
577
578 AM_CONDITIONAL(CAIRO_CAN_TEST_PS_SURFACE, test "x$test_ps" = "xyes")
579 AM_CONDITIONAL(CAIRO_HAS_SPECTRE, test "x$any2ppm_ps" = "xyes")
580 if test "x$any2ppm_ps" = "xyes"; then
581     AC_DEFINE([CAIRO_HAS_SPECTRE], 1, [Define to 1 if libspectre is available])
582 fi
583 AC_SUBST(LIBSPECTRE_CFLAGS)
584 AC_SUBST(LIBSPECTRE_LIBS)
585
586 dnl ===========================================================================
587
588 CAIRO_ENABLE_SURFACE_BACKEND(pdf, PDF, yes, [
589     # The pdf backend requires zlib.
590     use_pdf=$have_libz
591     pdf_NONPKGCONFIG_LIBS=-lz
592 ])
593
594 dnl ===========================================================================
595
596 # poppler-0.17.4 fixes text-pattern and text-transform
597 POPPLER_VERSION_REQUIRED=0.17.4
598 test_pdf=no
599 any2ppm_pdf=no
600 if test "x$use_pdf" = "xyes"; then
601   poppler_DEPENDENCY="poppler-glib >= $POPPLER_VERSION_REQUIRED"
602   PKG_CHECK_MODULES(POPPLER, $poppler_DEPENDENCY,
603                     [CAIRO_CHECK_FUNCS_WITH_FLAGS(poppler_page_render, [$POPPLER_CFLAGS], [$POPPLER_LIBS],
604                     [test_pdf=yes; any2ppm_pdf=yes],
605                     [test_pdf="no (requires $poppler_DEPENDENCY)"])],
606                     [test_pdf="no (requires $poppler_DEPENDENCY)"])
607   if test "x$test_pdf" = "xyes"; then
608     AC_DEFINE([CAIRO_CAN_TEST_PDF_SURFACE], 1, [Define to 1 if the PDF backend can be tested (need poppler and other dependencies for pdf2png)])
609   else
610     AC_MSG_WARN([PDF backend will not be tested since poppler >= $POPPLER_VERSION_REQUIRED is not available])
611   fi
612 fi
613
614 AM_CONDITIONAL(CAIRO_CAN_TEST_PDF_SURFACE, test "x$test_pdf" = "xyes")
615 AC_SUBST(POPPLER_CFLAGS)
616 AC_SUBST(POPPLER_LIBS)
617
618 AM_CONDITIONAL(CAIRO_HAS_MULTI_PAGE_SURFACES, test "x$use_ps" = "xyes" -o "x$use_pdf" = "xyes")
619
620 dnl ===========================================================================
621
622 CAIRO_ENABLE_SURFACE_BACKEND(svg, SVG, yes, [
623   if test "x$use_png" != "xyes"; then
624     use_svg="no (requires --enable-png)"
625   fi
626 ])
627
628 LIBRSVG_VERSION_REQUIRED=2.15.0
629 test_svg=no
630 any2ppm_svg=no
631 if test "x$use_svg" = "xyes"; then
632   librsvg_DEPENDENCY="librsvg-2.0 >= $LIBRSVG_VERSION_REQUIRED"
633   PKG_CHECK_MODULES(LIBRSVG, $librsvg_DEPENDENCY gdk-2.0,
634                     [CAIRO_CHECK_FUNCS_WITH_FLAGS(rsvg_pixbuf_from_file, [$LIBRSVG_CFLAGS], [$LIBRSVG_LIBS],
635                     [test_svg=yes; any2ppm_svg=yes],
636                     [test_svg="no (requires $librsvg_DEPENDENCY)"])],
637                     [test_svg="no (requires $librsvg_DEPENDENCY)"])
638   if test "x$test_svg" = "xyes"; then
639     AC_DEFINE([CAIRO_CAN_TEST_SVG_SURFACE], 1, [Define to 1 if the SVG backend can be tested])
640   else
641     AC_MSG_WARN([SVG backend will not be tested since librsvg >= $LIBRSVG_VERSION_REQUIRED is not available])
642   fi
643 fi
644
645 AM_CONDITIONAL(CAIRO_CAN_TEST_SVG_SURFACE, test "x$test_svg" = "xyes")
646 AC_SUBST(LIBRSVG_CFLAGS)
647 AC_SUBST(LIBRSVG_LIBS)
648
649 dnl ===========================================================================
650
651 dnl XXX make this a private feature?
652 CAIRO_ENABLE(test_surfaces, test surfaces, no)
653
654 dnl ===========================================================================
655
656 CAIRO_ENABLE_SURFACE_BACKEND(image, image, always, [
657   pixman_REQUIRES="pixman-1 >= 0.22.0"
658   PKG_CHECK_MODULES(pixman, $pixman_REQUIRES, ,
659     [use_image="no (requires $pixman_REQUIRES http://cairographics.org/releases/)"])
660   image_REQUIRES=$pixman_REQUIRES
661   image_CFLAGS=$pixman_CFLAGS
662   image_LIBS=$pixman_LIBS
663 ])
664
665 if pkg-config --exists 'pixman-1 >= 0.27.1'; then
666     AC_DEFINE([HAS_PIXMAN_GLYPHS], 1, [Enable pixman glyph cache])
667 fi
668
669
670 dnl ===========================================================================
671
672 CAIRO_ENABLE_SURFACE_BACKEND(mime, mime, always)
673 CAIRO_ENABLE_SURFACE_BACKEND(recording, recording, always)
674 CAIRO_ENABLE_SURFACE_BACKEND(observer, observer, always)
675 CAIRO_ENABLE_SURFACE_BACKEND(tee, tee, no)
676 CAIRO_ENABLE_SURFACE_BACKEND(xml, xml, no, [
677     use_xml=$have_libz
678     xml_NONPKGCONFIG_LIBS=-lz
679 ])
680
681 dnl ===========================================================================
682
683 CAIRO_ENABLE_FONT_BACKEND(user, user, always)
684
685 dnl ===========================================================================
686 dnl
687 dnl This needs to be last on our list of features so that the pthread libs and flags
688 dnl gets prefixed in front of everything else in CAIRO_{CFLAGS,LIBS}.
689 dnl
690 have_real_pthread=no
691 have_pthread=no
692 CAIRO_ENABLE(pthread, pthread, auto, [CAIRO_CONFIGURE_PTHREAD])
693 AM_CONDITIONAL(HAVE_REAL_PTHREAD, test "x$use_pthread" = "xyes" -a "x$have_real_pthread" = "xyes")
694 AM_CONDITIONAL(HAVE_PTHREAD, test "x$use_pthread" = "xyes")
695 AC_SUBST(pthread_CFLAGS)
696 AC_SUBST(pthread_LIBS)
697 AC_SUBST(real_pthread_CFLAGS)
698 AC_SUBST(real_pthread_LIBS)
699
700
701 dnl ===========================================================================
702 dnl Build gobject integration library
703
704 CAIRO_ENABLE_FUNCTIONS(gobject, gobject, auto, [
705   gobject_REQUIRES="gobject-2.0 glib-2.0"
706   PKG_CHECK_MODULES(GOBJECT, $gobject_REQUIRES, ,
707     [use_gobject="no (requires $gobject_REQUIRES http://download.gnome.org/pub/GNOME/sources/glib/)"])
708   gobject_NONPKGCONFIG_EXTRA_LIBS="-L\${libdir} -lcairo-gobject"
709 ])
710 dnl I'm too lazy to fix the caching properly
711 if test "x$use_gobject" = "xyes"; then
712   PKG_CHECK_MODULES(GOBJECT, $gobject_REQUIRES, : )
713 fi
714
715 dnl ===========================================================================
716 dnl Default to quick testing during development, but force a full test before
717 dnl release
718
719 AC_ARG_ENABLE(full-testing,
720   AS_HELP_STRING([--enable-full-testing],
721                  [Sets the test suite to perform full testing by default, which
722                   will dramatically slow down make check, but is a
723                   *requirement* before release.]), [
724 if test "x$enableval" = "xyes"; then
725     CAIRO_TEST_MODE=full
726     AC_SUBST(CAIRO_TEST_MODE)
727 fi
728 ])
729
730 dnl ===========================================================================
731 dnl Build the external converter if we have any of the test backends
732 AM_CONDITIONAL(BUILD_ANY2PPM,
733                test "x$any2ppm_svg" = "xyes" \
734                  -o "x$any2ppm_pdf" = "xyes" \
735                  -o "x$any2ppm_ps"  = "xyes" \
736                  -o "x$any2ppm_cs"  = "xyes")
737
738 dnl ===========================================================================
739 dnl Some utilities need to dlopen the shared libraries, so they need to
740 dnl know how libtools will name them
741
742 case $host in
743 *-*-darwin*)
744         SHLIB_EXT="dylib"
745         ;;
746 *)
747         SHLIB_EXT="so"
748         ;;
749 esac
750 AC_DEFINE_UNQUOTED(SHARED_LIB_EXT, "${SHLIB_EXT}", [Shared library file extension])
751 AC_SUBST(SHLIB_EXT)
752
753 dnl ===========================================================================
754 dnl The tracing utility requires LD_PRELOAD, so only build it for systems
755 dnl that are known to work.
756
757 case $host in
758 *-linux*|*-*bsd*|*-solaris*|*-*-darwin*|*-dragonfly*|*-*-gnu*)
759         have_ld_preload="yes"
760         ;;
761 *)
762         have_ld_preload="no"
763         ;;
764 esac
765
766 CAIRO_ENABLE(trace, cairo-trace, auto, [
767         if test "x$have_ld_preload" != "xyes" -o \
768                 "x$have_libz" != "xyes" -o \
769                 "x$have_real_pthread" != "xyes" -o \
770                 "x$have_dlsym" != "xyes"; then
771                 use_trace="no (requires dynamic linker and zlib and real pthreads)"
772         fi
773 ])
774
775 CAIRO_ENABLE(interpreter, cairo-script-interpreter, yes, [
776         if test "x$have_libz" != "xyes"; then
777                 use_interpreter="no (requires zlib)"
778         fi
779 ])
780
781 AC_CHECK_LIB(bfd, bfd_openr,
782          [AC_CHECK_HEADER(bfd.h, [have_bfd=yes],
783          [have_bfd=no])], [have_bfd=no])
784 AC_CHECK_HEADER(libiberty.h,, [have_bfd=no])
785 if test "x$have_bfd" = "xyes"; then
786     AC_DEFINE([HAVE_BFD], [1], [Define to 1 if you have the binutils development files installed])
787     BFD_LIBS=-lbfd
788     AC_SUBST(BFD_LIBS)
789 fi
790
791 CAIRO_ENABLE(symbol_lookup, symbol-lookup, auto, [
792         if test "x$have_bfd" != "xyes"; then
793                 use_symbol_lookup="no (requires bfd)"
794         fi
795 ])
796
797 PKG_CHECK_MODULES(glib, glib-2.0, have_glib=yes, have_glib=no)
798 AC_SUBST(glib_CFLAGS)
799 AC_SUBST(glib_LIBS)
800 AM_CONDITIONAL(BUILD_SPHINX, test "x$have_glib" = "xyes")
801
802 save_LIBS="$LIBS"
803 AC_CHECK_LIB(rt, shm_open, shm_LIBS="-lrt")
804 AC_SUBST(shm_LIBS)
805 LIBS="$save_LIBS"
806
807 dnl ===========================================================================
808
809 AC_ARG_ENABLE(some-floating-point,
810   AS_HELP_STRING([--disable-some-floating-point],
811                  [Disable certain code paths that rely heavily on double precision
812                   floating-point calculation. This option can improve
813                   performance on systems without a double precision floating-point
814                   unit, but might degrade performance on those that do.]), [
815 if test "x$enableval" = "xno"; then
816   # A value of 'no' for $enableval means that they want to disable, which
817   # means 'yes' for $disable_some_floating_point.
818   disable_some_floating_point=yes
819 fi
820 ], [disable_some_floating_point=no])
821
822 AM_CONDITIONAL(DISABLE_SOME_FLOATING_POINT,
823                test "x$disable_some_floating_point" = "xyes")
824 if test "x$disable_some_floating_point" = "xyes"; then
825   AC_DEFINE(DISABLE_SOME_FLOATING_POINT, 1,
826             [Define to 1 to disable certain code paths that rely heavily on
827              double precision floating-point calculation])
828 fi
829
830 dnl ===========================================================================
831
832 dnl Extra stuff we need to do when building C++ code
833 need_cxx="no"
834 AS_IF([test "x$use_skia" = "xyes"], [need_cxx="yes"])
835 AS_IF([test "x$use_qt" = "xyes"], [need_cxx="yes"])
836 AS_IF([test "x$use_beos" = "xyes"], [need_cxx="yes"])
837
838 AM_CONDITIONAL(BUILD_CXX, test "x$need_cxx" = "xyes")
839
840 dnl ===========================================================================
841
842 # We use GTK+ for some utility/debugging tools
843 PKG_CHECK_MODULES(gtk, "gtk+-2.0",have_gtk=yes, have_gtk=no)
844 AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes")
845
846 AC_CONFIG_FILES([
847 Makefile
848 boilerplate/Makefile
849 src/Makefile
850 test/Makefile
851 test/pdiff/Makefile
852 perf/Makefile
853 perf/micro/Makefile
854 util/Makefile
855 util/cairo-fdr/Makefile
856 util/cairo-gobject/Makefile
857 util/cairo-missing/Makefile
858 util/cairo-script/Makefile
859 util/cairo-script/examples/Makefile
860 util/cairo-sphinx/Makefile
861 util/cairo-trace/Makefile
862 util/cairo-trace/cairo-trace
863 doc/Makefile
864 doc/public/Makefile
865 ])
866
867 AC_OUTPUT
868 CAIRO_REPORT