From: Paul Eggert <eggert@cs.ucla.edu>
To: Werner LEMBERG <wl@gnu.org>
Cc: 30431@debbugs.gnu.org
Subject: bug#30431: 27.0.50; "Work even if libpng is install in /usr/local" causes build failure
Date: Mon, 12 Feb 2018 16:42:45 -0800 [thread overview]
Message-ID: <0e2b60fc-396d-d802-a090-7b856edc008c@cs.ucla.edu> (raw)
In-Reply-To: <20180212.223132.979071447450060549.wl@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 364 bytes --]
On 02/12/2018 01:31 PM, Werner LEMBERG wrote:
>>> - if test $HAVE_PNG = no; then
>>> + if test $HAVE_PNG = yes; then
>>> + LIBPNG="$PNG_LIBS"
>>> + else
>> Thanks, Glenn. Werner, does that work for you?
> It works just fine, thanks!
>
>
> Werner
Thanks for checking. I installed the attached patch, which attempts to
implement Glenn's suggestion.
[-- Attachment #2: 0001-Work-if-libpng-is-in-usr-local-2nd-try.patch --]
[-- Type: text/x-patch, Size: 3726 bytes --]
From 52d34fbc84c1d87a41c435a0db9494d768ebc667 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 12 Feb 2018 16:39:56 -0800
Subject: [PATCH] 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.
---
configure.ac | 75 ++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 42 insertions(+), 33 deletions(-)
diff --git a/configure.ac b/configure.ac
index f2a8332d71..cb452e053b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3612,39 +3612,48 @@ AC_DEFUN
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
--
2.14.3
prev parent reply other threads:[~2018-02-13 0:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-12 6:18 bug#30431: 27.0.50; "Work even if libpng is install in /usr/local" causes build failure Robert Cochran
2018-02-12 15:39 ` Michael Heerdegen
2018-02-12 16:07 ` Michael Heerdegen
2018-02-12 19:13 ` Glenn Morris
2018-02-12 19:42 ` Paul Eggert
2018-02-12 21:31 ` Werner LEMBERG
2018-02-13 0:42 ` Paul Eggert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e2b60fc-396d-d802-a090-7b856edc008c@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=30431@debbugs.gnu.org \
--cc=wl@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.