diff -u cairo/cairo.setup cairo-fix/cairo.setup
--- cairo/cairo.setup	2011-02-12 16:48:06.299081297 -0800
+++ cairo-fix/cairo.setup	2011-02-12 16:47:13.713174091 -0800
@@ -1,6 +1,22 @@
 ;;;; -*- Scheme -*-
+(use srfi-1)
+(use srfi-13)
 
-(let ((pkg-cflags (with-input-from-pipe "pkg-config --cflags cairo" read-line))
+;;; on some systems cairo is compiled with pthread support using the
+;;; option '-pthread'. We need to parse the pkgconfig output to prefix
+;;; any non-include directives with '-C' so that csc passes them through
+;;; to the c-compiler.
+(define mark-compiler-options 
+  (lambda (s)
+    (reduce (lambda (s1 s2) (string-append s1 " " s2))
+	    ""
+	    (map (lambda (option)
+		   (if (string-prefix? "-I" option)
+		       option
+		       (string-append "-C " option)))
+		 (string-tokenize s)))))
+
+(let ((pkg-cflags (mark-compiler-options (with-input-from-pipe "pkg-config --cflags cairo" read-line)))
       (pkg-lflags (with-input-from-pipe "pkg-config --libs cairo" read-line)))
       (compile -s -O2 cairo.scm -j cairo -lcairo ,pkg-cflags ,pkg-lflags)
       (compile -c -O2 cairo.scm -unit cairo ,pkg-cflags ,pkg-lflags)
