aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2014-05-02 12:34:03 -0700
committerPaul Eggert2014-05-02 12:34:03 -0700
commit6f074205d30c6922db52fdf9a63b9e0467fd82c1 (patch)
treee739dc5474dbc555ff87c612bc4cc9b274890f1d
parentcb9af965374fd1537b1b82705642c5c03d04c4d2 (diff)
downloademacs-6f074205d30c6922db52fdf9a63b9e0467fd82c1.tar.gz
emacs-6f074205d30c6922db52fdf9a63b9e0467fd82c1.zip
Consult libpng-config more consistently.
* configure.ac (edit_cflags): Move this up and to the top level, so that PNG_CFLAGS can use it too. (PNG_CFLAGS): New var. (png_longjmp): Use PNG_CFLAGS when checking. (LIBPNG): Be consistent about -lpng16 etc; e.g., don't use -lpng16 in some places and -lpng in others. Test libpng-config's exit status. If it succeeds, use its output rather than appending -lz -lm. * src/Makefile.in (PNG_CFLAGS): New var. (ALL_CFLAGS): Use it. * src/image.c [HAVE_PNG]: Don't worry about <libpng/png.h>, as CFLAGS now handles this. Fixes: debbugs:17339
-rw-r--r--ChangeLog11
-rw-r--r--configure.ac99
-rw-r--r--src/ChangeLog8
-rw-r--r--src/Makefile.in2
-rw-r--r--src/image.c4
5 files changed, 67 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index c79e1b01976..5b583849bd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
12014-05-02 Paul Eggert <eggert@cs.ucla.edu>
2
3 Consult libpng-config more consistently (Bug#17339).
4 * configure.ac (edit_cflags): Move this up and to the top level,
5 so that PNG_CFLAGS can use it too.
6 (PNG_CFLAGS): New var.
7 (png_longjmp): Use PNG_CFLAGS when checking.
8 (LIBPNG): Be consistent about -lpng16 etc; e.g., don't use -lpng16
9 in some places and -lpng in others. Test libpng-config's exit
10 status. If it succeeds, use its output rather than appending -lz -lm.
11
12014-05-01 Glenn Morris <rgm@gnu.org> 122014-05-01 Glenn Morris <rgm@gnu.org>
2 13
3 * configure.ac (LIBPNG): Consult libpng-config for the precise 14 * configure.ac (LIBPNG): Consult libpng-config for the precise
diff --git a/configure.ac b/configure.ac
index 5aed265849e..ee4826f1574 100644
--- a/configure.ac
+++ b/configure.ac
@@ -897,6 +897,12 @@ else
897 AC_SUBST([GNULIB_WARN_CFLAGS]) 897 AC_SUBST([GNULIB_WARN_CFLAGS])
898fi 898fi
899 899
900edit_cflags="
901 s,///*,/,g
902 s/^/ /
903 s/ -I/ $isystem/g
904 s/^ //
905"
900 906
901 907
902dnl Some other nice autoconf tests. 908dnl Some other nice autoconf tests.
@@ -1340,12 +1346,6 @@ AC_DEFUN([PKG_CHECK_MODULES], [
1340 if "$PKG_CONFIG" --exists "$2" 2>&AS_MESSAGE_LOG_FD && 1346 if "$PKG_CONFIG" --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
1341 $1_CFLAGS=`"$PKG_CONFIG" --cflags "$2" 2>&AS_MESSAGE_LOG_FD` && 1347 $1_CFLAGS=`"$PKG_CONFIG" --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
1342 $1_LIBS=`"$PKG_CONFIG" --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then 1348 $1_LIBS=`"$PKG_CONFIG" --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
1343 edit_cflags="
1344 s,///*,/,g
1345 s/^/ /
1346 s/ -I/ $isystem/g
1347 s/^ //
1348 "
1349 $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"` 1349 $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
1350 $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'` 1350 $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
1351 AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS']) 1351 AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
@@ -3070,62 +3070,55 @@ AC_SUBST(LIBJPEG)
3070### mingw32 doesn't use -lpng, since it loads the library dynamically. 3070### mingw32 doesn't use -lpng, since it loads the library dynamically.
3071HAVE_PNG=no 3071HAVE_PNG=no
3072LIBPNG= 3072LIBPNG=
3073PNG_CFLAGS=
3073if test "${opsys}" = "mingw32"; then 3074if test "${opsys}" = "mingw32"; then
3074 if test "${with_png}" != "no"; then 3075 if test "${with_png}" != "no"; then
3075 AC_CHECK_HEADER(png.h, HAVE_PNG=yes, HAVE_PNG=no) 3076 AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
3076 fi
3077 if test "${HAVE_PNG}" = "yes"; then
3078 AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library (-lpng).])
3079
3080 AC_CHECK_DECL(png_longjmp,
3081 [],
3082 [AC_DEFINE(PNG_DEPSTRUCT, [],
3083 [Define to empty to suppress deprecation warnings when building
3084 with --enable-gcc-warnings and with libpng versions before 1.5,
3085 which lack png_longjmp.])],
3086 [[#ifdef HAVE_LIBPNG_PNG_H
3087 # include <libpng/png.h>
3088 #else
3089 # include <png.h>
3090 #endif
3091 ]])
3092 fi 3077 fi
3093elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then 3078elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
3094 if test "${with_png}" != "no"; then 3079 if test "${with_png}" != "no"; then
3095 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
3096 # in /usr/include/libpng.
3097 AC_CHECK_HEADERS(png.h libpng/png.h, break)
3098 if test "$ac_cv_header_png_h" = yes || test "$ac_cv_header_libpng_png_h" = yes ; then
3099 AC_CHECK_LIB(png, png_get_channels, HAVE_PNG=yes, , -lz -lm)
3100 fi
3101 fi
3102 3080
3103 if test "${HAVE_PNG}" = "yes"; then 3081 dnl NetBSD 6 provides libpng16, not libpng.
3104 AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library.]) 3082 if png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
3105 3083 png_libs=`(libpng-config --libs) 2>&AS_MESSAGE_LOG_FD`
3106 dnl Some systems, eg NetBSD 6, only provide eg "libpng16", not "libpng". 3084 then
3107 lpng=`libpng-config --libs 2> /dev/null` 3085 HAVE_PNG=yes
3108 case $lpng in 3086 PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
3109 -l*) : ;; 3087 LIBPNG=$png_libs
3110 *) lpng="-lpng" ;; 3088 else
3111 esac 3089 # libpng-config does not work; configure it by hand.
3112 LIBPNG="$lpng -lz -lm" 3090 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
3113 3091 # in /usr/include/libpng.
3114 AC_CHECK_DECL(png_longjmp, 3092 AC_CHECK_HEADERS([png.h libpng/png.h],
3115 [], 3093 [AC_CHECK_LIB([png], [png_get_channels],
3116 [AC_DEFINE(PNG_DEPSTRUCT, [], 3094 [HAVE_PNG=yes
3117 [Define to empty to suppress deprecation warnings when building 3095 LIBPNG='-lpng -lz -lm'
3118 with --enable-gcc-warnings and with libpng versions before 1.5, 3096 if test "$ac_cv_header_libpng_png_h" = yes; then
3119 which lack png_longjmp.])], 3097 PNG_CFLAGS=-I/usr/include/libpng
3120 [[#ifdef HAVE_LIBPNG_PNG_H 3098 fi],
3121 # include <libpng/png.h> 3099 [],
3122 #else 3100 [-lz -lm])
3123 # include <png.h> 3101 break])
3124 #endif 3102 fi
3125 ]])
3126 fi 3103 fi
3127fi 3104fi
3105if test $HAVE_PNG = yes; then
3106 AC_DEFINE([HAVE_PNG], [1], [Define to 1 if you have the png library.])
3107
3108 SAVE_CFLAGS=$CFLAGS
3109 CFLAGS="$CFLAGS $PNG_CFLAGS"
3110 AC_CHECK_DECL([png_longjmp],
3111 [],
3112 [AC_DEFINE([PNG_DEPSTRUCT], [],
3113 [Define to empty to suppress deprecation warnings when building
3114 with --enable-gcc-warnings and with libpng versions before 1.5,
3115 which lack png_longjmp.])],
3116 [[#include <png.h>
3117 ]])
3118 CFLAGS=$SAVE_CFLAGS
3119fi
3128AC_SUBST(LIBPNG) 3120AC_SUBST(LIBPNG)
3121AC_SUBST(PNG_CFLAGS)
3129 3122
3130HAVE_ZLIB=no 3123HAVE_ZLIB=no
3131LIBZ= 3124LIBZ=
diff --git a/src/ChangeLog b/src/ChangeLog
index 12a0cd63dc0..29fb2dd1edf 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12014-05-02 Paul Eggert <eggert@cs.ucla.edu>
2
3 Consult libpng-config more consistently (Bug#17339).
4 * Makefile.in (PNG_CFLAGS): New var.
5 (ALL_CFLAGS): Use it.
6 * image.c [HAVE_PNG]: Don't worry about <libpng/png.h>, as
7 CFLAGS now handles this.
8
12014-05-01 Glenn Morris <rgm@gnu.org> 92014-05-01 Glenn Morris <rgm@gnu.org>
2 10
3 * floatfns.c (Fisnan): 11 * floatfns.c (Fisnan):
diff --git a/src/Makefile.in b/src/Makefile.in
index 388923596c9..c35e38bb290 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -77,6 +77,7 @@ C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
77C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@ 77C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
78 78
79GNUSTEP_CFLAGS=@GNUSTEP_CFLAGS@ 79GNUSTEP_CFLAGS=@GNUSTEP_CFLAGS@
80PNG_CFLAGS=@PNG_CFLAGS@
80 81
81## Define C_SWITCH_X_SITE to contain any special flags your compiler 82## Define C_SWITCH_X_SITE to contain any special flags your compiler
82## may need to deal with X Windows. For instance, if you've defined 83## may need to deal with X Windows. For instance, if you've defined
@@ -325,6 +326,7 @@ ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \
325 -I$(lib) -I$(srcdir)/../lib \ 326 -I$(lib) -I$(srcdir)/../lib \
326 $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ 327 $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
327 $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ 328 $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \
329 $(PNG_CFLAGS) \
328 $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) \ 330 $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) \
329 $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ 331 $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
330 $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \ 332 $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \
diff --git a/src/image.c b/src/image.c
index 4133aaa7621..dcbe5942b32 100644
--- a/src/image.c
+++ b/src/image.c
@@ -22,12 +22,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <unistd.h> 22#include <unistd.h>
23 23
24#ifdef HAVE_PNG 24#ifdef HAVE_PNG
25#if defined HAVE_LIBPNG_PNG_H
26# include <libpng/png.h>
27#else
28# include <png.h> 25# include <png.h>
29#endif 26#endif
30#endif
31 27
32#include <setjmp.h> 28#include <setjmp.h>
33#include <c-ctype.h> 29#include <c-ctype.h>