Opensource Compliance Issue.
[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(wayland-client, wl_display_connect,
54      [AC_CHECK_HEADER(wayland-client.h, [
55       have_wayland=yes
56       AC_DEFINE(HAVE_WAYLAND, 1, [Define to 1 if you have wayland available])
57       wayland_LIBS="-lwayland-client"
58      ],
59      [have_wayland="no (requires wayland-client)"])],
60      [have_wayland="no (requires wayland-client)"])
61 LIBS="$wayland_LIBS $LIBS"
62
63 save_LIBS="$LIBS"
64 AC_CHECK_LIB(lzo2, lzo2a_decompress,
65          [AC_CHECK_HEADER(lzo/lzo2a.h, [
66           have_lzo=yes
67           AC_DEFINE(HAVE_LZO, 1, [Define to 1 if you have lzo available])
68           lzo_LIBS="-llzo2"
69          ],
70          [have_lzo="no (requires lzpo http://www.oberhumer.com/opensource/lzo/)"])],
71          [have_lzo="no (requires lzpo http://www.oberhumer.com/opensource/lzo/)"])
72 AC_SUBST(lzo_LIBS)
73 LIBS="$save_LIBS"
74
75 AC_CHECK_LIB(dl, dlsym,
76              [have_dlsym=yes; have_dl=yes],
77              [have_dlsym=no; have_dl=no])
78 if test "x$have_dlsym" = "xno"; then
79    AC_CHECK_FUNC(dlsym, [have_dlsym=yes], [have_dlsym=no])
80 fi
81 AC_CHECK_HEADERS(dlfcn.h, [have_dlsym=yes], [have_dlsym=no])
82 AM_CONDITIONAL(CAIRO_HAS_DL, test "x$have_dl" = "xyes")
83 if test "x$have_dlsym" = "xyes"; then
84   AC_DEFINE([CAIRO_HAS_DLSYM], 1, [Define to 1 if dlsym is available])
85 fi
86 AM_CONDITIONAL(CAIRO_HAS_DLSYM, test "x$have_dlsym" = "xyes")
87
88 dnl ===========================================================================
89
90 CAIRO_ENABLE_SURFACE_BACKEND(xlib, Xlib, auto, [
91   xlib_REQUIRES="x11 xext"
92   PKG_CHECK_MODULES(xlib, $xlib_REQUIRES, ,
93                     [xlib_REQUIRES=""
94                      AC_PATH_XTRA
95                      if test "x$no_x" = xyes; then
96                        use_xlib="no (requires X development libraries)"
97                      else
98                        xlib_NONPKGCONFIG_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
99                        xlib_NONPKGCONFIG_CFLAGS=$X_CFLAGS
100                      fi])
101
102   AC_CHECK_HEADER(sys/ipc.h)
103   AC_CHECK_HEADER(sys/shm.h)
104
105   if test "$ac_cv_header_sys_ipc_h" = "yes" -a "$ac_cv_header_sys_shm_h" = "yes"; then
106       AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
107       AC_TRY_RUN([
108                   #include <sys/types.h>
109                   #include <sys/ipc.h>
110                   #include <sys/shm.h>
111                   int main()
112                   {
113                       char *shmaddr;
114                       int id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0600);
115                       if (id == -1) return 2;
116                       shmaddr = shmat (id, 0, 0);
117                       shmctl (id, IPC_RMID, 0);
118                       if ((char*) shmat (id, 0, 0) == (char*) -1) {
119                           shmdt (shmaddr);
120                           return 1;
121                       }
122                       shmdt (shmaddr);
123                       shmdt (shmaddr);
124                       return 0;
125                   }
126                   ],
127                   AC_DEFINE(IPC_RMID_DEFERRED_RELEASE, 1,
128                             [Define to 1 if shared memory segments are released deferred.])
129                   AC_MSG_RESULT(yes),
130                   AC_MSG_RESULT(no),
131                   AC_MSG_RESULT(assuming no))
132       fi
133
134       AC_CHECK_HEADERS([X11/extensions/XShm.h X11/extensions/shmproto.h X11/extensions/shmstr.h], [], [],
135                        [#include <X11/Xlibint.h>
136                         #include <X11/Xproto.h>])
137 ])
138
139 CAIRO_ENABLE_SURFACE_BACKEND(xlib_xrender, Xlib Xrender, auto, [
140   if test "x$use_xlib" != "xyes"; then
141     use_xlib_xrender="no (requires --enable-xlib)"
142   else
143     dnl Check for Xrender header files if the Xrender package is not installed:
144     xlib_xrender_BASE=cairo-xlib
145     xlib_xrender_REQUIRES="xrender >= 0.6"
146     PKG_CHECK_MODULES(xlib_xrender, $xlib_xrender_REQUIRES, ,
147                       [xlib_xrender_REQUIRES=""
148                        old_CPPFLAGS=$CPPFLAGS
149                        CPPFLAGS="$CPPFLAGS $xlib_CFLAGS $xlib_NONPKGCONFIG_CFLAGS"
150                        AC_CHECK_HEADER(X11/extensions/Xrender.h,
151                                        [xlib_xrender_NONPKGCONFIG_LIBS="-lXrender"],
152                                        [use_xlib_xrender="no (requires $xlib_xrender_REQUIRES http://freedesktop.org/Software/xlibs)"],
153                                        [#include <X11/X.h>])
154                        CPPFLAGS=$old_CPPFLAGS
155                       ])
156
157     old_CFLAGS=$CFLAGS
158     old_LIBS=$LIBS
159     CFLAGS="$CFLAGS $xlib_CFLAGS $xlib_NONPKGCONFIG_CFLAGS $xlib_xrender_CFLAGS $xlib_xrender_NONPKGCONFIG_CFLAGS"
160     LIBS="$LIBS $xlib_LIBS $xlib_NONPKGCONFIG_LIBS $xlib_xrender_LIBS $xlib_xrender_NONPKGCONFIG_LIBS"
161     AC_CHECK_FUNCS([XRenderCreateSolidFill XRenderCreateLinearGradient XRenderCreateRadialGradient XRenderCreateConicalGradient])
162     CFLAGS=$old_CFLAGS
163     LIBS=$old_LIBS
164
165   fi
166 ])
167
168 dnl ===========================================================================
169
170 CAIRO_ENABLE_SURFACE_BACKEND(xcb, XCB, auto, [
171   xcb_REQUIRES="xcb >= 1.6 xcb-render >= 1.6"
172   PKG_CHECK_MODULES(xcb, $xcb_REQUIRES, ,
173                     [use_xcb="no (requires $xcb_REQUIRES http://xcb.freedesktop.org)"])
174 ])
175
176 CAIRO_ENABLE_FUNCTIONS(xlib_xcb, Xlib/XCB, no, [
177   if test "x$use_xcb" = "xyes" -a "x$use_xlib" = "xyes"; then
178     xlib_xcb_REQUIRES="x11-xcb"
179     PKG_CHECK_MODULES(xlib_xcb, $xlib_xcb_REQUIRES, ,
180                       [use_xlib_xcb="no (requires $xlib_xcb_REQUIRES http://xcb.freedesktop.org)"])
181   else
182     use_xlib_xcb="no (requires both --enable-xlib and --enable-xcb)"
183   fi
184 ])
185
186 CAIRO_ENABLE_FUNCTIONS(xcb_shm, XCB/SHM, auto, [
187   if test "x$use_xcb" = "xyes"; then
188       xcb_shm_REQUIRES="xcb-shm"
189       PKG_CHECK_MODULES(xcb_shm, $xcb_shm_REQUIRES, ,
190                         [use_xcb_shm="no (requires $xcb_shm http://xcb.freedesktop.org)"])
191   else
192     use_xcb_shm="no (requires --enable-xcb)"
193   fi
194 ])
195
196 dnl ===========================================================================
197
198 CAIRO_ENABLE_SURFACE_BACKEND(qt, Qt, no, [
199   qt_REQUIRES="QtGui >= 4.4.0"
200   PKG_CHECK_MODULES(qt, $qt_REQUIRES, ,
201                     [qt_REQUIRES=""
202                      use_qt="no (requires Qt4 development libraries)"
203                      ])
204   qt_NONPKGCONFIG_LIBS="-lstdc++"
205 ])
206
207 dnl ===========================================================================
208
209 CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [
210   dnl There is no pkgconfig for quartz; lets do a header check
211   AC_CHECK_HEADERS([ApplicationServices/ApplicationServices.h Accelerate/Accelerate.h], , [use_quartz="no (requires ApplicationServices framework)"])
212   if test "x$use_quartz" != "xyes" ; then
213     dnl check for CoreGraphics as a separate framework
214     AC_CHECK_HEADERS([CoreGraphics/CoreGraphics.h Accelerate/Accelerate.h], , [use_quartz="no (requires CoreGraphics framework)"])
215     quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics -Xlinker -framework -Xlinker Accelerate"
216   else
217     quartz_LIBS="-Xlinker -framework -Xlinker ApplicationServices -Xlinker -framework -Xlinker Accelerate"
218   fi
219 ])
220
221 CAIRO_ENABLE_FONT_BACKEND(quartz_font, Quartz, auto, [
222   use_quartz_font=$use_quartz
223 ])
224
225 CAIRO_ENABLE_SURFACE_BACKEND(quartz_image, Quartz Image, no, [
226   use_quartz_image=$use_quartz
227 ])
228
229 dnl ===========================================================================
230
231 CAIRO_ENABLE_SURFACE_BACKEND(win32, Microsoft Windows, auto, [
232   if test "x$have_windows" != xyes; then
233     use_win32="no (requires a Win32 platform)"
234   fi
235   win32_LIBS="-lgdi32 -lmsimg32"
236 ])
237
238 CAIRO_ENABLE_FONT_BACKEND(win32_font, Microsoft Windows, auto, [
239   use_win32_font=$use_win32
240 ])
241
242 test_win32_printing=no
243 if test "x$use_win32" = "xyes"; then
244   AC_CHECK_PROG(GS, gs, gs)
245   if test "$GS"; then
246     AC_DEFINE([CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE], 1, [Define to 1 if the Win32 Printing backend can be tested (needs ghostscript)])
247     test_win32_printing="yes"
248   else
249     AC_MSG_WARN([Win32 Printing backend will not be tested since ghostscript is not available])
250     test_win32_printing="no (requires ghostscript)"
251   fi
252 fi
253
254 AM_CONDITIONAL(CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE, test "x$test_win32_printing" = "xyes")
255
256 dnl ===========================================================================
257
258 CAIRO_ENABLE_SURFACE_BACKEND(skia, Skia, no, [
259   AC_ARG_WITH([skia],
260               [AS_HELP_STRING([--with-skia=/path/to/skia],
261                               [directory to find compiled skia sources])],
262               [skia_DIR="$withval"],
263               [skia_DIR="`pwd`/../skia"])
264   AC_ARG_WITH([skia-build-type],
265               [AS_HELP_STRING([--with-skia-build-type=(Release|Debug)]
266                               [build of skia to link with, default is Release])],
267               [skia_BUILD_TYPE="$withval"],
268               [skia_BUILD_TYPE="Release"])
269   skia_NONPKGCONFIG_CFLAGS="-I$skia_DIR/include/config -I$skia_DIR/include/core -I$skia_DIR/include/effects"
270   if test "x$skia_BUILD_TYPE" = "xRelease"; then
271         skia_NONPKGCONFIG_CFLAGS="-DSK_RELEASE -DSK_CAN_USE_FLOAT $skia_NONPKGCONFIG_CFLAGS"
272   fi
273   skia_NONPKGCONFIG_LIBS="-L$skia_DIR/out/$skia_BUILD_TYPE/lib.target/ -lskia -lstdc++"
274   AC_SUBST(skia_DIR)
275 ])
276
277 dnl ===========================================================================
278
279 CAIRO_ENABLE_SURFACE_BACKEND(os2, OS/2, no, [
280   case "$host" in
281     *-*-os2*)
282       :
283       ;;
284     *)
285       use_os2="no (requires an OS/2 platform)"
286       ;;
287   esac
288 ])
289
290 dnl ===========================================================================
291
292 CAIRO_ENABLE_SURFACE_BACKEND(beos, BeOS/Zeta, no, [
293   case "$host" in
294     *-*-beos)
295       beos_LIBS=""
296       dnl Add libbe and libzeta if available
297       AC_CHECK_LIB(be,main,beos_LIBS="$beos_LIBS -lbe")
298       AC_CHECK_LIB(zeta,main,beos_LIBS="$beos_LIBS -lzeta")
299       ;;
300     *)
301       use_beos="no (requires a BeOS platform)"
302       ;;
303   esac
304 ])
305
306 dnl ===========================================================================
307
308 CAIRO_ENABLE_SURFACE_BACKEND(drm, DRM, no, [
309   drm_REQUIRES="libudev >= 136"
310   PKG_CHECK_MODULES(drm, $drm_REQUIRES, ,
311    [use_drm="no (requires $drm_REQUIRES, udev is available from git://git.kernel.org/pub/scm/linux/hotplug/udev.git)"])
312 ])
313
314 CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
315   if test "x$use_drm" = "xyes"; then
316       AC_ARG_WITH([gallium],
317                   [AS_HELP_STRING([--with-gallium=/path/to/mesa],
318                                   [directory to find gallium enabled mesa])],
319                   [mesa_DIR="$withval"],
320                   [mesa_DIR="`pwd`/../mesa"])
321       gallium_DIR="$mesa_DIR/src/gallium"
322       gallium_NONPKGCONFIG_CFLAGS="-I$mesa_DIR/include -I$mesa_DIR/src/mesa -I$gallium_DIR/include -I$gallium_DIR/auxiliary"
323       gallium_NONPKGCONFIG_LIBS="-lGL"
324       AC_SUBST(mesa_DIR)
325       AC_SUBST(gallium_DIR)
326   else
327     use_gallium="no (requires --enable-drm)"
328   fi
329 ])
330
331 dnl ===========================================================================
332
333 CAIRO_ENABLE_FUNCTIONS(png, PNG, yes, [
334   use_png=no
335   AC_ARG_VAR([png_REQUIRES], [module name for libpng to search for using pkg-config])
336   if test "x$png_REQUIRES" = x; then
337     # libpng13 is GnuWin32's libpng-1.2.8 :-(
338     for l in libpng libpng14 libpng12 libpng13 libpng10; do
339       if $PKG_CONFIG --exists $l ; then
340         png_REQUIRES=$l
341         use_png=yes
342         break
343       fi
344     done
345   else
346     use_png=yes
347   fi
348
349   if test "x$use_png" = "xyes" ; then 
350     PKG_CHECK_MODULES(png, $png_REQUIRES, , : )
351   else
352     AC_MSG_WARN([Could not find libpng in the pkg-config search path])
353   fi    
354 ])
355
356 dnl ===========================================================================
357 CAIRO_ENABLE_SURFACE_BACKEND(gl, OpenGL, no, [
358   gl_REQUIRES="gl"
359   PKG_CHECK_MODULES(gl, $gl_REQUIRES,, [
360           dnl Fallback to searching for headers
361           AC_CHECK_HEADER([GL/gl.h, OpenGL/gl.h], [use_gl="no (gl.pc nor OpenGL headers not found)"])
362           if test "x$use_gl" = "xyes"; then
363               gl_NONPKGCONFIG_CFLAGS=
364               gl_NONPKGCONFIG_LIBS=
365           fi])
366
367   if test "x$have_dl" = "xyes" -a "x$have_dlsym" = "xyes"; then
368     gl_LIBS="-ldl"
369   fi
370
371   need_glx_functions=yes
372   need_wgl_functions=yes
373   need_egl_functions=yes
374   need_evasgl_functions=yes
375   need_cgl_functions=yes
376 ])
377
378 dnl ===========================================================================
379 CAIRO_ENABLE_SURFACE_BACKEND(evasgl, EvasGL, no, [
380   evasgl_REQUIRES="evas ecore ecore-evas"
381   PKG_CHECK_MODULES(evasgl, $evasgl_REQUIRES,, [
382           dnl Fallback to searching for headers
383           AC_CHECK_HEADER(evas-1/Evas_GL.h,, [use_evasgl="no (evas.pc nor EvasGL headers not found)"])
384           gl_NONPKGCONFIG_CFLAGS=
385           gl_NONPKGCONFIG_LIBS="-levas"
386           ])
387
388   if test "x$have_dl" = "xyes" -a "x$have_dlsym" = "xyes"; then
389     gl_LIBS="$gl_LIBS -ldl"
390   fi
391
392   need_evasgl_functions=yes
393 ])
394
395 dnl ===========================================================================
396 CAIRO_ENABLE_SURFACE_BACKEND(glesv2, OpenGLESv2, no, [
397   glesv2_REQUIRES="glesv2"
398   PKG_CHECK_MODULES(glesv2, $glesv2_REQUIRES,, [
399           dnl Fallback to searching for headers
400           AC_CHECK_HEADER(GLES2/gl2.h,, [use_glesv2="no (glesv2.pc nor OpenGL ES 2.0 headers not found)"])
401           if test "x$use_glesv2" = "xyes"; then
402               glesv2_NONPKGCONFIG_CFLAGS=
403               glesv2_NONPKGCONFIG_LIBS="-lGLESv2"
404           fi])
405
406   if test "x$have_dl" = "xyes" -a "x$have_dlsym" = "xyes"; then
407     glesv2_LIBS="$glesv2_LIBS -ldl"
408   fi
409
410   if test "x$use_glesv2" = "xyes" -a "x$use_gl" = "xyes"; then
411       AC_MSG_ERROR([use either --enable-gl=yes or --enable-glesv2=yes. Not both at the same time.])
412   fi
413
414   need_egl_functions=yes
415 ])
416
417 dnl ===========================================================================
418 CAIRO_ENABLE_SURFACE_BACKEND(glesv3, OpenGLESv3, no, [
419   glesv3_REQUIRES="glesv2"
420   PKG_CHECK_MODULES(glesv3, $glesv3_REQUIRES,, [
421           dnl Fallback to searching for headers
422           AC_CHECK_HEADER(GLES3/gl3.h,, [use_glesv3="no (glesv2.pc nor OpenGL ES 3.0 headers not found)"])
423           if test "x$use_glesv3" = "xyes"; then
424               glesv3_NONPKGCONFIG_CFLAGS=
425               glesv3_NONPKGCONFIG_LIBS="-lGLESv2"
426           fi])
427
428   if test "x$have_dl" = "xyes" -a "x$have_dlsym" = "xyes"; then
429     glesv3_LIBS="$glesv3_LIBS -ldl"
430   fi
431
432   need_egl_functions=yes
433 ])
434
435 dnl ===========================================================================
436 CAIRO_ENABLE_SURFACE_BACKEND(cogl, Cogl, no, [
437   cogl_REQUIRES="cogl-2.0-experimental"
438   PKG_CHECK_MODULES(cogl, $cogl_REQUIRES,, [use_cogl="no"])
439 ])
440
441 dnl ===========================================================================
442
443 CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [
444   directfb_REQUIRES=directfb
445   PKG_CHECK_MODULES(directfb, $directfb_REQUIRES, ,
446                     [use_directfb="no (requires $directfb_REQUIRES http://www.directfb.org)"])
447 ])
448
449 dnl ===========================================================================
450
451 CAIRO_ENABLE_SURFACE_BACKEND(vg, OpenVG, no, [
452   dnl There is no pkgconfig for OpenVG; lets do a header check
453   AC_CHECK_HEADER(VG/openvg.h,, [use_vg="no (OpenVG headers not found)"])
454   if test "x$use_vg" = "xyes"; then
455       vg_NONPKGCONFIG_CFLAGS=
456       vg_NONPKGCONFIG_LIBS="-lOpenVG"
457       need_egl_functions=yes
458       need_glx_functions=yes
459   fi
460 ])
461
462 CAIRO_ENABLE_FUNCTIONS(egl, EGL, auto, [
463   if test "x$need_egl_functions" = "xyes"; then
464       egl_REQUIRES="egl"
465       PKG_CHECK_MODULES(egl, $egl_REQUIRES, ,
466                     [egl_REQUIRES=""
467                      AC_CHECK_HEADER(EGL/egl.h,, [use_egl="no (EGL headers not found)"])
468                      if test "x$use_egl" = "xyes"; then
469                          egl_NONPKGCONFIG_CFLAGS=
470                          egl_NONPKGCONFIG_LIBS=
471                          save_LIBS="$LIBS"
472                          other_egl_LIBS=""
473                          # Temporary workaround for missing link from egl13
474                          AC_CHECK_LIB(csi, csi_stream_attachresource, other_egl_LIBS="-lcsi")
475                          LIBS="$other_egl_LIBS $LIBS"
476                          for egl_lib in EGL egl13 egl12 egl11; do
477                              if test -z "$egl_NONPKGCONFIG_LIBS"; then
478                                  AC_CHECK_LIB($egl_lib, eglGetError, egl_NONPKGCONFIG_LIBS="-l$egl_lib")
479                              fi
480                          done
481                          if test -z "$egl_NONPKGCONFIG_LIBS"; then
482                              use_egl="no (EGL library not found)"
483                          else
484                              egl_NONPKGCONFIG_LIBS="$egl_NONPKGCONFIG_LIBS $other_egl_LIBS"
485                          fi
486                          LIBS="$save_LIBS"
487                      fi
488         ])
489   else
490       use_egl="no (not required by any backend)"
491   fi
492 ])
493
494 CAIRO_ENABLE_FUNCTIONS(glx, GLX, auto, [
495   if test "x$need_glx_functions" = "xyes"; then
496     save_CFLAGS="$CFLAGS"
497     CFLAGS="$CFLAGS $gl_CFLAGS $gl_NONPKGCONFIG_CFLAGS"
498     AC_CHECK_HEADER(GL/glx.h,, [use_glx="no (GLX headers not found)"])
499     glx_NONPKGCONFIG_CFLAGS=
500     glx_NONPKGCONFIG_LIBS="-lGL"
501     CFLAGS="$save_CFLAGS"
502     need_cgl_functions="no"
503   else
504       use_glx="no (not required by any backend)"
505   fi
506 ])
507
508 CAIRO_ENABLE_FUNCTIONS(cgl, CGL, auto, [
509   if test "x$need_cgl_functions" = "xyes"; then
510     save_CFLAGS="$CFLAGS"
511     CFLAGS="$CFLAGS $gl_CFLAGS $gl_NONPKGCONFIG_CFLAGS"
512     AC_CHECK_HEADER(OpenGL/gl.h,, [use_gl="no (CGL headers not found)"])
513     cgl_LIBS="-Xlinker -framework -Xlinker OpenGL"
514     cgl_NONPKGCONFIG_CFLAGS=
515     cgl_NONPKGCONFIG_LIBS=
516     CFLAGS="$save_CFLAGS"
517     need_glx_functions="no"
518   else
519       use_cgl="no (not required by any backend)"
520   fi
521 ])
522
523 CAIRO_ENABLE_FUNCTIONS(wgl, WGL, auto, [
524   if test "x$need_wgl_functions" = "xyes"; then
525     AC_CHECK_HEADER(windows.h,, [use_wgl="no (WGL headers not found)"])
526   else
527       use_wgl="no (not required by any backend)"
528   fi
529 ])
530
531 dnl ===========================================================================
532
533 any2ppm_cs=no
534 CAIRO_ENABLE_SURFACE_BACKEND(script, script, yes, [
535   any2ppm_cs=yes
536 ])
537
538 dnl ===========================================================================
539
540 # We use pkg-config to look for freetype2, but fall back to
541 # freetype-config if it fails.  We prefer pkg-config, since we can
542 # then just put freetype2 >= $FREETYPE_MIN_VERSION in
543 # Requires.private, but at least up to 2003-06-07, there was no
544 # freetype2.pc in the release.
545 #
546 # FreeType versions come in three forms:
547 #   release (such as 2.1.9)
548 #   libtool (such as 9.7.3) (returned by freetype-config and pkg-config)
549 #   platform-specific/soname (such as 6.3.4)
550 # and they recommend you never use the platform-specific version
551 # (see docs/VERSION.DLL in freetype2 sources)
552 #
553 # Set these as appropriate:
554
555 # release number - for information only
556 FREETYPE_MIN_RELEASE=2.1.9
557 # libtool-specific version - this is what is checked
558 FREETYPE_MIN_VERSION=9.7.3
559
560 CAIRO_ENABLE_FONT_BACKEND(ft, FreeType, auto, [
561
562     PKG_CHECK_MODULES(FREETYPE, freetype2 >= $FREETYPE_MIN_VERSION,
563                       [freetype_pkgconfig=yes],
564                       [freetype_pkgconfig=no])
565   
566     if test "x$freetype_pkgconfig" = "xyes"; then
567       ft_REQUIRES="freetype2 >= $FREETYPE_MIN_VERSION $ft_REQUIRES"
568     else
569   
570       if test -z "$FREETYPE_CONFIG"; then
571         AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
572       fi
573       if test "x$FREETYPE_CONFIG" = "xno" ; then
574         use_ft='no (freetype-config not found in path or $FREETYPE_CONFIG)'
575       else
576         AC_MSG_CHECKING(freetype2 libtool version)
577
578         FREETYPE_VERSION=`$FREETYPE_CONFIG --version`
579         AX_COMPARE_VERSION([$FREETYPE_VERSION], [gt], [$FREETYPE_MIN_VERSION],
580                            [AC_MSG_RESULT($FREETYPE_VERSION - OK)
581                            ft_NONPKGCONFIG_CFLAGS=`$FREETYPE_CONFIG --cflags`
582                            ft_NONPKGCONFIG_LIBS=`$FREETYPE_CONFIG --libs`],
583                            [AC_MSG_RESULT($FREETYPE_VERSION - Too old)
584                            use_ft="no ($FREETYPE_VERSION found; version $FREETYPE_MIN_VERSION from release $FREETYPE_MIN_RELEASE required)"])
585       fi
586     fi
587
588   ft_CFLAGS="$FREETYPE_CFLAGS"
589   ft_LIBS="$FREETYPE_LIBS"
590 ])
591
592 FONTCONFIG_MIN_VERSION=2.2.95
593 CAIRO_ENABLE_FONT_BACKEND(fc, Fontconfig, auto, [
594   use_fc=$use_ft
595   if test "x$use_fc" = "xyes"; then
596     fc_REQUIRES="fontconfig >= $FONTCONFIG_MIN_VERSION"
597     PKG_CHECK_MODULES(FONTCONFIG, $fc_REQUIRES,,
598                       [use_fc="no (requires $fc_REQUIRES)"])
599   fi
600   fc_CFLAGS="$FONTCONFIG_CFLAGS"
601   fc_LIBS="$FONTCONFIG_LIBS"
602 ])
603
604 if test "x$use_ft" = "xyes"; then
605   _save_libs="$LIBS"
606   _save_cflags="$CFLAGS"
607   LIBS="$LIBS $ft_LIBS"
608   CFLAGS="$CFLAGS $ft_CFLAGS"
609
610   AC_CHECK_FUNCS(FT_Get_X11_Font_Format FT_GlyphSlot_Embolden FT_GlyphSlot_Oblique FT_Load_Sfnt_Table FT_Library_SetLcdFilter)
611
612   LIBS="$_save_libs"
613   CFLAGS="$_save_cflags"
614 fi
615
616 if test "x$use_fc" = "xyes"; then
617   CAIRO_CHECK_FUNCS_WITH_FLAGS(FcInit FcFini, [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS])
618 fi
619
620 dnl ===========================================================================
621
622 CAIRO_ENABLE_SURFACE_BACKEND(ps, PostScript, yes, [
623     # The ps backend requires zlib.
624     use_ps=$have_libz
625     ps_NONPKGCONFIG_LIBS=-lz
626 ])
627
628 dnl ===========================================================================
629
630 SPECTRE_VERSION_REQUIRED=0.2.0
631 test_ps=no
632 any2ppm_ps=no
633 if test "x$use_ps" = "xyes"; then
634   AC_CHECK_PROG(GS, gs, gs)
635   if test "$GS"; then
636     AC_DEFINE([CAIRO_CAN_TEST_PS_SURFACE], 1, [Define to 1 if the PS backend can be tested (needs ghostscript)])
637     test_ps="yes"
638   else
639     AC_MSG_WARN([PS backend will not be tested since ghostscript is not available])
640     test_ps="no (requires ghostscript)"
641   fi
642
643   libspectre_DEPENDENCY="libspectre >= $SPECTRE_VERSION_REQUIRED"
644   PKG_CHECK_MODULES(LIBSPECTRE, $libspectre_DEPENDENCY,
645                     [any2ppm_ps=yes],
646                     [test_ps="no (requires libspectre)"])
647 fi
648
649 AM_CONDITIONAL(CAIRO_CAN_TEST_PS_SURFACE, test "x$test_ps" = "xyes")
650 AM_CONDITIONAL(CAIRO_HAS_SPECTRE, test "x$any2ppm_ps" = "xyes")
651 if test "x$any2ppm_ps" = "xyes"; then
652     AC_DEFINE([CAIRO_HAS_SPECTRE], 1, [Define to 1 if libspectre is available])
653 fi
654 AC_SUBST(LIBSPECTRE_CFLAGS)
655 AC_SUBST(LIBSPECTRE_LIBS)
656
657 dnl ===========================================================================
658
659 CAIRO_ENABLE_SURFACE_BACKEND(pdf, PDF, yes, [
660     # The pdf backend requires zlib.
661     use_pdf=$have_libz
662     pdf_NONPKGCONFIG_LIBS=-lz
663 ])
664
665 dnl ===========================================================================
666
667 # poppler-0.17.4 fixes text-pattern and text-transform
668 POPPLER_VERSION_REQUIRED=0.17.4
669 test_pdf=no
670 any2ppm_pdf=no
671 if test "x$use_pdf" = "xyes"; then
672   poppler_DEPENDENCY="poppler-glib >= $POPPLER_VERSION_REQUIRED"
673   PKG_CHECK_MODULES(POPPLER, $poppler_DEPENDENCY,
674                     [CAIRO_CHECK_FUNCS_WITH_FLAGS(poppler_page_render, [$POPPLER_CFLAGS], [$POPPLER_LIBS],
675                     [test_pdf=yes; any2ppm_pdf=yes],
676                     [test_pdf="no (requires $poppler_DEPENDENCY)"])],
677                     [test_pdf="no (requires $poppler_DEPENDENCY)"])
678   if test "x$test_pdf" = "xyes"; then
679     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)])
680   else
681     AC_MSG_WARN([PDF backend will not be tested since poppler >= $POPPLER_VERSION_REQUIRED is not available])
682   fi
683 fi
684
685 AM_CONDITIONAL(CAIRO_CAN_TEST_PDF_SURFACE, test "x$test_pdf" = "xyes")
686 AC_SUBST(POPPLER_CFLAGS)
687 AC_SUBST(POPPLER_LIBS)
688
689 AM_CONDITIONAL(CAIRO_HAS_MULTI_PAGE_SURFACES, test "x$use_ps" = "xyes" -o "x$use_pdf" = "xyes")
690
691 dnl ===========================================================================
692
693 CAIRO_ENABLE_SURFACE_BACKEND(svg, SVG, yes, [
694   if test "x$use_png" != "xyes"; then
695     use_svg="no (requires --enable-png)"
696   fi
697 ])
698
699 LIBRSVG_VERSION_REQUIRED=2.35.0
700 test_svg=no
701 any2ppm_svg=no
702 if test "x$use_svg" = "xyes"; then
703   librsvg_DEPENDENCY="librsvg-2.0 >= $LIBRSVG_VERSION_REQUIRED"
704   PKG_CHECK_MODULES(LIBRSVG, $librsvg_DEPENDENCY gdk-2.0,
705                     [CAIRO_CHECK_FUNCS_WITH_FLAGS(rsvg_pixbuf_from_file, [$LIBRSVG_CFLAGS], [$LIBRSVG_LIBS],
706                     [test_svg=yes; any2ppm_svg=yes],
707                     [test_svg="no (requires $librsvg_DEPENDENCY)"])],
708                     [test_svg="no (requires $librsvg_DEPENDENCY)"])
709   if test "x$test_svg" = "xyes"; then
710     AC_DEFINE([CAIRO_CAN_TEST_SVG_SURFACE], 1, [Define to 1 if the SVG backend can be tested])
711   else
712     AC_MSG_WARN([SVG backend will not be tested since librsvg >= $LIBRSVG_VERSION_REQUIRED is not available])
713   fi
714 fi
715
716 AM_CONDITIONAL(CAIRO_CAN_TEST_SVG_SURFACE, test "x$test_svg" = "xyes")
717 AC_SUBST(LIBRSVG_CFLAGS)
718 AC_SUBST(LIBRSVG_LIBS)
719
720 dnl ===========================================================================
721
722 dnl XXX make this a private feature?
723 CAIRO_ENABLE(test_surfaces, test surfaces, no)
724
725 dnl ===========================================================================
726
727 CAIRO_ENABLE_SURFACE_BACKEND(image, image, always, [
728   pixman_REQUIRES="pixman-1 >= 0.30.0"
729   PKG_CHECK_MODULES(pixman, $pixman_REQUIRES, ,
730     [use_image="no (requires $pixman_REQUIRES http://cairographics.org/releases/)"])
731   image_REQUIRES=$pixman_REQUIRES
732   image_CFLAGS=$pixman_CFLAGS
733   image_LIBS=$pixman_LIBS
734 ])
735
736 if pkg-config --exists 'pixman-1 >= 0.27.1'; then
737     AC_DEFINE([HAS_PIXMAN_GLYPHS], 1, [Enable pixman glyph cache])
738 fi
739
740
741 dnl ===========================================================================
742
743 CAIRO_ENABLE_SURFACE_BACKEND(mime, mime, always)
744 CAIRO_ENABLE_SURFACE_BACKEND(recording, recording, always)
745 CAIRO_ENABLE_SURFACE_BACKEND(observer, observer, always)
746 CAIRO_ENABLE_SURFACE_BACKEND(tee, tee, no)
747 CAIRO_ENABLE_SURFACE_BACKEND(xml, xml, no, [
748     use_xml=$have_libz
749     xml_NONPKGCONFIG_LIBS=-lz
750 ])
751
752 dnl ===========================================================================
753
754 CAIRO_ENABLE_FONT_BACKEND(user, user, always)
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 >= 2.14"
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" -a "x$have_windows" = "xno")
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 AC_CONFIG_COMMANDS([cairo-trace],
928                    [chmod a+x util/cairo-trace/cairo-trace])
929
930 AC_OUTPUT
931 CAIRO_REPORT