Behdad Esfahbod
2010-Dec-28 07:23 UTC
[Fontconfig] fontconfig: Branch ''master'' - 2 commits
Makefile.am | 2 configure.in | 64 ++++----------------- doc/Makefile.am | 19 +++--- fc-arch/Makefile.am | 54 ------------------ fc-arch/fc-arch.c | 138 ----------------------------------------------- fc-arch/fcarch.tmpl.h | 65 ---------------------- fc-cache/fc-cache.c | 2 fc-case/Makefile.am | 14 ++-- fc-cat/fc-cat.c | 2 fc-glyphname/Makefile.am | 14 ++-- fc-lang/Makefile.am | 17 +++-- src/Makefile.am | 6 +- src/fcarch.c | 72 ++++++++++++++++++++++++ src/fcarch.h | 71 ++++++++++++++++++++++++ src/fccache.c | 3 - src/fcint.h | 4 + 16 files changed, 204 insertions(+), 343 deletions(-) New commits: commit d1a0fca316ab8d9d61474028da54615e4d9f7540 Author: Behdad Esfahbod <behdad at behdad.org> Date: Tue Dec 28 00:59:19 2010 -0600 Make fc-arch stuff cross-compiling-safe Fixes: Bug 32679 - fontconfig-2.8.0 does not cross compile Bug 25462 - Cross-compilation doesn''t work diff --git a/Makefile.am b/Makefile.am index ce36505..7931717 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ # PERFORMANCE OF THIS SOFTWARE. DOCSRC=@DOCSRC@ -SUBDIRS=fontconfig fc-case fc-lang fc-glyphname fc-arch src \ +SUBDIRS=fontconfig fc-case fc-lang fc-glyphname src \ fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \ conf.d $(DOCSRC) test diff --git a/configure.in b/configure.in index 0a7b1b0..5d92b5f 100644 --- a/configure.in +++ b/configure.in @@ -56,7 +56,7 @@ AC_SUBST(LIBT_CURRENT_MINUS_AGE) dnl ========================================================================= -AM_CONFIG_HEADER(config.h) +AC_CONFIG_HEADERS(config.h) AC_PROG_CC AC_PROG_INSTALL @@ -98,59 +98,12 @@ AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes) dnl ========================================================================= -# Setup for compiling build tools (fc-glyphname, etc) -AC_MSG_CHECKING([for a C compiler for build tools]) -if test $cross_compiling = yes; then - AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc) -else - CC_FOR_BUILD=$CC -fi -AC_MSG_RESULT([$CC_FOR_BUILD]) -AC_SUBST(CC_FOR_BUILD) - -AC_MSG_CHECKING([for suffix of executable build tools]) -if test $cross_compiling = yes; then - cat >conftest.c <<\_______EOF -int -main () -{ - exit (0); -} -_______EOF - for i in .exe ""; do - compile="$CC_FOR_BUILD conftest.c -o conftest$i" - if AC_TRY_EVAL(compile); then - if (./conftest) 2>&AC_FD_CC; then - EXEEXT_FOR_BUILD=$i - break - fi - fi - done - rm -f conftest* - if test "${EXEEXT_FOR_BUILD+set}" != set; then - AC_MSG_ERROR([Cannot determine suffix of executable build tools]) - fi -else - EXEEXT_FOR_BUILD=$EXEEXT -fi -AC_MSG_RESULT([$EXEEXT_FOR_BUILD]) -AC_SUBST(EXEEXT_FOR_BUILD) - -dnl =========================================================================- AC_ARG_WITH(arch, [ --with-arch=ARCH Force architecture to ARCH], arch="$withval", arch=auto) -if test $cross_compiling = yes; then - case "$arch" in - auto) - AC_MSG_ERROR([Cannot autodetect architecture in cross compile environment] - [Use --with-arch=ARCH to specify architecture]) - ;; - esac +if test "x$arch" != xauto; then + AC_DEFINE_UNQUOTED([FC_ARCHITECTURE], "$arch", [Architecture prefix to use for cache file names]) fi -ARCHITECTURE=$arch -AC_SUBST(ARCHITECTURE) dnl ========================================================================= @@ -529,13 +482,20 @@ fi AC_SUBST(DOCSRC) AC_SUBST(DOCMAN3) + +dnl Figure out what cache format suffix to use for this architecture +AC_C_BIGENDIAN +AC_CHECK_SIZEOF([void *]) +AC_CHECK_ALIGNOF([double]) + + + AC_OUTPUT([ -Makefile +Makefile fontconfig/Makefile fc-lang/Makefile fc-glyphname/Makefile fc-case/Makefile -fc-arch/Makefile src/Makefile conf.d/Makefile fc-cache/Makefile diff --git a/fc-arch/Makefile.am b/fc-arch/Makefile.am deleted file mode 100644 index b1ecbf4..0000000 --- a/fc-arch/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -# -# $Id $ -# -# Copyright ?? 2003 Keith Packard -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of the author(s) not be used in -# advertising or publicity pertaining to distribution of the software without -# specific, written prior permission. The authors make no -# representations about the suitability of this software for any purpose. It -# is provided "as is" without express or implied warranty. -# -# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# - -CC = @CC_FOR_BUILD@ -EXEEXT = @EXEEXT_FOR_BUILD@ -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ - -INCLUDES=-I${top_srcdir}/src -I${top_srcdir} $(WARN_CFLAGS) - -TMPL=fcarch.tmpl.h -STMPL=${top_srcdir}/fc-arch/fcarch.tmpl.h -TARG=fcarch.h - -ARCHITECTURE=@ARCHITECTURE@ -.PRECIOUS: $(TARG) - -noinst_PROGRAMS=fc-arch - -EXTRA_DIST=$(TMPL) - -$(TARG):fc-arch${EXEEXT} $(STMPL) ${top_srcdir}/src/fcint.h ../config.h - $(AM_V_GEN) $(RM) $(TARG); \ - ./fc-arch${EXEEXT} $(ARCHITECTURE) < $(STMPL) > $(TARG).tmp && \ - mv $(TARG).tmp $(TARG) - -ALIAS_FILES = fcalias.h fcaliastail.h - -BUILT_SOURCES = $(ALIAS_FILES) $(TARG) - -$(ALIAS_FILES): - touch $(ALIAS_FILES) - -CLEANFILES=$(TARG) $(ALIAS_FILES) diff --git a/fc-arch/fc-arch.c b/fc-arch/fc-arch.c deleted file mode 100644 index 1ef0cf1..0000000 --- a/fc-arch/fc-arch.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright ?? 2006 Keith Packard - * Copyright ?? 2005 Patrick Lam - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "fcint.h" -#include <ctype.h> - -#define ENDIAN_TEST 0x01020304 -#define MACHINE_SIGNATURE_SIZE 1024 - -static char * -FcCacheMachineSignature (void) -{ - static char buf[MACHINE_SIGNATURE_SIZE]; - int32_t magic = ENDIAN_TEST; - char * m = (char *)&magic; - - sprintf (buf, "%01x%01x%01x%01x_" - "%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_" - "%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x_%02x", - m[0], m[1], m[2], m[3], - (unsigned int)sizeof (FcAlign), - (unsigned int)sizeof (char), - (unsigned int)sizeof (char *), - (unsigned int)sizeof (int), - (unsigned int)sizeof (intptr_t), - (unsigned int)sizeof (FcPattern), - (unsigned int)sizeof (FcPatternEltPtr), - (unsigned int)sizeof (struct FcPatternElt *), - (unsigned int)sizeof (FcPatternElt), - (unsigned int)sizeof (FcObject), - (unsigned int)sizeof (FcValueListPtr), - (unsigned int)sizeof (FcValue), - (unsigned int)sizeof (FcValueBinding), - (unsigned int)sizeof (struct FcValueList *), - (unsigned int)sizeof (FcStrSet *), /* For FcLangSet */ - (unsigned int)sizeof (FcCharSet), - (unsigned int)sizeof (FcCharLeaf **), - (unsigned int)sizeof (FcChar16 *), - (unsigned int)sizeof (FcChar16), - (unsigned int)sizeof (FcCharLeaf), - (unsigned int)sizeof (FcChar32), - (unsigned int)sizeof (FcCache)); - - return buf; -} - -int -main (int argc, char **argv) -{ - static char line[1024]; - char *signature; - int signature_length; - char *space; - char *arch = NULL; - int lineno = 0; - - if (argc != 2) - fprintf (stderr, "Usage: %s <architecture>|auto < fcarch.tmpl.h > fcarch.h\n", - argv[0]); - arch = argv[1]; - /* - * Scan the input until the marker is found - */ - - while (fgets (line, sizeof (line), stdin)) - { - lineno++; - if (!strncmp (line, "@@@", 3)) - break; - fputs (line, stdout); - } - signature = FcCacheMachineSignature(); - signature_length = strlen (signature); - - if (strcmp (arch, "auto") == 0) - { - arch = NULL; - /* - * Search for signature - */ - while (fgets (line, sizeof (line), stdin)) - { - lineno++; - /* - * skip comments - */ - if (!strncmp (line, "@@@", 3)) - continue; - space = line; - while (*space && !isspace (*space)) - space++; - if (!space) - { - fprintf (stderr, "%s: malformed input on line %d\n", - argv[0], lineno); - exit (1); - } - *space++ = ''\0''; - while (isspace (*space)) - space++; - if (!strncmp (space, signature, signature_length)) - { - arch = line; - break; - } - } - } - if (!arch) - { - fprintf (stderr, "%s: unknown signature \"%s\"\n", argv[0], signature); - fprintf (stderr, "\tPlease update fcarch.tmpl.h and rebuild\n"); - exit (1); - } - printf ("#define FC_ARCHITECTURE \"%s\"\n", arch); - fflush (stdout); - exit (ferror (stdout)); -} - diff --git a/fc-arch/fcarch.tmpl.h b/fc-arch/fcarch.tmpl.h deleted file mode 100644 index 2f972ba..0000000 --- a/fc-arch/fcarch.tmpl.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright ?? 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the author(s) not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors make no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -@@@ -@@@ Each unique machine architecture needs an entry in this file -@@@ If fc-arch runs and doesn''t find a matching entry, it will print -@@@ out the archtecture signature in the error message. Take that -@@@ signature and place it in this file along with a suitable architecture -@@@ name. Architecture names are used to construct file names, so -@@@ use something reasonable and don''t include any spaces -@@@ -@@@ So far the differences boil down to: endianness, 32 vs 64 bit pointers, -@@@ and on 32bit ones, whether double is aligned to one word or two words. -@@@ Those result in the 6 formats listed below. -@@@ -@@@ ,name (endianness,pointer-size,double-alignment) -@@@ | ,endian -@@@ | | ,FcAlign -@@@ | | | ,char -@@@ | | | | ,char* -@@@ | | | | | ,int -@@@ | | | | | | ,intptr_t -@@@ | | | | | | | ,Pattern -@@@ | | | | | | | | ,EltPtr -@@@ | | | | | | | | | ,Elt * -@@@ | | | | | | | | | | ,Elt -@@@ | | | | | | | | | | | ,ObjPtr -@@@ | | | | | | | | | | | | ,ValueListPtr -@@@ | | | | | | | | | | | | | ,Value -@@@ | | | | | | | | | | | | | | ,ValueBinding -@@@ | | | | | | | | | | | | | | | ,ValueList * -@@@ | | | | | | | | | | | | | | | | ,StrSet * -@@@ | | | | | | | | | | | | | | | | | ,CharSet -@@@ | | | | | | | | | | | | | | | | | | ,CharLeaf ** -@@@ | | | | | | | | | | | | | | | | | | | ,Char16 * -@@@ | | | | | | | | | | | | | | | | | | | | ,Char16 -@@@ | | | | | | | | | | | | | | | | | | | | | ,CharLeaf -@@@ | | | | | | | | | | | | | | | | | | | | | | ,Char32 -@@@ | | | | | | | | | | | | | | | | | | | | | | | ,Cache -@@@ | | | | | | | | | | | | | | | | | | | | | | | | -le32d4 4321_08_01_04_04_04_10_04_04_08_04_04_0c_04_04_04_10_04_04_02_20_04_20 -le32d8 4321_08_01_04_04_04_10_04_04_08_04_04_10_04_04_04_10_04_04_02_20_04_20 -le64 4321_08_01_08_04_08_18_08_08_10_04_08_10_04_08_08_18_08_08_02_20_04_38 -be32d4 1234_08_01_04_04_04_10_04_04_08_04_04_0c_04_04_04_10_04_04_02_20_04_20 -be32d8 1234_08_01_04_04_04_10_04_04_08_04_04_10_04_04_04_10_04_04_02_20_04_20 -be64 1234_08_01_08_04_08_18_08_08_10_04_08_10_04_08_08_18_08_08_02_20_04_38 diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c index a0da50e..d265350 100644 --- a/fc-cache/fc-cache.c +++ b/fc-cache/fc-cache.c @@ -22,7 +22,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "../fc-arch/fcarch.h" +#include "../src/fcarch.h" #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c index 40c38c4..c6c3993 100644 --- a/fc-cat/fc-cat.c +++ b/fc-cat/fc-cat.c @@ -32,7 +32,7 @@ #endif #include <fontconfig/fontconfig.h> -#include "../fc-arch/fcarch.h" +#include "../src/fcarch.h" #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/Makefile.am b/src/Makefile.am index 59b9c75..e300fe9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -84,13 +84,12 @@ noinst_HEADERS=fcint.h fcftint.h fcdeprecate.h ALIAS_FILES = fcalias.h fcaliastail.h fcftalias.h fcftaliastail.h BUILT_SOURCES = $(ALIAS_FILES) \ - ../fc-arch/fcarch.h \ ../fc-case/fccase.h \ ../fc-glyphname/fcglyphname.h \ ../fc-lang/fclang.h -../fc-arch/fcarch.h: - cd ../fc-arch && $(MAKE) $(AM_MAKEFLAGS) fcarch.h +noinst_PROGRAMS = fcarch + ../fc-case/fccase.h: cd ../fc-case && $(MAKE) $(AM_MAKEFLAGS) fccase.h ../fc-glyphname/fcglyphname.h: @@ -99,6 +98,7 @@ BUILT_SOURCES = $(ALIAS_FILES) \ cd ../fc-lang && $(MAKE) $(AM_MAKEFLAGS) fclang.h libfontconfig_la_SOURCES = \ + fcarch.h \ fcatomic.c \ fcblanks.c \ fccache.c \ diff --git a/src/fcarch.c b/src/fcarch.c new file mode 100644 index 0000000..36d0ce5 --- /dev/null +++ b/src/fcarch.c @@ -0,0 +1,72 @@ +/* + * Copyright ?? 2002 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdio.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* If architecture is hardcoded, skip the assert tests */ + +#ifndef FC_ARCHITECTURE + +#include "fcarch.h" + +/* Make sure the cache structure is consistent with what we expect */ + +#include "fcint.h" + +FC_ASSERT_STATIC (1 == sizeof (char)); +FC_ASSERT_STATIC (2 == sizeof (FcChar16)); +FC_ASSERT_STATIC (4 == sizeof (int)); +FC_ASSERT_STATIC (4 == sizeof (FcChar32)); +FC_ASSERT_STATIC (4 == sizeof (FcObject)); +FC_ASSERT_STATIC (4 == sizeof (FcValueBinding)); +FC_ASSERT_STATIC (8 == sizeof (FcAlign)); +FC_ASSERT_STATIC (0x20 == sizeof (FcCharLeaf)); + +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (intptr_t)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcPatternEltPtr)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcValueListPtr)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (char *)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (struct FcPatternElt *)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcValueList *)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcStrSet *)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcCharLeaf **)); +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcChar16 *)); + +FC_ASSERT_STATIC (0x08 + 1*SIZEOF_VOID_P == sizeof (FcValue)); +FC_ASSERT_STATIC (0x00 + 2*SIZEOF_VOID_P == sizeof (FcPatternElt)); +FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcPattern)); +FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcCharSet)); +FC_ASSERT_STATIC (0x08 + 6*SIZEOF_VOID_P == sizeof (FcCache)); + +#endif + + +int +main (int argc, char **argv) +{ + printf ("%s\n", FC_ARCHITECTURE); + return 0; +} diff --git a/src/fcarch.h b/src/fcarch.h new file mode 100644 index 0000000..0c8cd05 --- /dev/null +++ b/src/fcarch.h @@ -0,0 +1,71 @@ +/* + * Copyright ?? 2006 Keith Packard + * Copyright ?? 2010 Behdad Esfahbod + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef _FCARCH_H_ +#define _FCARCH_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* + * Each unique machine architecture needs an entry in this file + * So far the differences boil down to: endianness, 32 vs 64 bit pointers, + * and on 32bit ones, whether double is aligned to one word or two words. + * Those result in the 6 formats listed below. + * + * If any of the assertion errors in fccache.c fail, you need to add a new + * architecture. Contact the fontconfig mailing list in that case. + * + * name endianness pointer-size double-alignment + * + * le32d4 4321 4 4 + * le32d8 4321 4 8 + * le64 4321 8 8 + * be32d4 1234 4 4 + * be32d8 1234 4 8 + * be64 1234 8 8 + */ + +#if defined(WORDS_BIGENDIAN) && WORDS_BIGENDIAN +# define FC_ARCH_ENDIAN "be" +#else /* !WORDS_BIGENDIAN */ +# define FC_ARCH_ENDIAN "le" +#endif + +#if SIZEOF_VOID_P == 4 +# if ALIGNOF_DOUBLE == 4 +# define FC_ARCH_SIZE_ALIGN "32d4" +# else /* ALIGNOF_DOUBLE != 4 */ +# define FC_ARCH_SIZE_ALIGN "32d8" +# endif +#else /* SIZEOF_VOID_P != 4 */ +# define FC_ARCH_SIZE_ALIGN "64" +#endif + +#ifdef ARCHITECTURE +# define ARCHITECTURE FC_ARCHITECTURE +#else +# define FC_ARCHITECTURE FC_ARCH_ENDIAN FC_ARCH_SIZE_ALIGN +#endif + +#endif /* _FCARCH_H_ */ diff --git a/src/fccache.c b/src/fccache.c index d557d34..1bbd799 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -22,7 +22,7 @@ */ #include "fcint.h" -#include "../fc-arch/fcarch.h" +#include "fcarch.h" #include <stdio.h> #include <fcntl.h> #include <dirent.h> @@ -41,6 +41,7 @@ #define O_BINARY 0 #endif + struct MD5Context { FcChar32 buf[4]; FcChar32 bits[2]; diff --git a/src/fcint.h b/src/fcint.h index 2bc7878..a859913 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -107,6 +107,10 @@ #define FC_MEM_NUM 30 +#define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] +#define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond)) +#define FC_ASSERT_STATIC(_cond) _FC_ASSERT_STATIC0 (__LINE__, (_cond)) + #define FC_MIN(a,b) ((a) < (b) ? (a) : (b)) #define FC_MAX(a,b) ((a) > (b) ? (a) : (b)) #define FC_ABS(a) ((a) < 0 ? -(a) : (a)) commit 2a6b235ff6d2750171e8dff7cfdfe3bccb0f630e Author: Behdad Esfahbod <behdad at behdad.org> Date: Mon Dec 27 13:20:47 2010 -0600 Make most generated-files cross-compiling-safe By simply including a copy in the tarball. Remains fc-arch which is trickier. diff --git a/doc/Makefile.am b/doc/Makefile.am index 98121b1..8d7d5c8 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -21,10 +21,6 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -CC = @CC_FOR_BUILD@ -EXEEXT = @EXEEXT_FOR_BUILD@ -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ - DOC_SRC = $(srcdir) DOC_MODULE = fontconfig DOC2HTML = docbook2html @@ -83,7 +79,7 @@ DOC_FUNCS_SGML=\ fcstrset.sgml \ fcvalue.sgml -man5_MANS=fonts-conf.5 +man5_MANS=fonts-conf.5 man3_MANS=$(DOCMAN3) noinst_PROGRAMS=edit-sgml @@ -96,15 +92,20 @@ check_SCRIPTS=check-missing-doc TESTS_ENVIRONMENT=top_srcdir=${top_srcdir} sh TESTS=check-missing-doc -EXTRA_DIST=$(LOCAL_DOCS) $(SGML) $(DOC_FUNCS_FNCS) $(check_SCRIPTS) func.sgml confdir.sgml.in +EXTRA_DIST=$(LOCAL_DOCS) $(SGML) $(DOC_FUNCS_FNCS) $(DOC_FUNCS_SGML) $(check_SCRIPTS) func.sgml confdir.sgml.in SUFFIXES=.fncs .sgml .txt .html if USEDOCBOOK +if CROSS_COMPILING +.fncs.sgml: + @echo Warning: cannot rebuild $@ when cross-compiling +else .fncs.sgml: $(RM) $@ ./edit-sgml$(EXEEXT) $(FNCS_TMPL) < ''$<'' > $*.sgml +endif .sgml.txt: $(RM) $@ @@ -127,7 +128,7 @@ func.refs: local-fontconfig-devel.sgml $(DOC_FUNCS_SGML) version.sgml confdir.sg local-fontconfig-devel.sgml: fontconfig-devel.sgml $(LN_S) $< $@ -$(DOC_FUNCS_SGML): edit-sgml$(EXEEXT) $(FNCS_TMPL) +$(DOC_FUNCS_SGML): edit-sgml.c $(FNCS_TMPL) fonts-conf.5: local-fontconfig-user.sgml version.sgml confdir.sgml $(RM) $@ @@ -140,9 +141,11 @@ local-fontconfig-user.sgml: fontconfig-user.sgml all-local: $(LOCAL_DOCS) clean-local: - $(RM) $(man3_MANS) $(man5_MANS) $(DOC_FILES) $(DOC_FUNCS_SGML) func.refs + $(RM) $(man3_MANS) $(man5_MANS) $(DOC_FILES) func.refs $(RM) -r $(HTML_DIR) +MAINTAINERCLEANFILES = $(DOC_FUNCS_SGML) + $(HTML_DIR): local-fontconfig-devel.sgml $(DOC_FUNCS_SGML) version.sgml confdir.sgml $(RM) -r $(HTML_DIR) $(DOC2HTML) -V ''%use-id-as-filename%'' -o $(HTML_DIR) local-fontconfig-devel.sgml diff --git a/fc-arch/fcarch.tmpl.h b/fc-arch/fcarch.tmpl.h index 868454e..2f972ba 100644 --- a/fc-arch/fcarch.tmpl.h +++ b/fc-arch/fcarch.tmpl.h @@ -29,7 +29,7 @@ @@@ use something reasonable and don''t include any spaces @@@ @@@ So far the differences boil down to: endianness, 32 vs 64 bit pointers, -@@@ and on @@@ 32bit ones, whether double is aligned to one word or two words. +@@@ and on 32bit ones, whether double is aligned to one word or two words. @@@ Those result in the 6 formats listed below. @@@ @@@ ,name (endianness,pointer-size,double-alignment) diff --git a/fc-case/Makefile.am b/fc-case/Makefile.am index e462120..4f255fc 100644 --- a/fc-case/Makefile.am +++ b/fc-case/Makefile.am @@ -22,10 +22,6 @@ # PERFORMANCE OF THIS SOFTWARE. # -CC = @CC_FOR_BUILD@ -EXEEXT = @EXEEXT_FOR_BUILD@ -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ - INCLUDES=-I${top_srcdir}/src -I${top_srcdir} $(WARN_CFLAGS) TMPL=fccase.tmpl.h @@ -44,12 +40,17 @@ fc_case_SRCS= \ CASEFOLDING=CaseFolding.txt SCASEFOLDING=${top_srcdir}/fc-case/CaseFolding.txt -EXTRA_DIST=$(TMPL) $(CASEFOLDING) +EXTRA_DIST = $(TARG) $(TMPL) $(CASEFOLDING) +if CROSS_COMPILING +$(TARG): $(STMPL) fc-case.c $(SCASEFOLDING) + @echo Warning: cannot rebuild $(TARG) when cross-compiling +else $(TARG): $(STMPL) fc-case$(EXEEXT) $(SCASEFOLDING) $(AM_V_GEN) $(RM) $(TARG); \ ./fc-case$(EXEEXT) $(SCASEFOLDING) < $(STMPL) > $(TARG).tmp && \ mv $(TARG).tmp $(TARG) +endif ALIAS_FILES = fcalias.h fcaliastail.h @@ -58,5 +59,6 @@ BUILT_SOURCES = $(ALIAS_FILES) $(ALIAS_FILES): touch $(ALIAS_FILES) -CLEANFILES=$(TARG) $(ALIAS_FILES) +CLEANFILES = $(ALIAS_FILES) +MAINTAINERCLEANFILES = $(TARG) diff --git a/fc-glyphname/Makefile.am b/fc-glyphname/Makefile.am index 4106b32..3799880 100644 --- a/fc-glyphname/Makefile.am +++ b/fc-glyphname/Makefile.am @@ -22,10 +22,6 @@ # PERFORMANCE OF THIS SOFTWARE. # -CC = @CC_FOR_BUILD@ -EXEEXT = @EXEEXT_FOR_BUILD@ -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ - INCLUDES=-I${top_srcdir}/src -I${top_srcdir} $(WARN_CFLAGS) TMPL=fcglyphname.tmpl.h @@ -37,12 +33,17 @@ noinst_PROGRAMS=fc-glyphname GLYPHNAME=zapfdingbats.txt SGLYPHNAME=${top_srcdir}/fc-glyphname/zapfdingbats.txt -EXTRA_DIST=$(TMPL) $(GLYPHNAME) +EXTRA_DIST = $(TARG) $(TMPL) $(GLYPHNAME) +if CROSS_COMPILING +$(TARG): $(STMPL) fc-glyphname.c $(SGLYPHNAME) + @echo Warning: cannot rebuild $(TARG) when cross-compiling +else $(TARG): $(STMPL) fc-glyphname$(EXEEXT) $(SGLYPHNAME) $(AM_V_GEN) $(RM) $(TARG); \ ./fc-glyphname$(EXEEXT) $(SGLYPHNAME) < $(STMPL) > $(TARG).tmp && \ mv $(TARG).tmp $(TARG) +endif ALIAS_FILES = fcalias.h fcaliastail.h @@ -51,5 +52,6 @@ BUILT_SOURCES = $(ALIAS_FILES) $(TARG) $(ALIAS_FILES): touch $(ALIAS_FILES) -CLEANFILES=$(TARG) $(ALIAS_FILES) +CLEANFILES = $(ALIAS_FILES) +MAINTAINERCLEANFILES = $(TARG) diff --git a/fc-lang/Makefile.am b/fc-lang/Makefile.am index 242fae0..29cee59 100644 --- a/fc-lang/Makefile.am +++ b/fc-lang/Makefile.am @@ -22,10 +22,6 @@ # PERFORMANCE OF THIS SOFTWARE. # -CC = @CC_FOR_BUILD@ -EXEEXT = @EXEEXT_FOR_BUILD@ -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ - INCLUDES=-I${top_srcdir}/src -I${top_srcdir} $(WARN_CFLAGS) TMPL=fclang.tmpl.h @@ -36,21 +32,28 @@ noinst_PROGRAMS=fc-lang noinst_MANS=fc-lang.man -EXTRA_DIST=$(TMPL) $(ORTH) +EXTRA_DIST = $(TARG) $(TMPL) $(ORTH) +if CROSS_COMPILING +$(TARG):$(ORTH) fc-lang.c $(STMPL) + @echo Warning: cannot rebuild $(TARG) when cross-compiling +else $(TARG):$(ORTH) fc-lang${EXEEXT} $(STMPL) $(AM_V_GEN) $(RM) $(TARG); \ ./fc-lang${EXEEXT} -d ${srcdir} $(ORTH) < $(STMPL) > $(TARG).tmp && \ mv $(TARG).tmp $(TARG) +endif ALIAS_FILES = fcalias.h fcaliastail.h BUILT_SOURCES = $(ALIAS_FILES) $(TARG) -$(ALIAS_FILES): +$(ALIAS_FILES): touch $(ALIAS_FILES) -CLEANFILES = $(TARG) $(ALIAS_FILES) +CLEANFILES = $(ALIAS_FILES) + +MAINTAINERCLEANFILES = $(TARG) # NOTE: #
On 28/12/2010 07:23, Behdad Esfahbod wrote:> New commits: > commit d1a0fca316ab8d9d61474028da54615e4d9f7540 > Author: Behdad Esfahbod <behdad at behdad.org> > Date: Tue Dec 28 00:59:19 2010 -0600 > > Make fc-arch stuff cross-compiling-safe > > Fixes: > Bug 32679 - fontconfig-2.8.0 does not cross compile > Bug 25462 - Cross-compilation doesn''t work> +++ b/src/fcarch.c > @@ -0,0 +1,72 @@ > +/* > + * Copyright ?? 2002 Keith Packard > + * > + * Permission to use, copy, modify, distribute, and sell this software and its > + * documentation for any purpose is hereby granted without fee, provided that > + * the above copyright notice appear in all copies and that both that > + * copyright notice and this permission notice appear in supporting > + * documentation, and that the name of the author(s) not be used in > + * advertising or publicity pertaining to distribution of the software without > + * specific, written prior permission. The authors make no > + * representations about the suitability of this software for any purpose. It > + * is provided "as is" without express or implied warranty. > + * > + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, > + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO > + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR > + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, > + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER > + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR > + * PERFORMANCE OF THIS SOFTWARE. > + */ > + > +#include <stdio.h> > + > +#ifdef HAVE_CONFIG_H > +#include <config.h> > +#endif > + > +/* If architecture is hardcoded, skip the assert tests */ > + > +#ifndef FC_ARCHITECTURE > + > +#include "fcarch.h" > + > +/* Make sure the cache structure is consistent with what we expect */ > + > +#include "fcint.h" > + > +FC_ASSERT_STATIC (1 == sizeof (char)); > +FC_ASSERT_STATIC (2 == sizeof (FcChar16)); > +FC_ASSERT_STATIC (4 == sizeof (int)); > +FC_ASSERT_STATIC (4 == sizeof (FcChar32)); > +FC_ASSERT_STATIC (4 == sizeof (FcObject)); > +FC_ASSERT_STATIC (4 == sizeof (FcValueBinding)); > +FC_ASSERT_STATIC (8 == sizeof (FcAlign)); > +FC_ASSERT_STATIC (0x20 == sizeof (FcCharLeaf)); > + > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (intptr_t)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcPatternEltPtr)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcValueListPtr)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (char *)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (struct FcPatternElt *)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcValueList *)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcStrSet *)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcCharLeaf **)); > +FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcChar16 *)); > + > +FC_ASSERT_STATIC (0x08 + 1*SIZEOF_VOID_P == sizeof (FcValue));This compile-time assert fails on cygwin, see [1]. /opt/jhbuild/git/fontconfig/src/fcarch.c:58: error: size of array ''_static_assert_on_line_58_failed'' is negative make[3]: *** [fcarch.o] Error 1 cygwin is le32d8, and it looks to me like that assert isn''t going to be correct for 8-byte aligned doubles. I''m not sure what the invariant should be, would the following be better? -FC_ASSERT_STATIC (0x08 + 1*SIZEOF_VOID_P == sizeof (FcValue)); +FC_ASSERT_STATIC (ALIGNOF_DOUBLE + sizeof(double) == sizeof (FcValue)); [1] http://tinderbox.freedesktop.org/builds/2010-12-31-0009/logs/fontconfig/#build> +FC_ASSERT_STATIC (0x00 + 2*SIZEOF_VOID_P == sizeof (FcPatternElt)); > +FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcPattern)); > +FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcCharSet)); > +FC_ASSERT_STATIC (0x08 + 6*SIZEOF_VOID_P == sizeof (FcCache)); > + > +#endif > + > + > +int > +main (int argc, char **argv) > +{ > + printf ("%s\n", FC_ARCHITECTURE); > + return 0; > +}
Behdad Esfahbod
2011-Jan-02 20:27 UTC
[Fontconfig] fontconfig: Branch ''master'' - 2 commits
On 01/01/11 10:35, Jon TURNEY wrote:>> +FC_ASSERT_STATIC (0x08 + 1*SIZEOF_VOID_P == sizeof (FcValue)); > > This compile-time assert fails on cygwin, see [1]. > > /opt/jhbuild/git/fontconfig/src/fcarch.c:58: error: size of array > ''_static_assert_on_line_58_failed'' is negative > make[3]: *** [fcarch.o] Error 1 > > cygwin is le32d8, and it looks to me like that assert isn''t going to be > correct for 8-byte aligned doubles. > > I''m not sure what the invariant should be, would the following be better? > > -FC_ASSERT_STATIC (0x08 + 1*SIZEOF_VOID_P == sizeof (FcValue)); > +FC_ASSERT_STATIC (ALIGNOF_DOUBLE + sizeof(double) == sizeof (FcValue));Fixed. Thanks. behdad