From 9194042aed4deaa0c12ba446137aa48312573b068c54073fa2ced2235103888a Mon Sep 17 00:00:00 2001
From: Bernhard Wiedemann <bwiedemann@suse.com>
Date: Wed, 8 Jul 2020 18:22:50 +0000
Subject: [PATCH 1/2] Accepting request 819526 from
 home:marxin:branches:Archiving

- Use %make_build macro.
- Add upstream patch fix-lib-build.patch which fixes lib-mt target.

OBS-URL: https://build.opensuse.org/request/show/819526
OBS-URL: https://build.opensuse.org/package/show/Archiving/zstd?expand=0&rev=49
---
 fix-lib-build.patch | 37 +++++++++++++++++++++++++++++++++++++
 zstd.changes        |  6 ++++++
 zstd.spec           | 14 ++++++++++----
 3 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 fix-lib-build.patch

diff --git a/fix-lib-build.patch b/fix-lib-build.patch
new file mode 100644
index 0000000..3c0059f
--- /dev/null
+++ b/fix-lib-build.patch
@@ -0,0 +1,37 @@
+From 39a32f40c91c306898d771962aab5bd22235554f Mon Sep 17 00:00:00 2001
+From: Yann Collet <cyan@fb.com>
+Date: Mon, 25 May 2020 06:50:45 -0700
+Subject: [PATCH] fixed default rule for lib/Makefile
+
+default rule is `lib-release`
+
+`lib-release` wasn't working : it was just skipped.
+
+Removing `lib-release` from the list of .PHONY targets fixes it.
+
+Same for `lib-mt`.
+---
+ lib/Makefile | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Makefile b/lib/Makefile
+index e6213ac86..c4305d6f8 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -220,13 +220,14 @@ libzstd : $(LIBZSTD)
+ .PHONY: lib
+ lib : libzstd.a libzstd
+ 
+-.PHONY: lib-mt
++# note : do not define lib-mt or lib-release as .PHONY
++# make does not consider implicit pattern rule for .PHONY target
++
+ %-mt : CPPFLAGS += -DZSTD_MULTITHREAD
+ %-mt : LDFLAGS  += -pthread
+ %-mt : %
+ 	@echo multi-threading build completed
+ 
+-.PHONY: lib-release
+ %-release : DEBUGFLAGS :=
+ %-release : %
+ 	@echo release build completed
diff --git a/zstd.changes b/zstd.changes
index 9fe0f64..41bac34 100644
--- a/zstd.changes
+++ b/zstd.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Wed Jul  8 17:47:50 UTC 2020 - Martin Liška <mliska@suse.cz>
+
+- Use %make_build macro.
+- Add upstream patch fix-lib-build.patch which fixes lib-mt target.
+
 -------------------------------------------------------------------
 Fri May 22 08:05:28 UTC 2020 - Ismail Dönmez <idonmez@suse.com>
 
diff --git a/zstd.spec b/zstd.spec
index d9acf81..ba7d1ed 100644
--- a/zstd.spec
+++ b/zstd.spec
@@ -28,6 +28,7 @@ URL:            https://github.com/facebook/zstd
 Source0:        https://github.com/facebook/zstd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
 Source99:       baselibs.conf
 Patch1:         pzstd.1.patch
+Patch2:         fix-lib-build.patch
 BuildRequires:  gcc
 # C++ is needed for pzstd only
 BuildRequires:  gcc-c++
@@ -84,23 +85,28 @@ Needed for compiling programs that link with the library.
 %prep
 %setup -q
 %patch1 -p1
+%patch2 -p1
 
 %build
 %global _lto_cflags %{_lto_cflags} -ffat-lto-objects
 export CFLAGS="%{optflags}"
 export CXXFLAGS="%{optflags} -std=c++11"
-for dir in lib programs contrib/pzstd; do
-  make %{?_smp_mflags} -C "$dir"
+# lib-mt is alias for multi-threaded library support
+%make_build -C lib lib-mt
+for dir in programs contrib/pzstd; do
+  %make_build -C "$dir"
 done
 
 %check
 export CFLAGS="%{optflags}"
 export CXXFLAGS="%{optflags} -std=c++11"
-make %{?_smp_mflags} -C tests test-zstd
+%make_build -C tests test-zstd
 #make %{?_smp_mflags} -C contrib/pzstd test-pzstd
 
 %install
-%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir}
+export CFLAGS="%{optflags}"
+export CXXFLAGS="%{optflags} -std=c++11"
+%make_install V=1 VERBOSE=1 PREFIX=%{_prefix} LIBDIR=%{_libdir}
 install -D -m755 contrib/pzstd/pzstd %{buildroot}%{_bindir}/pzstd
 install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1
 

From c619345525c11f6b391011a0d680b0ad93b5d1d5fe7f51de52d9f0955f6bbf33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ismail=20D=C3=B6nmez?= <ismail@i10z.com>
Date: Thu, 9 Jul 2020 03:58:41 +0000
Subject: [PATCH 2/2] Accepting request 819529 from
 home:marxin:branches:Archiving

- Remove not needed exports in %install section.

OBS-URL: https://build.opensuse.org/request/show/819529
OBS-URL: https://build.opensuse.org/package/show/Archiving/zstd?expand=0&rev=50
---
 zstd.changes | 5 +++++
 zstd.spec    | 2 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/zstd.changes b/zstd.changes
index 41bac34..cf48291 100644
--- a/zstd.changes
+++ b/zstd.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Wed Jul  8 18:33:04 UTC 2020 - Martin Liška <mliska@suse.cz>
+
+- Remove not needed exports in %install section.
+
 -------------------------------------------------------------------
 Wed Jul  8 17:47:50 UTC 2020 - Martin Liška <mliska@suse.cz>
 
diff --git a/zstd.spec b/zstd.spec
index ba7d1ed..22ecb67 100644
--- a/zstd.spec
+++ b/zstd.spec
@@ -104,8 +104,6 @@ export CXXFLAGS="%{optflags} -std=c++11"
 #make %{?_smp_mflags} -C contrib/pzstd test-pzstd
 
 %install
-export CFLAGS="%{optflags}"
-export CXXFLAGS="%{optflags} -std=c++11"
 %make_install V=1 VERBOSE=1 PREFIX=%{_prefix} LIBDIR=%{_libdir}
 install -D -m755 contrib/pzstd/pzstd %{buildroot}%{_bindir}/pzstd
 install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1