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