HDF5 using my own libz (zlib)

I am trying to use a newer version of zlib (which I compiled myself) with hdf5-1.8.20, using pgfortran. I’ve done like this (in tcsh):

setenv ZLIB /usr/local/src/zlib-1.2.11

setenv CPPFLAGS “-I$ZLIB/include”
setenv LDFLAGS “-L$ZLIB/lib”
setenv LD_LIBRARY_PATH $ZLIB/lib:$LD_LIBRARY_PATH # note: first in the list

./configure
–prefix=pwd
–enable-fortran
–with-zlib=/usr/local/zlib-1.2.11
>&! my.configure.out

I tried using LDFLAGS “-L$ZLIB/lib -lz” like I would have expected, but had to instead use sed after configure:

sed -i “s|-L/usr/local/src/zlib-1.2.11/lib|-L/usr/local/src/zlib-1.2.11/lib -lz|g” Makefile
sed -i “s|-lz -ldl -lm|-ldl -lm|g” Makefile

After compilation, it still appears that the executables will use the system’s (gcc) version of libz:

ldd bin/h5dump | grep libz

    libz.so.1 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so.1 (0x00007f41f6c9f000)

What am I doing wrong? /usr/local/src/zlib-1.2.11/lib is the first element in $LD_LIBRARY_PATH in my normal environment.

Bart