SDL_image and mingw32

Hi,
Has anyone managed to successfully compile sdl, sdl_image and the relevant
dependencies (zlib, libpng and libjpeg) on MinGW as DLLs? I’ve spent the best
part of two days trying to get everything working, and all I’ve managed to do
is waste 100MB of hard drive space.
Ordinarily I’d use the binaries from libsdl.org, but the PNG loader seems
to be bugged - if I try and load a PNG onto an SDL surface, my program
segfaults.
Has anyone got a set of patches/makefiles (or even a HOWTO) that will allow
me to compile libsdl for mingw32, preferably some that don’t involve the use
of Visual C++?

Thanks.–
Phil. | Acorn Risc PC600 Mk3, SA202, 64MB, 6GB,
philpem at philpem.me.uk | ViewFinder, 10BaseT Ethernet, 2-slice,
http://www.philpem.me.uk/ | 48xCD, ARCINv6c IDE, SCSI
Failsafe - blows every part of the circuit except the fuse