[packages/libp2p] - added shared patch, build shared+static library

qboosh qboosh at pld-linux.org
Tue Apr 25 19:07:33 CEST 2023


commit 5e15a48e4a06590578d2203eb16789d059bd21f2
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Tue Apr 25 19:10:10 2023 +0200

    - added shared patch, build shared+static library

 libp2p-shared.patch | 42 ++++++++++++++++++++++++++++++++++++++++++
 libp2p.spec         | 30 ++++++++----------------------
 2 files changed, 50 insertions(+), 22 deletions(-)
---
diff --git a/libp2p.spec b/libp2p.spec
index ba1531c..3141adf 100644
--- a/libp2p.spec
+++ b/libp2p.spec
@@ -18,8 +18,10 @@ License:	WTFPL v2
 Group:		Libraries
 Source0:	https://github.com/sekrit-twc/libp2p/archive/%{gitref}/%{name}-%{snap}.tar.gz
 # Source0-md5:	663e2005ffe0eecea2cc9336e0b789e4
+Patch0:		%{name}-shared.patch
 URL:		https://github.com/sekrit-twc/libp2p
 BuildRequires:	libstdc++-devel >= 6:5
+BuildRequires:	libtool >= 2:1.5
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -65,6 +67,7 @@ Statyczna biblioteka libp2p.
 
 %prep
 %setup -q -n %{name}-%{gitref}
+%patch0 -p1
 
 %build
 %{__make} \
@@ -73,28 +76,21 @@ Statyczna biblioteka libp2p.
 	CPPFLAGS="%{rpmcppflags}" \
 	LDFLAGS="%{rpmldflags}" \
 %if %{with simd}
-	SIMD=1
+	SIMD=1 \
 %endif
+	libdir=%{_libdir}
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_libdir},%{_includedir}}
 
-%if %{with shared}
 %{__make} install \
-	DESTDIR=$RPM_BUILD_ROOT
-
-%{__rm} $RPM_BUILD_ROOT%{_libdir}/libp2p.la
-%else
-cp -p libp2p.a $RPM_BUILD_ROOT%{_libdir}
-cp -p p2p.h p2p_api.h $RPM_BUILD_ROOT%{_includedir}
-%endif
+	DESTDIR=$RPM_BUILD_ROOT \
+	includedir=%{_includedir} \
+	libdir=%{_libdir}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%if %{with shared}
-
 %post	-p /sbin/ldconfig
 %postun	-p /sbin/ldconfig
 
@@ -114,13 +110,3 @@ rm -rf $RPM_BUILD_ROOT
 %files static
 %defattr(644,root,root,755)
 %{_libdir}/libp2p.a
-
-%else
-
-%files devel
-%defattr(644,root,root,755)
-%{_libdir}/libp2p.a
-%{_includedir}/p2p.h
-%{_includedir}/p2p_api.h
-
-%endif
diff --git a/libp2p-shared.patch b/libp2p-shared.patch
new file mode 100644
index 0000000..fd1100c
--- /dev/null
+++ b/libp2p-shared.patch
@@ -0,0 +1,42 @@
+--- libp2p-5e65679ae54d0f9fa412ab36289eb2255e341625/Makefile.orig	2022-07-06 03:05:02.000000000 +0200
++++ libp2p-5e65679ae54d0f9fa412ab36289eb2255e341625/Makefile	2023-04-25 17:12:09.635765402 +0200
+@@ -12,6 +12,7 @@ libp2p_HDRS = \
+ 
+ libp2p_OBJS = \
+ 	p2p_api.o \
++	v210.o \
+ 	simd/cpuinfo_x86.o \
+ 	simd/p2p_simd.o \
+ 	simd/p2p_sse41.o
+@@ -21,13 +22,26 @@ ifeq ($(SIMD), 1)
+   MY_CPPFLAGS := -DP2P_SIMD $(MY_CPPFLAGS)
+ endif
+ 
+-all: libp2p.a
++all: libp2p.la
+ 
+-libp2p.a: $(libp2p_OBJS)
+-	ar rcs $@ $^
++includedir = /usr/include
++libdir = /usr/lib
++libp2p_LOBJS = $(libp2p_OBJS:.o=.lo)
+ 
+-%.o: %.cpp $(znedi3_HDRS) $(testapp_HDRS) $(vsxx_HDRS)
+-	$(CXX) -c $(EXTRA_CXXFLAGS) $(MY_CXXFLAGS) $(MY_CPPFLAGS) $< -o $@
++ifeq ($(SIMD), 1)
++  simd/p2p_sse41.lo: EXTRA_CXXFLAGS := -msse4.1
++endif
++
++libp2p.la: $(libp2p_LOBJS)
++	libtool --tag=CXX --mode=link $(CXX) $(MY_LDFLAGS) $(MY_CXXFLAGS) -o $@ $^ -rpath $(libdir)
++
++%.lo: %.cpp $(znedi3_HDRS) $(testapp_HDRS) $(vsxx_HDRS)
++	libtool --tag=CXX --mode=compile $(CXX) -c $(EXTRA_CXXFLAGS) $(MY_CXXFLAGS) $(MY_CPPFLAGS) $< -o $@
++
++install:
++	install -d $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
++	install -m644 p2p.h p2p_api.h $(DESTDIR)$(includedir)
++	libtool --mode=install install libp2p.la $(DESTDIR)$(libdir)
+ 
+ clean:
+ 	rm -f *.a *.o *.so simd/*.o
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/libp2p.git/commitdiff/5e15a48e4a06590578d2203eb16789d059bd21f2



More information about the pld-cvs-commit mailing list