[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.
This commit is contained in:
Werner Lemberg 2022-03-18 13:25:51 +01:00
parent a8e4563c34
commit 119e404b89
3 changed files with 66 additions and 44 deletions

View File

@ -985,32 +985,32 @@ fi
# 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 @@ LIBSSTATIC_CONFIG=`echo "$LIBSSTATIC_CONFIG" \
-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])

View File

@ -7,8 +7,8 @@ Name: FreeType 2
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

View File

@ -68,12 +68,14 @@ version_info := @version_info@
# 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 @@ prefix_x := $(subst $(space),\\$(space),$(prefix))
$(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 $@