mingw-harfbuzz/harfbuzz-enable-delayload-freetype.patch
2019-06-03 14:08:06 +02:00

87 lines
3.5 KiB
Diff

diff -rupN harfbuzz-2.5.1/configure.ac harfbuzz-2.5.1-new/configure.ac
--- harfbuzz-2.5.1/configure.ac 2019-06-01 07:56:56.000000000 +0200
+++ harfbuzz-2.5.1-new/configure.ac 2019-06-03 13:49:38.656463527 +0200
@@ -476,6 +476,30 @@ fi
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
@@ -530,4 +554,5 @@ Other features:
Documentation: ${enable_gtk_doc}
GObject bindings: ${have_gobject}
Introspection: ${have_introspection}
+ Enable delay loading: ${enable_delay_load}
])
diff -rupN harfbuzz-2.5.1/src/Makefile.am harfbuzz-2.5.1-new/src/Makefile.am
--- harfbuzz-2.5.1/src/Makefile.am 2019-05-24 02:34:19.000000000 +0200
+++ harfbuzz-2.5.1-new/src/Makefile.am 2019-06-03 13:49:38.656463527 +0200
@@ -46,14 +46,29 @@ HBHEADERS += $(HB_GLIB_headers)
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_sources)
HBHEADERS += $(HB_FT_headers)
endif
@@ -132,9 +147,9 @@ base_link_flags = $(AM_LDFLAGS) -lm -ver
libharfbuzz_la_LINK = $(chosen_linker) $(libharfbuzz_la_LDFLAGS)
libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
libharfbuzz_la_CPPFLAGS = $(HBCFLAGS) $(CODE_COVERAGE_CFLAGS)
-libharfbuzz_la_LDFLAGS = $(base_link_flags) $(export_symbols) $(CODE_COVERAGE_LDFLAGS)
+libharfbuzz_la_LDFLAGS = $(base_link_flags) $(export_symbols) $(CODE_COVERAGE_LDFLAGS) $(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 =
pkgconfigdir = $(libdir)/pkgconfig