From edd3f20049423ad5e769b9b6b852c3aff5dee57c Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Tue, 9 Feb 2010 16:57:30 +0100 Subject: [PATCH] Use PKG_CONFIG to search for libpng --- configure.ac | 12 ++++-- goo/Makefile.am | 7 +++- m4/libpng.m4 | 99 --------------------------------------------------- poppler/Makefile.am | 3 ++ 4 files changed, 17 insertions(+), 104 deletions(-) delete mode 100644 m4/libpng.m4 diff --git a/configure.ac b/configure.ac index eb0aa26..4bef90f 100644 --- a/configure.ac +++ b/configure.ac @@ -228,16 +228,20 @@ AH_TEMPLATE([ENABLE_LIBJPEG], dnl Test for libpng AC_ARG_ENABLE(libpng, AC_HELP_STRING([--disable-libpng], - [Don't build against libpng.]), + [Do not build against libpng.]), enable_libpng=$enableval, enable_libpng="try") + if test x$enable_libpng != xno; then - POPPLER_FIND_PNG + PKG_CHECK_MODULES(LIBPNG, libpng, [enable_libpng="yes"], + [enable_libpng="no"]) +fi + +if test x$enable_libpng = xyes; then + AC_DEFINE(ENABLE_LIBPNG, 1, [Build against libpng.]) fi AM_CONDITIONAL(BUILD_LIBPNG, test x$enable_libpng = xyes) -AH_TEMPLATE([ENABLE_LIBPNG], - [Build against libpng.]) dnl Check for freetype headers FREETYPE_LIBS= diff --git a/goo/Makefile.am b/goo/Makefile.am index aad1108..39d2683 100644 --- a/goo/Makefile.am +++ b/goo/Makefile.am @@ -21,8 +21,13 @@ poppler_goo_include_HEADERS = \ endif +if BUILD_LIBPNG +libpng_includes = $(LIBPNG_CFLAGS) +endif + INCLUDES = \ - -I$(top_srcdir) + -I$(top_srcdir) \ + $(libpng_includes) libgoo_la_SOURCES = \ gfile.cc \ diff --git a/m4/libpng.m4 b/m4/libpng.m4 deleted file mode 100644 index 2633c13..0000000 --- a/m4/libpng.m4 +++ /dev/null @@ -1,99 +0,0 @@ -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. -]) - 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 9654bcb..5f6a94a 100644 --- a/poppler/Makefile.am +++ b/poppler/Makefile.am @@ -68,6 +68,8 @@ if BUILD_LIBPNG libpng_libs = \ $(LIBPNG_LIBS) +libpng_includes = \ + $(LIBPNG_CFLAGS) endif @@ -127,6 +129,7 @@ INCLUDES = \ $(cairo_includes) \ $(arthur_includes) \ $(abiword_includes) \ + $(libpng_includes) \ $(FREETYPE_CFLAGS) \ $(FONTCONFIG_CFLAGS) -- 1.6.3.3