BUILD: Fix libpng detection when compiled as shared library with zlib.

This was breaking AmigaOS4 builds for the porter as his libpng was built
as a shared library depending on zlib. This should be safe for static
builds as well.