From: Nick Bowler Date: Sun, 1 Nov 2009 18:37:26 +0000 (-0500) Subject: build: Import the libpng check from marksim. X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/a5900574a2d9257695b70ec9a065e4638162e7d6 build: Import the libpng check from marksim. This replaces the PKG_CHECK macros from transcode. --- diff --git a/.gitignore b/.gitignore index a58fa89..92b03e3 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,4 @@ depcomp install-sh stamp-h1 -pkg_err_file -pkg_rpt_file - liblbx-*.tar.gz diff --git a/Makefile.am b/Makefile.am index 330a764..98eeac8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,3 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src doc/man -DISTCLEANFILES = pkg_err_file pkg_rpt_file diff --git a/acinclude.m4 b/acinclude.m4 deleted file mode 100644 index 89db997..0000000 --- a/acinclude.m4 +++ /dev/null @@ -1,229 +0,0 @@ -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 < +#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 +]) diff --git a/src/Makefile.am b/src/Makefile.am index 3602e24..13e47a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,6 @@ lbxtool_LDADD = liblbx.la if BUILD_LBXIMG bin_PROGRAMS += lbximg lbximg_SOURCES = tools.h lbximg.c -lbximg_LDADD = liblbx.la -lbximg_CFLAGS = $(PNG_CFLAGS) -lbximg_LDFLAGS = $(PNG_LIBS) +lbximg_LDADD = liblbx.la $(LIBPNG_LIBS) +lbximg_CFLAGS = $(LIBPNG_CFLAGS) endif