diff options
| author | Paul Eggert | 2018-02-12 16:39:56 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-02-12 16:41:08 -0800 |
| commit | b8c415180895f155b4aaebd9cae65124c95b0c98 (patch) | |
| tree | d1742c6bf4846c71c7993e673477e63d0a7cc461 | |
| parent | 3a718ffca097b35218c3e041a94adff937f3052f (diff) | |
| download | emacs-b8c415180895f155b4aaebd9cae65124c95b0c98.tar.gz emacs-b8c415180895f155b4aaebd9cae65124c95b0c98.zip | |
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.
| -rw-r--r-- | configure.ac | 75 |
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 | |||
| 3612 | if test "$opsys" = mingw32; then | 3612 | if test "$opsys" = mingw32; then |
| 3613 | AC_CHECK_HEADER([png.h], [HAVE_PNG=yes]) | 3613 | AC_CHECK_HEADER([png.h], [HAVE_PNG=yes]) |
| 3614 | elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then | 3614 | elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then |
| 3615 | AC_MSG_CHECKING([for png]) | 3615 | EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0]) |
| 3616 | png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` && | 3616 | if test $HAVE_PNG = yes; then |
| 3617 | png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || { | 3617 | LIBPNG=$PNG_LIBS |
| 3618 | # libpng-config does not work; configure by hand. | 3618 | else |
| 3619 | # Debian unstable as of July 2003 has multiple libpngs, and puts png.h | 3619 | # Test old way in case pkg-config doesn't have it (older machines). |
| 3620 | # in /usr/include/libpng. | 3620 | AC_MSG_CHECKING([for libpng not configured by pkg-config]) |
| 3621 | if test -r /usr/include/libpng/png.h && | 3621 | |
| 3622 | test ! -r /usr/include/png.h; then | 3622 | png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` && |
| 3623 | png_cflags=-I/usr/include/libpng | 3623 | png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || { |
| 3624 | else | 3624 | # libpng-config does not work; configure by hand. |
| 3625 | png_cflags= | 3625 | # Debian unstable as of July 2003 has multiple libpngs, and puts png.h |
| 3626 | fi | 3626 | # in /usr/include/libpng. |
| 3627 | png_ldflags='-lpng' | 3627 | if test -r /usr/include/libpng/png.h && |
| 3628 | } | 3628 | test ! -r /usr/include/png.h; then |
| 3629 | SAVE_CFLAGS=$CFLAGS | 3629 | png_cflags=-I/usr/include/libpng |
| 3630 | SAVE_LIBS=$LIBS | 3630 | else |
| 3631 | CFLAGS="$CFLAGS $png_cflags" | 3631 | png_cflags= |
| 3632 | LIBS="$png_ldflags -lz -lm $LIBS" | 3632 | fi |
| 3633 | AC_LINK_IFELSE( | 3633 | png_ldflags='-lpng' |
| 3634 | [AC_LANG_PROGRAM([[#include <png.h>]], | 3634 | } |
| 3635 | [[return !png_get_channels (0, 0);]])], | 3635 | SAVE_CFLAGS=$CFLAGS |
| 3636 | [HAVE_PNG=yes | 3636 | SAVE_LIBS=$LIBS |
| 3637 | PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"` | 3637 | CFLAGS="$CFLAGS $png_cflags" |
| 3638 | LIBPNG=$png_ldflags | 3638 | LIBS="$png_ldflags -lz -lm $LIBS" |
| 3639 | # $LIBPNG requires explicit -lz in some cases. | 3639 | AC_LINK_IFELSE( |
| 3640 | # We don't know what those cases are, exactly, so play it safe and | 3640 | [AC_LANG_PROGRAM([[#include <png.h>]], |
| 3641 | # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ. | 3641 | [[return !png_get_channels (0, 0);]])], |
| 3642 | if test -n "$LIBPNG" && test -z "$LIBZ"; then | 3642 | [HAVE_PNG=yes |
| 3643 | LIBPNG="$LIBPNG -lz" | 3643 | PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"` |
| 3644 | fi]) | 3644 | LIBPNG=$png_ldflags]) |
| 3645 | CFLAGS=$SAVE_CFLAGS | 3645 | CFLAGS=$SAVE_CFLAGS |
| 3646 | LIBS=$SAVE_LIBS | 3646 | LIBS=$SAVE_LIBS |
| 3647 | AC_MSG_RESULT([$HAVE_PNG]) | 3647 | AC_MSG_RESULT([$HAVE_PNG]) |
| 3648 | fi | ||
| 3649 | |||
| 3650 | # $LIBPNG requires explicit -lz in some cases. | ||
| 3651 | # We don't know what those cases are, exactly, so play it safe and | ||
| 3652 | # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ. | ||
| 3653 | case " $LIBPNG ",$LIBZ in | ||
| 3654 | *' -lz '*, | *' ',?*) ;; | ||
| 3655 | *) LIBPNG="$LIBPNG -lz" ;; | ||
| 3656 | esac | ||
| 3648 | fi | 3657 | fi |
| 3649 | fi | 3658 | fi |
| 3650 | if test $HAVE_PNG = yes; then | 3659 | if test $HAVE_PNG = yes; then |