## Wrapper Makefile.am to build cairo for TeX Live.
##
##   Copyright (C) 2012 Taco Hoekwater <taco@metatex.org>
##
##   This file is free software; the copyright holder
##   gives unlimited permission to copy and/or distribute it,
##   with or without modifications, as long as this notice is preserved.
##
ACLOCAL_AMFLAGS = -I ../../m4

# Rebuild
.PHONY: rebuild
rebuild: config.force all

## We want to re-distribute the whole original cairo source tree.
##
EXTRA_DIST = $(CAIRO_TREE)

## Changes applied to the original source tree
##
EXTRA_DIST += $(CAIRO_TREE)-PATCHES

# in case of an SVN repository
dist-hook:
	rm -rf `find $(distdir) -name .svn -o -name autom4te.cache`

noinst_DATA = libcairo.la

cairo-build/Makefile: config.force
	rm -rf cairo-build
	$(MKDIR_P) cairo-build
	cd cairo-build && \
	  CC='$(CC)' CONFIG_SITE=/dev/null CONFIG_SHELL='$(SHELL)' \
	  $(SHELL) $(abs_srcdir)/$(CAIRO_TREE)/configure \
	    $(config_args) --disable-shared --disable-pthread \
	    --disable-xlib --disable-xcb --disable-qt --disable-quartz \
	    --disable-win32 --disable-win32-font --disable-os2 --disable-beos \
	    --disable-drm --disable-gallium --disable-png --disable-gl \
	    --disable-directfb --disable-vg --disable-egl --disable-glx \
	    --disable-wgl --disable-script --disable-ft --disable-fc \
	    --disable-ps --disable-pdf --disable-svg --disable-test-surfaces \
	    --disable-tee --disable-xml --disable-gobject --disable-full-testing \
	    --disable-trace --disable-interpreter --disable-symbol-lookup \
	    CPPFLAGS=-DCAIRO_NO_MUTEX=1 \
	    pixman_CFLAGS='$(PIXMAN_INCLUDES)' pixman_LIBS='$(PIXMAN_LIBS)' \
	    --prefix=$(abs_builddir)/cairo-install \
	    --libdir=$(abs_builddir) \
	    --includedir=$(abs_builddir)

# Unfortunately the Cairo build system installs the headers after the library;
# to get our dependencies right we wait for a second and then touch the library.
libcairo.la: cairo-build/Makefile
	rm -rf cairo-install
	cd cairo-build \
	  && $(MAKE) $(AM_MAKEFLAGS) \
	  && $(MAKE) $(AM_MAKEFLAGS) install
	sleep 1
	@for f in libcairo.*; do touch $$f; done

clean-local:
	rm -rf cairo-* cairo libcairo* pkgconfig

######################

config.force: $(PIXMAN_DEPEND)
	echo timestamp >config.force
	$(SHELL) ./config.status --recheck

DISTCLEANFILES = config.force

## Rebuild pixman
@PIXMAN_RULE@

if build
check_PROGRAMS = 
dist_check_SCRIPTS = cairo.test
TESTS = cairo.test
endif build

## Files generated by TESTS

