* Fix Savannah bug #21250: builds/unix/configure installs bi-arch ftconfig.h if it works correctly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
diff --git a/ChangeLog b/ChangeLog
index 14d3ef9..94d2a1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008-09-11 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+ * builds/unix/ftconfig.in: Duplicate the cpp computation of
+ FT_SIZEOF_{INT|LONG} from include/freetype/config/ftconfig.h.
+ If FT_USE_AUTOCONF_SIZEOF_TYPES is defined, the cpp computation
+ is disabled and the statically configured sizes are used.
+ This fixes Savannah bug #21250
+
+ * builds/unix/configure.raw: Add the checks to compare the
+ cpp computation results of the bit length of int and long
+ versus the sizes detected by running configure. If the results
+ are different, FT_USE_AUTOCONF_SIZEOF_TYPES is defined to
+ prioritize the results detected by running configure.
+ New option --{enable|disable}-biarch-config is added to
+ define or undefine FT_USE_AUTOCONF_SIZEOF_TYPES manually.
+
2008-09-05 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* builds/unix/configure.raw: Clear FT2_EXTRA_LIBS when Carbon
diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw
index 477185b..140f55c 100644
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -126,6 +126,65 @@ AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
+# checks for cpp computation of size of int and long ftconfig.in works
+
+AC_MSG_CHECKING([cpp computation of bit length in ftconfig.in works])
+orig_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="-I${srcdir} -I. ${CPPFLAGS}"
+ac_clean_files="ft2build.h ftoption.h ftstdlib.h"
+touch ft2build.h ftoption.h ftstdlib.h
+cat > conftest.c <<\_ACEOF
+#include <limits.h>
+#define FT_CONFIG_OPTIONS_H "ftoption.h"
+#define FT_CONFIG_STANDARD_LIBRARY_H "ftstdlib.h"
+#define FT_UINT_MAX UINT_MAX
+#define FT_ULONG_MAX ULONG_MAX
+#include "ftconfig.in"
+_ACEOF
+echo >> conftest.c "#if FT_SIZEOF_INT == "${ac_cv_sizeof_int}
+echo >> conftest.c "ac_cpp_ft_sizeof_int="${ac_cv_sizeof_int}
+echo >> conftest.c "#endif"
+echo >> conftest.c "#if FT_SIZEOF_LONG == "${ac_cv_sizeof_long}
+echo >> conftest.c "ac_cpp_ft_sizeof_long="${ac_cv_sizeof_long}
+echo >> conftest.c "#endif"
+${CPP} ${CPPFLAGS} conftest.c | ${GREP} ac_cpp_ft > conftest.sh
+eval `cat conftest.sh`
+${RMF} conftest.c conftest.sh confft2build.h ftoption.h ftstdlib.h
+if test x != "x${ac_cpp_ft_sizeof_int}" -a x != x"${ac_cpp_ft_sizeof_long}"
+then
+ unset ft_use_autoconf_sizeof_types
+else
+ ft_use_autoconf_sizeof_types="yes"
+fi
+AC_ARG_ENABLE(biarch-config,
+[ --enable-biarch-config install biarch ftconfig.h to support multiple
+ architechtures by single file], [], [])
+
+case :${ft_use_autoconf_sizeof_types}:${enable_biarch_config}: in
+ :yes:yes: )
+ AC_MSG_RESULT([broken but use])
+ unset ft_use_autoconf_sizeof_types
+ ;;
+ ::no: )
+ AC_MSG_RESULT([works but ignore])
+ ft_use_autoconf_sizeof_types="yes"
+ ;;
+ ::yes: | ::: )
+ AC_MSG_RESULT([yes])
+ unset ft_use_autoconf_sizeof_types
+ ;;
+ * )
+ AC_MSG_RESULT([no])
+ ft_use_autoconf_sizeof_types="yes"
+ ;;
+esac
+if test xyes = x"${ft_use_autoconf_sizeof_types}"
+then
+ AC_DEFINE([FT_USE_AUTOCONF_SIZEOF_TYPES])
+fi
+CPPFLAGS="${orig_CPPFLAGS}"
+
+
# checks for library functions
# Here we check whether we can use our mmap file component.
diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index 6430abf..311b03a 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -59,15 +59,60 @@ FT_BEGIN_HEADER
#undef HAVE_UNISTD_H
#undef HAVE_FCNTL_H
+#undef HAVE_STDINT_H
+
+ /* There are systems (like the Texas Instruments 'C54x) where a `char' */
+ /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */
+ /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */
+ /* is probably unexpected. */
+ /* */
+ /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */
+ /* `char' type. */
+
+#ifndef FT_CHAR_BIT
+#define FT_CHAR_BIT CHAR_BIT
+#endif
+
+
+#undef FT_USE_AUTOCONF_SIZEOF_TYPES
+#ifdef FT_USE_AUTOCONF_SIZEOF_TYPES
#undef SIZEOF_INT
#undef SIZEOF_LONG
+#define FT_SIZEOF_INT SIZEOF_INT
+#define FT_SIZEOF_LONG SIZEOF_LONG
+#else /* ! FT_USE_AUTOCONF_SIZEOF_TYPES */
+
+ /* Following cpp computation of the bit length of int and long */
+ /* is copied from default include/freetype/config/ftconfig.h. */
+ /* If any improvement is required for this file, it should be */
+ /* applied to the original header file for the builders that */
+ /* does not use configure script. */
+
+ /* The size of an `int' type. */
+#if FT_UINT_MAX == 0xFFFFUL
+#define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
+#elif FT_UINT_MAX == 0xFFFFFFFFUL
+#define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
+#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
+#define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
+#else
+#error "Unsupported size of `int' type!"
+#endif
+ /* The size of a `long' type. A five-byte `long' (as used e.g. on the */
+ /* DM642) is recognized but avoided. */
+#if FT_ULONG_MAX == 0xFFFFFFFFUL
+#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
+#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
+#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
+#else
+#error "Unsupported size of `long' type!"
+#endif
-#define FT_SIZEOF_INT SIZEOF_INT
-#define FT_SIZEOF_LONG SIZEOF_LONG
-
-#define FT_CHAR_BIT CHAR_BIT
+#endif /* ! FT_USE_AUTOCONF_SIZEOF_TYPES */
/* Preferred alignment of data */
#define FT_ALIGNMENT 8