Description: Autogenerated patch header for a single-debian-patch file.
 The delta against upstream is either kept as a single patch, or maintained
 in some VCS, and exported as a single patch instead of more manageable
 atomic patches.
Forwarded: not-needed

---
--- pigz-2.8.orig/Makefile
+++ pigz-2.8/Makefile
@@ -1,13 +1,27 @@
-CC=gcc
-CFLAGS=-O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual
-LDFLAGS=
+CC?=gcc
+CFLAGS?=-O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual
+LDFLAGS?=
 # CFLAGS=-O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -g -fsanitize=thread
 # LDFLAGS=-g -fsanitize=thread
 # CFLAGS=-O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -g -fsanitize=address
 # LDFLAGS=-g -fsanitize=address
-LIBS=-lm -lpthread -lz
-ZOPFLI=zopfli/src/zopfli/
-ZOP=deflate.o blocksplitter.o tree.o lz77.o cache.o hash.o util.o squeeze.o katajainen.o symbols.o
+LIBS?=-lm -lpthread -lz
+
+# Optional: use system-installed zopfli
+# Usage: make ZOPFLI_PREFIX=/usr
+ifneq ($(ZOPFLI_PREFIX),)
+    ZOP=
+    LIBS+= -lzopfli
+    CFLAGS+= -I$(ZOPFLI_PREFIX)/include
+    LDFLAGS+= -L$(ZOPFLI_PREFIX)/lib
+		# to satisfy Makefile dependencies in any case
+    ZOPFLI=$(ZOPFLI_PREFIX)/include/zopfli/
+else
+# Use bundled sources
+    ZOPFLI=zopfli/src/zopfli/
+    CFLAGS+= -Izopfli/src
+    ZOP=deflate.o blocksplitter.o tree.o lz77.o cache.o hash.o util.o squeeze.o katajainen.o symbols.o
+endif
 
 # use gcc and gmake on Solaris
 
--- pigz-2.8.orig/README
+++ pigz-2.8/README
@@ -22,6 +22,10 @@ recommended, which reduces the overhead
 latest version of zlib at http://zlib.net/ .  You can look in pigz.c for the
 change history.
 
+A preinstalled version of the Zopfli library can be used, this is achievable
+with a make option like ZOPFLI_PREFIX=/usr/local . The build directorry should
+be cleaned ("make clean") when this option is added or removed.
+
 Questions, comments, bug reports, fixes, etc. can be emailed to Mark at his
 address in the license below.
 
--- pigz-2.8.orig/pigz.c
+++ pigz-2.8/pigz.c
@@ -432,7 +432,7 @@
 #endif
 
 #ifndef NOZOPFLI
-#  include "zopfli/src/zopfli/deflate.h"    // ZopfliDeflatePart(),
+#  include "zopfli/deflate.h"    // ZopfliDeflatePart(),
                                             // ZopfliInitOptions(),
                                             // ZopfliOptions
 #endif
@@ -4292,15 +4292,15 @@ local char *helptext[] = {
 };
 
 // Display the help text above.
-local void help(void) {
+local void help(FILE* stdtgt, int rc) {
     int n;
 
     if (g.verbosity == 0)
         return;
     for (n = 0; n < (int)(sizeof(helptext) / sizeof(char *)); n++)
-        fprintf(stderr, "%s\n", helptext[n]);
-    fflush(stderr);
-    exit(0);
+        fprintf(stdtgt, "%s\n", helptext[n]);
+    fflush(stdtgt);
+    exit(rc);
 }
 
 #ifndef NOTHREAD
@@ -4513,7 +4513,7 @@ local int option(char *arg) {
             case 'c':  g.pipeout = 1;  break;
             case 'd':  if (!g.decode) g.headis >>= 2;  g.decode = 1;  break;
             case 'f':  g.force = 1;  break;
-            case 'h':  help();  break;
+            case 'h':  help(stdout, EXIT_SUCCESS);  break;
             case 'i':  g.setdict = 0;  break;
             case 'k':  g.keep = 1;  break;
             case 'l':  g.list = 1;  break;
@@ -4697,7 +4697,7 @@ int main(int argc, char **argv) {
 
         // if no arguments and compressed data to/from terminal, show help
         if (argc < 2 && isatty(g.decode ? 0 : 1))
-            help();
+            help(stderr, EXIT_FAILURE);
 
         // process all command-line options first
         nop = argc;
