This will download libpng from the official "git" repository and build it in your "libpng" directory.
git clone https://github.com/glennrp/libpng.git libpng
cd libpng
./autogen.sh
./configure [--prefix=/path]
make install
where "/path" points to the installation directory where you want to put the libpng "lib", "include", and "bin" subdirectories.