-AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed]))
-
-case $host_os in
- aix*)
- LIBPNG_DEFINES="-DPNG_CONFIGURE_LIBPNG -D_ALL_SOURCE";;
- *)
- LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG;;
-esac
+AC_ARG_WITH(zlib-prefix,
+ AC_HELP_STRING([--with-zlib-prefix],
+ [prefix that may have been used in installed zlib]),
+ [ZPREFIX=${withval}],
+ [ZPREFIX='z_'])
+AC_CHECK_LIB(z, zlibVersion, ,
+ AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, ,
+ AC_ERROR([zlib not installed])))
+
+# The following is for pngvalid, to ensure it catches FP errors even on
+# platforms that don't enable FP exceptions, the function appears in the math
+# library (typically), it's not an error if it is not found.
+AC_CHECK_LIB([m], [feenableexcept])
+AC_CHECK_FUNCS([feenableexcept])
+
+LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG