Dear Albert,

Sorry for slow activity for this issue (emulation of pkg-config's
XXX_CFLAGS and XXX_LIBS environments). During the cross building
test with MinGW, I found a few related issues and I made more
patches. I attached them, and the description is following.

1) reflectUSER_INCLUDESinlibjpegm4.diff

m4/libjpeg.m4 uses USER_INCLUDES and USER_LDFLAGS in it, but
USER_INCLUDES is not reflected when jpeglib.h is searched.
this patch modifies m4/libjpeg.m4 to reflect USER_INCLUDES
when jpeglib.h is searched.

2) handleEnvCFLAGSandLIBSforJPEGandTIFF.diff

evaluate pkg-config-like environmental variables like LIBJPEG_CFLAGS,
LIBJPEG_LIBS, LIBTIFF_CFLAGS and LIBTIFF_LIBS in configuration.

3) reflectJPEG+TIFF+PNGflags.diff

update Makefile.am to reflect LIBJPEG_CFLAGS, LIBTIFF_CFLAGS,
LIBPNG_CFLAGS for related sources.

4) checkJPEGvsWin32.diff

In libjpeg6b, there is a type definition conflict issue in jmorecfg.h.
jmorecfg.h typedefs INT16 as short, INT32 as long. The latter conflict
with basetsd.h of Microsoft Windows SDK or MinGW that typedefs INT32
as int. basetsd.h is included by windows.h, so, if the users work with
ANSI C features only, the conflict does not appear, it would be the
background why such fundamental error has been preserved.
Anyway, jmorecfg.h designer was aware about the conflict with X11 headers
(Xmd.h defines INT16, INT32, etc), so if we pretend as if Xmd.h were
included (by defining XMD_H), this issue can be bypassed. Attached patch
checks the conflict, then, if there is a conflict, tries XMD_H trick, and
uses it if it works. If jmorecfg.h or basetsd.h was manually fixed to
prevent this issue, this trick is not used.

5) fix-use_glib.diff

this is quite small fix. In poppler's configure, basically the shell
variables are not enclosed, and not quoted, aslike
        if test x$use_glib = x; then
This syntax make the test command confused when use_glib is multi-word
value, as, "no (required cairo output)". In such case, test cannot know
how to evaluate the token "no" "(required" "cairo", so some "syntax error"
messages are given. Thus, quoting of the variable would be safer.

Regards,
mpsuzuki


Albert Astals Cid wrote:
El Divendres, 23 de març de 2012, a les 15:36:55, [email protected] va escriure:
Hi,

Hi

During the cross build for MinGW environment, I found
that small minor fixes for PNG headers.

If PNG library is available, goo/PNGWriter.h includes
it (goo/Makefile.am appropriately reflect LIBPNG_CFLAGS).
But when SplashBitmap.cc (including PNGWriter.h) is
being compiled, LIBPNG_CFLAGS is not considered.
Thus, when PNG library is installed in irregular directory,
SplashBitmap.cc cannot be proprocessed correctly.
LIBPNG_CFLAGS should be added to INCLUDES by fixing
splash/Makefile.am.

Exactly same problem (PNGWriter.h) is found in
HtmlOutputDev.cc compilation, so utils/Makefile.am
should be improved.

I guess similar things are expected for JPEG and TIFF
libraries, but now LIBJPEG_CFLAGS, LIBTIFF_CFLAGS are
not handled by configure. Should I prepare some hooks
for them?

Please, and also could you send the patches you sent here as attachment insteaf of inline, makes much easier to apply them and make sure there was no whitespace problem.

Cheers,
  Albert

diff --git a/splash/Makefile.am b/splash/Makefile.am
index 914b308..afd31df 100644
--- a/splash/Makefile.am
+++ b/splash/Makefile.am
@@ -3,6 +3,10 @@ INCLUDES =                                     \
        -I$(top_srcdir)/goo                     \
        $(FREETYPE_CFLAGS)

+if BUILD_LIBPNG
+INCLUDES += $(LIBPNG_CFLAGS)
+endif
+
 noinst_LTLIBRARIES = libsplash.la

 if ENABLE_XPDF_HEADERS
diff --git a/utils/Makefile.am b/utils/Makefile.am
index c0105d9..ad845c1 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -117,6 +117,12 @@ pdftohtml_SOURCES =                                \
        HtmlUtils.h                             \
        $(common)

+# HtmlOutputDev uses goo/PNGWriter.h that may depend on libpng header
+pdftohtml_CXXFLAGS = $(AM_CXXFLAGS)
+if BUILD_LIBPNG
+pdftohtml_CXXFLAGS += $(LIBPNG_CFLAGS)
+endif
+
 pdfseparate_SOURCES =                          \
        pdfseparate.cc                          \
        $(common)
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

diff --git a/m4/libjpeg.m4 b/m4/libjpeg.m4
index 505abc2..d384343 100644
--- a/m4/libjpeg.m4
+++ b/m4/libjpeg.m4
@@ -68,7 +68,13 @@ KDE_FIND_JPEG_HELPER(6b, 6b,
 
 dnl then search the headers (can't use simply AC_TRY_xxx, as jpeglib.h
 dnl requires system dependent includes loaded before it)
+ac_save_CPPFLAGS="$CPPFLAGS"
+ac_save_CFLAGS="$CFLAGS"
+CPPFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
+CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
 AC_CHECK_HEADER([jpeglib.h], [jpeg_incdir=yes], [jpeg_incdir=NO])
+CPPFLAGS="$ac_save_CPPFLAGS"
+CFLAGS="$ac_save_CFLAGS"
 test "x$jpeg_incdir" = xNO && jpeg_incdir=
 
 dnl if headers _and_ libraries are missing, this is no error, and we
diff --git a/configure.ac b/configure.ac
index 539dd17..e26c09d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,21 +193,46 @@ AC_ARG_ENABLE(libtiff,
 		enable_libtiff=$enableval,
 		enable_libtiff="try")
 
+AC_ARG_VAR([LIBTIFF_CFLAGS], [C compiler flags for LIBTIFF])
+AC_ARG_VAR([LIBTIFF_LIBS], [linker flags to link LIBTIFF (default is -ltiff)])
+ac_save_CPPFLAGS="$CPPFLAGS"
+ac_save_CXXFLAGS="$CXXFLAGS"
+ac_save_LIBS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $LIBTIFF_CFLAGS"
+CXXFLAGS="$CXXFLAGS $LIBTIFF_CFLAGS"
+LIBS="$LIBS $LIBTIFF_LIBS"
 if test x$enable_libtiff = xyes; then
-  AC_CHECK_LIB([tiff], [TIFFOpen],,
-		AC_MSG_ERROR("*** libtiff library not found ***"))
+  if test x"$LIBTIFF_LIBS" != ; then
+    AC_CHECK_FUNC([TIFFOpen],,
+		  AC_MSG_ERROR("*** libtiff library not found ***"))
+  else
+    AC_CHECK_LIB([tiff], [TIFFOpen],,
+		  AC_MSG_ERROR("*** libtiff library not found ***"))
+  fi
   AC_CHECK_HEADERS([tiffio.h],,
 		AC_MSG_ERROR("*** libtiff headers not found ***"))
 elif test x$enable_libtiff = xtry; then
-  AC_CHECK_LIB([tiff], [TIFFOpen],
-		[enable_libtiff="yes"],
-		[enable_libtiff="no"])
+  if test x"$LIBTIFF_LIBS" != x; then
+    AC_CHECK_FUNC([TIFFOpen],
+		  [enable_libtiff="yes"],
+		  [enable_libtiff="no"])
+  else
+    AC_CHECK_LIB([tiff], [TIFFOpen],
+		 [enable_libtiff="yes"],
+		 [enable_libtiff="no"])
+  fi
   AC_CHECK_HEADERS([tiffio.h],,
 		[enable_libtiff="no"])
 fi
+CPPFLAGS="$ac_save_CPPFLAGS"
+CXXFLAGS="$ac_save_CXXFLAGS"
+LIBS="$ac_save_LIBS"
 
 if test x$enable_libtiff = xyes; then
-  LIBTIFF_LIBS="-ltiff"
+  if test x"$LIBTIFF_LIBS" = x; then
+    LIBTIFF_LIBS="-ltiff"
+  fi
+  AC_SUBST(LIBTIFF_CFLAGSS)
   AC_SUBST(LIBTIFF_LIBS)
   AC_DEFINE(ENABLE_LIBTIFF)
 fi
@@ -283,8 +308,21 @@ AC_ARG_ENABLE(libjpeg,
 	                     [Don't build against libjpeg.]),
               enable_libjpeg=$enableval,
               enable_libjpeg="try")
+AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG])
 if test x$enable_libjpeg != xno; then
+  dnl
+  dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS"
+  dnl to receive the flags for header and library directories.
+  dnl
+  ac_save_USER_INCLUDES="$USER_INCLUDES"
+  ac_save_USER_LDFLAGS="$USER_LDFLAGS"
+  USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS"
+  USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS"
   POPPLER_FIND_JPEG
+  dnl POPPLER_FIND_JPEG sets LIBJPEG_LIBS
+  AC_SUBST(LIBJPEG_CFLAGS)
+  USER_INCLUDES="$ac_save_USER_INCLUDES"
+  USER_LDFLAGS="$ac_save_USER_LDFLAGS"
 fi
 
 AM_CONDITIONAL(BUILD_LIBJPEG, test x$enable_libjpeg = xyes)
diff --git a/goo/Makefile.am b/goo/Makefile.am
index 1921b1e..f4f9730 100644
--- a/goo/Makefile.am
+++ b/goo/Makefile.am
@@ -22,12 +22,27 @@ poppler_goo_include_HEADERS =			\
 
 endif
 
+if BUILD_LIBJPEG
+libjpeg_includes = $(LIBJPEG_CFLAGS)
+endif
+
+if BUILD_LIBTIFF
+libtiff_includes = $(LIBTIFF_CFLAGS)
+endif
+
+if BUILD_LIBOPENJPEG
+libjpeg2000_includes = $(LIBOPENJPEG_CFLAGS)
+endif
+
 if BUILD_LIBPNG
 libpng_includes = $(LIBPNG_CFLAGS)
 endif
 
 INCLUDES =					\
 	-I$(top_srcdir)				\
+	$(libjpeg_includes)                     \
+	$(libtiff_includes)                     \
+	$(libjpeg2000_includes)                 \
 	$(libpng_includes)
 
 libgoo_la_SOURCES =				\
diff --git a/poppler/Makefile.am b/poppler/Makefile.am
index 819938b..86ca4e0 100644
--- a/poppler/Makefile.am
+++ b/poppler/Makefile.am
@@ -61,6 +61,8 @@ libjpeg_sources =				\
 
 libjpeg_libs =					\
 	$(LIBJPEG_LIBS)
+libjpeg_includes =				\
+	$(LIBJPEG_CFLAGS)
 
 endif
 
@@ -90,6 +92,8 @@ libjpeg2000_sources =				\
 
 libjpeg2000_libs =				\
 	$(LIBOPENJPEG_LIBS)
+libjpeg2000_includes =				\
+	$(LIBOPENJPEG_CFLAGS)
 
 else
 
@@ -141,7 +145,9 @@ INCLUDES =					\
 	$(splash_includes)			\
 	$(cairo_includes)			\
 	$(arthur_includes)			\
+	$(libjpeg_includes)			\
 	$(libtiff_includes)			\
+	$(libjpeg2000_includes)			\
 	$(libpng_includes)			\
 	$(libcurl_includes)			\
 	$(FREETYPE_CFLAGS)			\
diff --git a/splash/Makefile.am b/splash/Makefile.am
index 914b308..4330c53 100644
--- a/splash/Makefile.am
+++ b/splash/Makefile.am
@@ -1,8 +1,24 @@
 INCLUDES =					\
 	-I$(top_srcdir)				\
 	-I$(top_srcdir)/goo			\
+	$(libjpeg_includes)			\
+	$(libtiff_includes)			\
+	$(libpng_includes)			\
 	$(FREETYPE_CFLAGS)
 
+# SplashBitmap includes JpegWriter.h, TiffWriter.h, PNGWriter.h
+if BUILD_LIBJPEG
+libjpeg_includes = $(LIBJPEG_CFLAGS)
+endif
+
+if BUILD_LIBTIFF
+libtiff_includes = $(LIBTIFF_CFLAGS)
+endif
+
+if BUILD_LIBPNG
+libpng_includes = $(LIBPNG_CFLAGS)
+endif
+
 noinst_LTLIBRARIES = libsplash.la
 
 if ENABLE_XPDF_HEADERS
diff --git a/utils/Makefile.am b/utils/Makefile.am
index c0105d9..ad845c1 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -117,6 +117,12 @@ pdftohtml_SOURCES =				\
 	HtmlUtils.h				\
 	$(common)
 
+# HtmlOutputDev uses goo/PNGWriter.h that may depend on libpng header
+pdftohtml_CXXFLAGS = $(AM_CXXFLAGS)
+if BUILD_LIBPNG
+pdftohtml_CXXFLAGS += $(LIBPNG_CFLAGS)
+endif
+
 pdfseparate_SOURCES =				\
 	pdfseparate.cc				\
 	$(common)
diff --git a/configure.ac b/configure.ac
index e26c09d..cb7e4b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,6 +310,7 @@ AC_ARG_ENABLE(libjpeg,
               enable_libjpeg="try")
 AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG])
 if test x$enable_libjpeg != xno; then
+
   dnl
   dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS"
   dnl to receive the flags for header and library directories.
@@ -319,6 +320,47 @@ if test x$enable_libjpeg != xno; then
   USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS"
   USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS"
   POPPLER_FIND_JPEG
+
+  dnl check INT16, INT32 typedef conflict in jmorecfg.h
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_CFLAGS="$CFLAGS"
+  CPPFLAGS="$CPPFLAGS $LIBJPEG_CFLAGS"
+  CFLAGS="$CFLAGS $LIBJPEG_CFLAGS"
+  AC_MSG_CHECKING([libjpeg.h works correctly])
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#include <sys/types.h>
+#include <stdio.h>
+#include <jpeglib.h>
+],[{return 0;}])],[
+    AC_MSG_RESULT([ok])
+  ],[
+    AC_MSG_RESULT([no])
+    AC_MSG_CHECKING([libjpeg.h problem can be fixed by XMD_H macro])
+    CPPFLAGS="$CPPFLAGS -DXMD_H"
+    CFLAGS="$CFLAGS -DXMD_H"
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#include <sys/types.h>
+#include <stdio.h>
+#include <jpeglib.h>
+],[{return 0;}])],[
+      AC_MSG_RESULT([ok, -DXMD_H is added to LIBJPEG_CFLAGS])
+      LIBJPEG_CFLAGS="$LIBJPEG_CFLAGS -DXMD_H"
+    ],[
+      AC_MSG_RESULT([no, disable libjpeg])
+      enable_libjpeg="no"
+    ])
+  ])
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  CFLAGS="$ac_save_CFLAGS"
+
   dnl POPPLER_FIND_JPEG sets LIBJPEG_LIBS
   AC_SUBST(LIBJPEG_CFLAGS)
   USER_INCLUDES="$ac_save_USER_INCLUDES"
diff --git a/configure.ac b/configure.ac
index cb7e4b6..3c30ea8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -546,8 +546,8 @@ else
   use_glib="no (requires cairo output)"
   enable_poppler_glib="no"
 fi
-if test x$use_glib = x; then
-   use_glib=$enable_poppler_glib
+if test x"$use_glib" = x; then
+   use_glib="$enable_poppler_glib"
 fi
 AM_CONDITIONAL(BUILD_POPPLER_GLIB, test x$enable_poppler_glib = xyes)
 AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to