Add -lz to the ld flags when the user has chosen to link in zlib *statically*.