see https://trac.sagemath.org/ticket/25818
--- a/configure	2018-07-10 18:26:57.462278000 +0000
+++ b/configure	2018-07-10 19:08:34.170278000 +0000
@@ -15488,49 +15488,67 @@
   cat >>confdefs.h <<_ACEOF
 #define HAVE_PNG_H 1
 _ACEOF
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpng" >&5
-$as_echo_n "checking for main in -lpng... " >&6; }
-if ${ac_cv_lib_png_main+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing png_sig_cmp" >&5
+$as_echo_n "checking for library containing png_sig_cmp... " >&6; }
+if ${ac_cv_search_png_sig_cmp+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpng  $LIBS"
+  ac_func_search_save_LIBS=$LIBS
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_sig_cmp ();
 int
 main ()
 {
-return main ();
+return png_sig_cmp ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  ac_cv_lib_png_main=yes
-else
-  ac_cv_lib_png_main=no
+for ac_lib in '' png16 png14 png12 png; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_search_png_sig_cmp=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+    conftest$ac_exeext
+  if ${ac_cv_search_png_sig_cmp+:} false; then :
+  break
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_main" >&5
-$as_echo "$ac_cv_lib_png_main" >&6; }
-if test "x$ac_cv_lib_png_main" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPNG 1
-_ACEOF
+done
+if ${ac_cv_search_png_sig_cmp+:} false; then :
 
-  LIBS="-lpng $LIBS"
+else
+  ac_cv_search_png_sig_cmp=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_png_sig_cmp" >&5
+$as_echo "$ac_cv_search_png_sig_cmp" >&6; }
+ac_res=$ac_cv_search_png_sig_cmp
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
 fi
 
 fi
 
 done
- fi
+
+fi
 
 
 
@@ -23154,7 +23172,7 @@
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C)  Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
