I'm having some trouble building libpng with a zlib newer than the system's zlib. My system has zlib 1.2.7 installed. But I want to build libpng against the latest zlib which I have built in a separate directory. So I'm doing this:
cd zlib-1.2.13
./configure
make
cd ../libpng-1.6.40
export CFLAGS=-I../zlib-1.2.13
export LDFLAGS=-L../zlib-1.2.13
./configure
But still, in the pnglibconf.h generated by configure, PNG_ZLIB_VERNUM is defined as 0x1270, i.e. zlib 1.2.7 - the system's zlib version. What do I need to do to tell libpng's configure to use zlib 1.2.13 instead? As you can see above, I've set CFLAGS and LDFLAGS to point to zlib-1.2.13 but it doesn't seem to work. It still uses the system's zlib.
From the documentation: