[cairo-commit] 7 commits - build/aclocal.makefile.m4 build/configure.ac.features Makefile.win32 src/cairo-atomic.c src/cairo-atomic-private.h src/cairo-directfb.h src/cairo.h src/cairoint.h src/cairo-mutex-impl-private.h src/cairo-mutex-list-private.h src/cairo-os2-surface.c src/cairo-quartz.h src/cairo-quartz-private.h src/cairo-system.c src/cairo-win32.h src/cairo-win32-surface.c src/check-includes.sh src/check-preprocessor-syntax.sh src/Makefile.am src/Makefile.sources src/Makefile.win32

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Sep 20 15:35:43 PDT 2008


 Makefile.win32                   |    2 
 build/aclocal.makefile.m4        |    5 +-
 build/configure.ac.features      |   16 +++---
 src/Makefile.am                  |    6 +-
 src/Makefile.sources             |    1 
 src/Makefile.win32               |   13 +----
 src/cairo-atomic-private.h       |    4 -
 src/cairo-atomic.c               |    2 
 src/cairo-directfb.h             |    2 
 src/cairo-mutex-impl-private.h   |    8 +++
 src/cairo-mutex-list-private.h   |    2 
 src/cairo-os2-surface.c          |    6 ++
 src/cairo-quartz-private.h       |   11 ++--
 src/cairo-quartz.h               |    4 -
 src/cairo-system.c               |   97 +++++++++++++++++++++++++++++++++++++++
 src/cairo-win32-surface.c        |   28 -----------
 src/cairo-win32.h                |    8 +++
 src/cairo.h                      |    6 ++
 src/cairoint.h                   |   17 ++++++
 src/check-includes.sh            |   58 -----------------------
 src/check-preprocessor-syntax.sh |   57 ++++++++++++++++++++++
 21 files changed, 228 insertions(+), 125 deletions(-)

New commits:
commit 3a45ff0e2fd624e52ddbf2b36fa70231405d79fe
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 18:35:10 2008 -0400

    Make checks happy again
    
    Minor syntax changes and improved check regexps.

diff --git a/src/cairo-mutex-impl-private.h b/src/cairo-mutex-impl-private.h
index d8b3889..ed3995b 100644
--- a/src/cairo-mutex-impl-private.h
+++ b/src/cairo-mutex-impl-private.h
@@ -74,7 +74,7 @@
  *	cairo_mutex_impl_t _cairo_some_mutex;
  *   </programlisting>
  *
- * - #define CAIRO_MUTEX_IMP_<NAME> 1 with suitable name for your platform.  You
+ * - #define %CAIRO_MUTEX_IMP_<NAME> 1 with suitable name for your platform.  You
  *   can later use this symbol in cairo-system.c.
  *
  * - #define CAIRO_MUTEX_IMPL_LOCK(mutex) and CAIRO_MUTEX_IMPL_UNLOCK(mutex) to
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index c55d691..5ec4171 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -233,8 +233,8 @@ void _buffer_free (void *buffer)
 }
 
 /* XXX
- * The cairo_os2_init/fini() functions should be removed and the LibMain
- * code moved to cairo-system.c.  It should also call
+ * The cairo_os2_ini() and cairo_os2_fini() functions should be removed and
+ * the LibMain code moved to cairo-system.c.  It should also call
  * cairo_debug_reset_static_data() instead of duplicating its logic...
  */
 
diff --git a/src/check-preprocessor-syntax.sh b/src/check-preprocessor-syntax.sh
index 12577eb..188e264 100755
--- a/src/check-preprocessor-syntax.sh
+++ b/src/check-preprocessor-syntax.sh
@@ -21,7 +21,7 @@ ALL="/dev/null $HEADERS $PRIVATE $SOURCES"
 echo 'Checking that public header files #include "cairo.h" first (or none)'
 
 for x in $HEADERS; do
-	grep '\<include\>' "$x" /dev/null | head -n 1
+	grep '#.*\<include\>' "$x" /dev/null | head -n 1
 done |
 grep -v '"cairo[.]h"' |
 grep -v 'cairo[.]h:' |
@@ -31,7 +31,7 @@ grep . && stat=1
 echo 'Checking that private header files #include "some cairo header" first (or none)'
 
 for x in $PRIVATE; do
-	grep '\<include\>' "$x" /dev/null | head -n 1
+	grep '#.*\<include\>' "$x" /dev/null | head -n 1
 done |
 grep -v '"cairo.*[.]h"' |
 grep -v 'cairoint[.]h:' |
@@ -41,14 +41,14 @@ grep . && stat=1
 echo 'Checking that source files #include "cairoint.h" first (or none)'
 
 for x in $SOURCES; do
-	grep '\<include\>' "$x" /dev/null | head -n 1
+	grep '#.*\<include\>' "$x" /dev/null | head -n 1
 done |
 grep -v '"cairoint[.]h"' |
 grep . && stat=1
 
 
 echo 'Checking that there is no #include <cairo.*.h>'
-grep '\<include\>.*<.*cairo' $ALL && stat=1
+grep '#.*\<include\>.*<.*cairo' $ALL && stat=1
 
 
 echo 'Checking that feature conditionals are used with #if only (not #ifdef)'
commit 9084f6baf6ab2ce9942b69720dac8201fd5e86cc
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 18:24:37 2008 -0400

    [Makefile.win32] Fix various issues reported by Damian Frank
    
    We now compile cairo-system.c twice when building static library, but
    that's fine because cairo-systemc. includes no other code.  Indeed
    that's why cairo-system.c was born in the first place.

diff --git a/src/Makefile.win32 b/src/Makefile.win32
index 09d56a2..b57478d 100644
--- a/src/Makefile.win32
+++ b/src/Makefile.win32
@@ -3,24 +3,19 @@ SUBMAKEFILE = 1
 include ../Makefile.win32
 include Makefile.win32.config
 
-SOURCES = \
-	$(enabled_cairo_headers) \
-	$(enabled_cairo_private) \
-	$(enabled_cairo_sources) \
-	$(NULL)
+SOURCES = $(enabled_cairo_sources)
 
-STATIC_SOURCES = cairo-win32-surface.c 
+STATIC_SOURCES = cairo-system.c
 
 OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(SOURCES))
-SHARED_OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(STATIC_SOURCES))
 STATIC_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(STATIC_SOURCES))
 
 all: inform $(CFG)/cairo.dll $(CFG)/cairo-static.lib
 static: inform $(CFG)/cairo-static.lib
 dynamic: inform $(CFG)/cairo.dll
 
-$(CFG)/cairo.dll: $(OBJECTS) $(SHARED_OBJECTS)
-	$(CC) -MD -LD -Fe$@ $(PIXMAN_LIBS) $(OBJECTS) $(SHARED_OBJECTS) -link user32.lib gdi32.lib libpng.lib zdll.lib msimg32.lib
+$(CFG)/cairo.dll: $(OBJECTS)
+	$(CC) -MD -LD -Fe$@ $(PIXMAN_LIBS) $(OBJECTS) -link user32.lib gdi32.lib libpng.lib zdll.lib msimg32.lib
 
 $(CFG)/cairo-static.lib: $(OBJECTS) $(STATIC_OBJECTS)
 	lib -NOLOGO -OUT:$@ $(PIXMAN_LIBS) $(OBJECTS) $(STATIC_OBJECTS)
commit 45609d840078288bf0fc096ee8bac642fed6674f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 18:17:19 2008 -0400

    Add cairo-system.c for platform system-specific code
    
    This is where DLL initialization/finalization should be done for example.
    Moved the one for win32.  For OS/2 just left a comment as the code needs
    more work.
    
    This change simplifies building shared and static libraries in the win32
    makefiles.

diff --git a/src/Makefile.sources b/src/Makefile.sources
index ba74702..0e2e487 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -134,6 +134,7 @@ cairo_sources = \
 	cairo-stroke-style.c \
 	cairo-surface.c \
 	cairo-surface-fallback.c \
+	cairo-system.c \
 	cairo-traps.c \
 	cairo-unicode.c \
 	cairo-user-font.c \
diff --git a/src/cairo-mutex-impl-private.h b/src/cairo-mutex-impl-private.h
index 95c666f..d8b3889 100644
--- a/src/cairo-mutex-impl-private.h
+++ b/src/cairo-mutex-impl-private.h
@@ -74,6 +74,9 @@
  *	cairo_mutex_impl_t _cairo_some_mutex;
  *   </programlisting>
  *
+ * - #define CAIRO_MUTEX_IMP_<NAME> 1 with suitable name for your platform.  You
+ *   can later use this symbol in cairo-system.c.
+ *
  * - #define CAIRO_MUTEX_IMPL_LOCK(mutex) and CAIRO_MUTEX_IMPL_UNLOCK(mutex) to
  *   proper statement to lock/unlock the mutex object passed in.
  *   You can (and should) assume that the mutex is already
@@ -155,6 +158,7 @@
 
   typedef int cairo_mutex_impl_t;
 
+# define CAIRO_MUTEX_IMPL_NO 1
 # define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
 # define CAIRO_MUTEX_IMPL_LOCK(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
 # define CAIRO_MUTEX_IMPL_UNLOCK(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
@@ -166,6 +170,7 @@
 
   typedef pthread_mutex_t cairo_mutex_impl_t;
 
+# define CAIRO_MUTEX_IMPL_PTHREAD 1
 # define CAIRO_MUTEX_IMPL_LOCK(mutex) pthread_mutex_lock (&(mutex))
 # define CAIRO_MUTEX_IMPL_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
 # define CAIRO_MUTEX_IMPL_FINI(mutex) pthread_mutex_destroy (&(mutex))
@@ -178,6 +183,7 @@
 
   typedef CRITICAL_SECTION cairo_mutex_impl_t;
 
+# define CAIRO_MUTEX_IMPL_WIN32 1
 # define CAIRO_MUTEX_IMPL_LOCK(mutex) EnterCriticalSection (&(mutex))
 # define CAIRO_MUTEX_IMPL_UNLOCK(mutex) LeaveCriticalSection (&(mutex))
 # define CAIRO_MUTEX_IMPL_INIT(mutex) InitializeCriticalSection (&(mutex))
@@ -192,6 +198,7 @@
 
   typedef HMTX cairo_mutex_impl_t;
 
+# define CAIRO_MUTEX_IMPL_OS2 1
 # define CAIRO_MUTEX_IMPL_LOCK(mutex) DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT)
 # define CAIRO_MUTEX_IMPL_UNLOCK(mutex) DosReleaseMutexSem(mutex)
 # define CAIRO_MUTEX_IMPL_INIT(mutex) DosCreateMutexSem (NULL, &(mutex), 0L, FALSE)
@@ -202,6 +209,7 @@
 
   typedef BLocker* cairo_mutex_impl_t;
 
+# define CAIRO_MUTEX_IMPL_BEOS 1
 # define CAIRO_MUTEX_IMPL_LOCK(mutex) (mutex)->Lock()
 # define CAIRO_MUTEX_IMPL_UNLOCK(mutex) (mutex)->Unlock()
 # define CAIRO_MUTEX_IMPL_INIT(mutex) (mutex) = new BLocker()
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index 80a1cd9..c55d691 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -232,6 +232,12 @@ void _buffer_free (void *buffer)
 #endif
 }
 
+/* XXX
+ * The cairo_os2_init/fini() functions should be removed and the LibMain
+ * code moved to cairo-system.c.  It should also call
+ * cairo_debug_reset_static_data() instead of duplicating its logic...
+ */
+
 #ifdef BUILD_CAIRO_DLL
 /* The main DLL entry for DLL initialization and uninitialization */
 /* Only include this code if we're about to build a DLL.          */
diff --git a/src/cairo-system.c b/src/cairo-system.c
new file mode 100644
index 0000000..9970fce
--- /dev/null
+++ b/src/cairo-system.c
@@ -0,0 +1,97 @@
+/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
+/* Cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is Red Hat, Inc.
+ *
+ * Contributor(s):
+ *	Owen Taylor <otaylor at redhat.com>
+ *	Stuart Parmenter <stuart at mozilla.com>
+ *	Vladimir Vukicevic <vladimir at pobox.com>
+ */
+
+/* This file should include code that is system-specific, not
+ * feature-specific.  For example, the DLL initialization/finalization
+ * code on Win32 or OS/2 must live here (not in cairo-whatever-surface.c).
+ * Same about possible ELF-specific code.
+ *
+ * And no other function should live here.
+ */
+
+
+#include "cairoint.h"
+
+
+
+#if CAIRO_MUTEX_IMPL_WIN32
+#if !defined(CAIRO_WIN32_STATIC_BUILD)
+
+#define WIN32_LEAN_AND_MEAN
+/* We require Windows 2000 features such as ETO_PDY */
+#if !defined(WINVER) || (WINVER < 0x0500)
+# define WINVER 0x0500
+#endif
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
+# define _WIN32_WINNT 0x0500
+#endif
+
+#include "cairo-clip-private.h"
+#include "cairo-paginated-private.h"
+#include "cairo-win32-private.h"
+#include "cairo-scaled-font-subsets-private.h"
+
+#include <windows.h>
+
+/* declare to avoid "no previous prototype for 'DllMain'" warning */
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved);
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved)
+{
+    switch (fdwReason) {
+        case DLL_PROCESS_ATTACH:
+            CAIRO_MUTEX_INITIALIZE ();
+            break;
+
+        case DLL_PROCESS_DETACH:
+            CAIRO_MUTEX_FINALIZE ();
+            break;
+    }
+
+    return TRUE;
+}
+
+#endif
+#endif
+
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 54c4ae4..395d818 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -2013,34 +2013,6 @@ static const cairo_surface_backend_t cairo_win32_surface_backend = {
  */
 
 
-#if !defined(CAIRO_WIN32_STATIC_BUILD)
-
-/* declare to avoid "no previous prototype for 'DllMain'" warning */
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
-         DWORD     fdwReason,
-         LPVOID    lpvReserved);
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
-         DWORD     fdwReason,
-         LPVOID    lpvReserved)
-{
-    switch (fdwReason) {
-        case DLL_PROCESS_ATTACH:
-            CAIRO_MUTEX_INITIALIZE ();
-            break;
-
-        case DLL_PROCESS_DETACH:
-            CAIRO_MUTEX_FINALIZE ();
-            break;
-    }
-
-    return TRUE;
-}
-
-#endif
-
 cairo_int_status_t
 _cairo_win32_save_initial_clip (HDC hdc, cairo_win32_surface_t *surface)
 {
commit 9c2732395987a29ee764c575cce2b13e94152151
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 18:05:01 2008 -0400

    [aclocal] In generated Makefile.win32.config, don't overwrite feature vars
    
    When I designed this first I thought people can define make vars on the
    command line to override default features.  That works.  However, it's
    natural to want to define the list of features in the toplevel Makefile
    and not on command line.  So, we don't override user's var now.  They
    can set a make feature var to 0 to disable it.

diff --git a/build/aclocal.makefile.m4 b/build/aclocal.makefile.m4
index b526b85..1602a32 100644
--- a/build/aclocal.makefile.m4
+++ b/build/aclocal.makefile.m4
@@ -50,6 +50,9 @@ AC_DEFUN([CAIRO_INIT_MAKEFILES],
 		AM_CONDITIONAL(cr_feature_tag, [test "x$use_]cr_feature[" = xyes])dnl
 	])dnl
 
+	dnl An empty line per feature for readability
+	CAIRO_MAKEFILE_ACCUMULATE(*,[]m4_newline[])dnl
+
 	dnl Turn win32 features on
 	CAIRO_FEATURE_HOOK_REGISTER_WIN32(*, [_CAIRO_MAKEFILES_WIN32_DEFINE_FEATURE])dnl
 ])dnl
@@ -58,7 +61,7 @@ m4_define([_CAIRO_MAKEFILES_WIN32_DEFINE_FEATURE],
 [
 	m4_foreach_w([cr_makefile], _CAIRO_MAKEFILES,
 	[dnl
-		CAIRO_ACCUMULATE_UNQUOTED_UNCHECKED([MAKEFILE_]cr_makefile[_WIN32], [cr_feature_tag = 1])dnl
+		CAIRO_ACCUMULATE([MAKEFILE_]cr_makefile[_WIN32], [ifeq ($(]cr_feature_tag[),)]m4_newline[]cr_feature_tag[ = 1]m4_newline[endif])dnl
 	])dnl
 ])dnl
 
diff --git a/build/configure.ac.features b/build/configure.ac.features
index fcdc77f..3660e8e 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -89,8 +89,8 @@ CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,!,
 [dnl
 all_$1_headers += $($1_$2_headers)
 all_$1_private += $($1_$2_private)
-all_$1_sources += $($1_$2_sources)
-])dnl
+all_$1_sources += $($1_$2_sources)]dnl
+)dnl
 
 dnl Collect list of source files for enabled public features
 CAIRO_MAKEFILE_ACCUMULATE(*,
@@ -104,8 +104,8 @@ CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,!,
 [dnl
 enabled_$1_headers += $($1_$2_headers)
 enabled_$1_private += $($1_$2_private)
-enabled_$1_sources += $($1_$2_sources)
-])dnl
+enabled_$1_sources += $($1_$2_sources)]dnl
+)dnl
 
 dnl No public headers for private features
 
@@ -113,15 +113,15 @@ dnl Collect list of source files for all private features
 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,,
 [dnl
 all_$1_private += $($1_$2_private) $($1_$2_headers)
-all_$1_sources += $($1_$2_sources)
-])dnl
+all_$1_sources += $($1_$2_sources)]dnl
+)dnl
 
 dnl Collect list of source files for enabled private features
 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,,
 [dnl
 enabled_$1_private += $($1_$2_private) $($1_$2_headers)
-enabled_$1_sources += $($1_$2_sources)
-])dnl
+enabled_$1_sources += $($1_$2_sources)]dnl
+)dnl
 
 
 dnl ===========================================================================
commit 6d0d5e7ba07c084deafed7118f626415a6c23764
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 17:52:19 2008 -0400

    Define cairo_public correctly for win32
    
    I'm conditioning on _MSC_VER.  Is this accurate?
    Note that we never overwrite cairo_public.  So one can define it to
    something else.

diff --git a/src/cairo.h b/src/cairo.h
index 6758a4d..8abf359 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -51,7 +51,11 @@
 #endif
 
 #ifndef cairo_public
-# define cairo_public
+# ifdef _MSC_VER
+#  define cairo_public __declspec(dllimport)
+# else
+#  define cairo_public
+# endif
 #endif
 
 CAIRO_BEGIN_DECLS
diff --git a/src/cairoint.h b/src/cairoint.h
index 793f99f..740281c 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -50,6 +50,10 @@
 #include "config.h"
 #endif
 
+#ifdef _MSC_VER
+#define cairo_public __declspec(dllexport)
+#endif
+
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
commit 11e96487d8994dd15b39b5ede5be189491f1c14a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 17:51:24 2008 -0400

    [Makefile.win32] Remove a few unused macro declarations
    
    An undefined PACKAGE_BUGREPORT is not properly handled where it's used.
    The other two were not being used after build system revamp.

diff --git a/Makefile.win32 b/Makefile.win32
index 54bf89a..e1a78a4 100644
--- a/Makefile.win32
+++ b/Makefile.win32
@@ -18,10 +18,8 @@ EXE_LDFLAGS = libpng.lib zlib.lib gdi32.lib msimg32.lib user32.lib
 
 DEFAULT_CFLAGS = -MD -nologo $(OPT)
 DEFAULT_CFLAGS += -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
-DEFAULT_CFLAGS += -DPACKAGE_BUGREPORT="" -DCAIRO_BUILD
 DEFAULT_CFLAGS += -I. 
 DEFAULT_CFLAGS += $(PIXMAN_CFLAGS)
-DEFAULT_CFLAGS += -DLIBCAIRO_EXPORTS
 
 CFLAGS := $(DEFAULT_CFLAGS)
 
commit fee72c26afff2120315ebbab32708520307e7a5e
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Sep 20 17:20:36 2008 -0400

    Make sure feature macros are checked using #if, not #ifdef; add a test for it
    
    This is more robust to cases where people want to assign 0 to those variables.
    (win32/alternate build systems, etc)

diff --git a/src/Makefile.am b/src/Makefile.am
index 9c43450..4b6d86b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,10 +70,10 @@ TESTS_ENVIRONMENT = \
 	$(NULL)
 TESTS_SH = \
 	check-def.sh \
-	check-plt.sh \
-	check-headers.sh \
-	check-includes.sh \
 	check-doc-syntax.sh\
+	check-headers.sh \
+	check-plt.sh \
+	check-preprocessor-syntax.sh \
 	$(NULL)
 TESTS += $(TESTS_SH)
 if CROSS_COMPILING
diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index fb5e60d..2914a02 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -47,7 +47,7 @@ CAIRO_BEGIN_DECLS
 
 #if HAVE_INTEL_ATOMIC_PRIMITIVES
 
-#define CAIRO_HAS_ATOMIC_OPS 1
+#define HAS_ATOMIC_OPS 1
 
 typedef int cairo_atomic_int_t;
 
@@ -58,7 +58,7 @@ typedef int cairo_atomic_int_t;
 #endif
 
 
-#ifndef CAIRO_HAS_ATOMIC_OPS
+#ifndef HAS_ATOMIC_OPS
 
 typedef int cairo_atomic_int_t;
 
diff --git a/src/cairo-atomic.c b/src/cairo-atomic.c
index 9fe53e6..c569000 100644
--- a/src/cairo-atomic.c
+++ b/src/cairo-atomic.c
@@ -36,7 +36,7 @@
 #include "cairo-atomic-private.h"
 #include "cairo-mutex-private.h"
 
-#ifndef CAIRO_HAS_ATOMIC_OPS
+#ifndef HAS_ATOMIC_OPS
 void
 _cairo_atomic_int_inc (int *x)
 {
diff --git a/src/cairo-directfb.h b/src/cairo-directfb.h
index 6b3fcbd..0396cb1 100644
--- a/src/cairo-directfb.h
+++ b/src/cairo-directfb.h
@@ -49,7 +49,7 @@
 
 #include "cairo.h"
 
-#ifdef  CAIRO_HAS_DIRECTFB_SURFACE
+#if  CAIRO_HAS_DIRECTFB_SURFACE
 
 #include <directfb.h>
 
diff --git a/src/cairo-mutex-list-private.h b/src/cairo-mutex-list-private.h
index 49f29db..6fdb389 100644
--- a/src/cairo-mutex-list-private.h
+++ b/src/cairo-mutex-list-private.h
@@ -51,7 +51,7 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex)
 CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex)
 #endif
 
-#if !defined (CAIRO_HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER)
+#if !defined (HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER)
 CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex)
 #endif
 
diff --git a/src/cairo-quartz-private.h b/src/cairo-quartz-private.h
index f321c5b..8ba8968 100644
--- a/src/cairo-quartz-private.h
+++ b/src/cairo-quartz-private.h
@@ -40,7 +40,7 @@
 
 #include "cairoint.h"
 
-#ifdef CAIRO_HAS_QUARTZ_SURFACE
+#if CAIRO_HAS_QUARTZ_SURFACE
 #include "cairo-quartz.h"
 
 typedef struct cairo_quartz_surface {
@@ -95,11 +95,10 @@ _cairo_quartz_create_cgimage (cairo_format_t format,
 CGFontRef
 _cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont);
 
-#endif /* CAIRO_HAS_QUARTZ_SURFACE */
+#else
 
-#if CAIRO_HAS_CGFONT_FONT
-CGFontRef
-_cairo_cgfont_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont);
-#endif /* CAIRO_HAS_CGFONT_FONT */
+# error Cairo was not compiled with support for the quartz backend
+
+#endif /* CAIRO_HAS_QUARTZ_SURFACE */
 
 #endif /* CAIRO_QUARTZ_PRIVATE_H */
diff --git a/src/cairo-quartz.h b/src/cairo-quartz.h
index d34cca6..769b29f 100644
--- a/src/cairo-quartz.h
+++ b/src/cairo-quartz.h
@@ -57,12 +57,12 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
 cairo_public CGContextRef
 cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);
 
+#if CAIRO_HAS_QUARTZ_FONT
+
 /*
  * Quartz font support
  */
 
-#ifdef CAIRO_HAS_QUARTZ_FONT
-
 cairo_public cairo_font_face_t *
 cairo_quartz_font_face_create_for_cgfont (CGFontRef font);
 
diff --git a/src/cairo-win32.h b/src/cairo-win32.h
index 8bd7a97..cb517bc 100644
--- a/src/cairo-win32.h
+++ b/src/cairo-win32.h
@@ -68,6 +68,12 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface);
 cairo_public cairo_surface_t *
 cairo_win32_surface_get_image (cairo_surface_t *surface);
 
+#if CAIRO_HAS_WIN32_FONT
+
+/*
+ * Win32 font support
+ */
+
 cairo_public cairo_font_face_t *
 cairo_win32_font_face_create_for_logfontw (LOGFONTW *logfont);
 
@@ -95,6 +101,8 @@ cairo_public void
 cairo_win32_scaled_font_get_device_to_logical (cairo_scaled_font_t *scaled_font,
 					       cairo_matrix_t *device_to_logical);
 
+#endif /* CAIRO_HAS_WIN32_FONT */
+
 CAIRO_END_DECLS
 
 #else  /* CAIRO_HAS_WIN32_SURFACE */
diff --git a/src/cairoint.h b/src/cairoint.h
index a032c12..793f99f 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -68,11 +68,20 @@
 
 #include "cairo-compiler-private.h"
 
-#if defined(CAIRO_HAS_PS_SURFACE) || defined(CAIRO_HAS_PDF_SURFACE) || defined(CAIRO_HAS_SVG_SURFACE)
+#if CAIRO_HAS_PS_SURFACE
+#define CAIRO_HAS_FONT_SUBSET 1
+#endif
+#if CAIRO_HAS_PDF_SURFACE
+#define CAIRO_HAS_FONT_SUBSET 1
+#endif
+#if CAIRO_HAS_SVG_SURFACE
 #define CAIRO_HAS_FONT_SUBSET 1
 #endif
 
-#if defined(CAIRO_HAS_PS_SURFACE) || defined(CAIRO_HAS_PDF_SURFACE)
+#if CAIRO_HAS_PS_SURFACE
+#define CAIRO_HAS_PDF_OPERATORS 1
+#endif
+#if CAIRO_HAS_PDF_SURFACE
 #define CAIRO_HAS_PDF_OPERATORS 1
 #endif
 
diff --git a/src/check-includes.sh b/src/check-includes.sh
deleted file mode 100755
index 8cfa260..0000000
--- a/src/check-includes.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-
-LANG=C
-
-test -z "$srcdir" && srcdir=.
-cd "$srcdir"
-stat=0
-
-
-HEADERS=$all_cairo_headers
-test "x$HEADERS" = x && HEADERS=`find . -name 'cairo*.h' ! -name 'cairo*-private.h' ! -name 'cairoint.h'`
-
-PRIVATE=$all_cairo_private
-test "x$PRIVATE" = x && PRIVATE=`find . -name 'cairo*-private.h' -or -name 'cairoint.h'`
-
-SOURCES=$all_cairo_sources
-test "x$SOURCES" = x && SOURCES=`find . -name 'cairo*.c' -or -name 'cairo*.cpp'`
-
-
-echo 'Checking that public header files #include "cairo.h" first (or none)'
-
-for x in $HEADERS; do
-	grep '\<include\>' "$x" /dev/null | head -n 1
-done |
-grep -v '"cairo[.]h"' |
-grep -v 'cairo[.]h:' |
-grep . && stat=1
-
-
-echo 'Checking that private header files #include "some cairo header" first (or none)'
-
-for x in $PRIVATE; do
-	grep '\<include\>' "$x" /dev/null | head -n 1
-done |
-grep -v '"cairo.*[.]h"' |
-grep -v 'cairoint[.]h:' |
-grep . && stat=1
-
-
-echo 'Checking that source files #include "cairoint.h" first (or none)'
-
-for x in $SOURCES; do
-	grep '\<include\>' "$x" /dev/null | head -n 1
-done |
-grep -v '"cairoint[.]h"' |
-grep . && stat=1
-
-
-echo 'Checking that there is no #include <cairo.*.h>'
-
-for x in $HEADERS $PRIVATE $SOURCES; do
-	grep '\<include\>.*<.*cairo' "$x" /dev/null
-done |
-grep . && stat=1
-
-
-
-exit $stat
diff --git a/src/check-preprocessor-syntax.sh b/src/check-preprocessor-syntax.sh
new file mode 100755
index 0000000..12577eb
--- /dev/null
+++ b/src/check-preprocessor-syntax.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+LANG=C
+
+test -z "$srcdir" && srcdir=.
+cd "$srcdir"
+stat=0
+
+
+HEADERS=$all_cairo_headers
+test "x$HEADERS" = x && HEADERS=`find . -name 'cairo*.h' ! -name 'cairo*-private.h' ! -name 'cairoint.h'`
+
+PRIVATE=$all_cairo_private
+test "x$PRIVATE" = x && PRIVATE=`find . -name 'cairo*-private.h' -or -name 'cairoint.h'`
+
+SOURCES=$all_cairo_sources
+test "x$SOURCES" = x && SOURCES=`find . -name 'cairo*.c' -or -name 'cairo*.cpp'`
+
+ALL="/dev/null $HEADERS $PRIVATE $SOURCES"
+
+echo 'Checking that public header files #include "cairo.h" first (or none)'
+
+for x in $HEADERS; do
+	grep '\<include\>' "$x" /dev/null | head -n 1
+done |
+grep -v '"cairo[.]h"' |
+grep -v 'cairo[.]h:' |
+grep . && stat=1
+
+
+echo 'Checking that private header files #include "some cairo header" first (or none)'
+
+for x in $PRIVATE; do
+	grep '\<include\>' "$x" /dev/null | head -n 1
+done |
+grep -v '"cairo.*[.]h"' |
+grep -v 'cairoint[.]h:' |
+grep . && stat=1
+
+
+echo 'Checking that source files #include "cairoint.h" first (or none)'
+
+for x in $SOURCES; do
+	grep '\<include\>' "$x" /dev/null | head -n 1
+done |
+grep -v '"cairoint[.]h"' |
+grep . && stat=1
+
+
+echo 'Checking that there is no #include <cairo.*.h>'
+grep '\<include\>.*<.*cairo' $ALL && stat=1
+
+
+echo 'Checking that feature conditionals are used with #if only (not #ifdef)'
+grep '#if.*CAIRO_HAS_' $ALL | grep def && stat=1
+
+exit $stat


More information about the cairo-commit mailing list