[poppler] (2/2) build: have libpng detection use libpng

Jan Engelhardt jengelh at medozas.de
Sat Mar 13 03:37:51 PST 2010


parent 3f0ab18596ab9c2a9fa03293a91da527bdc9ea31 ()
commit 60d6c3cba49a7530319070bc7e75a5bddd893bd0
Author: Jan Engelhardt <jengelh at medozas.de>
Date:   Sat Mar 13 12:34:09 2010 +0100

build: have libpng detection use libpng
---
 m4/libpng.m4        |   98 +++----------------------------------------
 poppler/Makefile.am |    9 +----
 qt/Makefile.am      |    2 +-
 3 files changed, 8 insertions(+), 101 deletions(-)

diff --git a/m4/libpng.m4 b/m4/libpng.m4
index 2633c13..3ae6f63 100644
--- a/m4/libpng.m4
+++ b/m4/libpng.m4
@@ -1,99 +1,13 @@
-dnl Based on Xpdf configure.in and evince configure.ac
-dnl Based on kde acinclude.m4.in, LGPL Licensed
-
-AC_DEFUN([AC_FIND_FILE],
-[
-$3=NO
-for i in $2;
-do
-  for j in $1;
-  do
-    echo "configure: __oline__: $i/$j" >&AC_FD_CC
-    if test -r "$i/$j"; then
-      echo "taking that" >&AC_FD_CC
-      $3=$i
-      break 2
-    fi
-  done
-done
-])
-
-AC_DEFUN([FIND_PNG_HELPER],
-[
-AC_MSG_CHECKING([for libpng])
-AC_CACHE_VAL(ac_cv_lib_png,
-[
-ac_save_LIBS="$LIBS"
-LIBS="$all_libraries $USER_LDFLAGS -lpng -lm"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
-AC_TRY_LINK(
-[
-#ifdef __cplusplus
-extern "C" {
-#endif
-void png_access_version_number();
-#ifdef __cplusplus
-}
-#endif
-],
-[png_access_version_number();],
-            eval "ac_cv_lib_png=-lpng",
-            eval "ac_cv_lib_png=no")
-LIBS="$ac_save_LIBS"
-CFLAGS="$ac_save_CFLAGS"
-])
-
-if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
-  enable_libpng=yes
-  LIBPNG_LIBS="$ac_cv_lib_png"
-  AC_MSG_RESULT($ac_cv_lib_png)
-else
-  AC_MSG_RESULT(no)
-  $1
-fi
-])
-
 
 AC_DEFUN([POPPLER_FIND_PNG],
 [
-dnl first look for libraries
-FIND_PNG_HELPER(
-   FIND_PNG_HELPER(normal, [],
-    [
-       LIBPNG_LIBS=
-    ]
-   )
-)
-
-dnl then search the headers (can't use simply AC_TRY_xxx, as png.h
-dnl requires system dependent includes loaded before it)
-png_incdirs="`eval echo $includedir` /usr/include /usr/local/include "
-AC_FIND_FILE(png.h, $png_incdirs, png_incdir)
-test "x$png_incdir" = xNO && png_incdir=
 
-dnl if headers _and_ libraries are missing, this is no error, and we
-dnl continue with a warning (the user will get no png support)
-dnl if only one is missing, it means a configuration error, but we still
-dnl only warn
-if test -n "$png_incdir" && test -n "$LIBPNG_LIBS" ; then
-  AC_DEFINE_UNQUOTED(ENABLE_LIBPNG, 1, [Define if you have libpng])
-else
-  if test -n "$png_incdir" || test -n "$LIBPNG_LIBS" ; then
-    AC_MSG_WARN([
-There is an installation error in png support. You seem to have only one of
-either the headers _or_ the libraries installed. You may need to either provide
-correct --with-extra-... options, or the development package of libpng. You
-can get a source package of libpng from http://www.libpng.org/pub/png/libpng.html
-Disabling PNG support.
+PKG_CHECK_MODULES([libpng], [libpng], [
+	AC_DEFINE_UNQUOTED([ENABLE_LIBPNG], [1], [Define if you have libpng])
+	enable_libpng="yes"
+], [
+	AC_MSG_WARN([libpng not found. disabled PNG support.])
+	enable_libpng="no"
 ])
-  else
-    AC_MSG_WARN([libpng not found. disable PNG support.])
-  fi
-  png_incdir=
-  enable_libpng=no
-  LIBPNG_LIBS=
-fi
 
-AC_SUBST(LIBPNG_LIBS)
 ])
diff --git a/poppler/Makefile.am b/poppler/Makefile.am
index ec79e31..7e8a7c3 100644
--- a/poppler/Makefile.am
+++ b/poppler/Makefile.am
@@ -62,13 +62,6 @@ libjpeg_libs =					\
 
 endif
 
-if BUILD_LIBPNG
-
-libpng_libs =					\
-	$(LIBPNG_LIBS)
-
-endif
-
 if BUILD_LIBOPENJPEG
 
 libjpeg2000_sources =				\
@@ -142,7 +135,7 @@ libpoppler_la_LIBADD =				\
 	$(cms_libs)				\
 	$(splash_libs)				\
 	$(libjpeg_libs)				\
-	$(libpng_libs)				\
+	$(libpng_LIBS)				\
 	$(zlib_libs)				\
 	$(libjpeg2000_libs)			\
 	$(abiword_libs)				\
diff --git a/qt/Makefile.am b/qt/Makefile.am
index 722d796..31e08e8 100644
--- a/qt/Makefile.am
+++ b/qt/Makefile.am
@@ -1,4 +1,4 @@
-INCLUDES =					\
+AM_CPPFLAGS =					\
 	-I$(top_srcdir)				\
 	-I$(top_srcdir)/poppler			\
 	$(cairo_includes)			\
-- 
# Created with git-export-patch


More information about the poppler mailing list