To build pngquant from source on Mac OS X and most Linux distributions, simply run:
$ make
It will create pngquant executable in the current directory. If you'd like to install it system-wide:
$ sudo make install
By default it will be installed in /usr/local/bin. To install it in another
directory set PREFIX or DESTDIR environmental variables.
pngquant uses GNU Makefile. To compile on FreeBSD you will need to use gmake, and on Windows the MinGW compiler (MSVC does not support C99).
If you have custom libpng and zlib compiled, you can specify their paths:
$ CUSTOMLIBPNG=/path/to/libpng/ CUSTOMZLIB=/path/to/zlib/ make
Alternatively, you can build your own versions in ../zlib and ../libpng directories. Use this only if you can't get your system's libpng/zlib to work.
Download the zlib source code from: http://www.zlib.net/
$ cd ..
$ wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.5.tar.gz?download
Unpack it into the parent directory of the 'pngquant' directory and rename it to 'zlib' - e.g.:
$ tar zxf zlib-1.2.5.tar.gz
$ mv zlib-1.2.5 zlib
Build it:
$ make
Download the libpng source code from: http://www.libpng.org/pub/png/libpng.html - e.g.:
$ cd ..
$ wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.46.tar.gz?download
Unpack it into the parent directory of the 'pngquant' directory and rename it to 'libpng' - e.g.:
$ tar zxf libpng-1.2.46.tar.gz
$ mv libpng-1.2.46 libpng
Build libpng:
$ cd libpng
$ ./configure && make
Go back to the pngquant directory and make using the Makefile make file:
$ cd ../pngquant/
$ make
pngquant will use SSE2 instructions only when compiled for x86-64. If you want
to enable SSE2 optimisation on 32-bit Intel, add -DUSE_SSE=1 to CFLAGS.
$ make openmp
This makes pngquant faster in wall-clock time on multicore machines when one image at a time is processed.
However, it significantly increases total CPU time used, and thus it's not recommended for server-side and parallelized batch jobs which run many pngquant instances at a time.