qmi: add sourcefilter option support
[openwrt/staging/nbd.git] / tools / zstd / patches / 100-Provide-variant-pkg-config-file-for-multi-threaded-s.patch
1 From 5886e6a45b3c20c8d8f837657d1506b580434136 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sat, 6 Apr 2024 14:41:54 +0200
4 Subject: [PATCH] Provide variant pkg-config file for multi-threaded static lib
5
6 Multi-threaded static library require -pthread to correctly link and works.
7 The pkg-config we provide tho only works with dynamic multi-threaded library
8 and won't provide the correct libs and cflags values if lib-mt is used.
9
10 To handle this, introduce a variant of libzstd.pc.in, mt-libzstd.pc.in
11 and intoduce a new make target, install-mt-pc to permit advanced user to
12 install and generate a correct pkg-config file for lib-mt.
13
14 This was notice while migrating from meson to make build system where
15 meson generates a correct .pc file while make doesn't.
16
17 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
18 ---
19 lib/Makefile | 16 ++++++++++++++++
20 lib/README.md | 4 ++++
21 lib/mt-libzstd.pc.in | 15 +++++++++++++++
22 3 files changed, 35 insertions(+)
23 create mode 100644 lib/mt-libzstd.pc.in
24
25 diff --git a/lib/Makefile b/lib/Makefile
26 index 8bfdade9..4933f0e9 100644
27 --- a/lib/Makefile
28 +++ b/lib/Makefile
29 @@ -319,6 +319,17 @@ libzstd.pc: libzstd.pc.in
30 -e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
31 $< >$@
32
33 +mt-libzstd.pc: mt-libzstd.pc.in
34 + @echo creating pkgconfig
35 + @sed \
36 + -e 's|@PREFIX@|$(PREFIX)|' \
37 + -e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
38 + -e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
39 + -e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
40 + -e 's|@VERSION@|$(VERSION)|' \
41 + -e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
42 + $< >$@
43 +
44 .PHONY: install
45 install: install-pc install-static install-shared install-includes
46 @echo zstd static and shared library installed
47 @@ -328,6 +339,11 @@ install-pc: libzstd.pc
48 [ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
49 $(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
50
51 +.PHONY: install-mt-pc
52 +install-mt-pc: mt-libzstd.pc
53 + [ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
54 + $(INSTALL_DATA) mt-libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
55 +
56 .PHONY: install-static
57 install-static:
58 # only generate libzstd.a if it's not already present
59 diff --git a/lib/README.md b/lib/README.md
60 index a560f06c..3038bc7a 100644
61 --- a/lib/README.md
62 +++ b/lib/README.md
63 @@ -33,6 +33,10 @@ For convenience, we provide a build target to generate multi and single threaded
64 When linking a POSIX program with a multithreaded version of `libzstd`,
65 note that it's necessary to invoke the `-pthread` flag during link stage.
66
67 +The `.pc` generated from `make install` or `make install-pc` always assume a single-threaded static library
68 +is compiled. If `make lib-mt` is used, to correctly generate a `.pc` for the multi-threaded static library,
69 +`make install-mt-pc` is needed.
70 +
71 Multithreading capabilities are exposed
72 via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
73
74 diff --git a/lib/mt-libzstd.pc.in b/lib/mt-libzstd.pc.in
75 new file mode 100644
76 index 00000000..cd93301a
77 --- /dev/null
78 +++ b/lib/mt-libzstd.pc.in
79 @@ -0,0 +1,15 @@
80 +# ZSTD - standard compression algorithm
81 +# Copyright (c) Meta Platforms, Inc. and affiliates.
82 +# BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
83 +
84 +prefix=@PREFIX@
85 +exec_prefix=@EXEC_PREFIX@
86 +includedir=@INCLUDEDIR@
87 +libdir=@LIBDIR@
88 +
89 +Name: zstd
90 +Description: fast lossless compression algorithm library
91 +URL: https://facebook.github.io/zstd/
92 +Version: @VERSION@
93 +Libs: -L${libdir} -lzstd @LIBS_PRIVATE@
94 +Cflags: -I${includedir} @LIBS_PRIVATE@
95 --
96 2.43.0
97