diff --git a/2.5.2...master.diff b/2.5.2...master.diff
new file mode 100644
index 0000000..bcb99f1
--- /dev/null
+++ b/2.5.2...master.diff
@@ -0,0 +1,188 @@
+diff --git a/Makefile b/Makefile
+index 3d41182..0fa7517 100644
+--- a/Makefile
++++ b/Makefile
+@@ -12,6 +12,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)
+@@ -32,6 +33,11 @@ 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
+@@ -46,6 +52,15 @@ $(TESTBIN): test/test.o $(STATICLIB)
+ test: $(BIN) $(TESTBIN)
+ ./test/test.sh ./test $(BIN) $(TESTBIN)
+
++bin.shared: $(OBJS) $(SHAREDLIB)
++ $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(BIN)
++
++testbin.shared: test/test.o $(SHAREDLIB)
++ $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(TESTBIN)
++
++test.shared: bin.shared testbin.shared
++ ./test/test.sh ./test $(BIN) $(TESTBIN)
++
+ dist: $(TARFILE)
+
+ $(TARFILE): $(DISTFILES)
+@@ -57,14 +72,15 @@ $(TARFILE): $(DISTFILES)
+ rm -rf $(TARNAME)
+ -shasum $(TARFILE)
+
+-install: $(BIN) pngquant.1
++install: $(BIN) $(BIN).1
+ -mkdir -p '$(BINPREFIX)'
+ -mkdir -p '$(MANPREFIX)/man1'
+ install -m 0755 -p '$(BIN)' '$(BINPREFIX)/$(BIN)'
+- cp pngquant.1 '$(MANPREFIX)/man1/'
++ install -m 0644 -p '$(BIN).1' '$(MANPREFIX)/man1/'
+
+ uninstall:
+ rm -f '$(BINPREFIX)/$(BIN)'
++ rm -f '$(MANPREFIX)/man1/$(BIN).1'
+
+ clean:
+ $(MAKE) -C lib clean
+diff --git a/README.md b/README.md
+index cbb3e6b..2ddb95d 100644
+--- a/README.md
++++ b/README.md
+@@ -1,11 +1,11 @@
+ #pngquant 2
+
+-This is the official `pngquant` and `libimagequant`.
++[This](https://github.com/pornel/pngquant) is the official `pngquant` and `libimagequant`.
+
+-[pngquant](http://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
+-Such images are compatible with all modern browsers, and a special compatibility setting exists which helps transparency degrade well in Internet Explorer 6.
++[pngquant](https://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
++Such images are fully standards-compliant and are supported by all web browsers.
+
+-Quantized files are often 40-70% smaller than their 24/32-bit version.
++Quantized files are often 60-80% smaller than their 24/32-bit versions.
+
+ This utility works on Linux, Mac OS X and Windows.
+
+@@ -14,7 +14,7 @@ This utility works on Linux, Mac OS X and Windows.
+ - batch conversion of multiple files: `pngquant *.png`
+ - Unix-style stdin/stdout chaining: `… | pngquant - | …`
+
+-To further reduce file size, try [optipng](http://optipng.sourceforge.net) or [ImageOptim](http://imageoptim.pornel.net).
++To further reduce file size, try [optipng](http://optipng.sourceforge.net) or [ImageOptim](https://imageoptim.com).
+
+ ##Improvements since 1.0
+
+@@ -28,16 +28,16 @@ Generated files are both smaller and look much better.
+ - feedback loop that repeats median cut for poorly quantized colors
+ - additional colormap improvement using Voronoi iteration
+ - supports much larger number of colors in input images without degradation of quality
+- - gamma correction (output is always generated with gamma 2.2 for web compatibility)
++ - gamma correction and optional color profile support (output is always in gamma 2.2 for web compatibility)
+
+ * More flexible commandline usage
+
+- - number of colors defaults to 256
++ - number of colors defaults to 256, and can be set automatically with the `--quality` switch
+ - long options and standard switches like `--` and `-` are allowed
+
+ * Refactored and modernised code
+
+- - C99 with no workarounds for old systems
++ - C99 with no workarounds for legacy systems or compilers ([apart from Visual Studio](https://github.com/pornel/pngquant/tree/msvc))
+ - floating-point math used throughout
+ - Intel SSE optimisations
+ - multicore support via OpenMP
+@@ -75,7 +75,7 @@ Disables Floyd-Steinberg dithering.
+
+ ###`--floyd=0.5`
+
+-Controls level of dithering (0 = none, 1 = full).
++Controls level of dithering (0 = none, 1 = full). Note that the `=` character is required.
+
+ ###`--posterize bits`
+
+diff --git a/configure b/configure
+index 99cf518..12bbb7b 100755
+--- a/configure
++++ b/configure
+@@ -40,8 +40,8 @@ for i in "$@"; do
+ help "--with-lcms2/--without-lcms2 compile with color profile support"
+ if [[ "$OSTYPE" =~ "darwin" ]]; then
+ help "--with-cocoa/--without-cocoa use Cocoa framework to read images"
+- help "--with-libpng=
search for libpng in directory"
+ fi
++ help "--with-libpng= search for libpng in directory"
+ echo
+ help "CC= use given compiler command"
+ help "CFLAGS= pass options to the compiler"
+@@ -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
+@@ -308,7 +307,13 @@ if [[ "$OSTYPE" =~ "darwin" ]]; then
+ fi
+
+ # pairs of possible *.h and lib*.so locations
+-DIRS=("/usr/local/include /usr/local/lib"
++DIRS=()
++
++if which -s libpng-config; then
++ DIRS+=("$(libpng-config --prefix) $(libpng-config --libdir)")
++fi
++
++DIRS+=("/usr/local/include /usr/local/lib"
+ "/usr/include /usr/lib"
+ "/opt/local/include /opt/local/lib" # macports
+ )
+diff --git a/lib/Makefile b/lib/Makefile
+index e4c5693..99448ce 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -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
+@@ -34,7 +35,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
+
+@@ -49,7 +51,7 @@ $(TARFILE): $(DISTFILES)
+ -shasum $(TARFILE)
+
+ clean:
+- rm -f $(OBJS) $(SHAREDOBJS) $(SHAREDLIB) $(STATICLIB) $(TARFILE) $(DLL) $(DLLIMP) $(DLLDEF)
++ rm -f $(OBJS) $(SHAREDOBJS) $(SHAREDLIB).$(SOVER) $(SHAREDLIB) $(STATICLIB) $(TARFILE) $(DLL) $(DLLIMP) $(DLLDEF)
+
+ distclean: clean
+ rm -f config.mk
diff --git a/pngquant-2.5.1_fix-Makefile.patch b/pngquant-2.5.1_fix-Makefile.patch
deleted file mode 100644
index 6bd4eb7..0000000
--- a/pngquant-2.5.1_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-08-03 00:05:09.000000000 +0100
-+++ ./Makefile 2015-08-27 22:26:01.956610053 +0100
-@@ -12,6 +12,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)
-@@ -32,12 +33,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 $@
-
- $(TESTBIN): test/test.o $(STATICLIB)
-@@ -68,7 +74,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
deleted file mode 100644
index a513a0d..0000000
--- a/pngquant-2.5.2-fix_configure.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-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 7361fe6..fcb06f6 100644
--- a/pngquant.spec
+++ b/pngquant.spec
@@ -5,7 +5,7 @@
Name: pngquant
Version: 2.5.2
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: PNG quantization tool for reducing image file size
License: BSD with advertising
@@ -13,8 +13,9 @@ License: BSD with advertising
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
+#wget https://github.com/pornel/pngquant/compare/2.5.2...master.diff
+#my upstreamed patches ...
+Patch2: 2.5.2...master.diff
BuildRequires: libpng-devel >= 1.2.46-1
BuildRequires: zlib-devel >= 1.2.3-1
@@ -56,53 +57,33 @@ There is also some brief API-documentation.
%prep
%setup -q
-%patch0 -p1 -b .fix_makefile
-%patch1 -p1 -b .fix_configure
+%patch2 -p1 -b .master
rm -f lib/configure
%build
%configure
-make %{?_smp_mflags} PREFIX=%{_prefix}
-
-# build testsuite
-pushd test
-gcc -std=c99 $CFLAGS $LDFLAGS \
- -L../lib -limagequant \
- -o test test.c
-popd
+%make_build bin.shared
%install
-mkdir -p %{buildroot}%{_includedir}/imagequant \
- %{buildroot}%{_bindir} \
- %{buildroot}%{_libdir} \
- %{buildroot}%{_mandir}/man1
+%make_install
-make install DESTDIR=%{buildroot} PREFIX=%{_prefix}
+mkdir -p %{buildroot}%{_includedir}/imagequant \
+ %{buildroot}%{_libdir}
# install libimagequant
install -pm 0755 lib/%{libname}.so.0 \
%{buildroot}%{_libdir}
ln -fs %{libname}.so.0 %{buildroot}%{_libdir}/%{libname}.so
+
install -pm 0644 lib/*.h \
%{buildroot}%{_includedir}/imagequant
-# install man-page for %%{name}
-install -pm 0644 %{name}.1 \
- %{buildroot}/%{_mandir}/man1/%{name}.1
-
-# install the binary
-install -pm 0755 %{name} \
- %{buildroot}/%{_bindir}/%{name}
-
-
%check
# needed by ld / testsuite to find libimagequant
export LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH"
-pushd test
-./test.sh . ../pngquant ./test
-popd
+make test.shared
%post -n %{libname} -p /sbin/ldconfig
@@ -130,6 +111,9 @@ popd
%changelog
+* Wed Jan 20 2016 Sérgio Basto - 2.5.2-6
+- Patches from here are upstreamed.
+
* Sat Dec 19 2015 Sérgio Basto - 2.5.2-5
- Following https://fedoraproject.org/wiki/EPEL:Packaging#The_.25license_tag