Fixed building against libpng 1.5 and above.

Gentoo's patch (http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-editors/ted/files/ted-2.21-libpng15.patch) has been applied manually.
Fixed building against GTK+.
Fixed building against musl.