shithub: freetype+ttf2subf

Download patch

ref: 119e404b892dc8bf7db53e868039aec187042587
parent: a8e4563c3418ed74d39019a6c5e2122d12c8f56f
author: Werner Lemberg <wl@gnu.org>
date: Fri Mar 18 09:25:51 EDT 2022

[builds] Fix creation of `freetype2.pc` for static-only builds.

We have to help `pkg-config` since it can't recognize that there is no
shared library installed.

Note that meson already does exactly the same.

* builds/unix/configure.raw (REQUIRES_PRIVATE, LIBS_PRIVATE): Rename to...
(PKGCONFIG_REQUIRES_PRIVATE, PKGCONFIG_LIBS_PRIVATE): This.  Adjust them
depending on `$enable_shared`.
(PKGCONFIG_REQUIRES, PKGCONFIG_LIBS): New variables.

* builds/unix/freetype2.in, builds/unix/unix-def.in: Use new and updated
variables.

git/fs: mount .git/fs: mount/attach disallowed
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -985,32 +985,32 @@
 
 
 # entries in Requires.private are separated by commas
-REQUIRES_PRIVATE="$zlib_reqpriv,     \
-                  $bzip2_reqpriv,    \
-                  $libpng_reqpriv,   \
-                  $harfbuzz_reqpriv, \
-                  $brotli_reqpriv"
+PKGCONFIG_REQUIRES_PRIVATE="$zlib_reqpriv,     \
+                            $bzip2_reqpriv,    \
+                            $libpng_reqpriv,   \
+                            $harfbuzz_reqpriv, \
+                            $brotli_reqpriv"
 # beautify
-REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
-                  | sed -e 's/^  *//'      \
-                        -e 's/  *$//'      \
-                        -e 's/, */,/g'     \
-                        -e 's/,,*/,/g'     \
-                        -e 's/^,*//'       \
-                        -e 's/,*$//'       \
-                        -e 's/,/, /g'`
+PKGCONFIG_REQUIRES_PRIVATE=`echo "$PKGCONFIG_REQUIRES_PRIVATE" \
+                            | sed -e 's/^  *//'      \
+                                  -e 's/  *$//'      \
+                                  -e 's/, */,/g'     \
+                                  -e 's/,,*/,/g'     \
+                                  -e 's/^,*//'       \
+                                  -e 's/,*$//'       \
+                                  -e 's/,/, /g'`
 
-LIBS_PRIVATE="$zlib_libspriv     \
-              $bzip2_libspriv    \
-              $libpng_libspriv   \
-              $harfbuzz_libspriv \
-              $brotli_libspriv   \
-              $ft2_extra_libs"
+PKGCONFIG_LIBS_PRIVATE="$zlib_libspriv     \
+                        $bzip2_libspriv    \
+                        $libpng_libspriv   \
+                        $harfbuzz_libspriv \
+                        $brotli_libspriv   \
+                        $ft2_extra_libs"
 # beautify
-LIBS_PRIVATE=`echo "$LIBS_PRIVATE"  \
-              | sed -e 's/^  *//'   \
-                    -e 's/  *$//'   \
-                    -e 's/  */ /g'`
+PKGCONFIG_LIBS_PRIVATE=`echo "$PKGCONFIG_LIBS_PRIVATE"  \
+                        | sed -e 's/^  *//'   \
+                              -e 's/  *$//'   \
+                              -e 's/  */ /g'`
 
 LIBSSTATIC_CONFIG="-lfreetype               \
                    $zlib_libsstaticconf     \
@@ -1028,10 +1028,28 @@
                          -e 's/  *$//'                \
                          -e 's/  */ /g'`
 
+# If FreeType gets installed with `--disable-shared', don't use
+# 'private' fields.  `pkg-config' only looks into `.pc' files and is
+# completely agnostic to whether shared libraries are actually present
+# or not.  As a consequence, the user had to specify `--static' while
+# calling `pkg-config', which configure scripts are normally not
+# prepared for.
 
+PKGCONFIG_REQUIRES=
+PKGCONFIG_LIBS='-L${libdir} -lfreetype'
+
+if test $enable_shared = "no"; then
+  PKGCONFIG_REQUIRES="$PKGCONFIG_REQUIRES $PKGCONFIG_REQUIRES_PRIVATE"
+  PKGCONFIG_REQUIRES_PRIVATE=
+  PKGCONFIG_LIBS="$PKGCONFIG_LIBS $PKGCONFIG_LIBS_PRIVATE"
+  PKGCONFIG_LIBS_PRIVATE=
+fi
+
 AC_SUBST([ftmac_c])
-AC_SUBST([REQUIRES_PRIVATE])
-AC_SUBST([LIBS_PRIVATE])
+AC_SUBST([PKGCONFIG_REQUIRES])
+AC_SUBST([PKGCONFIG_LIBS])
+AC_SUBST([PKGCONFIG_REQUIRES_PRIVATE])
+AC_SUBST([PKGCONFIG_LIBS_PRIVATE])
 AC_SUBST([LIBSSTATIC_CONFIG])
 
 AC_SUBST([hardcode_libdir_flag_spec])
--- a/builds/unix/freetype2.in
+++ b/builds/unix/freetype2.in
@@ -7,8 +7,8 @@
 URL: https://freetype.org
 Description: A free, high-quality, and portable font engine.
 Version: %ft_version%
-Requires:
-Requires.private: %REQUIRES_PRIVATE%
-Libs: -L${libdir} -lfreetype
-Libs.private: %LIBS_PRIVATE%
+Requires: %PKGCONFIG_REQUIRES%
+Requires.private: %PKGCONFIG_REQUIRES_PRIVATE%
+Libs: %PKGCONFIG_LIBS%
+Libs.private: %PKGCONFIG_LIBS_PRIVATE%
 Cflags: -I${includedir}/freetype2
--- a/builds/unix/unix-def.in
+++ b/builds/unix/unix-def.in
@@ -68,12 +68,14 @@
 
 # Variables needed for `freetype-config' and `freetype.pc'.
 #
-PKG_CONFIG         := @PKG_CONFIG@
-REQUIRES_PRIVATE   := @REQUIRES_PRIVATE@
-LIBS_PRIVATE       := @LIBS_PRIVATE@
-LIBSSTATIC_CONFIG  := @LIBSSTATIC_CONFIG@
-build_libtool_libs := @build_libtool_libs@
-ft_version         := @ft_version@
+PKG_CONFIG                 := @PKG_CONFIG@
+PKGCONFIG_REQUIRES         := @PKGCONFIG_REQUIRES@
+PKGCONFIG_REQUIRES_PRIVATE := @PKGCONFIG_REQUIRES_PRIVATE@
+PKGCONFIG_LIBS             := @PKGCONFIG_LIBS@
+PKGCONFIG_LIBS_PRIVATE     := @PKGCONFIG_LIBS_PRIVATE@
+LIBSSTATIC_CONFIG          := @LIBSSTATIC_CONFIG@
+build_libtool_libs         := @build_libtool_libs@
+ft_version                 := @ft_version@
 
 # The directory where all library files are placed.
 #
@@ -137,15 +139,17 @@
 
 $(OBJ_BUILD)/freetype2.pc: $(TOP_DIR)/builds/unix/freetype2.in
 	rm -f $@ $@.tmp
-	sed -e 's|%REQUIRES_PRIVATE%|$(REQUIRES_PRIVATE)|'     \
-	    -e 's|%LIBS_PRIVATE%|$(LIBS_PRIVATE)|'             \
-	    -e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
-	    -e 's|%exec_prefix%|$(exec_prefix_x)|'             \
-	    -e 's|%ft_version%|$(ft_version)|'                 \
-	    -e 's|%includedir%|$(includedir_x)|'               \
-	    -e 's|%libdir%|$(libdir_x)|'                       \
-	    -e 's|%prefix%|$(prefix_x)|'                       \
-	    $<                                                 \
+	sed -e 's|%PKGCONFIG_REQUIRES%|$(PKGCONFIG_REQUIRES)|'                 \
+	    -e 's|%PKGCONFIG_REQUIRES_PRIVATE%|$(PKGCONFIG_REQUIRES_PRIVATE)|' \
+	    -e 's|%PKGCONFIG_LIBS%|$(PKGCONFIG_LIBS)|'                         \
+	    -e 's|%PKGCONFIG_LIBS_PRIVATE%|$(PKGCONFIG_LIBS_PRIVATE)|'         \
+	    -e 's|%build_libtool_libs%|$(build_libtool_libs)|'                 \
+	    -e 's|%exec_prefix%|$(exec_prefix_x)|'                             \
+	    -e 's|%ft_version%|$(ft_version)|'                                 \
+	    -e 's|%includedir%|$(includedir_x)|'                               \
+	    -e 's|%libdir%|$(libdir_x)|'                                       \
+	    -e 's|%prefix%|$(prefix_x)|'                                       \
+	    $<                                                                 \
 	    > $@.tmp
 	chmod a-w $@.tmp
 	mv $@.tmp $@