]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[lib] Fix libzstd.pc for lib-mt builds 2659/head
authorÉrico Nogueira <erico.erc@gmail.com>
Sun, 16 May 2021 01:56:08 +0000 (22:56 -0300)
committerÉrico Nogueira <erico.erc@gmail.com>
Sat, 19 Jun 2021 20:42:24 +0000 (17:42 -0300)
Add the libzstd.pc target to the lib target in lib/Makefile, which makes
it inherit LDFLAGS_DYNLIB from the lib-mt target. This allows us to add
a Libs.private field to libzstd.pc which gets conditionally populated
with '-pthread'.

The 1.5.0 release notes mention that the static library isn't
multi-threaded by default, due to concern for people building static
binaries with libzstd:

   Now the dynamic library supports multi-threaded compression by
   default.  Note that this property is not extended to the static
   library because doing so would have impacted the build script of
   existing client applications (requiring them to add -pthread to their
   recipe), thus potentially breaking their build.

To get closer to being able to enable multi-threading for all library
builds by default, this commit makes it so that any libzstd consumer
using pkg-config gets the correct flags.

We also fix the indentation of the rule for libzstd.pc and move it
outside the if/endif block for install rules (which uses a list of OSs
where the rules were validated), so the rule is available for all users
of the 'lib*' targets.

lib/Makefile
lib/libzstd.pc.in

index 376a6690cd558e5787368f29d5499f704978b699..fd79898eff66ea6d359bac0140f1d9cc96823a65 100644 (file)
@@ -308,7 +308,7 @@ endif  # if windows
 libzstd : $(LIBZSTD)
 
 .PHONY: lib
-lib : libzstd.a libzstd
+lib : libzstd.a libzstd libzstd.pc
 
 
 # note : do not define lib-mt or lib-release as .PHONY
@@ -371,6 +371,18 @@ clean:
        $(RM) -r obj/*
        @echo Cleaning library completed
 
+libzstd.pc:
+libzstd.pc: libzstd.pc.in
+       @echo creating pkgconfig
+       @sed $(SED_ERE_OPT) \
+               -e 's|@PREFIX@|$(PREFIX)|' \
+               -e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
+               -e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
+               -e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
+               -e 's|@VERSION@|$(VERSION)|' \
+               -e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
+               $< >$@
+
 #-----------------------------------------------------------------------------
 # make install is validated only for below listed environments
 #-----------------------------------------------------------------------------
@@ -421,17 +433,6 @@ INSTALL_PROGRAM ?= $(INSTALL)
 INSTALL_DATA    ?= $(INSTALL) -m 644
 
 
-libzstd.pc:
-libzstd.pc: libzstd.pc.in
-       @echo creating pkgconfig
-       @sed $(SED_ERE_OPT) \
-               -e 's|@PREFIX@|$(PREFIX)|' \
-               -e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
-          -e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
-          -e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
-          -e 's|@VERSION@|$(VERSION)|' \
-          $< >$@
-
 .PHONY: install
 install: install-pc install-static install-shared install-includes
        @echo zstd static and shared library installed
index 8465c977068156c1676cf8e0ea5d09b32c3a0779..43ebaec35760e40f672498931df8f20178e9df39 100644 (file)
@@ -12,4 +12,5 @@ Description: fast lossless compression algorithm library
 URL: http://www.zstd.net/
 Version: @VERSION@
 Libs: -L${libdir} -lzstd
+Libs.private: @LIBS_PRIVATE@
 Cflags: -I${includedir}