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