1 dnl Copyright (C) 2009-2010 Nick Bowler
2 dnl Copying and distribution of this file, with or without modification,
3 dnl are permitted in any medium without royalty provided the copyright
4 dnl notice and this notice are preserved. This file is offered as-is,
5 dnl without any warranty.
7 dnl _DX_LIBPNG_TEST_PROGRAM(major, minor, release)
8 AC_DEFUN([_DX_LIBPNG_TEST_PROGRAM], [AC_LANG_PROGRAM([dnl
10 ifelse([$1], [], [], [dnl
11 #if PNG_LIBPNG_VER_MAJOR < $1
12 # error Invalid libpng major version
13 ifelse([$2], [], [], [dnl
14 #elif PNG_LIBPNG_VER_MAJOR == $1
15 # if PNG_LIBPNG_VER_MINOR < $2
16 # error Invalid libpng minor version
17 ifelse([$3], [], [], [dnl
18 # elif PNG_LIBPNG_VER_MINOR == $2
19 # if PNG_LIBPNG_VER_RELEASE < $3
20 # error Invalid libpng release
28 png_structp png = png_create_read_struct("", 0, 0, 0);
29 png_infop info = png_create_info_struct(png);
32 dnl DX_CHECK_LIBPNG([min-version], [action-if-ok], [action-if-fail])
33 AC_DEFUN([DX_CHECK_LIBPNG],
34 [DX_PKG_CONFIG([libpng], [libpng], [libpng])
36 DX_CHECK_LIB([libpng],
37 [for libpng[]ifelse([$1], [], [], [ version at least $1])],
38 [m4_apply([_DX_LIBPNG_TEST_PROGRAM], m4_split([$1], [\.]))], [dnl
39 [[$LIBPNG_CFLAGS], [$LIBPNG_LIBS]],
40 [[$pkg_cv_libpng_cflags], [$pkg_cv_libpng_libs],
41 [test ! x"$pkg_failed" = x"yes"]],
45 if test x"$dx_cv_libpng_found" = x"yes"; then
46 ifelse([$2], [], [:], [$2])
48 ifelse([$3], [], [AC_MSG_FAILURE([dnl
49 libpng[]ifelse([$1], [], [], [ version at least $1]) is required. The latest
50 version can be obtained from http://libpng.org/pub/png/libpng.html.
52 If libpng is installed but was not found by this configure script,
53 consider adjusting LIBPNG_CFLAGS and/or LIBPNG_LIBS as necessary.
55 If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
56 if libpng is installed in a non-standard prefix.