From 683a434730965463f7ce2b48677430eebf909a39 Mon Sep 17 00:00:00 2001 From: Jakub Bogusz Date: Sun, 21 Jun 2015 16:03:10 +0200 Subject: [PATCH] - new - soname patch adds SONAME field to library - shared patch makes pngquant program link with shared library instead of static --- pngquant-shared.patch | 33 +++++++++++ pngquant-soname.patch | 12 ++++ pngquant.spec | 135 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 pngquant-shared.patch create mode 100644 pngquant-soname.patch create mode 100644 pngquant.spec diff --git a/pngquant-shared.patch b/pngquant-shared.patch new file mode 100644 index 0000000..9566b7f --- /dev/null +++ b/pngquant-shared.patch @@ -0,0 +1,33 @@ +--- pngquant-2.4.1/Makefile.orig 2015-06-21 15:34:33.361895698 +0200 ++++ pngquant-2.4.1/Makefile 2015-06-21 15:34:40.398562068 +0200 +@@ -10,7 +10,7 @@ + OBJS += $(COCOA_OBJS) + endif + +-STATICLIB = lib/libimagequant.a ++SHAREDLIB = lib/libimagequant.so + + DISTFILES = *.[chm] pngquant.1 Makefile configure README.md INSTALL CHANGELOG COPYRIGHT + TARNAME = pngquant-$(VERSION) +@@ -24,17 +24,17 @@ + + all: $(BIN) + +-staticlib: +- $(MAKE) -C lib static ++sharedlib: ++ $(MAKE) -C lib shared + +-$(STATICLIB): config.mk staticlib ++$(SHAREDLIB): config.mk sharedlib + + $(OBJS): $(wildcard *.h) config.mk + + rwpng_cocoa.o: rwpng_cocoa.m + $(CC) -Wno-enum-conversion -c $(CFLAGS) -o $@ $< || clang -Wno-enum-conversion -c -O3 $(CFLAGS) -o $@ $< + +-$(BIN): $(OBJS) $(STATICLIB) ++$(BIN): $(OBJS) $(SHAREDLIB) + $(CC) $^ $(LDFLAGS) -o $@ + + test: $(BIN) diff --git a/pngquant-soname.patch b/pngquant-soname.patch new file mode 100644 index 0000000..f67c8ea --- /dev/null +++ b/pngquant-soname.patch @@ -0,0 +1,12 @@ +--- pngquant-2.4.1/lib/Makefile.orig 2015-06-12 23:46:49.000000000 +0200 ++++ pngquant-2.4.1/lib/Makefile 2015-06-21 15:21:49.201927767 +0200 +@@ -36,7 +36,8 @@ + $(CC) -fPIC $(CFLAGS) -c $(@:.lo=.c) -o $@ + + $(SHAREDLIB): $(SHAREDOBJS) +- $(CC) -shared -o $@ $^ $(LDFLAGS) ++ $(CC) -shared -o $@ $^ $(LDFLAGS) -Wl,-soname,$(SHAREDLIB) ++ ln -sf $(SHAREDLIB) libimagequant.so + + $(OBJS): $(wildcard *.h) config.mk + diff --git a/pngquant.spec b/pngquant.spec new file mode 100644 index 0000000..ac38428 --- /dev/null +++ b/pngquant.spec @@ -0,0 +1,135 @@ +# +# Conditional build: +%bcond_without static_libs # static library +%bcond_without gomp # OpenMP support +%bcond_without lcms # LCMS support +%bcond_with sse # SSE instructions +# +%ifarch pentium3 pentium4 %{x8664} x32 +%define with_sse 1 +%endif +Summary: PNG converter and lossy image compressor +Summary(pl.UTF-8): Konwerter i stratny kompresor dla plików PNG +Name: pngquant +Version: 2.4.1 +Release: 1 +License: BSD +Group: Libraries +#Source0Download: https://pngquant.org/releases.html +Source0: https://pngquant.org/%{name}-%{version}-src.tar.bz2 +# Source0-md5: 2809b10f8d183853c1283cfdfa292ab3 +Patch0: %{name}-soname.patch +Patch1: %{name}-shared.patch +URL: https://pngquant.org/ +%{?with_gomp:BuildRequires: gcc >= 6:4.2} +%{?with_gomp:BuildRequires: libgomp-devel} +%{?with_lcms:BuildRequires: lcms2-devel >= 2} +BuildRequires: libpng-devel +BuildRequires: pkgconfig +BuildRequires: zlib-devel +Requires: libimagequant = %{version}-%{release} +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%description +PNG converter and lossy image compressor. + +%description -l pl.UTF-8 +Konwerter i stratny kompresor dla plików PNG. + +%package -n libimagequant +Summary: Image Quantization library +Summary(pl.UTF-8): Biblioteka do kwantyzacji obrazów +Group: Libraries +URL: https://pngquant.org/lib/ + +%description -n libimagequant +Image Quantization library. + +%description -n libimagequant -l pl.UTF-8 +Biblioteka do kwantyzacji obrazów. + +%package -n libimagequant-devel +Summary: Header files for libimagequant library +Summary(pl.UTF-8): Pliki nagłówkowe biblioteki libimagequant +Group: Development/Libraries +URL: https://pngquant.org/lib/ +Requires: libimagequant = %{version}-%{release} + +%description -n libimagequant-devel +Header files for libimagequant library. + +%description -n libimagequant-devel -l pl.UTF-8 +Pliki nagłówkowe biblioteki libimagequant. + +%package -n libimagequant-static +Summary: Static libimagequant library +Summary(pl.UTF-8): Statyczna biblioteka libimagequant +Group: Development/Libraries +URL: https://pngquant.org/lib/ +Requires: libimagequant-devel = %{version}-%{release} + +%description -n libimagequant-static +Static libimagequant library. + +%description -n libimagequant-static -l pl.UTF-8 +Statyczna biblioteka libimagequant. + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 + +%build +# not autoconf configure +./configure \ + CC="%{__cc}" \ + CFLAGS="%{rpmcflags} %{rpmcppflags}" \ + LDFLAGS="%{rpmldflags}" \ + --prefix=%{_prefix} \ + %{?with_sse:--enable-sse} \ + %{?with_lcms:--with-lcms2} \ + %{?with_gomp:--with-openmp} + +%{__make} -C lib %{!?with_static_libs:shared} + +%{__make} + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT{%{_libdir},%{_includedir}} + +%{__make} install \ + DESTDIR=$RPM_BUILD_ROOT + +cp -a lib/libimagequant.so* $RPM_BUILD_ROOT%{_libdir} +%if %{with static_libs} +cp -p lib/libimagequant.a $RPM_BUILD_ROOT%{_libdir} +%endif +cp -p lib/libimagequant.h $RPM_BUILD_ROOT%{_includedir} + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -n libimagequant -p /sbin/ldconfig +%postun -n libimagequant -p /sbin/ldconfig + +%files +%defattr(644,root,root,755) +%doc CHANGELOG COPYRIGHT README.md +%attr(755,root,root) %{_bindir}/pngquant + +%files -n libimagequant +%defattr(644,root,root,755) +%doc lib/{COPYRIGHT,MANUAL.md} +%attr(755,root,root) %{_libdir}/libimagequant.so.0 + +%files -n libimagequant-devel +%defattr(644,root,root,755) +%attr(755,root,root) %{_libdir}/libimagequant.so +%{_includedir}/libimagequant.h + +%if %{with static_libs} +%files -n libimagequant-static +%defattr(644,root,root,755) +%{_libdir}/libimagequant.a +%endif -- 2.43.0