Hi,
for some time I've been using various fixes for the build system in my
personal tree. See the attachments.
Patch 1 adds a proper "Requires" field to the .pc file to make static
linking work correctly.
Patch 2 and 3 fix icu building, especially without glib.
Patch 4 adds toggles for glib, icu and uniscribe support (uniscribe
disabled by default, because apparently it's mostly for testing purposes).
Patch 5 is not specific to the build system. This implements atomic
reference counting and mutexes with GCC's intrinsics, as a fallback if
there's no glib or win32 support for these operations.
Please let me know what you think about these additions and fixes.
Best regards,
Grigori
>From e80e911e8af19f525a4ba7f47b4524518e14b1f6 Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@blackbox>
Date: Tue, 23 Aug 2011 14:25:35 +0200
Subject: [PATCH 5/5] Use GCC builtin atomics, if no library support
This uses GCC builtin atomics for reference counting and a simple mutex
implementation to make harfbuzz threadsafe without any support from
system libraries or glib. This codepath is only used as a fallback.
---
src/hb-mutex-private.hh | 10 ++++++++++
src/hb-object-private.hh | 8 ++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh
index 9855a56..d841178 100644
--- a/src/hb-mutex-private.hh
+++ b/src/hb-mutex-private.hh
@@ -64,6 +64,16 @@ typedef CRITICAL_SECTION hb_mutex_impl_t;
#define hb_mutex_impl_free(M) DeleteCriticalSection (M)
+#elif defined(__GNUC__)
+
+typedef volatile int hb_mutex_impl_t;
+#define HB_MUTEX_IMPL_INIT 0
+#define hb_mutex_impl_init(M) __sync_lock_test_and_set((M), 0)
+#define hb_mutex_impl_lock(M) while (__sync_lock_test_and_set((M),
1));
+#define hb_mutex_impl_unlock(M) __sync_lock_release((M))
+#define hb_mutex_impl_free(M)
+
+
#else
#warning "Could not find any system to define platform macros, library will
NOT be thread-safe"
diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh
index 72ed8ba..db5095f 100644
--- a/src/hb-object-private.hh
+++ b/src/hb-object-private.hh
@@ -73,6 +73,14 @@ typedef long hb_atomic_int_t;
#define hb_atomic_int_set(AI, V) ((void) _InterlockedExchange (&(AI),
(V)))
+#elif defined(__GNUC__)
+
+typedef volatile int hb_atomic_int_t;
+#define hb_atomic_int_add(AI, V) __sync_fetch_and_add(&(AI), (V))
+#define hb_atomic_int_get(AI) (__sync_synchronize(), (AI))
+#define hb_atomic_int_set(AI, V) __sync_lock_test_and_set(&(AI),
(V))
+
+
#else
#warning "Could not find any system to define atomic_int macros, library will
NOT be thread-safe"
--
1.7.2.3
>From f354be2b3a044ed21fe221c94c7164112d890ebe Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@blackbox>
Date: Thu, 13 Oct 2011 04:44:08 +0200
Subject: [PATCH 2/5] icu: fix pkg-config check, use the correct package name
---
configure.ac | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1b8a3ff..d3f46dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,7 +112,7 @@ AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft)
dnl ==========================================================================
-PKG_CHECK_MODULES(ICU, icu, have_icu=true, [
+PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, [
have_icu=true
AC_CHECK_HEADERS(unicode/uchar.h,, have_icu=false)
AC_MSG_CHECKING([for libicuuc])
--
1.7.2.3
>From 141b8794c69a3a40617d4b871b3c41e20d9de94a Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@blackbox>
Date: Sat, 15 Oct 2011 00:06:56 +0200
Subject: [PATCH 3/5] icu: do not use glib types
---
src/hb-icu.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hb-icu.cc b/src/hb-icu.cc
index 0f5ed1c..cc551d3 100644
--- a/src/hb-icu.cc
+++ b/src/hb-icu.cc
@@ -175,7 +175,7 @@ hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs
HB_UNUSED,
return FALSE;
UChar utf16[4], normalized[5];
- gint len;
+ int len;
hb_bool_t ret, err;
UErrorCode icu_err;
@@ -209,7 +209,7 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs
HB_UNUSED,
void *user_data HB_UNUSED)
{
UChar utf16[2], normalized[20];
- gint len;
+ int len;
hb_bool_t ret, err;
UErrorCode icu_err;
--
1.7.2.3
>From 449fce8c9842cd81a8d7dfd680dfc60218075059 Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@blackbox>
Date: Thu, 13 Oct 2011 05:05:32 +0200
Subject: [PATCH 4/5] configure: add toggles for glib/ICU/uniscribe
---
configure.ac | 103 +++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 62 insertions(+), 41 deletions(-)
diff --git a/configure.ac b/configure.ac
index d3f46dd..6b42cf2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,27 +73,40 @@ if test "x$GCC" = "xyes"; then
esac
fi
+AC_ARG_ENABLE([uniscribe], AS_HELP_STRING([--enable-uniscribe],
+ [enable uniscribe backend @<:@default=no@:>@]))
+AC_ARG_ENABLE([glib], AS_HELP_STRING([--disable-glib],
+ [disable glib unicode support @<:@default=check@:>@]))
+AC_ARG_ENABLE([icu], AS_HELP_STRING([--disable-icu],
+ [disable ICU unicode support @<:@default=check@:>@]))
+
dnl ==========================================================================
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, have_glib=true, have_glib=false)
-if $have_glib; then
- AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library])
- pkg_requires="glib-2.0 >= 2.16 ${pkg_requires}"
+have_glib=false
+have_gthread=false
+have_gobject=false
+if test x$enable_glib != xno; then
+ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, have_glib=true, have_glib=false)
+ if $have_glib; then
+ AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library])
+ pkg_requires="glib-2.0 >= 2.16 ${pkg_requires}"
+ fi
+
+ PKG_CHECK_MODULES(GTHREAD, gthread-2.0, have_gthread=true,
have_gthread=false)
+ if $have_gthread; then
+ AC_DEFINE(HAVE_GTHREAD, 1, [Have gthread2 library])
+ fi
+
+ PKG_CHECK_MODULES(GOBJECT, gobject-2.0, have_gobject=true,
have_gobject=false)
+ if $have_gobject; then
+ AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library])
+ GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+ AC_SUBST(GLIB_MKENUMS)
+ fi
fi
-AM_CONDITIONAL(HAVE_GLIB, $have_glib)
-PKG_CHECK_MODULES(GTHREAD, gthread-2.0, have_gthread=true, have_gthread=false)
-if $have_gthread; then
- AC_DEFINE(HAVE_GTHREAD, 1, [Have gthread2 library])
-fi
+AM_CONDITIONAL(HAVE_GLIB, $have_glib)
AM_CONDITIONAL(HAVE_GTHREAD, $have_gthread)
-
-PKG_CHECK_MODULES(GOBJECT, gobject-2.0, have_gobject=true, have_gobject=false)
-if $have_gobject; then
- AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library])
- GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
- AC_SUBST(GLIB_MKENUMS)
-fi
AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject)
dnl ==========================================================================
@@ -112,28 +125,33 @@ AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft)
dnl ==========================================================================
-PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, [
- have_icu=true
- AC_CHECK_HEADERS(unicode/uchar.h,, have_icu=false)
- AC_MSG_CHECKING([for libicuuc])
- LIBS_old=$LIBS
- LIBS="$LIBS -licuuc"
- AC_TRY_LINK([#include <unicode/uchar.h>],
- [u_getIntPropertyValue (0, (UProperty)0);],
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no);have_icu=false)
- LIBS=$LIBS_old
- if $have_icu; then
- ICU_CFLAGS=-D_REENTRANT
- ICU_LIBS="-licuuc"
- AC_SUBST(ICU_CFLAGS)
- AC_SUBST(ICU_LIBS)
- fi
-])
+have_icu=false
+if test x$enable_icu != xno; then
+ PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, [
+ have_icu=true
+ AC_CHECK_HEADERS(unicode/uchar.h,, have_icu=false)
+ AC_MSG_CHECKING([for libicuuc])
+ LIBS_old=$LIBS
+ LIBS="$LIBS -licuuc"
+ AC_TRY_LINK([#include <unicode/uchar.h>],
+ [u_getIntPropertyValue (0, (UProperty)0);],
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no);have_icu=false)
+ LIBS=$LIBS_old
+ if $have_icu; then
+ ICU_CFLAGS=-D_REENTRANT
+ ICU_LIBS="-licuuc"
+ AC_SUBST(ICU_CFLAGS)
+ AC_SUBST(ICU_LIBS)
+ fi
+ ])
+fi
+
if $have_icu; then
AC_DEFINE(HAVE_ICU, 1, [Have ICU library])
pkg_requires="icu ${pkg_requires}"
fi
+
AM_CONDITIONAL(HAVE_ICU, $have_icu)
dnl ==========================================================================
@@ -171,13 +189,16 @@ AM_CONDITIONAL(HAVE_OT, $have_ot)
dnl ===========================================================================
-AC_CHECK_HEADERS(usp10.h windows.h, have_uniscribe=true, have_uniscribe=false)
-if $have_uniscribe; then
- UNISCRIBE_CFLAGS=
- UNISCRIBE_LIBS="-lusp10 -lgdi32"
- AC_SUBST(UNISCRIBE_CFLAGS)
- AC_SUBST(UNISCRIBE_LIBS)
- AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe backend])
+have_uniscribe=false
+if test x$enable_uniscribe = xyes; then
+ AC_CHECK_HEADERS(usp10.h windowsx.h, have_uniscribe=true,
have_uniscribe=false)
+ if $have_uniscribe; then
+ UNISCRIBE_CFLAGS=
+ UNISCRIBE_LIBS="-lusp10 -lgdi32"
+ AC_SUBST(UNISCRIBE_CFLAGS)
+ AC_SUBST(UNISCRIBE_LIBS)
+ AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe backend])
+ fi
fi
AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe)
--
1.7.2.3
>From eca7b78f82257d281a17a1e0997e50183023de79 Mon Sep 17 00:00:00 2001
From: Grigori Goronzy <greg@blackbox>
Date: Tue, 27 Sep 2011 20:55:16 +0200
Subject: [PATCH 1/5] pkg-config: add Requires field
---
configure.ac | 6 ++++++
harfbuzz.pc.in | 1 +
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 856fb98..1b8a3ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,7 @@ dnl
==========================================================================
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, have_glib=true, have_glib=false)
if $have_glib; then
AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library])
+ pkg_requires="glib-2.0 >= 2.16 ${pkg_requires}"
fi
AM_CONDITIONAL(HAVE_GLIB, $have_glib)
@@ -131,6 +132,7 @@ PKG_CHECK_MODULES(ICU, icu, have_icu=true, [
])
if $have_icu; then
AC_DEFINE(HAVE_ICU, 1, [Have ICU library])
+ pkg_requires="icu ${pkg_requires}"
fi
AM_CONDITIONAL(HAVE_ICU, $have_icu)
@@ -139,6 +141,7 @@ dnl
==========================================================================
PKG_CHECK_MODULES(GRAPHITE, graphite2, have_graphite=true, have_graphite=false)
if $have_graphite; then
AC_DEFINE(HAVE_GRAPHITE, 1, [Have Graphite library])
+ pkg_requires="graphite2 ${pkg_requires}"
fi
AM_CONDITIONAL(HAVE_GRAPHITE, $have_graphite)
@@ -154,6 +157,7 @@ if $have_freetype; then
AC_CHECK_FUNCS(FT_Face_GetCharVariantIndex)
LIBS="$_save_libs"
CFLAGS="$_save_cflags"
+ pkg_requires="freetype2 >= 2.3.8 ${pkg_requires}"
fi
AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
@@ -177,6 +181,8 @@ if $have_uniscribe; then
fi
AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe)
+AC_SUBST([PKG_REQUIRES], ${pkg_requires})
+
AC_CONFIG_FILES([
Makefile
harfbuzz.pc
diff --git a/harfbuzz.pc.in b/harfbuzz.pc.in
index e92319e..28eb567 100644
--- a/harfbuzz.pc.in
+++ b/harfbuzz.pc.in
@@ -7,5 +7,6 @@ Name: harfbuzz
Description: Text shaping library
Version: @VERSION@
+Requires: @PKG_REQUIRES@
Libs: -L${libdir} -lharfbuzz
Cflags: -I${includedir}/harfbuzz
--
1.7.2.3
_______________________________________________
HarfBuzz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/harfbuzz