compiling gnuplot 4.4.3 on Mac OS X 10.6; libpng related errors

I compiled gnuplot 4.4.3 on Mac OS X Snow Leopard on an Intel machine, Darwin Kernel Version 10.8.0 which seemed to go ok, but when trying to generate a png:
libpng warning: Application was compiled with png.h from libpng-1.5.5
libpng warning: Application  is  running with png.c from libpng-1.2.44
gd-png:  fatal libpng error: Incompatible libpng version in application and library
Segmentation fault
A problem mentioned on this blog.
http://www.dansanderson.com/blog/2011/03/installing-gnuplot-on-mac-os-x-106.html

otool (darwin version of ldd) shows gnuplot is linked to both versions of libpng, the one which comes with OS X in /usr/X11/lib and the one I installed in /usr/local/lib

otool -L /usr/local/bin/gnuplot | grep png
	/usr/X11/lib/libpng12.0.dylib (compatibility version 45.0.0, current version 45.0.0)
	/usr/local/lib/libpng15.15.dylib (compatibility version 21.0.0, current version 21.0.0)
I tried numerous things to get gnuplot to build with only one library or the other, but nothing worked until I temporarily moved the libpng12-config file while I ran ./configure and built gnuplot.
I noticed ./configure was finding it due to these lines output by ./configure:
checking for libpng12-config... /usr/X11/bin/libpng12-config
checking for libpng-config... /usr/local/bin/libpng-config
temporarily moving the libpng12-config:
sudo mv /usr/X11/bin/libpng12-config /tmp/
./configure, make, sudo make install
works without the libpng error
then, after building:
sudo mv /tmp/libpng12-config /usr/X11/bin/libpng12-config
now gnuplot is only linked to 1.5 libpng
otool -L /usr/local/bin/gnuplot | grep png
	/usr/local/lib/libpng15.15.dylib (compatibility version 21.0.0, current version 21.0.0)

-- linux_macosx_hints_etc page