From 89d8d0745ac70e778c5526e741049030049327c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sat, 19 Dec 2015 10:07:33 +0100 Subject: [PATCH] Add Patch1: make the configure-script work with %%configure Build and run the testsuite Conditionalize %%license Remove all el5-related things, since we need gcc >= 4.2 anyways Fix %%{?_isa} on (Build)Requires --- pngquant-2.4.0_fix-Makefile.patch | 60 --------------------- pngquant-2.5.0_fix-Makefile.patch | 60 --------------------- pngquant-2.5.2-fix_configure.patch | 14 +++++ pngquant.spec | 85 ++++++++++++++++++------------ 4 files changed, 66 insertions(+), 153 deletions(-) delete mode 100644 pngquant-2.4.0_fix-Makefile.patch delete mode 100644 pngquant-2.5.0_fix-Makefile.patch create mode 100644 pngquant-2.5.2-fix_configure.patch diff --git a/pngquant-2.4.0_fix-Makefile.patch b/pngquant-2.4.0_fix-Makefile.patch deleted file mode 100644 index a29085f..0000000 --- a/pngquant-2.4.0_fix-Makefile.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- pngquant-2.4.0.1.orig/lib/Makefile 2015-04-11 23:24:38.000000000 +0100 -+++ pngquant-2.4.0.1/lib/Makefile 2015-04-19 03:35:15.687199897 +0100 -@@ -1,7 +1,8 @@ - -include config.mk - - STATICLIB=libimagequant.a --SHAREDLIB=libimagequant.so.0 -+SHAREDLIB=libimagequant.so -+SOVER=0 - - DLL=libimagequant.dll - DLLIMP=libimagequant_dll.a -@@ -36,7 +37,8 @@ $(SHAREDOBJS): - $(CC) -fPIC $(CFLAGS) -c $(@:.lo=.c) -o $@ - - $(SHAREDLIB): $(SHAREDOBJS) -- $(CC) -shared -o $@ $^ $(LDFLAGS) -+ $(CC) -shared -Wl,-soname,$(SHAREDLIB).$(SOVER) -o $(SHAREDLIB).$(SOVER) $^ $(LDFLAGS) -+ ln -fs $(SHAREDLIB).$(SOVER) $(SHAREDLIB) - - $(OBJS): $(wildcard *.h) config.mk - ---- pngquant-2.4.0.1.orig/Makefile 2015-04-11 23:24:38.000000000 +0100 -+++ pngquant-2.4.0.1/Makefile 2015-04-19 02:19:40.340909213 +0100 -@@ -11,6 +11,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) -@@ -29,12 +30,17 @@ staticlib: - - $(STATICLIB): config.mk staticlib - -+sharedlib: -+ $(MAKE) -C lib shared -+ -+$(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) -@@ -60,7 +66,7 @@ uninstall: - - clean: - $(MAKE) -C lib clean -- rm -f '$(BIN)' $(OBJS) $(COCOA_OBJS) $(STATICLIB) $(TARFILE) -+ rm -f '$(BIN)' $(OBJS) $(COCOA_OBJS) $(TARFILE) - - distclean: clean - $(MAKE) -C lib distclean diff --git a/pngquant-2.5.0_fix-Makefile.patch b/pngquant-2.5.0_fix-Makefile.patch deleted file mode 100644 index d84679e..0000000 --- a/pngquant-2.5.0_fix-Makefile.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- pngquant-2.4.0.1.orig/lib/Makefile 2015-04-11 23:24:38.000000000 +0100 -+++ pngquant-2.4.0.1/lib/Makefile 2015-04-19 03:35:15.687199897 +0100 -@@ -1,7 +1,8 @@ - -include config.mk - - STATICLIB=libimagequant.a --SHAREDLIB=libimagequant.so.0 -+SHAREDLIB=libimagequant.so -+SOVER=0 - - DLL=libimagequant.dll - DLLIMP=libimagequant_dll.a -@@ -36,7 +37,8 @@ $(SHAREDOBJS): - $(CC) -fPIC $(CFLAGS) -c $(@:.lo=.c) -o $@ - - $(SHAREDLIB): $(SHAREDOBJS) -- $(CC) -shared -o $@ $^ $(LDFLAGS) -+ $(CC) -shared -Wl,-soname,$(SHAREDLIB).$(SOVER) -o $(SHAREDLIB).$(SOVER) $^ $(LDFLAGS) -+ ln -fs $(SHAREDLIB).$(SOVER) $(SHAREDLIB) - - $(OBJS): $(wildcard *.h) config.mk - ---- ./Makefile.orig 2015-06-28 23:52:06.000000000 +0100 -+++ ./Makefile 2015-07-02 13:59:38.465100226 +0100 -@@ -11,6 +11,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) -@@ -29,12 +30,17 @@ staticlib: - - $(STATICLIB): config.mk staticlib - -+sharedlib: -+ $(MAKE) -C lib shared -+ -+$(SHAREDLIB): config.mk sharedlib -+ - $(OBJS): $(wildcard *.h) config.mk - - rwpng_cocoa.o: rwpng_cocoa.m - $(CC) -Wno-enum-conversion -c $(CFLAGS) -o $@ $< &> /dev/null || clang -Wno-enum-conversion -c -O3 $(CFLAGS) -o $@ $< - --$(BIN): $(OBJS) $(STATICLIB) -+$(BIN): $(OBJS) $(SHAREDLIB) - $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ - - test: $(BIN) -@@ -60,7 +66,7 @@ uninstall: - - clean: - $(MAKE) -C lib clean -- rm -f '$(BIN)' $(OBJS) $(COCOA_OBJS) $(STATICLIB) $(TARFILE) -+ rm -f '$(BIN)' $(OBJS) $(COCOA_OBJS) $(STATICLIB) $(SHAREDLIB) $(TARFILE) - - distclean: clean - $(MAKE) -C lib distclean diff --git a/pngquant-2.5.2-fix_configure.patch b/pngquant-2.5.2-fix_configure.patch new file mode 100644 index 0000000..a513a0d --- /dev/null +++ b/pngquant-2.5.2-fix_configure.patch @@ -0,0 +1,14 @@ +Index: pngquant-2.5.2/configure +=================================================================== +--- pngquant-2.5.2.orig/configure ++++ pngquant-2.5.2/configure +@@ -102,8 +102,7 @@ fi + EXTRA_LDFLAGS="$EXTRA_LDFLAGS ${i#*=}" + ;; + *) +- echo "error: unknown switch ${i%%=*} (see $0 --help for the list)" +- exit 1 ++ echo "warning: unknown switch ${i%%=*} (see $0 --help for the list)" + ;; + esac + done diff --git a/pngquant.spec b/pngquant.spec index d1d2a5e..4ce6a15 100644 --- a/pngquant.spec +++ b/pngquant.spec @@ -1,10 +1,17 @@ +# add some speed-relevant compiler-flags +%global optflags %(echo %{optflags} -fno-math-errno -funroll-loops -fomit-frame-pointer -fPIC ) + +# we use %%license on recent distros, only +%if 0%{?fedora} >= 22 || 0%{?rhel} >= 8 +%global with_license 1 +%endif # 0%%{?fedora} >= 22 || 0%%{?rhel} >= 8 + %global libname libimagequant Name: pngquant Version: 2.5.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: PNG quantization tool for reducing image file size -%{?el5:Group: Applications/Multimedia} License: BSD with advertising @@ -12,16 +19,14 @@ URL: http://%{name}.org Source0: https://github.com/pornel/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz Patch0: %{name}-2.5.1_fix-Makefile.patch +Patch1: %{name}-2.5.2-fix_configure.patch - -%{?el5:BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)} -BuildRequires: libpng-devel%{?_isa} >= 1.2.46-1 -BuildRequires: zlib-devel%{?_isa} >= 1.2.3-1 -BuildRequires: gcc%{?_isa} >= 4.2-1 +BuildRequires: libpng-devel >= 1.2.46-1 +BuildRequires: zlib-devel >= 1.2.3-1 BuildRequires: lcms2-devel Requires: libpng%{?_isa} >= 1.2.46-1 -Requires: zlib%{?isa} >= 1.2.3-1 -Requires: %{libname} = %{version}-%{release} +Requires: zlib%{?_isa} >= 1.2.3-1 +Requires: %{libname}%{?_isa} = %{version}-%{release} %description @@ -34,7 +39,7 @@ their 24/32-bit version. %{name} uses the median cut algorithm. %package -n %{libname} Summary: Small, portable C lib for HQ conversion of RGBA to 8-bit indexed-color -%{?el5:Group: System Environment/Libraries} + %description -n %{libname} %{libname} converts 24/32-bit RGBA PNG images to 8-bit palette with alpha @@ -46,9 +51,8 @@ their 24/32-bit version. %{libname} uses the median cut algorithm. %package -n %{libname}-devel Summary: Development files for %{libname} -%{?el5:Group: Development/Libraries} +Requires: %{libname}%{?_isa} = %{version}-%{release} -Requires: %{libname} = %{version}-%{release} %description -n %{libname}-devel This package contains files for development with %{libname}. @@ -56,27 +60,24 @@ There is also some brief API-documentation. %prep -%global optflags %(echo %{optflags} -fno-math-errno -funroll-loops -fomit-frame-pointer -fPIC ) %setup -q -%patch0 -p1 -rm lib/configure +%patch0 -p1 -b .fix_makefile +%patch1 -p1 -b .fix_configure +rm -f lib/configure %build -# export flags like macro configure do -# and don't use macro configure because fails in configure. -CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS -CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS -FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS - -./configure --prefix=%{_prefix} - +%configure make %{?_smp_mflags} PREFIX=%{_prefix} +# build testsuite +pushd test +gcc $CFLAGS $LDFLAGS -L../lib -limagequant \ + -o test test.c +popd -%install -%{?el5:rm -rf %{buildroot}} +%install mkdir -p %{buildroot}%{_includedir}/imagequant \ %{buildroot}%{_bindir} \ %{buildroot}%{_libdir} \ @@ -95,28 +96,39 @@ install -pm 0644 lib/*.h \ install -pm 0644 %{name}.1 \ %{buildroot}/%{_mandir}/man1/%{name}.1 -mkdir -p %{buildroot}/%{_bindir} -make install PREFIX=%{_prefix} DESTDIR=%{buildroot} -install -Dpm0755 pngquant %{buildroot}/%{_bindir}/pngquant -install -Dpm0644 pngquant.1 %{buildroot}/%{_mandir}/man1/pngquant.1 +# install the binary +install -pm 0755 %{name} \ + %{buildroot}/%{_bindir}/%{name} -%clean -%{?el5:rm -rf %{buildroot}} +%check +# needed by ld / testsuite to find libimagequant +export LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH" +pushd test +./test.sh . ../pngquant ./test +popd -%post -n %{libname} -p /sbin/ldconfig +%post -n %{libname} -p /sbin/ldconfig %postun -n %{libname} -p /sbin/ldconfig %files %doc README.md CHANGELOG +%if 0%{?with_license} %license COPYRIGHT +%else # 0%%{?with_license} +%doc COPYRIGHT +%endif # 0%%{?with_license} %{_bindir}/%{name} %{_mandir}/man1/%{name}.1* %files -n %{libname} +%if 0%{?with_license} %license lib/COPYRIGHT +%else # 0%%{?with_license} +%doc lib/COPYRIGHT +%endif # 0%%{?with_license} %{_libdir}/%{libname}.so.* %files -n %{libname}-devel @@ -126,6 +138,13 @@ install -Dpm0644 pngquant.1 %{buildroot}/%{_mandir}/man1/pngquant.1 %changelog +* Sat Dec 19 2015 Björn Esser - 2.5.2-3 +- Add Patch1: make the configure-script work with %%configure +- Build and run the testsuite +- Conditionalize %%license +- Remove all el5-related things, since we need gcc >= 4.2 anyways +- Fix %%{?_isa} on (Build)Requires + * Sat Dec 19 2015 Sérgio Basto - 2.5.2-2 - Disable pngquant debug (#1291885) @@ -150,7 +169,7 @@ install -Dpm0644 pngquant.1 %{buildroot}/%{_mandir}/man1/pngquant.1 - Add license tag. * Mon Apr 20 2015 Sérgio Basto - 2.4.1-1 -- Update to 2.4.1 +- Update to 2.4.1 - Dropped "epel compile fix" patch * Sun Apr 19 2015 Sérgio Basto - 2.4.0.1-4