[cairo] [Windows] Patch to build under Windows
Andrea Canciani
ranma42 at gmail.com
Thu May 5 10:51:30 PDT 2011
On Wed, May 4, 2011 at 11:21 PM, Brent Fulgham <bfulgham at gmail.com> wrote:
> I had to make a few changes to the Makefiles to build Cairo and the test
> suite. Please see the attached patch for details.
I tried your patch in a Cygwin shell (executed with VS environment
variables set)
but it does not fix Makefile.sources. I'm attaching a patch which
improves a little
the behavior of the cairo build system on win32, but it touches Makefile.sources
in a way which is not compatible with automake (and it hacks around a bug in the
static data reset).
More work on this is definitely needed.
Andrea
-------------- next part --------------
From 4bcd865ccc399d2f26c6a56da42f1eba817a8ee9 Mon Sep 17 00:00:00 2001
From: U-NIRVANA-XP\ranma42 <ranma42 at nirvana-xp.(none)>
Date: Tue, 22 Mar 2011 18:47:44 +0100
Subject: [PATCH] wip
---
boilerplate/Makefile.sources | 3 ++-
boilerplate/Makefile.win32 | 3 +++
boilerplate/Makefile.win32.features | 18 +++++++++++++++---
boilerplate/cairo-boilerplate-pdf.c | 4 +---
boilerplate/cairo-boilerplate-ps.c | 5 +++--
boilerplate/cairo-boilerplate-svg.c | 5 +++--
boilerplate/cairo-boilerplate-win32-printing.c | 5 +++--
build/Makefile.win32.common | 6 +++---
src/Makefile.sources | 10 +++++-----
test/Makefile.win32 | 13 ++++++++-----
test/cairo-test.c | 3 ++-
test/cairo-test.h | 3 +++
test/pdiff/perceptualdiff.c | 19 +++++++++++++++++++
13 files changed, 70 insertions(+), 27 deletions(-)
diff --git a/boilerplate/Makefile.sources b/boilerplate/Makefile.sources
index 63ef34e..1714c30 100644
--- a/boilerplate/Makefile.sources
+++ b/boilerplate/Makefile.sources
@@ -33,7 +33,8 @@ cairo_boilerplate_script_sources = cairo-boilerplate-script.c
cairo_boilerplate_skia_sources = cairo-boilerplate-skia.c
cairo_boilerplate_svg_sources = cairo-boilerplate-svg.c
cairo_boilerplate_test_surfaces_sources = cairo-boilerplate-test-surfaces.c
-cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-win32-printing.c
+cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c
+cairo_boilerplate_win32_printing_sources = cairo-boilerplate-win32-printing.c
cairo_boilerplate_xcb_sources = cairo-boilerplate-xcb.c
cairo_boilerplate_xlib_headers = cairo-boilerplate-xlib.h
cairo_boilerplate_xlib_sources = cairo-boilerplate-xlib.c
diff --git a/boilerplate/Makefile.win32 b/boilerplate/Makefile.win32
index 286ea2b..b6b306d 100644
--- a/boilerplate/Makefile.win32
+++ b/boilerplate/Makefile.win32
@@ -11,10 +11,13 @@ HEADERS = \
SOURCES = \
$(enabled_cairo_boilerplate_sources) \
+ cairo-boilerplate-constructors.c \
$(NULL)
OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
+cairo-boilerplate-constructors.c: Makefile.win32 $(enabled_cairo_boilerplate_sources) $(enabled_cairo_boilerplate_cxx_sources) make-cairo-boilerplate-constructors.sh
+ sh ./make-cairo-boilerplate-constructors.sh $(enabled_cairo_boilerplate_sources) $(enabled_cairo_boilerplate_cxx_sources) > $@
all: $(CFG)/boiler.lib
diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index b97f6d0..56ac642 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -139,6 +139,18 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_cxx_sources)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_sources)
endif
+supported_cairo_boilerplate_headers += $(cairo_boilerplate_win32_printing_headers)
+all_cairo_boilerplate_headers += $(cairo_boilerplate_win32_printing_headers)
+all_cairo_boilerplate_private += $(cairo_boilerplate_win32_printing_private)
+all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_printing_cxx_sources)
+all_cairo_boilerplate_sources += $(cairo_boilerplate_win32_printing_sources)
+ifeq ($(CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE),1)
+enabled_cairo_boilerplate_headers += $(cairo_boilerplate_win32_printing_headers)
+enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_printing_private)
+enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_printing_cxx_sources)
+enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_printing_sources)
+endif
+
supported_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private)
@@ -360,7 +372,7 @@ all_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_ps_private)
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ps_cxx_sources)
all_cairo_boilerplate_sources += $(cairo_boilerplate_ps_sources)
-ifeq ($(CAIRO_HAS_PS_SURFACE),1)
+ifeq ($(CAIRO_CAN_TEST_PS_SURFACE),1)
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
enabled_cairo_boilerplate_private += $(cairo_boilerplate_ps_private)
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ps_cxx_sources)
@@ -372,7 +384,7 @@ all_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_pdf_private)
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pdf_cxx_sources)
all_cairo_boilerplate_sources += $(cairo_boilerplate_pdf_sources)
-ifeq ($(CAIRO_HAS_PDF_SURFACE),1)
+ifeq ($(CAIRO_CAN_TEST_PDF_SURFACE),1)
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers)
enabled_cairo_boilerplate_private += $(cairo_boilerplate_pdf_private)
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pdf_cxx_sources)
@@ -384,7 +396,7 @@ all_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_svg_private)
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_svg_cxx_sources)
all_cairo_boilerplate_sources += $(cairo_boilerplate_svg_sources)
-ifeq ($(CAIRO_HAS_SVG_SURFACE),1)
+ifeq ($(CAIRO_CAN_TEST_SVG_SURFACE),1)
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers)
enabled_cairo_boilerplate_private += $(cairo_boilerplate_svg_private)
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_svg_cxx_sources)
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index ea66c23..fe9d09f 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -238,10 +238,8 @@ _cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
x_pixels_per_inch,
y_pixels_per_inch);
}
-#endif
static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_PDF_SURFACE
{
"pdf", "pdf", ".pdf", NULL,
CAIRO_SURFACE_TYPE_PDF,
@@ -267,6 +265,6 @@ static const cairo_boilerplate_target_t targets[] = {
_cairo_boilerplate_pdf_cleanup,
NULL, NULL, FALSE, TRUE, TRUE
},
-#endif
};
CAIRO_BOILERPLATE (pdf, targets)
+#endif
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index e4a3f71..45339e3 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -26,6 +26,8 @@
#include "cairo-boilerplate-private.h"
+#if CAIRO_CAN_TEST_PS_SURFACE
+
#include <cairo-ps.h>
#include <cairo-ps-surface-private.h>
@@ -302,7 +304,6 @@ _cairo_boilerplate_ps_force_fallbacks (cairo_surface_t *abstract_surface,
}
static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_PS_SURFACE
{
"ps2", "ps", ".ps", NULL,
CAIRO_SURFACE_TYPE_PS,
@@ -353,6 +354,6 @@ static const cairo_boilerplate_target_t targets[] = {
_cairo_boilerplate_ps_cleanup,
NULL, NULL, FALSE, TRUE, TRUE
},
-#endif
};
CAIRO_BOILERPLATE (ps, targets)
+#endif
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index 7e7f1e7..bc286a2 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -26,6 +26,8 @@
#include "cairo-boilerplate-private.h"
+#if CAIRO_CAN_TEST_SVG_SURFACE
+
#include <cairo-svg.h>
#include <cairo-svg-surface-private.h>
#include <cairo-paginated-surface-private.h>
@@ -274,7 +276,6 @@ _cairo_boilerplate_svg_force_fallbacks (cairo_surface_t *abstract_surface,
}
static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_SVG_SURFACE
/* It seems we should be able to round-trip SVG content perfectly
* through librsvg and cairo, but for some mysterious reason, some
* systems get an error of 1 for some pixels on some of the text
@@ -328,6 +329,6 @@ static const cairo_boilerplate_target_t targets[] = {
_cairo_boilerplate_svg_cleanup,
NULL, NULL, FALSE, TRUE, TRUE
},
-#endif
};
CAIRO_BOILERPLATE (svg, targets)
+#endif
diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c
index 0d70620..38ccfa6 100644
--- a/boilerplate/cairo-boilerplate-win32-printing.c
+++ b/boilerplate/cairo-boilerplate-win32-printing.c
@@ -36,6 +36,8 @@
#include "cairo-boilerplate-private.h"
+#if CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE
+
#include <cairo-win32.h>
#include <cairo-win32-private.h>
#include <cairo-paginated-surface-private.h>
@@ -343,7 +345,6 @@ _cairo_boilerplate_win32_printing_cleanup (void *closure)
}
static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE
{
"win32-printing", "win32", ".ps", NULL,
CAIRO_SURFACE_TYPE_WIN32_PRINTING,
@@ -367,6 +368,6 @@ static const cairo_boilerplate_target_t targets[] = {
_cairo_boilerplate_win32_printing_cleanup,
NULL, NULL, FALSE, TRUE, TRUE
},
-#endif
};
CAIRO_BOILERPLATE (win32_printing, targets)
+#endif
diff --git a/build/Makefile.win32.common b/build/Makefile.win32.common
index c1f0cb8..6401bb5 100644
--- a/build/Makefile.win32.common
+++ b/build/Makefile.win32.common
@@ -37,7 +37,7 @@ CAIRO_LIBS += $(top_builddir)/../zlib/zdll.lib
endif
DEFAULT_CFLAGS = -nologo $(MS_MDFLAGS) $(OPT)
-DEFAULT_CFLAGS += -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
+DEFAULT_CFLAGS += -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DDISABLE_SOME_FLOATING_POINT -D_BIND_TO_CURRENT_VCLIBS_VERSION -D_MT
DEFAULT_CFLAGS += -I. -I$(top_srcdir)
DEFAULT_CFLAGS += $(PIXMAN_CFLAGS) $(LIBPNG_CFLAGS) $(ZLIB_CFLAGS)
@@ -61,11 +61,11 @@ endif
$(CFG)/%.obj: %.c
@mkdir -p $(CFG)
- @$(CC) $(CAIRO_CFLAGS) -c -Fo"$@" $<
+ $(CC) $(CAIRO_CFLAGS) -c -Fo"$@" $<
$(CFG)/%-static.obj: %.c
@mkdir -p $(CFG)
- @$(CC) $(CAIRO_CFLAGS) -c -DCAIRO_WIN32_STATIC_BUILD=1 -Fo"$@" $<
+ $(CC) $(CAIRO_CFLAGS) -c -DCAIRO_WIN32_STATIC_BUILD=1 -Fo"$@" $<
clean:
@rm -f $(CFG)/*.obj $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk || exit 0
diff --git a/src/Makefile.sources b/src/Makefile.sources
index c4ca001..905ed76 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -217,7 +217,7 @@ cairo_deflate_stream_sources = cairo-deflate-stream.c
cairo_pdf_headers = cairo-pdf.h
cairo_pdf_private = cairo-pdf-surface-private.h
cairo_pdf_sources = cairo-pdf-surface.c
-if CAIRO_HAS_PDF_SURFACE
+ifeq ($(CAIRO_HAS_PDF_SURFACE), 1)
req_cairo_deflate_stream_sources = $(cairo_deflate_stream_sources)
endif
@@ -251,7 +251,7 @@ cairo_xlib_private = \
cairo-xlib-surface-private.h \
cairo-xlib-xrender-private.h \
$(NULL)
-if BUILD_XLIB_XCB
+ifeq ($(BUILD_XLIB_XCB),1)
cairo_xlib_sources = cairo-xlib-xcb-surface.c
else
cairo_xlib_sources = \
@@ -276,7 +276,7 @@ cairo_xcb_sources = \
cairo-xcb-surface-core.c \
cairo-xcb-surface-render.c \
$(NULL)
-if BUILD_XCB_SHM
+ifeq ($(BUILD_XCB_SHM), 1)
cairo_xcb_sources += \
cairo-xcb-shm.c \
cairo-xcb-connection-shm.c \
@@ -375,7 +375,7 @@ cairo_drm_xr_sources = \
cairo_script_headers = cairo-script.h
cairo_script_sources = cairo-script-surface.c
-if CAIRO_HAS_SCRIPT_SURFACE
+ifeq ($(CAIRO_HAS_SCRIPT_SURFACE), 1)
req_cairo_deflate_stream_sources = $(cairo_deflate_stream_sources)
endif
@@ -385,7 +385,7 @@ cairo_tee_sources = cairo-tee-surface.c
cairo_xml_headers = cairo-xml.h
cairo_xml_sources = cairo-xml-surface.c
-if CAIRO_HAS_XML_SURFACE
+ifeq ($(CAIRO_HAS_XML_SURFACE), 1)
req_cairo_deflate_stream_sources = $(cairo_deflate_stream_sources)
endif
diff --git a/test/Makefile.win32 b/test/Makefile.win32
index 8d8f1f8..50ef17d 100644
--- a/test/Makefile.win32
+++ b/test/Makefile.win32
@@ -14,18 +14,21 @@ TESTCORE_SOURCES = \
all: cairo-test-suite.exe
-make-cairo-test-constructors.exe: $(CFG)/make-cairo-test-constructors.obj
- $(CC) $(OPT) $(MS_MDFLAGS) $(CFG)/make-cairo-test-constructors.obj -Fe"$@" -link $(LDFLAGS) user32.lib /NODEFAULTLIB:library
+cairo-test-constructors.c: Makefile.win32 $(test_sources) make-cairo-test-constructors.sh
+ sh ./make-cairo-test-constructors.sh $(test_sources) > $@
-cairo-test-constructors.c: $(test_sources) make-cairo-test-constructors.exe
- ./make-cairo-test-constructors.exe $(test_sources) > $@
+#make-cairo-test-constructors.exe: $(CFG)/make-cairo-test-constructors.obj
+# $(CC) $(OPT) $(MS_MDFLAGS) $(CFG)/make-cairo-test-constructors.obj -Fe"$@" -link $(LDFLAGS) user32.lib /NODEFAULTLIB:library
+
+#cairo-test-constructors.c: $(test_sources) make-cairo-test-constructors.exe
+# ./make-cairo-test-constructors.exe $(test_sources) > $@
SOURCES = $(cairo_test_suite_sources) $(test_sources) cairo-test-constructors.c
OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
cairo-test-suite.exe: $(OBJECTS) ./pdiff/pdiff.lib ../boilerplate/$(CFG)/boiler.lib
- $(CC) $(OPT) $(MS_MDFLAGS) $(OBJECTS) -Fe"$@" -link $(LDFLAGS) $(CAIRO_LIBS) /NODEFAULTLIB:library
+ $(CC) $(OPT) $(OBJECTS) -Fe"$@" -link $(LDFLAGS) $(CAIRO_LIBS)
./pdiff/pdiff.lib:
(cd pdiff ; $(MAKE) -f Makefile.win32)
diff --git a/test/cairo-test.c b/test/cairo-test.c
index e03f9f7..093b4e0 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -75,6 +75,7 @@
#include <crtdbg.h>
#define vsnprintf _vsnprintf
#define access _access
+#define unlink _unlink
#define F_OK 0
#endif
@@ -258,7 +259,7 @@ cairo_test_fini (cairo_test_context_t *ctx)
cairo_boilerplate_fini ();
- cairo_debug_reset_static_data ();
+ //cairo_debug_reset_static_data ();
#if HAVE_FCFINI
FcFini ();
#endif
diff --git a/test/cairo-test.h b/test/cairo-test.h
index c4f38c5..b402a0a 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -50,6 +50,9 @@ typedef unsigned __int64 uint64_t;
# ifndef HAVE_UINT64_T
# define HAVE_UINT64_T 1
# endif
+# ifndef UINT32_MAX
+# define UINT32_MAX 0xFFFFFFFFUL
+# endif
#else
#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, \etc.)
#endif
diff --git a/test/pdiff/perceptualdiff.c b/test/pdiff/perceptualdiff.c
index a3a6e80..f1adad6 100644
--- a/test/pdiff/perceptualdiff.c
+++ b/test/pdiff/perceptualdiff.c
@@ -17,7 +17,26 @@
*/
#include <stdio.h>
+
+#if defined(_MSC_VER)
+typedef __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+# ifndef HAVE_UINT64_T
+# define HAVE_UINT64_T 1
+# endif
+# ifndef UINT32_MAX
+# define UINT32_MAX 0xFFFFFFFFUL
+# endif
+#else
#include <stdint.h>
+#endif
+
#include <string.h>
#include <math.h>
#include "lpyramid.h"
--
1.7.4
More information about the cairo
mailing list