Make freetype an optional runtime dependency instead of a hard dependency (using delay load)

This commit is contained in:
Erik van Pienbroek 2015-12-31 16:38:24 +01:00
parent 634b5c757f
commit 9ea7539723
2 changed files with 94 additions and 1 deletions

View File

@ -0,0 +1,84 @@
--- harfbuzz-1.1.2/configure.ac.orig 2015-12-31 15:58:04.284354714 +0100
+++ harfbuzz-1.1.2/configure.ac 2015-12-31 16:08:46.848239317 +0100
@@ -432,6 +432,30 @@
dnl ===========================================================================
+AC_ARG_ENABLE(delay-load,
+ [AC_HELP_STRING([--enable-delay-load],
+ [makes the freetype dependency optional at runtime (win32 only)])],,
+ [enable_delay_load=no])
+
+AC_MSG_CHECKING([whether to enable the use of delay-loaded freetype dependencies])
+if test $hb_os_win32 = false; then
+ enable_delay_load=false
+fi
+AM_CONDITIONAL(ENABLE_DELAY_LOAD, test x"$enable_delay_load" = x"yes")
+AC_MSG_RESULT([$enable_delay_load])
+
+if test x"$enable_delay_load" = x"yes" ; then
+ AC_CHECK_TOOL([GENDEF], [gendef])
+
+ AC_MSG_CHECKING([whether gendef was found])
+ if test x"$GENDEF" = x"" ; then
+ AC_MSG_ERROR([The gendef tool (required for delay loading the freetype dependency) could not be detected])
+ fi
+ AC_MSG_RESULT([yes])
+fi
+
+dnl ===========================================================================
+
AC_CONFIG_FILES([
Makefile
src/Makefile
@@ -475,4 +499,5 @@
Documentation: ${have_gtk_doc}
GObject bindings: ${have_gobject}
Introspection: ${have_introspection}
+ Enable delay loading: ${enable_delay_load}
])
--- harfbuzz-1.1.2/src/Makefile.am.orig 2015-11-27 01:24:17.545771865 +0100
+++ harfbuzz-1.1.2/src/Makefile.am 2015-12-31 16:08:07.869821859 +0100
@@ -149,14 +149,29 @@
endif
if HAVE_FREETYPE
-HBCFLAGS += $(FREETYPE_CFLAGS)
+if ENABLE_DELAY_LOAD
+# Create delay-loaded import library for freetype
+libfreetype-delay-loaded.dll.a:
+ DLL=$(bindir)/libfreetype-6.dll; \
+ if test ! -f "$$DLL" ; then \
+ echo "*** File $$DLL could not be found, unable to create delay-loaded import library"; \
+ exit 1; \
+ fi; \
+ $(GENDEF) - "$$DLL" > freetype_delay_load.def; \
+ $(DLLTOOL) --def freetype_delay_load.def --kill-at --output-delaylib libfreetype-delay-loaded.dll.a
+
+harfbuzz_delayload_ldflags = -Wl,libfreetype-delay-loaded.dll.a -Wl,-lmingwex -Wl,-lkernel32
+harfbuzz_delayload_dependency = libfreetype-delay-loaded.dll.a
+else
HBLIBS += $(FREETYPE_LIBS)
+endif
# XXX
# The following creates a recursive dependency on FreeType if FreeType is
# built with HarfBuzz support enabled. Newer pkg-config handles that just
# fine but pkg-config 0.26 as shipped in Ubuntu 14.04 crashes. Remove
# in a year or two, or otherwise work around it...
#HBDEPS += $(FREETYPE_DEPS)
+HBCFLAGS += $(FREETYPE_CFLAGS)
HBSOURCES += hb-ft.cc
HBHEADERS += hb-ft.h
endif
@@ -226,9 +226,9 @@
libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS) $(HBNODISTHEADERS)
libharfbuzz_la_CPPFLAGS = $(HBCFLAGS)
-libharfbuzz_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) $(export_symbols) -no-undefined
+libharfbuzz_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) $(export_symbols) -no-undefined $(harfbuzz_delayload_ldflags)
libharfbuzz_la_LIBADD = $(HBLIBS)
-EXTRA_libharfbuzz_la_DEPENDENCIES = $(harfbuzz_def_dependency)
+EXTRA_libharfbuzz_la_DEPENDENCIES = $(harfbuzz_def_dependency) $(harfbuzz_delayload_dependency)
pkginclude_HEADERS = $(HBHEADERS)
nodist_pkginclude_HEADERS = $(HBNODISTHEADERS)
pkgconfigdir = $(libdir)/pkgconfig

View File

@ -10,6 +10,9 @@ Group: Development/Libraries
URL: http://www.harfbuzz.org
Source0: http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-%{version}.tar.bz2
# Allow the freetype dependency to be optional at runtime
Patch0: harfbuzz-enable-delayload-freetype.patch
BuildArch: noarch
BuildRequires: mingw32-filesystem >= 95
@ -26,6 +29,9 @@ BuildRequires: mingw64-freetype
BuildRequires: mingw64-cairo
BuildRequires: mingw64-icu
BuildRequires: autoconf automake libtool
%description
HarfBuzz is an implementation of the OpenType Layout engine.
@ -66,10 +72,12 @@ Static version of the MinGW Windows Harfbuzz library.
%prep
%setup -q -n harfbuzz-%{version}
%patch0 -p1
autoreconf -i --force
%build
%mingw_configure --enable-shared --enable-static
%mingw_configure --enable-shared --enable-static --enable-delay-load
%mingw_make %{?_smp_mflags}
@ -120,6 +128,7 @@ find $RPM_BUILD_ROOT -name "*.la" -delete
%changelog
* Thu Dec 31 2015 Erik van Pienbroek <epienbro@fedoraproject.org> - 1.1.2-1
- Update to 1.1.2
- Make freetype an optional runtime dependency instead of a hard dependency (using delay load)
* Fri Sep 25 2015 Kalev Lember <klember@redhat.com> - 1.0.3-1
- Update to 1.0.3