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