jbig2dec

Ralph Giles <[email protected]> Wed, 14 Aug 2002 09:07:54 -0700
Newsgroups gmane.comp.printing.ghostscript.jbig2dec.cvs
Message-ID <[email protected]>
Update of /cvsroot/jbig2dec/jbig2dec
In directory usw-pr-cvs1:/tmp/cvs-serv8569

Modified Files:
	configure.ac 
Log Message:
Add a --with-libpng[=prefix] option. This can be used to specify the
prefix where libpng is installed (assuming prefix/include, prefix/lib)
if it's not on the default search path. It can also be used (as --without-libpng)
to explicitely disable the png output option.


Index: configure.ac
===================================================================
RCS file: /cvsroot/jbig2dec/jbig2dec/configure.ac,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- configure.ac	14 Aug 2002 14:21:15 -0000	1.14
+++ configure.ac	14 Aug 2002 16:07:52 -0000	1.15
@@ -14,15 +14,36 @@
 AC_PROG_RANLIB
 
 # Checks for libraries.
-dnl libpng requires pow() which may be in libm
-AC_SEARCH_LIBS([pow], [m])
-AC_CHECK_LIB([png], [png_check_sig], [
-  AC_CHECK_LIB([z], [deflate], [
-    AC_DEFINE(HAVE_LIBPNG, 1, [Define if libpng is available (-lpng)])
-    LIBS="$LIBS -lpng -lz"
-    AC_LIBOBJ([jbig2_image_png])
+dnl by default we want png support if possible
+AC_ARG_WITH([libpng], 
+  AC_HELP_STRING([--with-libpng[=prefix]],
+    [include support for png output (if libpng is available)]),
+  [ac_cv_want_libpng="$withval"], [ac_cv_want_libpng="yes"])
+save_cflags="$CFLAGS"
+save_ldflags="$LDFLAGS"
+have_libpng="no"
+if test "x$ac_cv_want_libpng" != "xno"; then
+  if test "x$ac_cv_want_libpng" != "xyes"; then
+    dnl if it's not yes or no, treat as a prefix
+    CFLAGS="$CFLAGS -I$ac_cv_want_libpng/include"
+    LDFLAGS="$LDFLAGS -L$ac_cv_want_libpng/lib"
+  fi
+  AC_CHECK_LIB([png], [png_check_sig], [
+    dnl libpng requires pow() which may be in libm
+    AC_SEARCH_LIBS([pow], [m])
+    AC_CHECK_LIB([z], [deflate], [
+      AC_DEFINE(HAVE_LIBPNG, 1, [Define if libpng is available (-lpng)])
+      LIBS="$LIBS -lpng -lz"
+      AC_LIBOBJ([jbig2_image_png])
+      have_libpng="yes"
+    ])
   ])
-])
+fi
+dnl restore (possibly changed) flags if we didn't find working libpng
+if test "x$have_libpng" != "xyes"; then
+  CFLAGS="$save_cflags"
+  LDFLAGS="$save_ldflags"
+fi
 
 # Checks for header files.
 AC_HEADER_STDC