AC_ARG_WITH(png-include, [  --with-png-include=DIR   PNG includes are in DIR], PNG_INC_DIR=$withval, PNG_INC_DIR="/usr/include")
AC_ARG_WITH(png-lib, [  --with-png-lib=DIR	  PNG libraries are in DIR], PNG_LIB_DIR=$withval, PNG_LIB_DIR="/usr/lib")

AC_ARG_ENABLE(pngstatic, [  --enable-png-static     link static with libpng.a], [tcl_ok=$enableval], [tcl_ok=$1])


AC_MSG_CHECKING([for png header])
if test ! -f ${PNG_INC_DIR}/png.h ; then
    AC_MSG_ERROR(Cannot find png.h in $PNG_INC_DIR use -with-png-include=?)
fi
AC_MSG_RESULT([yes])

TEA_ADD_INCLUDES([-I ${PNG_INC_DIR}])


AC_MSG_CHECKING([for libpng lib])
if test "$tcl_ok" = "yes"; then
    if test ! -f ${PNG_LIB_DIR}/libpng.a ; then
    	AC_MSG_ERROR(Cannot find libpng.a in $PNG_LIB_DIR use --with-png-lib=?)
    fi
else 
    if test ! -f ${PNG_LIB_DIR}/libpng${TCL_SHLIB_SUFFIX} ; then
    	AC_MSG_ERROR(Cannot find libpng${TCL_SHLIB_SUFFIX} in $PNG_LIB_DIR use --with-png-lib=?)
    fi
fi
AC_MSG_RESULT([yes])

if test "$tcl_ok" = "yes"; then
    TEA_ADD_LIBS([${PNG_LIB_DIR}/libpng.a]"
else
    TEA_ADD_LIBS([-L${PNG_LIB_DIR} -lpng])
fi
