Commit 59188661e622e078cc0fc16f203573c79fcc2c98

Suzuki, Toshiya (鈴木俊哉) 2008-09-11T08:02:23

* Fix Savannah bug #21250: builds/unix/configure installs bi-arch ftconfig.h if it works correctly

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