02b5c67
diff --git a/Makefile b/Makefile
02b5c67
index 3d41182..0fa7517 100644
02b5c67
--- a/Makefile
02b5c67
+++ b/Makefile
02b5c67
@@ -12,6 +12,7 @@ OBJS += $(COCOA_OBJS)
02b5c67
 endif
02b5c67
 
02b5c67
 STATICLIB = lib/libimagequant.a
02b5c67
+SHAREDLIB = lib/libimagequant.so
02b5c67
 
02b5c67
 DISTFILES = *.[chm] pngquant.1 Makefile configure README.md INSTALL CHANGELOG COPYRIGHT
02b5c67
 TARNAME = pngquant-$(VERSION)
02b5c67
@@ -32,6 +33,11 @@ staticlib:
02b5c67
 
02b5c67
 $(STATICLIB): config.mk staticlib
02b5c67
 
02b5c67
+sharedlib:
02b5c67
+	$(MAKE) -C lib shared
02b5c67
+
02b5c67
+$(SHAREDLIB): config.mk sharedlib
02b5c67
+
02b5c67
 $(OBJS): $(wildcard *.h) config.mk
02b5c67
 
02b5c67
 rwpng_cocoa.o: rwpng_cocoa.m
02b5c67
@@ -46,6 +52,15 @@ $(TESTBIN): test/test.o $(STATICLIB)
02b5c67
 test: $(BIN) $(TESTBIN)
02b5c67
 	./test/test.sh ./test $(BIN) $(TESTBIN)
02b5c67
 
02b5c67
+bin.shared: $(OBJS) $(SHAREDLIB)
02b5c67
+	$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(BIN)
02b5c67
+
02b5c67
+testbin.shared: test/test.o $(SHAREDLIB)
02b5c67
+	$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(TESTBIN)
02b5c67
+
02b5c67
+test.shared: bin.shared testbin.shared
02b5c67
+	./test/test.sh ./test $(BIN) $(TESTBIN)
02b5c67
+
02b5c67
 dist: $(TARFILE)
02b5c67
 
02b5c67
 $(TARFILE): $(DISTFILES)
02b5c67
@@ -57,14 +72,15 @@ $(TARFILE): $(DISTFILES)
02b5c67
 	rm -rf $(TARNAME)
02b5c67
 	-shasum $(TARFILE)
02b5c67
 
02b5c67
-install: $(BIN) pngquant.1
02b5c67
+install: $(BIN) $(BIN).1
02b5c67
 	-mkdir -p '$(BINPREFIX)'
02b5c67
 	-mkdir -p '$(MANPREFIX)/man1'
02b5c67
 	install -m 0755 -p '$(BIN)' '$(BINPREFIX)/$(BIN)'
02b5c67
-	cp pngquant.1 '$(MANPREFIX)/man1/'
02b5c67
+	install -m 0644 -p '$(BIN).1' '$(MANPREFIX)/man1/'
02b5c67
 
02b5c67
 uninstall:
02b5c67
 	rm -f '$(BINPREFIX)/$(BIN)'
02b5c67
+	rm -f '$(MANPREFIX)/man1/$(BIN).1'
02b5c67
 
02b5c67
 clean:
02b5c67
 	$(MAKE) -C lib clean
02b5c67
diff --git a/README.md b/README.md
02b5c67
index cbb3e6b..2ddb95d 100644
02b5c67
--- a/README.md
02b5c67
+++ b/README.md
02b5c67
@@ -1,11 +1,11 @@
02b5c67
 #pngquant 2
02b5c67
 
02b5c67
-This is the official `pngquant` and `libimagequant`.
02b5c67
+[This](https://github.com/pornel/pngquant) is the official `pngquant` and `libimagequant`.
02b5c67
 
02b5c67
-[pngquant](http://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
02b5c67
-Such images are compatible with all modern browsers, and a special compatibility setting exists which helps transparency degrade well in Internet Explorer 6.
02b5c67
+[pngquant](https://pngquant.org) converts 24/32-bit RGBA PNGs to 8-bit palette with *alpha channel preserved*.
02b5c67
+Such images are fully standards-compliant and are supported by all web browsers.
02b5c67
 
02b5c67
-Quantized files are often 40-70% smaller than their 24/32-bit version.
02b5c67
+Quantized files are often 60-80% smaller than their 24/32-bit versions.
02b5c67
 
02b5c67
 This utility works on Linux, Mac OS X and Windows.
02b5c67
 
02b5c67
@@ -14,7 +14,7 @@ This utility works on Linux, Mac OS X and Windows.
02b5c67
 - batch conversion of multiple files: `pngquant *.png`
02b5c67
 - Unix-style stdin/stdout chaining: `… | pngquant - | …`
02b5c67
 
02b5c67
-To further reduce file size, try [optipng](http://optipng.sourceforge.net) or [ImageOptim](http://imageoptim.pornel.net).
02b5c67
+To further reduce file size, try [optipng](http://optipng.sourceforge.net) or [ImageOptim](https://imageoptim.com).
02b5c67
 
02b5c67
 ##Improvements since 1.0
02b5c67
 
02b5c67
@@ -28,16 +28,16 @@ Generated files are both smaller and look much better.
02b5c67
   - feedback loop that repeats median cut for poorly quantized colors
02b5c67
   - additional colormap improvement using Voronoi iteration
02b5c67
   - supports much larger number of colors in input images without degradation of quality
02b5c67
-  - gamma correction (output is always generated with gamma 2.2 for web compatibility)
02b5c67
+  - gamma correction and optional color profile support (output is always in gamma 2.2 for web compatibility)
02b5c67
 
02b5c67
 * More flexible commandline usage
02b5c67
 
02b5c67
-  - number of colors defaults to 256
02b5c67
+  - number of colors defaults to 256, and can be set automatically with the `--quality` switch
02b5c67
   - long options and standard switches like `--` and `-` are allowed
02b5c67
 
02b5c67
 * Refactored and modernised code
02b5c67
 
02b5c67
-  - C99 with no workarounds for old systems
02b5c67
+  - C99 with no workarounds for legacy systems or compilers ([apart from Visual Studio](https://github.com/pornel/pngquant/tree/msvc))
02b5c67
   - floating-point math used throughout
02b5c67
   - Intel SSE optimisations
02b5c67
   - multicore support via OpenMP
02b5c67
@@ -75,7 +75,7 @@ Disables Floyd-Steinberg dithering.
02b5c67
 
02b5c67
 ###`--floyd=0.5`
02b5c67
 
02b5c67
-Controls level of dithering (0 = none, 1 = full).
02b5c67
+Controls level of dithering (0 = none, 1 = full). Note that the `=` character is required.
02b5c67
 
02b5c67
 ###`--posterize bits`
02b5c67
 
02b5c67
diff --git a/configure b/configure
02b5c67
index 99cf518..12bbb7b 100755
02b5c67
--- a/configure
02b5c67
+++ b/configure
02b5c67
@@ -40,8 +40,8 @@ for i in "$@"; do
02b5c67
         help "--with-lcms2/--without-lcms2  compile with color profile support"
02b5c67
 if [[ "$OSTYPE" =~ "darwin" ]]; then
02b5c67
         help "--with-cocoa/--without-cocoa  use Cocoa framework to read images"
02b5c67
-        help "--with-libpng=<dir>           search for libpng in directory"
02b5c67
 fi
02b5c67
+        help "--with-libpng=<dir>           search for libpng in directory"
02b5c67
         echo
02b5c67
         help "CC=<compiler>                 use given compiler command"
02b5c67
         help "CFLAGS=<flags>                pass options to the compiler"
02b5c67
@@ -102,8 +102,7 @@ fi
02b5c67
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS ${i#*=}"
02b5c67
         ;;
02b5c67
     *)
02b5c67
-        echo "error: unknown switch ${i%%=*} (see $0 --help for the list)"
02b5c67
-        exit 1
02b5c67
+        echo "warning: unknown switch ${i%%=*} (see $0 --help for the list)"
02b5c67
         ;;
02b5c67
     esac
02b5c67
 done
02b5c67
@@ -308,7 +307,13 @@ if [[ "$OSTYPE" =~ "darwin" ]]; then
02b5c67
 fi
02b5c67
 
02b5c67
 # pairs of possible *.h and lib*.so locations
02b5c67
-DIRS=("/usr/local/include /usr/local/lib"
02b5c67
+DIRS=()
02b5c67
+
02b5c67
+if which -s libpng-config; then
02b5c67
+    DIRS+=("$(libpng-config --prefix) $(libpng-config --libdir)")
02b5c67
+fi
02b5c67
+
02b5c67
+DIRS+=("/usr/local/include /usr/local/lib"
02b5c67
       "/usr/include /usr/lib"
02b5c67
       "/opt/local/include /opt/local/lib" # macports
02b5c67
       )
02b5c67
diff --git a/lib/Makefile b/lib/Makefile
02b5c67
index e4c5693..99448ce 100644
02b5c67
--- a/lib/Makefile
02b5c67
+++ b/lib/Makefile
02b5c67
@@ -1,7 +1,8 @@
02b5c67
 -include config.mk
02b5c67
 
02b5c67
 STATICLIB=libimagequant.a
02b5c67
-SHAREDLIB=libimagequant.so.0
02b5c67
+SHAREDLIB=libimagequant.so
02b5c67
+SOVER=0
02b5c67
 
02b5c67
 DLL=libimagequant.dll
02b5c67
 DLLIMP=libimagequant_dll.a
02b5c67
@@ -34,7 +35,8 @@ $(SHAREDOBJS):
02b5c67
 	$(CC) -fPIC $(CFLAGS) -c $(@:.lo=.c) -o $@
02b5c67
 
02b5c67
 $(SHAREDLIB): $(SHAREDOBJS)
02b5c67
-	$(CC) -shared -o $@ $^ $(LDFLAGS)
02b5c67
+	$(CC) -shared -Wl,-soname,$(SHAREDLIB).$(SOVER) -o $(SHAREDLIB).$(SOVER) $^ $(LDFLAGS)
02b5c67
+	ln -fs $(SHAREDLIB).$(SOVER) $(SHAREDLIB)
02b5c67
 
02b5c67
 $(OBJS): $(wildcard *.h) config.mk
02b5c67
 
02b5c67
@@ -49,7 +51,7 @@ $(TARFILE): $(DISTFILES)
02b5c67
 	-shasum $(TARFILE)
02b5c67
 
02b5c67
 clean:
02b5c67
-	rm -f $(OBJS) $(SHAREDOBJS) $(SHAREDLIB) $(STATICLIB) $(TARFILE) $(DLL) $(DLLIMP) $(DLLDEF)
02b5c67
+	rm -f $(OBJS) $(SHAREDOBJS) $(SHAREDLIB).$(SOVER) $(SHAREDLIB) $(STATICLIB) $(TARFILE) $(DLL) $(DLLIMP) $(DLLDEF)
02b5c67
 
02b5c67
 distclean: clean
02b5c67
 	rm -f config.mk