#!/bin/bash

# Configure script for readpng.
# We need to figure out just two things: whether we're under 32-bit or 64-bit Linux,
# and the ZLIB_VERNUM from zlib.h

echo -n "Detecting sizeof(void*)..."
if [ `uname -m` == x86_64 ]; then
	echo "8 bytes; setting output to ../lib/linux_x64/"
	PLATFORM=linux_x64
else
	echo "4 bytes; setting output to ../lib/linux_x86/"
	PLATFORM=linux_x86
fi
echo -n "Detecting zlib vernum..."
ZLIB_VERNUM=`cat /usr/include/zlib.h | grep ZLIB_VERNUM | sed 's/.*VERNUM //g'`
echo $ZLIB_VERNUM

echo "configure: creating Makefile"
cat Makefile.in | sed s/PLATFORM/$PLATFORM/g > Makefile
echo "configure: creating example/Makefile"
cat example/Makefile.in | sed s/PLATFORM/$PLATFORM/g > example/Makefile
echo "configure: creating png_zlib_vernum.h"
echo "#define PNG_ZLIB_VERNUM $ZLIB_VERNUM" > png_zlib_vernum.h
echo "Done. Now run 'make'."

