From 838038efc520f8a67cafed1c4b5d0578466b3602 Mon Sep 17 00:00:00 2001 From: Alexander Dreyer Date: Wed, 12 Sep 2012 17:22:02 +0200 Subject: [PATCH 1/2] Using pkg-config for libpng --- macros/png-check.m4 | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/macros/png-check.m4 b/macros/png-check.m4 index f428ea5..372cac9 100644 --- a/macros/png-check.m4 +++ b/macros/png-check.m4 @@ -6,36 +6,17 @@ dnl Test for the libpng and define PNG_CFLAGS, PNG_LIBS, and HAVE_LIBPNG AC_DEFUN([LB_CHECK_PNG], [ -PNG_LIBS= -PNG_CFLAGS= +# This is because the first PKG_CHECK_MODULES call is inside a conditional. +PKG_PROG_PKG_CONFIG -AC_ARG_WITH(png,[ - --with-png= |yes Enable use of PNG library. -],[ -if test "$withval" = yes ; then - AC_CHECK_LIB([png], [png_create_write_struct_2], [ - AC_DEFINE(HAVE_LIBPNG,1,Enable use of libpng) - PNG_LIBS="-lpng" - ]) -elif test "$withval" != no ; then - BACKUP_LIBS=$LIBS - LIBS=$withval/lib - AC_CHECK_LIB([png], [png_create_write_struct_2],[ - AC_DEFINE(HAVE_LIBPNG,1,Enable use of libpng) - PNG_CFLAGS="-I$withval/include -lpng" - PNG_LIBS="-L$withval/lib -lpng" - ],[ - AC_MSG_WARN([Could not find libpng in path $withval, disabling]) - ]) - LIBS=$BACKUP_LIBS -fi -],[ - AC_CHECK_LIB([png], [png_create_write_struct_2], [ - AC_DEFINE(HAVE_LIBPNG,1,Enable use of libpng) - PNG_LIBS="-lpng" - ],[AC_MSG_RESULT(not found)]) -]) - -AC_SUBST(PNG_CFLAGS) -AC_SUBST(PNG_LIBS) +AC_ARG_WITH([png], + [AS_HELP_STRING([--with-png], + [support handling png files @<:@default=check@:>@])], + [], + [with_png=check]) +AS_CASE(["$with_png"], + [yes], [PKG_CHECK_MODULES([PNG], [libpng], [HAVE_LIBPNG=1])], + [no], [], + [PKG_CHECK_MODULES([PNG], [libpng], [HAVE_LIBPNG=1], [HAVE_LIBPNG=0])]) +AM_CONDITIONAL([USE_LIBPNG], [test "$with_png" != no -a "$HAVE_LIBPNG" -eq 1]) ]) From f179ed5c0dc00900c3bd4f378d9034be955f378d Mon Sep 17 00:00:00 2001 From: Alexander Dreyer Date: Wed, 12 Sep 2012 17:22:02 +0200 Subject: [PATCH 2/2] Using pkg-config for libpng --- macros/png-check.m4 | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/macros/png-check.m4 b/macros/png-check.m4 index f428ea5..fae7634 100644 --- a/macros/png-check.m4 +++ b/macros/png-check.m4 @@ -6,36 +6,17 @@ dnl Test for the libpng and define PNG_CFLAGS, PNG_LIBS, and HAVE_LIBPNG AC_DEFUN([LB_CHECK_PNG], [ -PNG_LIBS= -PNG_CFLAGS= +# This is because the first PKG_CHECK_MODULES call is inside a conditional. +PKG_PROG_PKG_CONFIG -AC_ARG_WITH(png,[ - --with-png= |yes Enable use of PNG library. -],[ -if test "$withval" = yes ; then - AC_CHECK_LIB([png], [png_create_write_struct_2], [ - AC_DEFINE(HAVE_LIBPNG,1,Enable use of libpng) - PNG_LIBS="-lpng" - ]) -elif test "$withval" != no ; then - BACKUP_LIBS=$LIBS - LIBS=$withval/lib - AC_CHECK_LIB([png], [png_create_write_struct_2],[ - AC_DEFINE(HAVE_LIBPNG,1,Enable use of libpng) - PNG_CFLAGS="-I$withval/include -lpng" - PNG_LIBS="-L$withval/lib -lpng" - ],[ - AC_MSG_WARN([Could not find libpng in path $withval, disabling]) - ]) - LIBS=$BACKUP_LIBS -fi -],[ - AC_CHECK_LIB([png], [png_create_write_struct_2], [ - AC_DEFINE(HAVE_LIBPNG,1,Enable use of libpng) - PNG_LIBS="-lpng" - ],[AC_MSG_RESULT(not found)]) -]) - -AC_SUBST(PNG_CFLAGS) -AC_SUBST(PNG_LIBS) +AC_ARG_WITH([png], + [AS_HELP_STRING([--with-png], + [support handling png files @<:@default=check@:>@])], + [], + [with_png=check]) +AS_CASE(["$with_png"], + [yes], [PKG_CHECK_MODULES([PNG], [libpng], [HAVE_LIBPNG=1])], + [no], [], + [PKG_CHECK_MODULES([PNG], [libpng], [HAVE_LIBPNG=1], [HAVE_LIBPNG=0])]) +AM_CONDITIONAL([USE_LIBPNG], [test "$with_png" != no -a "$HAVE_LIBPNG" == "1"]) ])