freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Conditionalize Bzip2-compressed font support for inflexible d


From: suzuki toshiya
Subject: [ft-devel] Conditionalize Bzip2-compressed font support for inflexible dynamic linker platforms
Date: Fri, 01 Apr 2011 22:34:09 +0900
User-agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080406)

Hi all,

The latest FreeType2 on GIT repository supports Bzip2-compressed
font files which are used in Ubuntu GNU/Linux platform. It uses
Bzip2 library out of FreeType2, so FreeType2 with this feature has
new inter-library dependency (older does not depends on libbz2 but
newer depends). There can be some unresolved symbol problems on
the platform with inflexible dynamic linker that cannot resolve
the chained inter-library dependency.

# One of the typical inter-library dependency problem is found
# on Mac OS X, see:
#
#     http://lists.gnu.org/archive/html/freetype/2006-05/msg00035.html

To prevent the trouble, I wrote a patch to do following workarounds:

1) detect the inflexible platforms by GNU libtool configuration result,
   by using link_all_deplibs value.
   1-a) LT_INIT() is moved before library checking (zlib, bzip2lib)
   1-b) Mac OS X compiler/linker flag harmonization is moved before LT_INIT().

2) detect if "-lbz2" links shared version of libbz2, by checking
   the symbols in linked binary. if the system has only static
   library for libbz2, there wouldn't be such problem.

   AC_CHECK_LIB() is decomposed to more low-level shell script
   to check the status of the symbols from linked binary.

3) detect if the user tries to ignore the inter-library dependency,
   by new option to configure "--enable-new-dependency".

By this patch, "configure && make" on GNU/Linux (maybe most modern
Unix platforms using ELF format) will enable Bzip2-compression by
default, but "configure && make" on Mac OS X will disable it by
default.

Please comment if this is too coward attitude, or too dirty/lengthy
in comparison with the impact of the problem.

Regards,
mpsuzuki


diff --git a/docs/CHANGES b/docs/CHANGES
index 61442ec..310268f 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -20,7 +20,10 @@ CHANGES BETWEEN 2.4.4 and 2.4.5

     - Support for PCF files compressed with bzip2 has been contributed
       by Joel  Klinghed.  To  make this  work, the  OS must  provide a
-      bzip2 library.
+      bzip2 library.  To prevent the unresolved symbol troubles,  this
+      feature is disabled by default on the platforms without flexible
+      linker (e.g. Mac OS X).  New option "--enable-new-dependency" is
+      added to configure script to enable the feature forcibly.

     - Bradley  Grainger  contributed  project  and  solution  files in
       Visual Studio 2010 format.
diff --git a/ChangeLog b/ChangeLog
index 86a9468..88ff7cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-01  suzuki toshiya  <address@hidden>
+
+       * builds/unix/configure.raw: Check linker flexibility for Bzip2.
+       If the dynamic linker is inflexible and GNU libtool mark it as
+       all dependency libraries must be linked explicitly (e.g. Mac OS X),
+       the support for Bzip2-compressed fonts is disabled to prevent
+       the troubles of unresolved symbols of libbz2.  To enable the
+       feature forcibly, "--enable-new-dependency" option is introduced.
+
 2011-03-30  Werner Lemberg  <address@hidden>

        * src/autofit/aftypes.h (AF_OutlineRec): Removed, unused.
diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw
index a58d20c..0a53504 100644
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -213,36 +213,6 @@ AC_SUBST([FTSYS_SRC])

 AC_CHECK_FUNCS([memcpy memmove])

-
-# check for system zlib
-
-# don't quote AS_HELP_STRING!
-AC_ARG_WITH([zlib],
-  AS_HELP_STRING([--without-zlib],
-                 [use internal zlib instead of system-wide]))
-if test x$with_zlib != xno && test -z "$LIBZ"; then
-  AC_CHECK_LIB([z], [gzsetparams], [AC_CHECK_HEADER([zlib.h], [LIBZ='-lz'])])
-fi
-if test x$with_zlib != xno && test -n "$LIBZ"; then
-  CFLAGS="$CFLAGS -DFT_CONFIG_OPTION_SYSTEM_ZLIB"
-  LDFLAGS="$LDFLAGS $LIBZ"
-  SYSTEM_ZLIB=yes
-fi
-
-# check for system libbz2
-
-# don't quote AS_HELP_STRING!
-AC_ARG_WITH([bzip2],
-  AS_HELP_STRING([--without-bzip2],
-                 [do not support bzip2 compressed fonts]))
-if test x$with_bzip2 != xno && test -z "$LIBBZ2"; then
-  AC_CHECK_LIB([bz2], [BZ2_bzDecompress], [AC_CHECK_HEADER([bzlib.h], 
[LIBBZ2='-lbz2'])])
-fi
-if test x$with_bzip2 != xno && test -n "$LIBBZ2"; then
-  CFLAGS="$CFLAGS -DFT_CONFIG_OPTION_USE_BZIP2"
-  LDFLAGS="$LDFLAGS $LIBBZ2"
-fi
-
 # Some options handling SDKs/archs in CFLAGS should be copied
 # to LDFLAGS. Apple TechNote 2137 recommends to include these
 # options in CFLAGS but not in LDFLAGS.
@@ -286,6 +256,96 @@ do
 done
 set ${save_config_args}

+# switch to permit the incompatible dependency of libfreetype.
+AC_ARG_ENABLE([new-dependency],
+  AS_HELP_STRING([--enable-new-dependency],
+                 [allow linking with the shared libraries that
+                  older freetype2 didn't use (default=no), only
+                  for the platform with inflexible linker.]))
+
+# initialize GNU libtool before checking of other libraries,
+# to predict the chained dependency issue by ${link_all_deplibs}.
+LT_INIT(win32-dll)
+
+# check for system zlib
+
+# don't quote AS_HELP_STRING!
+AC_ARG_WITH([zlib],
+  AS_HELP_STRING([--without-zlib],
+                 [use internal zlib instead of system-wide]))
+if test x$with_zlib != xno && test -z "$LIBZ"; then
+  AC_CHECK_LIB([z], [gzsetparams], [AC_CHECK_HEADER([zlib.h], [LIBZ='-lz'])])
+fi
+if test x$with_zlib != xno && test -n "$LIBZ"; then
+  CFLAGS="$CFLAGS -DFT_CONFIG_OPTION_SYSTEM_ZLIB"
+  LDFLAGS="$LDFLAGS $LIBZ"
+  SYSTEM_ZLIB=yes
+fi
+
+# check for system libbz2
+
+# don't quote AS_HELP_STRING!
+AC_ARG_WITH([bzip2],
+  AS_HELP_STRING([--without-bzip2],
+                 [do not support bzip2 compressed fonts]))
+if test x$with_bzip2 != xno; then
+  if test -n "$LIBBZ2"; then
+    ac_LIBBZ2=$LIBBZ2
+  else
+    ac_LIBBZ2="-lbz2"
+  fi
+  AC_MSG_CHECKING([BZ2_bzDecompress in $ac_LIBBZ2])
+  cat >> conftest.c << ACEOF
+char BZ2_bzDecompress ();
+int
+main ()
+{
+return BZ2_bzDecompress ();
+  ;
+  return 0;
+}
+ACEOF
+  $CC $CFLAGS $LDFLAGS -o conftest conftest.c $ac_LIBBZ2 2>/dev/null 
1>/dev/null || rm -f conftest
+  if test ! -r conftest; then
+    AC_MSG_RESULT([no])
+    LIBBZ2=""
+    with_bzip2="no"
+  elif test x$link_all_deplibs = xno || test x$enable_shared = xno; then
+    AC_MSG_RESULT([yes])
+    rm -f conftest
+    with_bzip2="yes"
+  elif test x$enable_new_dependency = xyes; then
+    AC_MSG_RESULT([yes])
+    AC_MSG_WARN([*** the built library may have new inter-library dependency 
different from older release])
+    rm -f conftest
+    with_bzip2="yes"
+  else
+    AC_MSG_RESULT([yes])
+    AC_MSG_CHECKING(if $ac_LIBBZ2 will link shared library)
+    case `$NM conftest | fgrep BZ2_bzDecompress | expand | sed 's/  */ /g;s/^ 
*//;s/ *$//'` in
+    U*) is_libbz2_shared="yes" ;;
+    *) is_libbz2_shared="no" ;;
+    esac
+    rm -f conftest
+    AC_MSG_RESULT($is_libbz2_shared)
+    if test x$is_libbz2_shared = xyes ; then
+      AC_MSG_WARN([*** to prevent the incompatible dependency of FreeType2, 
bzip2-compressed font support is disabled by default])
+      with_bzip2="no"
+    else
+      with_bzip2="yes"
+    fi
+  fi
+  if test x$with_bzip2 = xyes; then
+    AC_CHECK_HEADER([bzlib.h], [LIBBZ2=$ac_LIBBZ2], [with_bzip2="no"])
+  fi
+
+  if test x$with_bzip2 != xno && test -n "$LIBBZ2"; then
+    CFLAGS="$CFLAGS -DFT_CONFIG_OPTION_USE_BZIP2"
+    LDFLAGS="$LDFLAGS $LIBBZ2"
+  fi
+fi
+
+

 # Whether to use Mac OS resource-based fonts.

@@ -664,8 +724,6 @@ AC_SUBST([FT2_EXTRA_LIBS])
 AC_SUBST([SYSTEM_ZLIB])


-LT_INIT(win32-dll)
-
 AC_SUBST([hardcode_libdir_flag_spec])
 AC_SUBST([wl])
 AC_SUBST([build_libtool_libs])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]