Previously we would unconditionally link with -lpng leading to build
failures on systems without libpng.
dnl ==================
dnl libpng
-AC_CHECK_LIB([png], [png_write_info], [have_libpng=yes], [have_libpng=no])
+PKG_CHECK_MODULES(PNG, [libpng], have_libpng=yes, have_libpng=no)
if test x$have_libpng = xyes; then
AC_DEFINE([HAVE_LIBPNG], [1], [Whether we have libpng])
AM_CFLAGS = @OPENMP_CFLAGS@
AM_LDFLAGS = @OPENMP_CFLAGS@ @TESTPROGS_EXTRA_LDFLAGS@
-LDADD = $(top_builddir)/pixman/libpixman-1.la -lm -lpng
-INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman
+LDADD = $(top_builddir)/pixman/libpixman-1.la -lm @PNG_LIBS@
+INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman @PNG_CFLAGS@
TESTPROGRAMS = \
a1-trap-test \