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