summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOneric <oneric@oneric.stub>2022-03-20 23:53:52 +0100
committerOneric <oneric@oneric.stub>2022-05-03 00:50:02 +0200
commitb77c58cd43281a05cd242888a8aac39668d67266 (patch)
tree1fdf41878d97493e61a4cd9c3b21b2ada48cc0f6
parent8e80f49ba70d6f16d8f244a7f41dfeee98d416df (diff)
downloadlibass-b77c58cd43281a05cd242888a8aac39668d67266.tar.bz2
libass-b77c58cd43281a05cd242888a8aac39668d67266.tar.xz
configure: mutate pc-file for static-only builds
This effectively reverts c9c4fed39339ffde45123013a117e06d0bb9c488. The mutation was originally removed because no one knew why it was done, the spec suggests the fields should be independent of the static or shared nature, the mutation bears risk of overlinking and no other project I looked at did such a thing. This works out well for full shared and full static builds. Mixed builds with some libraries linked static and others shared were not considered when removing the mutation and apparently pkg-config did not consider this case either. Using a custom static-only build of the desired libraries with a mutated pc-file has become a common workaround for poor mixed build support of pkg-config and many buildsystems. It's still very much an imperfect workaround and doesn't do anything for mixed builds when both library variants were built. Ideally pkg-config and buildsystems should be improved to be able to handle this in the general case. Realistically this won't happen in the foreseeable future though. At least for the pkg-config side and when using a major (modern) linker the effect can be emulated without mutating the pc-file by using pkg-config's `--static` flag and telling the linker to only link actually used libraries (`--as-needed` for GNU bfd, GNU gold, LLVM lld and mold; `-z ignore` for illumos' linker). In between the mutation being removed from libass and now being added again, FriBidi and FreeType adopted this mutation workaround, FreeType citing meson doing the same as a motivation. Indeed HarfBuzz's meson build (but not the autotools build) will also mutate its pc-file. meson itself started mutating pc files in 2018 (see meson commit 3f7c6cf3d6a204e9665faad3c05bb5049f08ac74). Going further back, FFmpeg already mutates its pc-files since 2009 (see FFmpeg commit 12701f6e31f465377462c0fc2d5b34477c1c422b). Reinstate the mutation (now with explaining comment) in libass to help out affected builders and to foster consistency with other projects while hoping no one runs into overlinking issues.
-rw-r--r--configure.ac15
-rw-r--r--libass.pc.in4
2 files changed, 15 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 4c4613c..89b60ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,8 +301,19 @@ AC_SUBST([ASFLAGS], ["$ASFLAGS"])
AC_SUBST([AS], ["$AS"])
## Relay package configuration to libass.pc.in
-AC_SUBST([PKG_LIBS_PRIVATE], [${pkg_libs}])
-AC_SUBST([PKG_REQUIRES_PRIVATE], [${pkg_requires}])
+AS_IF([test "x$enable_shared" != xno], [
+ AC_SUBST([PKG_LIBS_PUBLIC], [])
+ AC_SUBST([PKG_REQUIRES_PUBLIC], [])
+ AC_SUBST([PKG_LIBS_PRIVATE], [${pkg_libs}])
+ AC_SUBST([PKG_REQUIRES_PRIVATE], [${pkg_requires}])
+], [
+ # Not mentioned by the pkg-config specification, but
+ # a common workaround for poor support for mixed builds
+ AC_SUBST([PKG_LIBS_PUBLIC], [${pkg_libs}])
+ AC_SUBST([PKG_REQUIRES_PUBLIC], [${pkg_requires}])
+ AC_SUBST([PKG_LIBS_PRIVATE], [])
+ AC_SUBST([PKG_REQUIRES_PRIVATE], [])
+])
## Setup conditionals for use in Makefiles
AM_CONDITIONAL([ASM], [test "x$can_asm" = xtrue])
diff --git a/libass.pc.in b/libass.pc.in
index 222cc25..48de494 100644
--- a/libass.pc.in
+++ b/libass.pc.in
@@ -6,8 +6,8 @@ includedir=@includedir@
Name: libass
Description: LibASS is an SSA/ASS subtitles rendering library
Version: @PACKAGE_VERSION@
-Requires:
+Requires: @PKG_REQUIRES_PUBLIC@
Requires.private: @PKG_REQUIRES_PRIVATE@
-Libs: -L${libdir} -lass
+Libs: -L${libdir} -lass @PKG_LIBS_PUBLIC@
Libs.private: @PKG_LIBS_PRIVATE@
Cflags: -I${includedir}