Commit 0d1b87f9 authored by Paul Eggert's avatar Paul Eggert

Port recent libpng changes to hosts with missing png.h.

* configure.ac (HAVE_PNG): Port to platforms where libpng-config
succeeds but png.h is absent, by testing libpng-config's output
rather than trusting it.  I ran into this problem when building
Emacs trunk on a Solaris 10 host.
parent 8208d2bf
2014-05-18 Paul Eggert <eggert@cs.ucla.edu>
Port recent libpng changes to hosts with missing png.h.
* configure.ac (HAVE_PNG): Port to platforms where libpng-config
succeeds but png.h is absent, by testing libpng-config's output
rather than trusting it. I ran into this problem when building
Emacs trunk on a Solaris 10 host.
2014-05-17 Paul Eggert <eggert@cs.ucla.edu> 2014-05-17 Paul Eggert <eggert@cs.ucla.edu>
Assume C99 or later (Bug#17487). Assume C99 or later (Bug#17487).
......
...@@ -3064,31 +3064,40 @@ elif test "${with_png}" != no; then ...@@ -3064,31 +3064,40 @@ elif test "${with_png}" != no; then
# mingw32 loads the library dynamically. # mingw32 loads the library dynamically.
if test "$opsys" = mingw32; then if test "$opsys" = mingw32; then
AC_CHECK_HEADER([png.h], [HAVE_PNG=yes]) AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
elif png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
png_libs=`(libpng-config --libs) 2>&AS_MESSAGE_LOG_FD`
then
HAVE_PNG=yes
PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
LIBPNG=$png_libs
else else
# libpng-config does not work; configure by hand. AC_MSG_CHECKING([for png])
# Debian unstable as of July 2003 has multiple libpngs, and puts png.h png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
# in /usr/include/libpng. png_libs=`(libpng-config --libs) 2>&AS_MESSAGE_LOG_FD` || {
AC_CHECK_HEADERS([png.h libpng/png.h], # libpng-config does not work; configure by hand.
[AC_CHECK_LIB([png], [png_get_channels], # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
[HAVE_PNG=yes # in /usr/include/libpng.
LIBPNG='-lpng' if test -r /usr/include/libpng/png.h &&
if test "$ac_cv_header_png_h" != yes; then test ! -r /usr/include/png.h; then
PNG_CFLAGS=-I/usr/include/libpng png_cflags=-I/usr/include/libpng
fi else
break], png_cflags=
[], [-lz -lm])]) fi
fi png_libs='-lpng'
# $LIBPNG requires explicit -lz in some cases. }
# We don't know what those cases are, exactly, so play it safe and SAVE_CFLAGS=$CFLAGS
# append -lz to any nonempty $LIBPNG, unless we're already using LIBZ. SAVE_LIBS=$LIBS
if test -n "$LIBPNG" && test -z "$LIBZ"; then CFLAGS="$CFLAGS $png_cflags"
LIBPNG="$LIBPNG -lz" LIBS="$png_libs -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_libs
# $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])
fi fi
fi fi
if test $HAVE_PNG = yes; then if test $HAVE_PNG = yes; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment