+++ /dev/null
-dnl Borrowed from Transcode (http://www.transcoding.org/cgi-bin/transcode)
-
-dnl PKG_INIT(rptfile, errfile)
-dnl
-AC_DEFUN([PKG_INIT],
-[
-pkg_err="no"
-pkg_err_file="pkg_err_file"
-pkg_rpt_file="pkg_rpt_file"
-
-if test x"$1" != x"" ; then
- pkg_rpt_file="$1"
-fi
-echo -n > $pkg_rpt_file
-
-if test x"$2" != x"" ; then
- pkg_err_file="$2"
-fi
-echo -n > $pkg_err_file
-])
-
-
-dnl PKG_ERROR(name, object, req-enable, pkg, url, [error message])
-AC_DEFUN([PKG_ERROR],
-[
-pkg_err="yes"
-this_pkg_err="yes"
-
-prob=""
-if test x"$3" = x"required" ; then
- prob="requirement failed"
-else
- prob="option '--enable-$1' failed"
-fi
-
-cat >> $pkg_err_file <<EOF
-ERROR: $prob: $6
-$2 can be found in the following packages:
- $4 $5
-
-EOF
-])
-
-
-dnl PKG_CHECK(pkg-name, def-enabled, var-name, pkgconfig-name, conf-script,
-dnl header, lib, symbol)
-dnl Test for pkg-name, and define var-name_CFLAGS and var-name_LIBS
-dnl and HAVE_var-name if found
-dnl
-dnl 1 name name of package; required (pkg-config name if applicable)
-dnl 2 req-enable enable by default, 'required', 'yes' or 'no'; required
-dnl 3 var-name name stub for variables, preferably uppercase; required
-dnl 4 conf-script name of "-config" script or 'no'
-dnl 5 header header file to check or 'none'
-dnl 6 lib library to check or 'none'
-dnl 7 symbol symbol from the library to check or ''
-dnl 8 pkg package (pkg-config name if applicable)
-dnl 9 url homepage for the package
-
-AC_DEFUN([PKG_CHECK],
-[
-if test x"$2" != x"required" ; then
- AC_MSG_CHECKING([whether $1 support is requested])
- AC_ARG_ENABLE($1,
- AC_HELP_STRING([--enable-$1],
- [build with $1 support ($2)]),
- [case "${enableval}" in
- yes) ;;
- no) ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-$1) ;;
- esac],
- enable_$1="$2")
- AC_MSG_RESULT($enable_$1)
-else
- enable_$1="yes"
-fi
-
-AC_ARG_WITH($1-prefix,
- AC_HELP_STRING([--with-$1-prefix=PFX],
- [prefix where $1 is installed (/usr)]),
- w_$1_p="$withval", w_$1_p="")
-
-AC_ARG_WITH($1-includes,
- AC_HELP_STRING([--with-$1-includes=DIR],
- [directory where $1 headers ($5) are installed (/usr/include)]),
- w_$1_i="$withval", w_$1_i="")
-
-AC_ARG_WITH($1-libs,
- AC_HELP_STRING([--with-$1-libs=DIR],
- [directory where $1 libararies (lib$6.so) are installed (/usr/lib)]),
- w_$1_l="$withval", w_$1_l="")
-
-have_$1="no"
-this_pkg_err="no"
-
-if test x"$enable_$1" = x"yes" ; then
-
- dnl pkg-config
-
- pkg_config_$1="no"
- AC_MSG_CHECKING([for pkgconfig support for $1])
- if test x"$PKG_CONFIG" != x"no" ; then
- if $PKG_CONFIG $8 --exists ; then
- pkg_config_$1="yes"
- fi
- fi
- AC_MSG_RESULT($pkg_config_$1)
-
- dnl *-config
-
- if test x"$4" != x"no" ; then
- if test x"$w_$1_p" != x"" ; then
- if test -x $w_$1_p/bin/$4 ; then
- $1_config="$w_$1_p/bin/$4"
- fi
- fi
- AC_PATH_PROG($1_config, $4, no)
- else
- $1_config="no"
- fi
-
- # get and test the _CFLAGS
-
- AC_MSG_CHECKING([how to determine $3_CFLAGS])
- if test x"$w_$1_i" != x"" ; then
- $1_ii="-I$w_$1_i"
- AC_MSG_RESULT(user)
- else
- if test x"$pkg_config_$1" != x"no" ; then
- $1_ii="`$PKG_CONFIG $8 --cflags`"
- AC_MSG_RESULT(pkg-config)
- else
- if test x"$$1_config" != x"no" ; then
- $1_ii="`$$1_config --cflags`"
- AC_MSG_RESULT($$1_config)
- else
- if test x"$w_$1_p" != x"" ; then
- $1_ii="-I$w_$1_p/include"
- AC_MSG_RESULT(prefix)
- else
- $1_ii="-I/usr/include"
- AC_MSG_RESULT(default)
- fi
- fi
- fi
- fi
- ipaths="" ; xi=""
- for i in $$1_ii ; do
- case $i in
- -I*) ipaths="$ipaths $i" ;;
- *) xi="$xi $i" ;;
- esac
- done
- $1_ii="$ipaths"
- $1_ii="`echo $$1_ii | sed -e 's/ */ /g'`"
- $3_EXTRA_CFLAGS="$$3_EXTRA_CFLAGS $xi"
- $3_EXTRA_CFLAGS="`echo $$3_EXTRA_CFLAGS | sed -e 's/ */ /g'`"
-
- if test x"$5" != x"none" ; then
- save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $$1_ii"
- AC_CHECK_HEADER([$5],
- [$3_CFLAGS="$$1_ii"],
- [PKG_ERROR($1, $5, $2, $8, $9, [cannot compile $5])])
- CPPFLAGS="$save_CPPFLAGS"
- fi
-
- # get and test the _LIBS
-
- AC_MSG_CHECKING([how to determine $3_LIBS])
- if test x"$w_$1_l" != x"" ; then
- $1_ll="-L$w_$1_l"
- AC_MSG_RESULT(user)
- else
- if test x"$pkg_config_$1" != x"no" ; then
- $1_ll="`$PKG_CONFIG $8 --libs`"
- AC_MSG_RESULT(pkg-config)
- else
- if test x"$$1_config" != x"no" ; then
- $1_ll="`$$1_config --libs`"
- AC_MSG_RESULT($$1_config)
- else
- if test x"$w_$1_p" != x"" ; then
- $1_ll="-L$w_$1_p${deflib}"
- AC_MSG_RESULT(prefix)
- else
- $1_ll="-L/usr${deflib}"
- AC_MSG_RESULT(default)
- fi
- fi
- fi
- fi
- lpaths="" ; xlibs="" ; xlf=""
- for l in $$1_ll ; do
- case $l in
- -L*) lpaths="$lpaths $l" ;;
- -l*) test x"$l" != x"-l$6" && xlibs="$xlibs $l" ;;
- *) xlf="$xlf $l" ;;
- esac
- done
- $1_ll="$lpaths"
- $1_ll="`echo $$1_ll | sed -e 's/ */ /g'`"
- xl=""
- for i in $xlibs $xlf ; do
- echo " $$3_EXTRA_LIBS " | grep -vq " $i " && xl="$xl $i"
- done
- $3_EXTRA_LIBS="$$3_EXTRA_LIBS $xl"
- $3_EXTRA_LIBS="`echo $$3_EXTRA_LIBS | sed -e 's/ */ /g'`"
-
- if test x"$6" != x"none" ; then
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $$1_ll"
- AC_CHECK_LIB([$6], [$7],
- [$3_LIBS="$$1_ll -l$6 $$3_EXTRA_LIBS"],
- [PKG_ERROR($1, lib$6, $2, $8, $9, [cannot link against lib$6])],
- [$$3_EXTRA_LIBS])
- LDFLAGS="$save_LDFLAGS"
- fi
-
- if test x"$this_pkg_err" = x"no" ; then
- have_$1="yes"
- fi
-
-else
- $3_CFLAGS=""
- $3_LIBS=""
-fi
-])
-
--- /dev/null
+dnl Copyright (C) 2009 Nick Bowler
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved. This file is offered as-is,
+dnl without any warranty.
+
+dnl _LIBPNG_TRY_VERSION(min-version)
+AC_DEFUN([_LIBPNG_TRY_VERSION], [dnl
+sedhead='s/@<:@0-9@:>@@<:@0-9@:>@*/<<<&>>>/'
+sedtail='s/.*<<<\(.*\)>>>.*/\1/;t;s/.*/0/'
+png_min_major=`printf '%s' '$1' | sed -e "$sedhead"1 -e "$sedtail"`
+png_min_minor=`printf '%s' '$1' | sed -e "$sedhead"2 -e "$sedtail"`
+png_min_release=`printf '%s' '$1' | sed -e "$sedhead"3 -e "$sedtail"`
+png_min_build=`printf '%s' '$1' | sed -e "$sedhead"4 -e "$sedtail"`
+png_min_status=`printf '%s' '$1' | sed '
+ t; s/.*alpha.*/PNG_LIBPNG_BUILD_ALPHA/
+ t; s/.*beta.*/PNG_LIBPNG_BUILD_BETA/
+ t; s/.*rc.*/PNG_LIBPNG_BUILD_RC/
+ t; s/.*/PNG_LIBPNG_BUILD_STABLE/
+'`
+
+AC_CACHE_CHECK([for libpng version at least $1],
+ [libpng_cv_sufficient_ver],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+#include <png.h>
+#if PNG_LIBPNG_VER_MAJOR < $png_min_major
+# error Invalid libpng major version
+#elif PNG_LIBPNG_VER_MAJOR == $png_min_major
+# if PNG_LIBPNG_VER_MINOR < $png_min_minor
+# error Invalid libpng minor version
+# elif PNG_LIBPNG_VER_MINOR == $png_min_minor
+# if PNG_LIBPNG_VER_RELEASE < $png_min_release
+# error Invalid libpng release
+# elif PNG_LIBPNG_VER_RELEASE == $png_min_release
+# if PNG_LIBPNG_BUILD_BASE_TYPE < $png_min_status
+# error Invalid libpng release status
+# elif PNG_LIBPNG_BUILD_BASE_TYPE == $png_min_status
+# if PNG_LIBPNG_VER_BUILD < $png_min_build
+# error Invalid libpng build
+# endif
+# endif
+# endif
+# endif
+#endif
+], [dnl
+png_structp png = png_create_read_struct("", 0, 0, 0);
+png_infop info = png_create_info_struct(png);
+])], [libpng_cv_sufficient_ver=yes], [libpng_cv_sufficient_ver=no])])
+])
+
+dnl CHECK_LIBPNG([min-version], [action-if-ok], [action-if-fail])
+AC_DEFUN([CHECK_LIBPNG],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([LIBPNG_CFLAGS], [C compiler flags for libpng])dnl
+AC_ARG_VAR([LIBPNG_LIBS], [linker flags for libpng])dnl
+
+if test x"$PKG_CONFIG" != x; then
+ AC_MSG_CHECKING([pkg-config database for libpng])
+ _PKG_CONFIG([libpng_cflags], [cflags], [libpng])
+ _PKG_CONFIG([libpng_libs], [libs], [libpng])
+ if test x$pkg_failed = xyes; then
+ errors=`$PKG_CONFIG --errors-to-stdout --print-errors libpng`
+ echo "$errors" >&AS_MESSAGE_LOG_FD
+ AC_MSG_RESULT([no])
+ else
+ if test x"$LIBPNG_CFLAGS" = x; then
+ LIBPNG_CFLAGS=$pkg_cv_libpng_cflags
+ fi
+ if test x"$LIBPNG_LIBS" = x; then
+ LIBPNG_LIBS=$pkg_cv_libpng_libs
+ fi
+
+ AC_MSG_RESULT([yes])
+ fi
+fi
+
+if test x"$LIBPNG_LIBS" = x; then
+ LIBPNG_LIBS=-lpng
+fi
+
+AC_LANG_PUSH([C])
+old_cflags=$CFLAGS
+old_libs=$LIBS
+CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
+LIBS="$LIBPNG_LIBS $LIBS"
+
+_LIBPNG_TRY_VERSION(ifelse([$1], [], [1.0], [$1]))
+
+CFLAGS=$old_cflags
+LIBS=$old_libs
+AC_LANG_POP([C])
+
+if test x"$libpng_cv_sufficient_ver" = x"yes"; then
+ AC_SUBST([LIBPNG_CFLAGS])
+ AC_SUBST([LIBPNG_LIBS])
+ ifelse([$2], [], [true], [$2])
+else
+ ifelse([$3], [], [AC_MSG_FAILURE([dnl
+libpng version >= ifelse([$1], [], [1.0], [$1]) is required. The latest
+version can be obtained from http://libpng.org/pub/png/libpng.html.
+
+If libpng is installed but was not found by this configure script,
+consider adjusting LIBPNG_CFLAGS and/or LIBPNG_LIBS as necessary.
+
+If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
+if libpng is installed in a non-standard prefix.
+])], [$3])
+fi
+])