Blob Blame History Raw
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=<dir>           search for libpng in directory"
 fi
+        help "--with-libpng=<dir>           search for libpng in directory"
         echo
         help "CC=<compiler>                 use given compiler command"
         help "CFLAGS=<flags>                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