summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-02-12 16:39:56 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2018-02-12 16:41:08 -0800
commitb8c415180895f155b4aaebd9cae65124c95b0c98 (patch)
treed1742c6bf4846c71c7993e673477e63d0a7cc461 /configure.ac
parent3a718ffca097b35218c3e041a94adff937f3052f (diff)
downloademacs-b8c415180895f155b4aaebd9cae65124c95b0c98.tar.gz
Work if libpng is in /usr/local (2nd try)
Problem reported by Werner Lemberg in: https://lists.gnu.org/r/emacs-devel/2018-02/msg00304.html with a further fix suggested by Glenn Morris in Bug#30431#14. * configure.ac: Try pkg-config before libpng-config. Adjust LIBPNG accordingly, and append -lz regardless of whether it was pkg-config.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac75
1 files changed, 42 insertions, 33 deletions
diff --git a/configure.ac b/configure.ac
index f2a8332d71a..cb452e053be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3612,39 +3612,48 @@ elif test "${with_png}" != no; then
if test "$opsys" = mingw32; then
AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
- AC_MSG_CHECKING([for png])
- png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
- png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || {
- # libpng-config does not work; configure by hand.
- # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
- # in /usr/include/libpng.
- if test -r /usr/include/libpng/png.h &&
- test ! -r /usr/include/png.h; then
- png_cflags=-I/usr/include/libpng
- else
- png_cflags=
- fi
- png_ldflags='-lpng'
- }
- SAVE_CFLAGS=$CFLAGS
- SAVE_LIBS=$LIBS
- CFLAGS="$CFLAGS $png_cflags"
- LIBS="$png_ldflags -lz -lm $LIBS"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[#include <png.h>]],
- [[return !png_get_channels (0, 0);]])],
- [HAVE_PNG=yes
- PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
- LIBPNG=$png_ldflags
- # $LIBPNG requires explicit -lz in some cases.
- # We don't know what those cases are, exactly, so play it safe and
- # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
- if test -n "$LIBPNG" && test -z "$LIBZ"; then
- LIBPNG="$LIBPNG -lz"
- fi])
- CFLAGS=$SAVE_CFLAGS
- LIBS=$SAVE_LIBS
- AC_MSG_RESULT([$HAVE_PNG])
+ EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0])
+ if test $HAVE_PNG = yes; then
+ LIBPNG=$PNG_LIBS
+ else
+ # Test old way in case pkg-config doesn't have it (older machines).
+ AC_MSG_CHECKING([for libpng not configured by pkg-config])
+
+ png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
+ png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || {
+ # libpng-config does not work; configure by hand.
+ # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
+ # in /usr/include/libpng.
+ if test -r /usr/include/libpng/png.h &&
+ test ! -r /usr/include/png.h; then
+ png_cflags=-I/usr/include/libpng
+ else
+ png_cflags=
+ fi
+ png_ldflags='-lpng'
+ }
+ SAVE_CFLAGS=$CFLAGS
+ SAVE_LIBS=$LIBS
+ CFLAGS="$CFLAGS $png_cflags"
+ LIBS="$png_ldflags -lz -lm $LIBS"
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[#include <png.h>]],
+ [[return !png_get_channels (0, 0);]])],
+ [HAVE_PNG=yes
+ PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
+ LIBPNG=$png_ldflags])
+ CFLAGS=$SAVE_CFLAGS
+ LIBS=$SAVE_LIBS
+ AC_MSG_RESULT([$HAVE_PNG])
+ fi
+
+ # $LIBPNG requires explicit -lz in some cases.
+ # We don't know what those cases are, exactly, so play it safe and
+ # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
+ case " $LIBPNG ",$LIBZ in
+ *' -lz '*, | *' ',?*) ;;
+ *) LIBPNG="$LIBPNG -lz" ;;
+ esac
fi
fi
if test $HAVE_PNG = yes; then