summaryrefslogtreecommitdiff
path: root/libs/cairo-1.16.0/util/cairo-sphinx
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-10-12 12:03:23 -0500
committersanine <sanine.not@pm.me>2022-10-12 12:03:23 -0500
commit530ffd0b7d3c39757b20f00716e486b5caf89aff (patch)
tree76b35fdf57317038acf6b828871f6ae25fce2ebe /libs/cairo-1.16.0/util/cairo-sphinx
parent3dbe9332e47c143a237db12440f134caebd1cfbe (diff)
add cairo
Diffstat (limited to 'libs/cairo-1.16.0/util/cairo-sphinx')
-rw-r--r--libs/cairo-1.16.0/util/cairo-sphinx/Makefile.am43
-rw-r--r--libs/cairo-1.16.0/util/cairo-sphinx/Makefile.in886
-rw-r--r--libs/cairo-1.16.0/util/cairo-sphinx/fdr.c261
-rw-r--r--libs/cairo-1.16.0/util/cairo-sphinx/sphinx.c1545
4 files changed, 2735 insertions, 0 deletions
diff --git a/libs/cairo-1.16.0/util/cairo-sphinx/Makefile.am b/libs/cairo-1.16.0/util/cairo-sphinx/Makefile.am
new file mode 100644
index 0000000..3c11263
--- /dev/null
+++ b/libs/cairo-1.16.0/util/cairo-sphinx/Makefile.am
@@ -0,0 +1,43 @@
+cairolibdir = $(libdir)/cairo
+
+cairolib_LTLIBRARIES = cairo-sphinx.la
+bin_PROGRAMS = cairo-sphinx
+
+AM_CPPFLAGS = -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ -I$(top_srcdir)/boilerplate \
+ -I$(top_srcdir)/util/cairo-script
+
+cairo_sphinx_la_SOURCES = fdr.c
+cairo_sphinx_la_CPPFLAGS = $(AM_CPPFLAGS)
+cairo_sphinx_la_CFLAGS = $(CAIRO_CFLAGS)
+cairo_sphinx_la_LDFLAGS = -module -no-undefined -avoid-version
+if CAIRO_HAS_DL
+cairo_sphinx_la_LIBADD = -ldl
+endif
+
+cairo_sphinx_SOURCES = sphinx.c
+cairo_sphinx_CPPFLAGS = $(AM_CPPFLAGS) -DLIBDIR="\"$(cairolibdir)\""
+cairo_sphinx_CFLAGS = $(CAIRO_CFLAGS) $(real_pthread_CFLAGS) $(glib_CFLAGS)
+cairo_sphinx_LDADD = \
+ $(real_pthread_LIBS) \
+ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/boilerplate/libcairoboilerplate.la \
+ $(top_builddir)/src/libcairo.la \
+ $(glib_LIBS) \
+ $(CAIRO_LDADD) \
+ $(shm_LIBS)
+cairo_sphinx_DEPENDENCIES = \
+ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/boilerplate/libcairoboilerplate.la \
+ $(top_builddir)/src/libcairo.la
+
+# Install rules to rebuild the libraries and add explicit dependencies
+$(top_builddir)/boilerplate/libcairoboilerplate.la: $(top_builddir)/src/libcairo.la
+ cd $(top_builddir)/boilerplate && $(MAKE) $(AM_MAKEFLAGS) libcairoboilerplate.la
+
+$(top_builddir)/src/libcairo.la:
+ cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) libcairo.la
+
+$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la: $(top_builddir)/src/libcairo.la
+ cd $(top_builddir)/util/cairo-script && $(MAKE) $(AM_MAKEFLAGS) libcairo-script-interpreter.la
diff --git a/libs/cairo-1.16.0/util/cairo-sphinx/Makefile.in b/libs/cairo-1.16.0/util/cairo-sphinx/Makefile.in
new file mode 100644
index 0000000..bcd45d2
--- /dev/null
+++ b/libs/cairo-1.16.0/util/cairo-sphinx/Makefile.in
@@ -0,0 +1,886 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = cairo-sphinx$(EXEEXT)
+subdir = util/cairo-sphinx
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/build/aclocal.cairo.m4 \
+ $(top_srcdir)/build/aclocal.compare.m4 \
+ $(top_srcdir)/build/aclocal.enable.m4 \
+ $(top_srcdir)/build/aclocal.float.m4 \
+ $(top_srcdir)/build/aclocal.makefile.m4 \
+ $(top_srcdir)/build/aclocal.pkg.m4 \
+ $(top_srcdir)/build/gtk-doc.m4 $(top_srcdir)/build/libtool.m4 \
+ $(top_srcdir)/build/ltoptions.m4 \
+ $(top_srcdir)/build/ltsugar.m4 \
+ $(top_srcdir)/build/ltversion.m4 \
+ $(top_srcdir)/build/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/cairo-version.h \
+ $(top_srcdir)/build/configure.ac.version \
+ $(top_srcdir)/build/configure.ac.tools \
+ $(top_srcdir)/build/configure.ac.features \
+ $(top_srcdir)/build/configure.ac.warnings \
+ $(top_srcdir)/build/configure.ac.system \
+ $(top_srcdir)/build/configure.ac.analysis \
+ $(top_srcdir)/build/configure.ac.noversion \
+ $(top_srcdir)/build/configure.ac.pthread \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(cairolibdir)" "$(DESTDIR)$(bindir)"
+LTLIBRARIES = $(cairolib_LTLIBRARIES)
+cairo_sphinx_la_DEPENDENCIES =
+am_cairo_sphinx_la_OBJECTS = cairo_sphinx_la-fdr.lo
+cairo_sphinx_la_OBJECTS = $(am_cairo_sphinx_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+cairo_sphinx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+ $(cairo_sphinx_la_CFLAGS) $(CFLAGS) $(cairo_sphinx_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
+PROGRAMS = $(bin_PROGRAMS)
+am_cairo_sphinx_OBJECTS = cairo_sphinx-sphinx.$(OBJEXT)
+cairo_sphinx_OBJECTS = $(am_cairo_sphinx_OBJECTS)
+am__DEPENDENCIES_1 =
+cairo_sphinx_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(cairo_sphinx_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(cairo_sphinx_la_SOURCES) $(cairo_sphinx_SOURCES)
+DIST_SOURCES = $(cairo_sphinx_la_SOURCES) $(cairo_sphinx_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/build/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BFD_LIBS = @BFD_LIBS@
+CAIROBOILERPLATE_LIBS = @CAIROBOILERPLATE_LIBS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LDFLAGS = @CAIRO_LDFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CAIRO_LIBTOOL_VERSION_INFO = @CAIRO_LIBTOOL_VERSION_INFO@
+CAIRO_NONPKGCONFIG_CFLAGS = @CAIRO_NONPKGCONFIG_CFLAGS@
+CAIRO_NONPKGCONFIG_LIBS = @CAIRO_NONPKGCONFIG_LIBS@
+CAIRO_RELEASE_STATUS = @CAIRO_RELEASE_STATUS@
+CAIRO_REQUIRES = @CAIRO_REQUIRES@
+CAIRO_TEST_MODE = @CAIRO_TEST_MODE@
+CAIRO_TEST_UNDEFINED_LDFLAGS = @CAIRO_TEST_UNDEFINED_LDFLAGS@
+CAIRO_VERSION_MAJOR = @CAIRO_VERSION_MAJOR@
+CAIRO_VERSION_MICRO = @CAIRO_VERSION_MICRO@
+CAIRO_VERSION_MINOR = @CAIRO_VERSION_MINOR@
+CAIRO_VERSION_SONUM = @CAIRO_VERSION_SONUM@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FIND = @FIND@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GOBJECT_CFLAGS = @GOBJECT_CFLAGS@
+GOBJECT_LIBS = @GOBJECT_LIBS@
+GREP = @GREP@
+GS = @GS@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBSPECTRE_CFLAGS = @LIBSPECTRE_CFLAGS@
+LIBSPECTRE_LIBS = @LIBSPECTRE_LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LTP = @LTP@
+LTP_GENHTML = @LTP_GENHTML@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+POPPLER_CFLAGS = @POPPLER_CFLAGS@
+POPPLER_LIBS = @POPPLER_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SHM_LIBS = @SHM_LIBS@
+SHTOOL = @SHTOOL@
+STRIP = @STRIP@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VERSION = @VERSION@
+XARGS = @XARGS@
+XMKMF = @XMKMF@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cogl_CFLAGS = @cogl_CFLAGS@
+cogl_LIBS = @cogl_LIBS@
+datadir = @datadir@
+datarootdir = @datarootdir@
+directfb_CFLAGS = @directfb_CFLAGS@
+directfb_LIBS = @directfb_LIBS@
+docdir = @docdir@
+drm_CFLAGS = @drm_CFLAGS@
+drm_LIBS = @drm_LIBS@
+dvidir = @dvidir@
+egl_CFLAGS = @egl_CFLAGS@
+egl_LIBS = @egl_LIBS@
+exec_prefix = @exec_prefix@
+gallium_DIR = @gallium_DIR@
+gl_CFLAGS = @gl_CFLAGS@
+gl_LIBS = @gl_LIBS@
+glesv2_CFLAGS = @glesv2_CFLAGS@
+glesv2_LIBS = @glesv2_LIBS@
+glesv3_CFLAGS = @glesv3_CFLAGS@
+glesv3_LIBS = @glesv3_LIBS@
+glib_CFLAGS = @glib_CFLAGS@
+glib_LIBS = @glib_LIBS@
+gtk_CFLAGS = @gtk_CFLAGS@
+gtk_LIBS = @gtk_LIBS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lzo_LIBS = @lzo_LIBS@
+mandir = @mandir@
+mesa_DIR = @mesa_DIR@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pixman_CFLAGS = @pixman_CFLAGS@
+pixman_LIBS = @pixman_LIBS@
+png_CFLAGS = @png_CFLAGS@
+png_LIBS = @png_LIBS@
+png_REQUIRES = @png_REQUIRES@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pthread_CFLAGS = @pthread_CFLAGS@
+pthread_LIBS = @pthread_LIBS@
+qt_CFLAGS = @qt_CFLAGS@
+qt_LIBS = @qt_LIBS@
+real_pthread_CFLAGS = @real_pthread_CFLAGS@
+real_pthread_LIBS = @real_pthread_LIBS@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+shm_LIBS = @shm_LIBS@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xcb_CFLAGS = @xcb_CFLAGS@
+xcb_LIBS = @xcb_LIBS@
+xcb_shm_CFLAGS = @xcb_shm_CFLAGS@
+xcb_shm_LIBS = @xcb_shm_LIBS@
+xlib_CFLAGS = @xlib_CFLAGS@
+xlib_LIBS = @xlib_LIBS@
+xlib_xcb_CFLAGS = @xlib_xcb_CFLAGS@
+xlib_xcb_LIBS = @xlib_xcb_LIBS@
+xlib_xrender_CFLAGS = @xlib_xrender_CFLAGS@
+xlib_xrender_LIBS = @xlib_xrender_LIBS@
+cairolibdir = $(libdir)/cairo
+cairolib_LTLIBRARIES = cairo-sphinx.la
+AM_CPPFLAGS = -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ -I$(top_srcdir)/boilerplate \
+ -I$(top_srcdir)/util/cairo-script
+
+cairo_sphinx_la_SOURCES = fdr.c
+cairo_sphinx_la_CPPFLAGS = $(AM_CPPFLAGS)
+cairo_sphinx_la_CFLAGS = $(CAIRO_CFLAGS)
+cairo_sphinx_la_LDFLAGS = -module -no-undefined -avoid-version
+@CAIRO_HAS_DL_TRUE@cairo_sphinx_la_LIBADD = -ldl
+cairo_sphinx_SOURCES = sphinx.c
+cairo_sphinx_CPPFLAGS = $(AM_CPPFLAGS) -DLIBDIR="\"$(cairolibdir)\""
+cairo_sphinx_CFLAGS = $(CAIRO_CFLAGS) $(real_pthread_CFLAGS) $(glib_CFLAGS)
+cairo_sphinx_LDADD = \
+ $(real_pthread_LIBS) \
+ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/boilerplate/libcairoboilerplate.la \
+ $(top_builddir)/src/libcairo.la \
+ $(glib_LIBS) \
+ $(CAIRO_LDADD) \
+ $(shm_LIBS)
+
+cairo_sphinx_DEPENDENCIES = \
+ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/boilerplate/libcairoboilerplate.la \
+ $(top_builddir)/src/libcairo.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign util/cairo-sphinx/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign util/cairo-sphinx/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+install-cairolibLTLIBRARIES: $(cairolib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(cairolib_LTLIBRARIES)'; test -n "$(cairolibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(cairolibdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(cairolibdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(cairolibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(cairolibdir)"; \
+ }
+
+uninstall-cairolibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(cairolib_LTLIBRARIES)'; test -n "$(cairolibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(cairolibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(cairolibdir)/$$f"; \
+ done
+
+clean-cairolibLTLIBRARIES:
+ -test -z "$(cairolib_LTLIBRARIES)" || rm -f $(cairolib_LTLIBRARIES)
+ @list='$(cairolib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+cairo-sphinx.la: $(cairo_sphinx_la_OBJECTS) $(cairo_sphinx_la_DEPENDENCIES) $(EXTRA_cairo_sphinx_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(cairo_sphinx_la_LINK) -rpath $(cairolibdir) $(cairo_sphinx_la_OBJECTS) $(cairo_sphinx_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ || test -f $$p1 \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+cairo-sphinx$(EXEEXT): $(cairo_sphinx_OBJECTS) $(cairo_sphinx_DEPENDENCIES) $(EXTRA_cairo_sphinx_DEPENDENCIES)
+ @rm -f cairo-sphinx$(EXEEXT)
+ $(AM_V_CCLD)$(cairo_sphinx_LINK) $(cairo_sphinx_OBJECTS) $(cairo_sphinx_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo_sphinx-sphinx.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo_sphinx_la-fdr.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+cairo_sphinx_la-fdr.lo: fdr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cairo_sphinx_la_CPPFLAGS) $(CPPFLAGS) $(cairo_sphinx_la_CFLAGS) $(CFLAGS) -MT cairo_sphinx_la-fdr.lo -MD -MP -MF $(DEPDIR)/cairo_sphinx_la-fdr.Tpo -c -o cairo_sphinx_la-fdr.lo `test -f 'fdr.c' || echo '$(srcdir)/'`fdr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cairo_sphinx_la-fdr.Tpo $(DEPDIR)/cairo_sphinx_la-fdr.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fdr.c' object='cairo_sphinx_la-fdr.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cairo_sphinx_la_CPPFLAGS) $(CPPFLAGS) $(cairo_sphinx_la_CFLAGS) $(CFLAGS) -c -o cairo_sphinx_la-fdr.lo `test -f 'fdr.c' || echo '$(srcdir)/'`fdr.c
+
+cairo_sphinx-sphinx.o: sphinx.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cairo_sphinx_CPPFLAGS) $(CPPFLAGS) $(cairo_sphinx_CFLAGS) $(CFLAGS) -MT cairo_sphinx-sphinx.o -MD -MP -MF $(DEPDIR)/cairo_sphinx-sphinx.Tpo -c -o cairo_sphinx-sphinx.o `test -f 'sphinx.c' || echo '$(srcdir)/'`sphinx.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cairo_sphinx-sphinx.Tpo $(DEPDIR)/cairo_sphinx-sphinx.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sphinx.c' object='cairo_sphinx-sphinx.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cairo_sphinx_CPPFLAGS) $(CPPFLAGS) $(cairo_sphinx_CFLAGS) $(CFLAGS) -c -o cairo_sphinx-sphinx.o `test -f 'sphinx.c' || echo '$(srcdir)/'`sphinx.c
+
+cairo_sphinx-sphinx.obj: sphinx.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cairo_sphinx_CPPFLAGS) $(CPPFLAGS) $(cairo_sphinx_CFLAGS) $(CFLAGS) -MT cairo_sphinx-sphinx.obj -MD -MP -MF $(DEPDIR)/cairo_sphinx-sphinx.Tpo -c -o cairo_sphinx-sphinx.obj `if test -f 'sphinx.c'; then $(CYGPATH_W) 'sphinx.c'; else $(CYGPATH_W) '$(srcdir)/sphinx.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cairo_sphinx-sphinx.Tpo $(DEPDIR)/cairo_sphinx-sphinx.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sphinx.c' object='cairo_sphinx-sphinx.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cairo_sphinx_CPPFLAGS) $(CPPFLAGS) $(cairo_sphinx_CFLAGS) $(CFLAGS) -c -o cairo_sphinx-sphinx.obj `if test -f 'sphinx.c'; then $(CYGPATH_W) 'sphinx.c'; else $(CYGPATH_W) '$(srcdir)/sphinx.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(cairolibdir)" "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-cairolibLTLIBRARIES clean-generic \
+ clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-cairolibLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-cairolibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
+ clean-binPROGRAMS clean-cairolibLTLIBRARIES clean-generic \
+ clean-libtool cscopelist-am ctags ctags-am distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-binPROGRAMS \
+ install-cairolibLTLIBRARIES install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+ uninstall-am uninstall-binPROGRAMS \
+ uninstall-cairolibLTLIBRARIES
+
+.PRECIOUS: Makefile
+
+
+# Install rules to rebuild the libraries and add explicit dependencies
+$(top_builddir)/boilerplate/libcairoboilerplate.la: $(top_builddir)/src/libcairo.la
+ cd $(top_builddir)/boilerplate && $(MAKE) $(AM_MAKEFLAGS) libcairoboilerplate.la
+
+$(top_builddir)/src/libcairo.la:
+ cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) libcairo.la
+
+$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la: $(top_builddir)/src/libcairo.la
+ cd $(top_builddir)/util/cairo-script && $(MAKE) $(AM_MAKEFLAGS) libcairo-script-interpreter.la
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libs/cairo-1.16.0/util/cairo-sphinx/fdr.c b/libs/cairo-1.16.0/util/cairo-sphinx/fdr.c
new file mode 100644
index 0000000..aeda89b
--- /dev/null
+++ b/libs/cairo-1.16.0/util/cairo-sphinx/fdr.c
@@ -0,0 +1,261 @@
+/* cairo-fdr - a 'flight data recorder', a black box, for cairo
+ *
+ * Copyright © 2009 Chris Wilson
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define _GNU_SOURCE
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <cairo.h>
+#include <cairo-script.h>
+#include <cairo-tee.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <dlfcn.h>
+
+static void *_dlhandle = RTLD_NEXT;
+#define DLCALL(name, args...) ({ \
+ static typeof (&name) name##_real; \
+ if (name##_real == NULL) { \
+ name##_real = dlsym (_dlhandle, #name); \
+ if (name##_real == NULL && _dlhandle == RTLD_NEXT) { \
+ _dlhandle = dlopen ("libcairo.so", RTLD_LAZY); \
+ name##_real = dlsym (_dlhandle, #name); \
+ assert (name##_real != NULL); \
+ } \
+ } \
+ (*name##_real) (args); \
+})
+
+static cairo_device_t *fdr_context;
+static const cairo_user_data_key_t fdr_key;
+
+static void
+fdr_get_extents (cairo_surface_t *surface,
+ cairo_rectangle_t *extents)
+{
+ cairo_t *cr;
+
+ cr = DLCALL (cairo_create, surface);
+ DLCALL (cairo_clip_extents, cr,
+ &extents->x, &extents->y, &extents->width, &extents->height);
+ DLCALL (cairo_destroy, cr);
+
+ extents->width -= extents->x;
+ extents->height -= extents->y;
+}
+
+static void
+fdr_surface_destroy (void *surface)
+{
+ DLCALL (cairo_surface_destroy, surface);
+}
+
+static void
+fdr_surface_reference (void *surface)
+{
+ DLCALL (cairo_surface_reference, surface);
+}
+
+static cairo_surface_t *
+fdr_surface_get_tee (cairo_surface_t *surface)
+{
+ return DLCALL (cairo_surface_get_user_data, surface, &fdr_key);
+}
+
+static cairo_surface_t *
+fdr_tee_surface_index (cairo_surface_t *surface, int index)
+{
+ return DLCALL (cairo_tee_surface_index, surface, index);
+}
+
+static cairo_status_t
+fdr_write (void *closure, const unsigned char *data, unsigned int len)
+{
+ int fd = (int) (intptr_t) closure;
+ while (len) {
+ int ret = write (fd, data, len);
+ if (ret < 0) {
+ switch (errno) {
+ case EAGAIN:
+ case EINTR:
+ continue;
+ default:
+ return CAIRO_STATUS_WRITE_ERROR;
+ }
+ } else if (ret == 0) {
+ return CAIRO_STATUS_WRITE_ERROR;
+ } else {
+ data += ret;
+ len -= ret;
+ }
+ }
+ return CAIRO_STATUS_SUCCESS;
+}
+
+cairo_t *
+cairo_create (cairo_surface_t *surface)
+{
+ cairo_surface_t *tee;
+
+ tee = fdr_surface_get_tee (surface);
+ if (tee == NULL) {
+ cairo_surface_t *script;
+ cairo_rectangle_t extents;
+ cairo_content_t content;
+
+ if (fdr_context == NULL) {
+ const char *env = getenv ("CAIRO_SPHINX_FD");
+ int fd = env ? atoi (env) : 1;
+ fdr_context = DLCALL (cairo_script_create_for_stream,
+ fdr_write, (void *) (intptr_t) fd);
+ }
+
+ fdr_get_extents (surface, &extents);
+ content = DLCALL (cairo_surface_get_content, surface);
+
+ tee = DLCALL (cairo_tee_surface_create, surface);
+ script = DLCALL (cairo_script_surface_create,
+ fdr_context, content, extents.width, extents.height);
+ DLCALL (cairo_tee_surface_add, tee, script);
+
+ DLCALL (cairo_surface_set_user_data, surface,
+ &fdr_key, tee, fdr_surface_destroy);
+ }
+
+ return DLCALL (cairo_create, tee);
+}
+
+static void
+fdr_remove_tee (cairo_surface_t *surface)
+{
+ fdr_surface_reference (surface);
+ DLCALL (cairo_surface_set_user_data, surface, &fdr_key, NULL, NULL);
+ fdr_surface_destroy (surface);
+}
+
+void
+cairo_destroy (cairo_t *cr)
+{
+ cairo_surface_t *tee;
+
+ tee = DLCALL (cairo_get_target, cr);
+ DLCALL (cairo_destroy, cr);
+
+ if (DLCALL (cairo_surface_get_reference_count, tee) == 1)
+ fdr_remove_tee (fdr_tee_surface_index (tee, 0));
+}
+
+void
+cairo_pattern_destroy (cairo_pattern_t *pattern)
+{
+ if (DLCALL (cairo_pattern_get_type, pattern) == CAIRO_PATTERN_TYPE_SURFACE) {
+ cairo_surface_t *surface;
+
+ if (DLCALL (cairo_pattern_get_surface, pattern, &surface) == CAIRO_STATUS_SUCCESS &&
+ DLCALL (cairo_surface_get_type, surface) == CAIRO_SURFACE_TYPE_TEE &&
+ DLCALL (cairo_surface_get_reference_count, surface) == 2)
+ {
+ fdr_remove_tee (fdr_tee_surface_index (surface, 0));
+ }
+ }
+
+ DLCALL (cairo_pattern_destroy, pattern);
+}
+
+cairo_surface_t *
+cairo_get_target (cairo_t *cr)
+{
+ cairo_surface_t *tee;
+
+ tee = DLCALL (cairo_get_target, cr);
+ return fdr_tee_surface_index (tee, 0);
+}
+
+cairo_surface_t *
+cairo_get_group_target (cairo_t *cr)
+{
+ cairo_surface_t *tee;
+
+ tee = DLCALL (cairo_get_group_target, cr);
+ return fdr_tee_surface_index (tee, 0);
+}
+
+cairo_pattern_t *
+cairo_pattern_create_for_surface (cairo_surface_t *surface)
+{
+ cairo_surface_t *tee;
+
+ tee = fdr_surface_get_tee (surface);
+ if (tee != NULL)
+ surface = tee;
+
+ return DLCALL (cairo_pattern_create_for_surface, surface);
+}
+
+cairo_status_t
+cairo_pattern_get_surface (cairo_pattern_t *pattern,
+ cairo_surface_t **surface)
+{
+ cairo_status_t status;
+ cairo_surface_t *tee;
+
+ status = DLCALL (cairo_pattern_get_surface, pattern, surface);
+ if (status != CAIRO_STATUS_SUCCESS)
+ return status;
+
+ tee = fdr_surface_get_tee (*surface);
+ if (tee != NULL)
+ *surface = tee;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+void
+cairo_set_source_surface (cairo_t *cr,
+ cairo_surface_t *surface,
+ double x, double y)
+{
+ cairo_surface_t *tee;
+
+ tee = fdr_surface_get_tee (surface);
+ if (tee != NULL)
+ surface = tee;
+
+ DLCALL (cairo_set_source_surface, cr, surface, x, y);
+}
+
+cairo_surface_t *
+cairo_surface_create_similar (cairo_surface_t *surface,
+ cairo_content_t content,
+ int width, int height)
+{
+ cairo_surface_t *tee;
+
+ tee = fdr_surface_get_tee (surface);
+ if (tee != NULL)
+ surface = tee;
+
+ return DLCALL (cairo_surface_create_similar,
+ surface, content, width, height);
+}
diff --git a/libs/cairo-1.16.0/util/cairo-sphinx/sphinx.c b/libs/cairo-1.16.0/util/cairo-sphinx/sphinx.c
new file mode 100644
index 0000000..238d400
--- /dev/null
+++ b/libs/cairo-1.16.0/util/cairo-sphinx/sphinx.c
@@ -0,0 +1,1545 @@
+/*
+ * The intention for sphinx is for detection of rendering errors inside
+ * applications by simultaneously rendering on to the target device and on
+ * an image surface and comparing the two. If it found a discrepancy, it
+ * would then dump the trace that reproduces the error. (Then apply
+ * delta-debugging to reduce that down to a minimal trace.)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/poll.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <errno.h>
+#include <assert.h>
+#include <pthread.h>
+
+#include <cairo.h>
+#include <cairo-script.h>
+#include <cairo-script-interpreter.h>
+#include <cairo-boilerplate.h>
+
+#include <glib.h> /* for checksumming */
+
+#ifndef CAIRO_HAS_REAL_PTHREAD
+# error "cairo-sphinx needs real pthreads"
+#endif
+
+#ifndef MAP_NORESERVE
+#define MAP_NORESERVE 0
+#endif
+
+#define DATA_SIZE (256 << 20)
+#define SHM_PATH_XXX "/shmem-cairo-sphinx"
+
+struct client {
+ int sk;
+ const cairo_boilerplate_target_t *target;
+ cairo_surface_t *surface;
+ void *base;
+
+ cairo_script_interpreter_t *csi;
+ struct context_closure {
+ struct context_closure *next;
+ unsigned long id;
+ cairo_t *context;
+ cairo_surface_t *surface;
+ cairo_surface_t *original;
+ } *contexts;
+
+ unsigned long context_id;
+};
+
+struct surface_tag {
+ long width, height;
+};
+static const cairo_user_data_key_t surface_tag;
+
+static int
+client_socket (const char *socket_path);
+
+static int
+writen (int fd, const void *ptr, int len)
+{
+#if 1
+ const uint8_t *data = ptr;
+ while (len) {
+ int ret = write (fd, data, len);
+ if (ret < 0) {
+ switch (errno) {
+ case EAGAIN:
+ case EINTR:
+ continue;
+ default:
+ return FALSE;
+ }
+ } else if (ret == 0) {
+ return FALSE;
+ } else {
+ data += ret;
+ len -= ret;
+ }
+ }
+ return TRUE;
+#else
+ int ret = send (fd, ptr, len, 0);
+ return ret == len;
+#endif
+}
+
+static int
+readn (int fd, void *ptr, int len)
+{
+#if 0
+ uint8_t *data = ptr;
+ while (len) {
+ int ret = read (fd, data, len);
+ if (ret < 0) {
+ switch (errno) {
+ case EAGAIN:
+ case EINTR:
+ continue;
+ default:
+ return FALSE;
+ }
+ } else if (ret == 0) {
+ return FALSE;
+ } else {
+ data += ret;
+ len -= ret;
+ }
+ }
+ return TRUE;
+#else
+ int ret = recv (fd, ptr, len, MSG_WAITALL);
+ return ret == len;
+#endif
+}
+static int
+open_devnull_to_fd (int want_fd, int flags)
+{
+ int error;
+ int got_fd;
+
+ close (want_fd);
+
+ got_fd = open("/dev/null", flags | O_CREAT, 0700);
+ if (got_fd == -1)
+ return -1;
+
+ error = dup2 (got_fd, want_fd);
+ close (got_fd);
+
+ return error;
+}
+
+static int
+daemonize (void)
+{
+ void (*oldhup) (int);
+
+ /* Let the parent go. */
+ switch (fork ()) {
+ case -1: return -1;
+ case 0: break;
+ default: _exit (0);
+ }
+
+ /* Become session leader. */
+ if (setsid () == -1)
+ return -1;
+
+ /* Refork to yield session leadership. */
+ oldhup = signal (SIGHUP, SIG_IGN);
+ switch (fork ()) {
+ case -1: return -1;
+ case 0: break;
+ default: _exit (0);
+ }
+ signal (SIGHUP, oldhup);
+
+ /* Establish stdio. */
+ if (open_devnull_to_fd (0, O_RDONLY) == -1)
+ return -1;
+ if (open_devnull_to_fd (1, O_WRONLY | O_APPEND) == -1)
+ return -1;
+ if (dup2 (1, 2) == -1)
+ return -1;
+
+ return 0;
+}
+
+static int
+server_socket (const char *socket_path)
+{
+ long flags;
+ struct sockaddr_un addr;
+ int sk;
+
+ unlink (socket_path);
+
+ sk = socket (PF_UNIX, SOCK_STREAM, 0);
+ if (sk == -1)
+ return -1;
+
+ memset (&addr, 0, sizeof (addr));
+ addr.sun_family = AF_UNIX;
+ strcpy (addr.sun_path, socket_path);
+ if (bind (sk, (struct sockaddr *) &addr, sizeof (addr)) == -1) {
+ close (sk);
+ return -1;
+ }
+
+ flags = fcntl (sk, F_GETFL);
+ if (flags == -1 || fcntl (sk, F_SETFL, flags | O_NONBLOCK) == -1) {
+ close (sk);
+ return -1;
+ }
+
+ if (listen (sk, 5) == -1) {
+ close (sk);
+ return -1;
+ }
+
+ return sk;
+}
+
+static int
+readline (int fd, char *line, int max)
+{
+ int len = 0;
+ do {
+ int ret = read (fd, &line[len], 1);
+ if (ret <= 0)
+ return -1;
+ } while (line[len] != '\n' && ++len < max);
+ line[len] = '\0';
+ return len;
+}
+
+struct clients {
+ int count, size;
+ int complete;
+
+ cairo_surface_t *recording;
+ unsigned long serial;
+
+ struct client_info {
+ int sk;
+ int trace;
+ unsigned long image_serial;
+ cairo_surface_t *image;
+ char *name;
+ char *target;
+ char *reference;
+
+ uint8_t *out_buf;
+ int out_len;
+ int out_size;
+ } *clients;
+ const char *shm_path;
+ unsigned long offset;
+ uint8_t *base;
+};
+
+static void *
+clients_shm (const char *shm_path)
+{
+ void *base;
+ int fd;
+
+ shm_unlink (shm_path);
+ fd = shm_open (shm_path, O_RDWR | O_EXCL | O_CREAT, 0777);
+ if (fd == -1)
+ return MAP_FAILED;
+
+ if (ftruncate (fd, DATA_SIZE) == -1) {
+ close (fd);
+ return MAP_FAILED;
+ }
+
+ base = mmap (NULL, DATA_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ close (fd);
+
+ return base;
+}
+
+static int
+clients_init (struct clients *clients)
+{
+ clients->count = 0;
+ clients->complete = 0;
+ clients->size = 4;
+ clients->clients = xmalloc (clients->size * sizeof (struct client_info));
+
+ clients->shm_path = SHM_PATH_XXX;
+ clients->base = clients_shm (clients->shm_path);
+ if (clients->base == MAP_FAILED)
+ return -1;
+ clients->offset = 0;
+
+ clients->recording = NULL;
+ clients->serial = 0;
+
+ return 0;
+}
+
+static void
+clients_add_command (struct clients *clients, int fd, char *info)
+{
+ struct client_info *c;
+ char buf[1024];
+ int len;
+ char *str;
+
+ if (clients->count == clients->size) {
+ clients->size *= 2;
+ clients->clients = xrealloc (clients->clients,
+ clients->size * sizeof (struct client_info));
+ }
+
+ c = &clients->clients[clients->count++];
+ c->sk = fd;
+ c->trace = -1;
+ c->image_serial = 0;
+ c->image = NULL;
+ c->name = c->target = c->reference = NULL;
+
+ c->out_size = 8192;
+ c->out_buf = xmalloc (c->out_size);
+ c->out_len = 0;
+
+ str = strstr (info, "name=");
+ if (str != NULL) {
+ char *sp = strchr (str + 5, ' ');
+ int len;
+ if (sp)
+ len = sp - str - 5;
+ else
+ len = strlen (str + 5);
+ c->name = xmalloc (len + 1);
+ memcpy (c->name, str + 5, len);
+ c->name[len] = '\0';
+ }
+
+ str = strstr (info, "target=");
+ if (str != NULL) {
+ char *sp = strchr (str + 7, ' ');
+ int len;
+ if (sp)
+ len = sp - str - 7;
+ else
+ len = strlen (str + 7);
+ c->target = xmalloc (len + 1);
+ memcpy (c->target, str + 7, len);
+ c->target[len] = '\0';
+ }
+
+ str = strstr (info, "reference=");
+ if (str != NULL) {
+ char *sp = strchr (str + 10, ' ');
+ int len;
+ if (sp)
+ len = sp - str - 10;
+ else
+ len = strlen (str + 10);
+ c->reference = xmalloc (len + 1);
+ memcpy (c->reference, str + 10, len);
+ c->reference[len] = '\0';
+ }
+
+ len = sprintf (buf, "%s\n", clients->shm_path);
+ writen (fd, buf, len);
+}
+
+static void
+clients_add_trace (struct clients *clients, int fd, char *info)
+{
+ char *str, *sp;
+ char *name;
+ int i;
+
+ str = strstr (info, "name=");
+ assert (str != NULL);
+ sp = strchr (str + 5, ' ');
+ if (sp)
+ i = sp - str - 5;
+ else
+ i = strlen (str + 5);
+
+ name = xmalloc (i + 1);
+ memcpy (name, str + 5, i);
+ name[i] = '\0';
+
+ for (i = 0; i < clients->count; i++) {
+ struct client_info *c = &clients->clients[i];
+ if (strcmp (name, c->name) == 0) {
+ c->trace = fd;
+ break;
+ }
+ }
+
+ free (name);
+}
+
+static int
+clients_image (struct clients *clients, int fd, char *info)
+{
+ struct client_info *c = NULL;
+ int format, width, height, stride, size;
+ int i;
+
+ for (i = 0; i < clients->count; i++) {
+ if (clients->clients[i].sk == fd) {
+ c = &clients->clients[i];
+ break;
+ }
+ }
+
+ if (c == NULL)
+ return 0;
+
+ if (sscanf (info, "%lu %d %d %d %d",
+ &c->image_serial, &format, &width, &height, &stride) != 5)
+ {
+ return 0;
+ }
+
+ size = height * stride;
+ size = (size + 4095) & -4096;
+ assert (clients->offset + size <= DATA_SIZE);
+
+ c->image =
+ cairo_image_surface_create_for_data (clients->base + clients->offset,
+ format, width, height, stride);
+
+ if (! writen (fd, &clients->offset, sizeof (clients->offset)))
+ return 0;
+
+ clients->offset += size;
+
+ return 1;
+}
+
+static int
+u8_cmp (const void *A, const void *B)
+{
+ const uint8_t *a = A, *b = B;
+ return (int) *a - (int) *b;
+}
+
+static uint8_t
+median (uint8_t *values, int count)
+{
+ /* XXX could use a fast median here if we cared */
+ qsort (values, count, 1, u8_cmp);
+ return values[count/2];
+}
+
+static uint32_t
+get_pixel32 (int x, int y, const uint8_t *data, int stride)
+{
+ return ((uint32_t *)(data + y * stride))[x];
+}
+
+static uint8_t
+get_median_32 (int x, int y, int channel,
+ const uint8_t *data, int width, int height, int stride)
+{
+ uint8_t neighbourhood[25];
+ int cnt = 0;
+ int xx, yy;
+
+ for (yy = y - 2; yy <= y + 2; yy++) {
+ if (yy < 0)
+ continue;
+ if (yy >= height)
+ continue;
+
+ for (xx = x - 2; xx <= x + 2; xx++) {
+ if (xx < 0)
+ continue;
+ if (xx >= width)
+ continue;
+
+ neighbourhood[cnt++] = (get_pixel32 (xx, yy, data, stride) >> (channel*8)) & 0xff;
+ }
+ }
+
+ return median (neighbourhood, cnt);
+}
+
+static uint8_t
+get_pixel8 (int x, int y, const uint8_t *data, int stride)
+{
+ return data[y * stride + x];
+}
+
+static uint8_t
+get_median_8 (int x, int y, const uint8_t *data, int width, int height, int stride)
+{
+ uint8_t neighbourhood[25];
+ int cnt = 0;
+ int xx, yy;
+
+ for (yy = y - 2; yy <= y + 2; yy++) {
+ if (yy < 0)
+ continue;
+ if (yy >= height)
+ continue;
+
+ for (xx = x - 2; xx <= x + 2; xx++) {
+ if (xx < 0)
+ continue;
+ if (xx >= width)
+ continue;
+
+ neighbourhood[cnt++] = get_pixel8 (xx, yy, data, stride);
+ }
+ }
+
+ return median (neighbourhood, cnt);
+}
+
+static cairo_bool_t
+compare_images (cairo_surface_t *a,
+ cairo_surface_t *b)
+{
+ int width, height, stride;
+ const uint8_t *aa, *bb;
+ int x, y;
+
+ if (cairo_surface_status (a) || cairo_surface_status (b))
+ return FALSE;
+
+ if (cairo_surface_get_type (a) != cairo_surface_get_type (b))
+ return FALSE;
+
+ if (cairo_image_surface_get_format (a) != cairo_image_surface_get_format (b))
+ return FALSE;
+
+ if (cairo_image_surface_get_width (a) != cairo_image_surface_get_width (b))
+ return FALSE;
+
+ if (cairo_image_surface_get_height (a) != cairo_image_surface_get_height (b))
+ return FALSE;
+
+ if (cairo_image_surface_get_stride (a) != cairo_image_surface_get_stride (b))
+ return FALSE;
+
+
+ width = cairo_image_surface_get_width (a);
+ height = cairo_image_surface_get_height (a);
+ stride = cairo_image_surface_get_stride (a);
+
+ aa = cairo_image_surface_get_data (a);
+ bb = cairo_image_surface_get_data (b);
+ switch (cairo_image_surface_get_format (a)) {
+ case CAIRO_FORMAT_ARGB32:
+ for (y = 0; y < height; y++) {
+ const uint32_t *ua = (uint32_t *) aa;
+ const uint32_t *ub = (uint32_t *) bb;
+ for (x = 0; x < width; x++) {
+ if (ua[x] != ub[x]) {
+ int channel;
+
+ for (channel = 0; channel < 4; channel++) {
+ unsigned va, vb, diff;
+
+ va = (ua[x] >> (channel*8)) & 0xff;
+ vb = (ub[x] >> (channel*8)) & 0xff;
+ diff = abs (va - vb);
+ if (diff > 1) {
+ va = get_median_32 (x, y, channel, aa, width, height, stride);
+ vb = get_median_32 (x, y, channel, bb, width, height, stride);
+ diff = abs (va - vb);
+ if (diff > 1)
+ return FALSE;
+ }
+ }
+ }
+ }
+ aa += stride;
+ bb += stride;
+ }
+ break;
+
+ case CAIRO_FORMAT_RGB24:
+ for (y = 0; y < height; y++) {
+ const uint32_t *ua = (uint32_t *) aa;
+ const uint32_t *ub = (uint32_t *) bb;
+ for (x = 0; x < width; x++) {
+ if ((ua[x] & 0x00ffffff) != (ub[x] & 0x00ffffff)) {
+ int channel;
+
+ for (channel = 0; channel < 3; channel++) {
+ unsigned va, vb, diff;
+
+ va = (ua[x] >> (channel*8)) & 0xff;
+ vb = (ub[x] >> (channel*8)) & 0xff;
+ diff = abs (va - vb);
+ if (diff > 1) {
+ va = get_median_32 (x, y, channel, aa, width, height, stride);
+ vb = get_median_32 (x, y, channel, bb, width, height, stride);
+ diff = abs (va - vb);
+ if (diff > 1)
+ return FALSE;
+ }
+ }
+ }
+ }
+ aa += stride;
+ bb += stride;
+ }
+ break;
+
+ case CAIRO_FORMAT_A8:
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ if (aa[x] != bb[x]) {
+ unsigned diff = abs (aa[x] - bb[x]);
+ if (diff > 1) {
+ uint8_t va, vb;
+
+ va = get_median_8 (x, y, aa, width, height, stride);
+ vb = get_median_8 (x, y, bb, width, height, stride);
+ diff = abs (va - vb);
+ if (diff > 1)
+ return FALSE;
+ }
+
+ }
+ }
+ aa += stride;
+ bb += stride;
+ }
+ break;
+
+ case CAIRO_FORMAT_A1:
+ width /= 8;
+ for (y = 0; y < height; y++) {
+ if (memcmp (aa, bb, width))
+ return FALSE;
+ aa += stride;
+ bb += stride;
+ }
+ break;
+
+ case CAIRO_FORMAT_INVALID:
+ case CAIRO_FORMAT_RGB16_565: /* XXX */
+ break;
+ }
+
+ return TRUE;
+}
+
+static int
+check_images (struct clients *clients)
+{
+ int i, j;
+
+ for (i = 0; i < clients->count; i++) {
+ struct client_info *c = &clients->clients[i];
+
+ if (c->reference == NULL)
+ continue;
+
+ for (j = 0; j < clients->count; j++) {
+ struct client_info *ref = &clients->clients[j];
+
+ if (strcmp (c->reference, ref->name))
+ continue;
+
+ if (! compare_images (c->image, ref->image))
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+static gchar *
+checksum (const char *filename)
+{
+ gchar *str = NULL;
+ gchar *data;
+ gsize len;
+
+ if (g_file_get_contents (filename, &data, &len, NULL)) {
+ str = g_compute_checksum_for_data (G_CHECKSUM_SHA1, (guchar *) data, len);
+ g_free (data);
+ }
+
+ return str;
+}
+
+static void
+write_trace (struct clients *clients)
+{
+ cairo_device_t *ctx;
+ gchar *csum;
+ char buf[4096];
+ int i;
+
+ mkdir ("output", 0777);
+
+ ctx = cairo_script_create ("output/cairo-sphinx.trace");
+ cairo_script_from_recording_surface (ctx, clients->recording);
+ cairo_device_destroy (ctx);
+
+ csum = checksum ("output/cairo-sphinx.trace");
+
+ sprintf (buf, "output/%s.trace", csum);
+ if (! g_file_test (buf, G_FILE_TEST_EXISTS)) {
+ rename ("output/cairo-sphinx.trace", buf);
+
+ sprintf (buf, "output/%s.recording.png", csum);
+ cairo_surface_write_to_png (clients->recording, buf);
+
+ for (i = 0; i < clients->count; i++) {
+ struct client_info *c = &clients->clients[i];
+ if (c->image != NULL) {
+ sprintf (buf, "output/%s.%s.png", csum, c->name);
+ cairo_surface_write_to_png (c->image, buf);
+ }
+ }
+ }
+}
+
+static void
+clients_complete (struct clients *clients, int fd)
+{
+ int i;
+
+ for (i = 0; i < clients->count; i++) {
+ if (clients->clients[i].sk == fd) {
+ break;
+ }
+ }
+ if (i == clients->count)
+ return;
+
+ if (++clients->complete != clients->count)
+ return;
+
+ clients->offset = 0;
+ clients->complete = 0;
+
+ if (! check_images (clients))
+ write_trace (clients);
+
+ /* ack */
+ for (i = 0; i < clients->count; i++) {
+ struct client_info *c = &clients->clients[i];
+
+ cairo_surface_destroy (c->image);
+ c->image = NULL;
+
+ if (! writen (c->sk, &clients->serial, sizeof (clients->serial)))
+ continue;
+
+ c->image_serial = 0;
+ }
+
+ clients->recording = NULL;
+ clients->serial = 0;
+}
+
+static void
+clients_recording (struct clients *clients, int fd, char *info)
+{
+ sscanf (info, "%p %lu", &clients->recording, &clients->serial);
+ clients_complete (clients, fd);
+}
+
+static void
+clients_remove (struct clients *clients, int fd)
+{
+ int i, j;
+
+ for (i = 0; i < clients->count; i++) {
+ struct client_info *c = &clients->clients[i];
+ if (c->sk == fd) {
+ free (c->out_buf);
+ break;
+ }
+ }
+
+ for (j = i++; i < clients->count; i++)
+ clients->clients[j] = clients->clients[i];
+
+ clients->count = j;
+}
+
+static void
+clients_send_trace (struct clients *clients,
+ const char * const line, const int len)
+{
+ int i;
+
+ for (i = 0; i < clients->count; i++) {
+ struct client_info *c = &clients->clients[i];
+ int ret, rem = len;
+
+ if (c->trace == -1)
+ continue;
+
+ if (c->out_len) {
+ ret = write (c->trace, c->out_buf, c->out_len);
+ if (ret > 0) {
+ c->out_len -= ret;
+ if (c->out_len)
+ memmove (c->out_buf, c->out_buf + ret, c->out_len);
+ }
+ }
+
+ if (! c->out_len) {
+ ret = write (c->trace, line, rem);
+ if (ret > 0)
+ rem -= ret;
+ }
+
+ if (rem) {
+ if (c->out_len + rem > c->out_size) {
+ c->out_size *= 2;
+ c->out_buf = xrealloc (c->out_buf, c->out_size);
+ }
+
+ memcpy (c->out_buf + c->out_len, line, rem);
+ c->out_len += rem;
+ }
+ }
+}
+
+static void
+clients_fini (struct clients *clients)
+{
+ shm_unlink (clients->shm_path);
+ munmap (clients->base, DATA_SIZE);
+ free (clients->clients);
+}
+
+static int
+nonblocking (int fd)
+{
+ long flags;
+
+ flags = fcntl (fd, F_GETFL);
+ if (flags == -1)
+ return -1;
+
+ return fcntl (fd, F_SETFL, flags | O_NONBLOCK);
+}
+
+static void *
+request_image (struct client *c,
+ struct context_closure *closure,
+ cairo_format_t format,
+ int width, int height, int stride)
+{
+ char buf[1024];
+ unsigned long offset = -1;
+ int len;
+
+ assert (format != CAIRO_FORMAT_INVALID);
+
+ len = sprintf (buf, ".image %lu %d %d %d %d\n",
+ closure->id, format, width, height, stride);
+ writen (c->sk, buf, len);
+
+ readn (c->sk, &offset, sizeof (offset));
+ if (offset == (unsigned long) -1)
+ return NULL;
+
+ return (uint8_t *) c->base + offset;
+}
+
+static cairo_format_t
+format_for_content (cairo_content_t content)
+{
+ switch (content) {
+ case CAIRO_CONTENT_ALPHA:
+ return CAIRO_FORMAT_A8;
+ case CAIRO_CONTENT_COLOR:
+ return CAIRO_FORMAT_RGB24;
+ default:
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ return CAIRO_FORMAT_ARGB32;
+ }
+}
+
+static void
+get_surface_size (cairo_surface_t *surface,
+ int *width, int *height,
+ cairo_format_t *format)
+{
+ if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE) {
+ *width = cairo_image_surface_get_width (surface);
+ *height = cairo_image_surface_get_height (surface);
+ *format = cairo_image_surface_get_format (surface);
+ } else {
+ struct surface_tag *tag;
+
+ tag = cairo_surface_get_user_data (surface, &surface_tag);
+ if (tag != NULL) {
+ *width = tag->width;
+ *height = tag->height;
+ } else {
+ double x0, x1, y0, y1;
+ cairo_t *cr;
+
+ /* presumably created using cairo_surface_create_similar() */
+ cr = cairo_create (surface);
+ cairo_clip_extents (cr, &x0, &y0, &x1, &y1);
+ cairo_destroy (cr);
+
+ tag = xmalloc (sizeof (*tag));
+ *width = tag->width = ceil (x1 - x0);
+ *height = tag->height = ceil (y1 - y0);
+
+ if (cairo_surface_set_user_data (surface, &surface_tag, tag, free))
+ exit (-1);
+ }
+ }
+}
+
+
+static void
+send_surface (struct client *c,
+ struct context_closure *closure)
+{
+ cairo_surface_t *source = closure->surface;
+ cairo_surface_t *image;
+ cairo_format_t format = CAIRO_FORMAT_INVALID;
+ cairo_t *cr;
+ int width, height, stride;
+ void *data;
+ unsigned long serial;
+
+ get_surface_size (source, &width, &height, &format);
+ if (format == CAIRO_FORMAT_INVALID)
+ format = format_for_content (cairo_surface_get_content (source));
+
+ stride = cairo_format_stride_for_width (format, width);
+
+ data = request_image (c, closure, format, width, height, stride);
+ if (data == NULL)
+ exit (-1);
+
+ image = cairo_image_surface_create_for_data (data,
+ format,
+ width, height,
+ stride);
+ cr = cairo_create (image);
+ cairo_surface_destroy (image);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface (cr, source, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ /* signal completion */
+ writen (c->sk, ".complete\n", strlen (".complete\n"));
+
+ /* wait for image check */
+ serial = 0;
+ readn (c->sk, &serial, sizeof (serial));
+ if (serial != closure->id)
+ exit (-1);
+}
+
+static void
+send_recording (struct client *c,
+ struct context_closure *closure)
+{
+ cairo_surface_t *source = closure->surface;
+ char buf[1024];
+ int len;
+ unsigned long serial;
+
+ assert (cairo_surface_get_type (source) == CAIRO_SURFACE_TYPE_RECORDING);
+ len = sprintf (buf, ".recording %p %lu\n", source, closure->id);
+ writen (c->sk, buf, len);
+
+ /* wait for image check */
+
+ serial = 0;
+ readn (c->sk, &serial, sizeof (serial));
+ if (serial != closure->id)
+ exit (-1);
+}
+
+static cairo_surface_t *
+_surface_create (void *closure,
+ cairo_content_t content,
+ double width, double height,
+ long uid)
+{
+ struct client *c = closure;
+ cairo_surface_t *surface;
+
+ surface = cairo_surface_create_similar (c->surface,
+ content, width, height);
+ if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_IMAGE) {
+ struct surface_tag *tag;
+
+ tag = xmalloc (sizeof (*tag));
+ tag->width = width;
+ tag->height = height;
+ if (cairo_surface_set_user_data (surface, &surface_tag, tag, free))
+ exit (-1);
+ }
+
+ return surface;
+}
+
+static cairo_t *
+_context_create (void *closure, cairo_surface_t *surface)
+{
+ struct client *c = closure;
+ struct context_closure *l;
+ cairo_bool_t foreign = FALSE;
+
+ l = xmalloc (sizeof (*l));
+ l->next = c->contexts;
+ l->surface = surface;
+ l->original = cairo_surface_reference (surface);
+ l->id = ++c->context_id;
+ if (l->id == 0)
+ l->id = ++c->context_id;
+ c->contexts = l;
+
+ /* record everything, including writes to images */
+ if (c->target == NULL) {
+ if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_RECORDING) {
+ cairo_format_t format;
+ int width, height;
+
+ get_surface_size (surface, &width, &height, &format);
+ l->surface = cairo_surface_create_similar (c->surface,
+ cairo_surface_get_content (surface),
+ width, height);
+ foreign = TRUE;
+ }
+ }
+
+ l->context = cairo_create (l->surface);
+ if (foreign) {
+ cairo_set_source_surface (l->context, surface, 0, 0);
+ cairo_paint (l->context);
+ }
+
+ return l->context;
+}
+
+static void
+_context_destroy (void *closure, void *ptr)
+{
+ struct client *c = closure;
+ struct context_closure *l, **prev = &c->contexts;
+
+ while ((l = *prev) != NULL) {
+ if (l->context == ptr) {
+ if (cairo_surface_status (l->surface) == CAIRO_STATUS_SUCCESS) {
+ if (c->target == NULL)
+ send_recording (c, l);
+ else
+ send_surface (c, l);
+ } else {
+ exit (-1);
+ }
+
+ cairo_surface_destroy (l->original);
+ *prev = l->next;
+ free (l);
+ return;
+ }
+ prev = &l->next;
+ }
+}
+
+static void *
+recorder (void *arg)
+{
+ struct client client;
+ const cairo_script_interpreter_hooks_t hooks = {
+ .closure = &client,
+ .surface_create = _surface_create,
+ .context_create = _context_create,
+ .context_destroy = _context_destroy,
+ };
+ char *buf;
+ int buf_size;
+ int len = 0, ret;
+ struct pollfd pfd;
+
+ client.target = NULL;
+ client.sk = client_socket ("/tmp/cairo-sphinx");
+ if (client.sk < 0)
+ return NULL;
+
+ buf_size = 65536;
+ buf = xmalloc (buf_size);
+
+ len = sprintf (buf, "client-command target=recording name=.recorder\n");
+ if (! writen (client.sk, buf, len))
+ return NULL;
+
+ /* drain the shm_path */
+ len = readline (client.sk, buf, buf_size);
+
+ pfd.fd = client_socket ("/tmp/cairo-sphinx");
+ if (pfd.fd < 0)
+ return NULL;
+
+ len = sprintf (buf, "client-trace name=.recorder\n");
+ if (! writen (pfd.fd, buf, len))
+ return NULL;
+
+ client.surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA,
+ NULL);
+
+ client.context_id = 0;
+ client.csi = cairo_script_interpreter_create ();
+ cairo_script_interpreter_install_hooks (client.csi, &hooks);
+
+ nonblocking (pfd.fd);
+ pfd.events = POLLIN;
+ len = 0;
+ while (poll (&pfd, 1, -1) > 0) {
+ while ((ret = read (pfd.fd, buf + len, buf_size - len)) > 0) {
+ int end;
+
+ if (ret == buf_size - len) {
+ buf_size *= 2;
+ buf = xrealloc (buf, buf_size);
+ }
+ len += ret;
+
+ for (end = len; end > 0 && buf[--end] != '\n'; )
+ ;
+ if (end > 0) {
+ buf[end] = '\0';
+ cairo_script_interpreter_feed_string (client.csi, buf, end);
+
+ len -= end + 1;
+ if (len)
+ memmove (buf, buf + end + 1, len);
+ }
+ }
+ if (ret == 0)
+ break;
+ if (! (errno == EAGAIN || errno == EINTR))
+ break;
+ }
+
+ cairo_script_interpreter_finish (client.csi);
+ cairo_script_interpreter_destroy (client.csi);
+
+ cairo_surface_destroy (client.surface);
+ return NULL;
+}
+
+static int
+do_server (const char *path)
+{
+ pthread_t thread;
+ struct clients clients;
+ char line[4096];
+ struct pollfd *pfd;
+ int num_pfd, size_pfd;
+ int n, cnt, ret = 1;
+ int sk, source = -1;
+ int waiter = -1, waiter_count = 0;
+ int len;
+
+ signal (SIGPIPE, SIG_IGN);
+
+ if (clients_init (&clients) < 0) {
+ fprintf (stderr, "Failed to initialise clients structure\n");
+ return -1;
+ }
+
+ sk = server_socket (path);
+ if (sk < 0) {
+ fprintf (stderr, "Failed to create server socket\n");
+ return 1;
+ }
+
+ if (daemonize () < 0)
+ return 1;
+
+ if (pthread_create (&thread, NULL, recorder, NULL) < 0) {
+ fprintf (stderr, "Failed to create spawn recording thread\n");
+ return 1;
+ }
+
+ size_pfd = 4;
+ pfd = xmalloc (sizeof (*pfd) * size_pfd);
+ pfd[0].fd = sk;
+ pfd[0].events = POLLIN;
+ num_pfd = 1;
+
+ while ((cnt = poll (pfd, num_pfd, -1)) > 0) {
+ int have_source;
+
+ if (pfd[0].revents) {
+ while ((sk = accept (pfd[0].fd, NULL, NULL)) != -1) {
+ len = readline (sk, line, sizeof (line));
+ if (strcmp (line, "source") == 0) {
+
+ if (source != -1)
+ exit (1);
+
+ source = sk;
+ if (nonblocking (sk) < 0) {
+ close (sk);
+ continue;
+ }
+ } else if (strncmp (line, "client-command", 14) == 0) {
+ if (source == -1)
+ clients_add_command (&clients, sk, line);
+ } else if (strncmp (line, "client-trace", 12) == 0) {
+ if (source == -1) {
+ clients_add_trace (&clients, sk, line);
+ if (nonblocking (sk) < 0) {
+ close (sk);
+ continue;
+ }
+
+ if (clients.count == waiter_count) {
+ for (n = 1; n < num_pfd; n++) {
+ if (pfd[n].fd == waiter) {
+ pfd[n].fd = -1;
+ break;
+ }
+ }
+ close (waiter);
+ waiter_count = -1;
+ }
+ }
+ } else if (strncmp (line, "wait", 4) == 0) {
+ int count = atoi (line + 5) + 1;
+ if (clients.count == count) {
+ close (sk);
+ continue;
+ } else {
+ waiter = sk;
+ waiter_count = count;
+ }
+ }
+
+ if (num_pfd == size_pfd) {
+ size_pfd *= 2;
+ pfd = xrealloc (pfd, sizeof (*pfd) * size_pfd);
+ }
+
+ pfd[num_pfd].fd = sk;
+ pfd[num_pfd].events = POLLIN;
+ pfd[num_pfd].revents = 0;
+ num_pfd++;
+ }
+ cnt--;
+ }
+
+ have_source = 0;
+ for (n = 1; cnt && n < num_pfd; n++) {
+ if (! pfd[n].revents)
+ continue;
+ cnt--;
+
+ if (pfd[n].fd == -1)
+ continue;
+
+ if (source == pfd[n].fd) {
+ have_source = n;
+ } else {
+ len = readline (pfd[n].fd, line, sizeof (line));
+ if (len < 0) {
+ clients_remove (&clients, pfd[n].fd);
+ close (pfd[n].fd);
+ pfd[n].fd = -1;
+ continue;
+ }
+
+ if (strncmp (line, ".image", 6) == 0) {
+ if (! clients_image (&clients, pfd[n].fd, line + 7)) {
+ clients_remove (&clients, pfd[n].fd);
+ close (pfd[n].fd);
+ pfd[n].fd = -1;
+ continue;
+ }
+ } else if (strncmp (line, ".complete", 9) == 0) {
+ clients_complete (&clients, pfd[n].fd);
+ } else if (strncmp (line, ".recording", 10) == 0) {
+ clients_recording (&clients, pfd[n].fd, line + 6);
+ } else {
+ printf ("do_command (%s)\n", line);
+ }
+ }
+ }
+
+ if (have_source) {
+ do {
+ len = read (source, line, sizeof (line));
+ if (len > 0) {
+ clients_send_trace (&clients, line, len);
+ } else if (len == 0) {
+ close (source);
+ pfd[have_source].fd = source = -1;
+ goto done;
+ } else
+ break;
+ } while (1);
+ }
+
+ for (n = cnt = 1; n < num_pfd; n++) {
+ if (pfd[n].fd != -1) {
+ if (cnt != n)
+ pfd[cnt] = pfd[n];
+ cnt++;
+ }
+ }
+ num_pfd = cnt;
+ }
+
+done:
+ ret = 0;
+ for (n = 0; n < num_pfd; n++) {
+ if (pfd[n].fd != -1)
+ close (pfd[n].fd);
+ }
+ free (pfd);
+ clients_fini (&clients);
+
+ return ret;
+}
+
+static void *
+client_shm (const char *shm_path)
+{
+ void *base;
+ int fd;
+
+ fd = shm_open (shm_path, O_RDWR, 0);
+ if (fd == -1)
+ return MAP_FAILED;
+
+ base = mmap (NULL, DATA_SIZE,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_NORESERVE,
+ fd, 0);
+ close (fd);
+
+ return base;
+}
+
+static int
+client_socket (const char *socket_path)
+{
+ struct sockaddr_un addr;
+ int sk;
+
+ sk = socket (PF_UNIX, SOCK_STREAM, 0);
+ if (sk == -1)
+ return -1;
+
+ memset (&addr, 0, sizeof (addr));
+ addr.sun_family = AF_UNIX;
+ strcpy (addr.sun_path, socket_path);
+
+ if (connect (sk, (struct sockaddr *) &addr, sizeof (addr)) == -1)
+ return -1;
+
+ return sk;
+}
+
+static int
+do_client (int fd,
+ const char *target,
+ const char *name,
+ const char *reference,
+ cairo_content_t content)
+{
+ struct client client;
+ const cairo_script_interpreter_hooks_t hooks = {
+ .closure = &client,
+ .surface_create = _surface_create,
+ .context_create = _context_create,
+ .context_destroy = _context_destroy,
+ };
+ void *closure;
+ char *buf;
+ int buf_size;
+ int len = 0, ret;
+ struct pollfd pfd;
+
+ client.sk = fd;
+ client.target = cairo_boilerplate_get_target_by_name (target, content);
+ client.context_id = 0;
+
+ client.surface = client.target->create_surface (NULL, content, 1, 1, 1, 1,
+ CAIRO_BOILERPLATE_MODE_TEST,
+ &closure);
+ if (client.surface == NULL) {
+ fprintf (stderr, "Failed to create target surface: %s.\n",
+ client.target->name);
+ return 1;
+ }
+
+ buf_size = 65536;
+ buf = xmalloc (buf_size);
+
+ if (reference != NULL) {
+ len = sprintf (buf,
+ "client-command name=%s target=%s reference=%s\n",
+ name, target, reference);
+ } else {
+ len = sprintf (buf,
+ "client-command name=%s target=%s\n",
+ name, target);
+ }
+ if (! writen (fd, buf, len))
+ return 1;
+
+ len = readline (fd, buf, buf_size);
+ client.base = client_shm (buf);
+ if (client.base == MAP_FAILED) {
+ fprintf (stderr, "Failed to map shared memory segment '%s'.\n", buf);
+ return 1;
+ }
+
+ if (daemonize () < 0)
+ return 1;
+
+ pfd.fd = client_socket ("/tmp/cairo-sphinx");
+ if (pfd.fd < 0)
+ return 1;
+
+ len = sprintf (buf, "client-trace name=%s\n", name);
+ if (! writen (pfd.fd, buf, len))
+ return 1;
+
+ client.csi = cairo_script_interpreter_create ();
+ cairo_script_interpreter_install_hooks (client.csi, &hooks);
+
+ nonblocking (pfd.fd);
+ pfd.events = POLLIN;
+ len = 0;
+ while (poll (&pfd, 1, -1) > 0) {
+ while ((ret = read (pfd.fd, buf + len, buf_size - len)) > 0) {
+ int end;
+
+ if (ret == buf_size - len) {
+ buf_size *= 2;
+ buf = xrealloc (buf, buf_size);
+ }
+ len += ret;
+
+ for (end = len; end > 0 && buf[--end] != '\n'; )
+ ;
+ if (end > 0) {
+ buf[end] = '\0';
+ cairo_script_interpreter_feed_string (client.csi, buf, end);
+
+ len -= end + 1;
+ if (len)
+ memmove (buf, buf + end + 1, len);
+ }
+ }
+ if (ret == 0)
+ break;
+ if (! (errno == EAGAIN || errno == EINTR))
+ break;
+ }
+
+ cairo_script_interpreter_finish (client.csi);
+ cairo_script_interpreter_destroy (client.csi);
+
+ cairo_surface_destroy (client.surface);
+ close (fd);
+
+ return 0;
+}
+
+static int
+do_exec (int fd, char **argv)
+{
+ char buf[4096];
+
+ if (*argv == NULL)
+ return 0;
+
+ snprintf (buf, sizeof (buf), "%s/cairo-trace.so", LIBDIR);
+ setenv ("LD_PRELOAD", buf, 1);
+
+ snprintf (buf, sizeof (buf), "0");
+ setenv ("CAIRO_TRACE_LINE_INFO", buf, 1);
+
+ snprintf (buf, sizeof (buf), "%d", fd);
+ setenv ("CAIRO_TRACE_FD", buf, 1);
+ putenv (buf);
+
+ return execvp (argv[0], argv);
+}
+
+static int
+do_wait (int fd)
+{
+ char buf;
+ int ret = read (fd, &buf, 1);
+ return ret != 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ char buf[4096];
+ int len;
+ int fd;
+
+ if (argc == 1)
+ return do_server ("/tmp/cairo-sphinx");
+
+ fd = client_socket ("/tmp/cairo-sphinx");
+ if (fd < 0)
+ return 1;
+
+ if (strcmp (argv[1], "client") == 0) {
+ return do_client (fd, argv[2], argv[3], argv[4],
+ CAIRO_CONTENT_COLOR_ALPHA);
+ }
+
+ if (strcmp (argv[1], "wait") == 0) {
+ len = snprintf (buf, sizeof (buf), "wait %s\n", argv[2]);
+ if (! writen (fd, buf, len))
+ return 1;
+
+ return do_wait (fd);
+ }
+
+ if (strcmp (argv[1], "exec") == 0) {
+ len = snprintf (buf, sizeof (buf), "source\n");
+ if (! writen (fd, buf, len))
+ return 1;
+
+ return do_exec (fd, argv+2);
+ }
+
+ if (strcmp (argv[1], "replay") == 0) {
+ len = snprintf (buf, sizeof (buf), "replay %s\n", argv[2]);
+ return ! writen (fd, buf, len);
+ }
+
+ return 0;
+}