Some fixes and improvements to the Win32 build

This commit is contained in:
Azar@.(none) 2008-02-01 18:45:59 -08:00 committed by Behdad Esfahbod
parent 7800cfd7de
commit 95db215cc1
13 changed files with 470 additions and 35 deletions

View file

@ -4,19 +4,24 @@
CC := cl
LINK := link
ifeq ($(CFG),debug)
OPT := -Od -Zi
else
OPT := -O2
endif
PIXMAN_CFLAGS := -I../../pixman/pixman
PIXMAN_LIBS := ../../pixman/pixman/pixman-1.lib
PIXMAN_LIBS := ../../pixman/pixman/$(CFG)/pixman-1.lib
EXE_LDFLAGS = libpng.lib zlib.lib gdi32.lib msimg32.lib user32.lib
DEFAULT_CFLAGS = -MD -Zi -nologo $(OPT)
DEFAULT_CFLAGS = -MD -nologo $(OPT)
DEFAULT_CFLAGS += -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
DEFAULT_CFLAGS += -DPACKAGE_VERSION="" -DPACKAGE_BUGREPORT="" -DCAIRO_BUILD
DEFAULT_CFLAGS += -I.
DEFAULT_CFLAGS += $(PIXMAN_CFLAGS)
DEFAULT_CFLAGS += -DCAIRO_NO_MUTEX=1
DEFAULT_CFLAGS += -DCAIRO_NO_MUTEX=1 -DLIBCAIRO_EXPORTS
CFLAGS := $(DEFAULT_CFLAGS)
@ -33,7 +38,7 @@ SUBDIRS = src
TEST_SUBDIRS = boilerplate test
all: cairo
all: inform cairo
cairo: src/cairo-features.h
@list='$(SUBDIRS)'; for f in $$list ; do \
@ -51,13 +56,28 @@ test: cairo
html:
@(cd test ; make -f Makefile.win32 html)
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo -n "You must specify a configuration when "
@echo "running make, e.g. make CFG=debug"
@echo
@echo -n "Possible choices for configuration are "
@echo "'release' and 'debug'"
@exit 1
endif
endif
endif
# Some generic rules
%.obj: %.c
$(CFG)/%.obj: %.c
@mkdir -p $(CFG)
@$(CC) $(CFLAGS) -c -Fo"$@" $<
%-static.obj: %.c
$(CFG)/%-static.obj: %.c
@mkdir -p $(CFG)
@$(CC) $(CFLAGS) -c -DCAIRO_WIN32_STATIC_BUILD=1 -Fo"$@" $<

View file

@ -11,13 +11,30 @@ SOURCES = \
cairo-boilerplate-ps.c \
cairo-boilerplate-svg.c \
cairo-boilerplate-pdf.c \
cairo-boilerplate-getopt.c \
xmalloc.c \
$(NULL)
OBJECTS = $(subst .c,.obj,$(SOURCES))
OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(SOURCES))
all: boiler.lib
boiler.lib: $(OBJECTS)
lib -NOLOGO -OUT:$@ $(OBJECTS)
all: $(CFG)/boiler.lib
$(CFG)/boiler.lib: $(OBJECTS)
lib -NOLOGO -OUT:$@ $(OBJECTS) $(WIN_LIBS)
clean:
@rm -f $(CFG)/*.obj $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk || exit 0
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo -n "You must specify a configuration when "
@echo "running make, e.g. make CFG=debug"
@echo
@echo -n "Possible choices for configuration are "
@echo "'release' and 'debug'"
@exit 1
endif
endif

View file

@ -0,0 +1,250 @@
/*****************************************************************************
* getopt.c - competent and free getopt library.
* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $
*
* Copyright (c)2002-2003 Mark K. Kim
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the original author of this software nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cairo-boilerplate-getopt.h"
static const char* ID = "$Id: getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $";
char* optarg = NULL;
int optind = 0;
int opterr = 1;
int optopt = '?';
static char** prev_argv = NULL; /* Keep a copy of argv and argc to */
static int prev_argc = 0; /* tell if getopt params change */
static int argv_index = 0; /* Option we're checking */
static int argv_index2 = 0; /* Option argument we're checking */
static int opt_offset = 0; /* Index into compounded "-option" */
static int dashdash = 0; /* True if "--" option reached */
static int nonopt = 0; /* How many nonopts we've found */
static void increment_index()
{
/* Move onto the next option */
if(argv_index < argv_index2)
{
while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-'
&& argv_index < argv_index2+1);
}
else argv_index++;
opt_offset = 1;
}
/*
* Permutes argv[] so that the argument currently being processed is moved
* to the end.
*/
static int permute_argv_once()
{
/* Movability check */
if(argv_index + nonopt >= prev_argc) return 1;
/* Move the current option to the end, bring the others to front */
else
{
char* tmp = prev_argv[argv_index];
/* Move the data */
memmove(&prev_argv[argv_index], &prev_argv[argv_index+1],
sizeof(char**) * (prev_argc - argv_index - 1));
prev_argv[prev_argc - 1] = tmp;
nonopt++;
return 0;
}
}
int _cairo_getopt(int argc, char** argv, char* optstr)
{
int c = 0;
/* If we have new argv, reinitialize */
if(prev_argv != argv || prev_argc != argc)
{
/* Initialize variables */
prev_argv = argv;
prev_argc = argc;
argv_index = 1;
argv_index2 = 1;
opt_offset = 1;
dashdash = 0;
nonopt = 0;
}
/* Jump point in case we want to ignore the current argv_index */
getopt_top:
/* Misc. initializations */
optarg = NULL;
/* Dash-dash check */
if(argv[argv_index] && !strcmp(argv[argv_index], "--"))
{
dashdash = 1;
increment_index();
}
/* If we're at the end of argv, that's it. */
if(argv[argv_index] == NULL)
{
c = -1;
}
/* Are we looking at a string? Single dash is also a string */
else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-"))
{
/* If we want a string... */
if(optstr[0] == '-')
{
c = 1;
optarg = argv[argv_index];
increment_index();
}
/* If we really don't want it (we're in POSIX mode), we're done */
else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT"))
{
c = -1;
/* Everything else is a non-opt argument */
nonopt = argc - argv_index;
}
/* If we mildly don't want it, then move it back */
else
{
if(!permute_argv_once()) goto getopt_top;
else c = -1;
}
}
/* Otherwise we're looking at an option */
else
{
char* opt_ptr = NULL;
/* Grab the option */
c = argv[argv_index][opt_offset++];
/* Is the option in the optstr? */
if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c);
else opt_ptr = strchr(optstr, c);
/* Invalid argument */
if(!opt_ptr)
{
if(opterr)
{
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
}
optopt = c;
c = '?';
/* Move onto the next option */
increment_index();
}
/* Option takes argument */
else if(opt_ptr[1] == ':')
{
/* ie, -oARGUMENT, -xxxoARGUMENT, etc. */
if(argv[argv_index][opt_offset] != '\0')
{
optarg = &argv[argv_index][opt_offset];
increment_index();
}
/* ie, -o ARGUMENT (only if it's a required argument) */
else if(opt_ptr[2] != ':')
{
/* One of those "you're not expected to understand this" moment */
if(argv_index2 < argv_index) argv_index2 = argv_index;
while(argv[++argv_index2] && argv[argv_index2][0] == '-');
optarg = argv[argv_index2];
/* Don't cross into the non-option argument list */
if(argv_index2 + nonopt >= prev_argc) optarg = NULL;
/* Move onto the next option */
increment_index();
}
else
{
/* Move onto the next option */
increment_index();
}
/* In case we got no argument for an option with required argument */
if(optarg == NULL && opt_ptr[2] != ':')
{
optopt = c;
c = '?';
if(opterr)
{
fprintf(stderr,"%s: option requires an argument -- %c\n",
argv[0], optopt);
}
}
}
/* Option does not take argument */
else
{
/* Next argv_index */
if(argv[argv_index][opt_offset] == '\0')
{
increment_index();
}
}
}
/* Calculate optind */
if(c == -1)
{
optind = argc - nonopt;
}
else
{
optind = argv_index;
}
return c;
}
/* vim:ts=3
*/

View file

@ -0,0 +1,63 @@
/*****************************************************************************
* getopt.h - competent and free getopt library.
* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $
*
* Copyright (c)2002-2003 Mark K. Kim
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the original author of this software nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#ifndef GETOPT_H_
#define GETOPT_H_
#ifdef __cplusplus
extern "C" {
#endif
extern char* optarg;
extern int optind;
extern int opterr;
extern int optopt;
int _cairo_getopt(int argc, char** argv, char* optstr);
#ifdef __cplusplus
}
#endif
#endif /* GETOPT_H_ */
/* vim:ts=3
*/

View file

@ -86,6 +86,10 @@
#define TRUE 1
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/* A fake format we use for the flattened ARGB output of the PS and
* PDF surfaces. */

View file

@ -1,16 +1,58 @@
CC = cl
CFLAGS = /nologo /Zi /O2 /MD /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /I../src /I../pixman/src /I../boilerplate
LDFLAGS = ../src/cairo.lib ../pixman/src/pixman.lib ../boilerplate/boiler.lib libpng.lib zlib.lib gdi32.lib msimg32.lib user32.lib
#
# Win32 makefile
#
SUBMAKEFILE = 1
include ../Makefile.win32
LDFLAGS += ../src/$(CFG)/cairo-static.lib $(PIXMAN_LIBS) ../boilerplate/$(CFG)/boiler.lib $(EXE_LDFLAGS)
PERF_SOURCES = \
box-outline.c \
cairo-perf-win32.c \
cairo-perf-cover.c \
cairo-perf.c \
cairo-stats.c \
fill.c \
long-dashed-lines.c \
long-lines.c \
mosaic.c \
paint.c \
paint-with-alpha.c \
pattern_create_radial.c \
rectangles.c \
stroke.c \
subimage_copy.c \
tessellate.c \
text.c \
unaligned-clip.c \
world-map.c \
zrusin.c \
# extend-pad.c \
$(NULL)
all: cairo-perf.exe
OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(PERF_SOURCES))
cairo-perf.exe: $(PERF_SOURCES)
$(CC) $(CFLAGS) /Fe"$@" $^ /link $(LDFLAGS)
all: inform $(CFG)/cairo-perf.exe
$(CFG)/cairo-perf.exe: $(OBJECTS)
@mkdir -p $(CFG)
@$(CC) $(CFLAGS) -Fe"$@" $^ -link $(LDFLAGS)
clean:
@rm -f $(CFG)/*.obj $(CFG)/*.exe $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk || exit 0
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo -n "You must specify a configuration when "
@echo "running make, e.g. make CFG=debug"
@echo
@echo -n "Possible choices for configuration are "
@echo "'release' and 'debug'"
@exit 1
endif
endif

View file

@ -28,10 +28,7 @@
#include "cairo-perf.h"
/* For getopt */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "cairo-boilerplate-getopt.h"
/* For basename */
#ifdef HAVE_LIBGEN_H
@ -276,7 +273,7 @@ parse_options (cairo_perf_t *perf, int argc, char *argv[])
perf->num_names = 0;
while (1) {
c = getopt (argc, argv, "i:lr");
c = _cairo_getopt (argc, argv, "i:lr");
if (c == -1)
break;

View file

@ -90,7 +90,7 @@ cairo_perf_cover_sources_and_operators (cairo_perf_t *perf,
const char *name,
cairo_perf_func_t perf_func);
#define CAIRO_PERF_DECL(func) void (func) (cairo_perf_t *perf, cairo_t *cr, int width, int height);
#define CAIRO_PERF_DECL(func) void (func) (cairo_perf_t *perf, cairo_t *cr, int width, int height)
CAIRO_PERF_DECL (fill);
CAIRO_PERF_DECL (paint);

View file

@ -26,7 +26,9 @@
#include "cairo-perf.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
typedef enum {
WM_NEW_PATH,

View file

@ -9,6 +9,7 @@ srcdir = `pwd`
SOURCES = \
cairo-arc.c \
cairo-array.c \
cairo-atomic.c \
cairo-bentley-ottmann.c \
cairo-cache.c \
cairo-clip.c \
@ -28,13 +29,14 @@ SOURCES = \
cairo-meta-surface.c \
cairo-mutex.c \
cairo-output-stream.c \
cairo-operator.c \
cairo-path-bounds.c \
cairo-path-fixed.c \
cairo-path-fill.c \
cairo-path-stroke.c \
cairo-path.c \
cairo-pattern.c \
cairo-pdf-surface.c \
cairo-pdf-operators.c \
cairo-pen.c \
cairo-polygon.c \
cairo-png.c \
@ -63,6 +65,7 @@ SOURCES = \
cairo-analysis-surface.c \
cairo-base85-stream.c \
cairo-win32-printing-surface.c \
cairo-win32.c \
$(NULL)
STATIC_SOURCES = cairo-win32-surface.c
@ -79,11 +82,13 @@ cairo_headers = \
cairo-svg-test.h \
$(NULL)
OBJECTS = $(subst .c,.obj,$(SOURCES))
SHARED_OBJECTS = $(subst .c,.obj,$(STATIC_SOURCES))
STATIC_OBJECTS = $(subst .c,-static.obj,$(STATIC_SOURCES))
OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(SOURCES))
SHARED_OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(STATIC_SOURCES))
STATIC_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(STATIC_SOURCES))
all: cairo.dll cairo-static.lib
all: inform $(CFG)/cairo.dll $(CFG)/cairo-static.lib
static: inform $(CFG)/cairo-static.lib
dynamic: inform $(CFG)/cairo.dll
$(DEFFILE):
(echo EXPORTS; \
@ -97,11 +102,24 @@ $(DEFFILE):
) >$@
@ ! grep -q cairo_ERROR $@ || ($(RM) $@; false)
cairo.dll: $(OBJECTS) $(SHARED_OBJECTS) $(DEFFILE)
$(CC) -MD -Zi -LD -Fe$@ $(PIXMAN_LIBS) $(OBJECTS) $(SHARED_OBJECTS) -link -DEF:$(DEFFILE) user32.lib gdi32.lib libpng.lib zdll.lib msimg32.lib
$(CFG)/cairo.dll: $(OBJECTS) $(SHARED_OBJECTS) $(DEFFILE)
$(CC) -MD -LD -Fe$@ $(PIXMAN_LIBS) $(OBJECTS) $(SHARED_OBJECTS) -link -DEF:$(DEFFILE) user32.lib gdi32.lib libpng.lib zdll.lib msimg32.lib
cairo-static.lib: $(OBJECTS) $(STATIC_OBJECTS)
$(CFG)/cairo-static.lib: $(OBJECTS) $(STATIC_OBJECTS)
lib -NOLOGO -OUT:$@ $(PIXMAN_LIBS) $(OBJECTS) $(STATIC_OBJECTS)
clean:
@rm -f *.obj *.dll *.lib *.pdb *.ilk || exit 0
@rm -f $(CFG)/*.obj $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk || exit 0
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo -n "You must specify a configuration when "
@echo "running make, e.g. make CFG=debug"
@echo
@echo -n "Possible choices for configuration are "
@echo "'release' and 'debug'"
@exit 1
endif
endif

View file

@ -5,7 +5,7 @@ include ../Makefile.win32
CFLAGS += -I../src -I../boilerplate -I./pdiff
LDFLAGS += ./pdiff/pdiff.lib ../src/cairo.lib $(PIXMAN_LIBS) ../boilerplate/boiler.lib $(EXE_LDFLAGS)
LDFLAGS += ./pdiff/pdiff.lib ../src/$(CFG)/cairo-static.lib $(PIXMAN_LIBS) ../boilerplate/$(CFG)/boiler.lib $(EXE_LDFLAGS)
TESTS = \
a8-mask \
@ -32,6 +32,7 @@ dash-zero-length \
degenerate-path \
device-offset \
device-offset-positive \
extend-pad \
extend-reflect \
fill-and-stroke \
fill-and-stroke-alpha \
@ -99,11 +100,13 @@ TESTCORE_SOURCES = \
buffer-diff.c \
$(NULL)
TEST_EXE = $(addsuffix .exe,$(TESTS))
TEST_EXE = $(patsubst %, $(CFG)/%.exe, $(TESTS))
# TEST_EXE = $(addsuffix .exe,$(TESTS))
all: $(TEST_EXE)
%.exe: %.c ./pdiff/pdiff.lib
$(CFG)/%.exe: %.c ./pdiff/pdiff.lib
@mkdir -p $(CFG)
@$(CC) $(CFLAGS) -Fe"$@" $< $(TESTCORE_SOURCES) -link $(LDFLAGS)
./pdiff/pdiff.lib:
@ -118,3 +121,19 @@ test: $(TEST_EXE)
html:
@echo Creating index.html...
@perl make-html.pl > index.html
clean:
@rm -f $(CFG)/*.obj $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk $(CFG)/*.exe || exit 0
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo -n "You must specify a configuration when "
@echo "running make, e.g. make CFG=debug"
@echo
@echo -n "Possible choices for configuration are "
@echo "'release' and 'debug'"
@exit 1
endif
endif

View file

@ -54,7 +54,7 @@ static cairo_test_status_t
box_text (cairo_t *cr, const char *utf8, double x, double y)
{
double line_width;
cairo_text_extents_t extents = {}, scaled_extents = {};
cairo_text_extents_t extents = {0}, scaled_extents = {0};
cairo_scaled_font_t *scaled_font;
cairo_save (cr);

View file

@ -16,3 +16,6 @@ all: pdiff.lib
pdiff.lib: $(OBJECTS)
lib -NOLOGO -OUT:$@ $(OBJECTS)
%.obj: %.c
@$(CC) $(CFLAGS) -c -Fo"$@" $<