Set lang properly for openssl tests and convert improper CFLAGS refs.

git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-cpp/trunk@1833741 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configure.ac b/configure.ac
index 91b27b5..031243e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,7 +85,16 @@
 
 AC_LANG(C++)
 
+# Note that the pkg-config macros improperly set pkg_CFLAGS rather
+# than CPPFLAGS and/or CXXFLAGS, so this requires some workarounds.
+# Where possible, we clear the CFLAGS version to make sure nothing
+# is depending on it downstream. Compile tests are favored over
+# preproc-only tests so that CXXFLAGS should be sufficient.
+
 AX_PKG_CHECK_MODULES([xerces],,[xerces-c >= 3.2])
+xerces_CXXFLAGS=$xerces_CFLAGS
+xerces_CFLAGS=""
+AC_SUBST([xerces_CXXFLAGS])
 
 # Get user options
 
@@ -110,12 +119,12 @@
     # Updated to include nls/include as this is generally needed for
     # compilation against non-installed xalan.
     # Also now include XALANCROOT/include to cater for installed xalan
-    xalan_CFLAGS="-I${XALANCROOT}/src -I${XALANCROOT}/include -I${XALANCROOT}/nls/include"
+    xalan_CXXFLAGS="-I${XALANCROOT}/src -I${XALANCROOT}/include -I${XALANCROOT}/nls/include"
     xalan_LIBS="-L${XALANCROOT}/lib -lxalan-c"
-    AX_SAVE_FLAGS_WITH_PREFIX([xalan],[[CFLAGS]])
+    AX_SAVE_FLAGS_WITH_PREFIX([xalan],[[CXXFLAGS]])
     AC_CHECK_HEADER([xalanc/Include/XalanVersion.hpp],
                     [xalan_found=yes])
-    AX_RESTORE_FLAGS_WITH_PREFIX([xalan],[[CFLAGS]])
+    AX_RESTORE_FLAGS_WITH_PREFIX([xalan],[[CXXFLAGS]])
 
   fi
 
@@ -125,7 +134,7 @@
     unset ac_cv_header_xalanc_Include_XalanVersion_hpp
     AC_CHECK_HEADER([xalanc/Include/XalanVersion.hpp],
                     [xalan_found=yes
-		     xalan_CFLAGS=""
+		     xalan_CXXFLAGS=""
 		     xalan_LIBS="-lxalan-c"],
 		    [AC_MSG_NOTICE([WARNING - configuring without Xalan])])
 
@@ -133,10 +142,10 @@
 fi
 
 if test "${xalan_found}" = "yes" ; then
-AX_SAVE_FLAGS_WITH_PREFIX([xalan],[[CFLAGS],[LIBS]])
+AX_SAVE_FLAGS_WITH_PREFIX([xalan],[[CXXFLAGS],[LIBS]])
 
 AC_MSG_CHECKING([Xalan version])
-AC_PREPROC_IFELSE(
+AC_COMPILE_IFELSE(
     [AC_LANG_PROGRAM([#include <xalanc/Include/XalanVersion.hpp>],
 [#if  _XALAN_VERSION >= 11100
 int i = 0;
@@ -150,14 +159,15 @@
   AC_SEARCH_LIBS([XalanInitialize],[xalanMsg],[xalan_LIBS="$LIBS"])
   
   AC_DEFINE([XSEC_HAVE_XALAN],[1],[Define to 1 if Xalan is available.])
-  AC_SUBST([xalan_CFLAGS])
+  AC_SUBST([xalan_CXXFLAGS])
   AC_SUBST([xalan_LIBS])
 
-AX_RESTORE_FLAGS_WITH_PREFIX([xalan],[[CFLAGS],[LIBS]])
+AX_RESTORE_FLAGS_WITH_PREFIX([xalan],[[CXXFLAGS],[LIBS]])
 else
   AC_MSG_NOTICE([Xalan not included in build - XPath and XSLT will not be available])
 fi
 
+AC_LANG(C)
 
 # Crypto provider options (OpenSSL / NSS)
 
diff --git a/xml-security-c.pc.in b/xml-security-c.pc.in
index 1488e48..b254803 100644
--- a/xml-security-c.pc.in
+++ b/xml-security-c.pc.in
@@ -8,6 +8,6 @@
 Version: @VERSION@
 Libs: -L${libdir} -lxml-security-c
 Libs.private: @xalan_LIBS@
-Cflags: -I${includedir} @xalan_CFLAGS@
+Cflags: -I${includedir} @xalan_CXXFLAGS@
 Requires: @AX_PACKAGE_REQUIRES@
 Requires.private: @AX_PACKAGE_REQUIRES_PRIVATE@
diff --git a/xsec/Makefile.am b/xsec/Makefile.am
index 1700fd2..4d1fb51 100644
--- a/xsec/Makefile.am
+++ b/xsec/Makefile.am
@@ -21,7 +21,7 @@
 noinst_PROGRAMS = ${samples}
 bin_PROGRAMS = ${tools}
 
-AM_CXXFLAGS = $(xerces_CFLAGS) $(xalan_CFLAGS)
+AM_CXXFLAGS = $(xerces_CXXFLAGS) $(xalan_CXXFLAGS)
 LDADD = libxml-security-c.la $(xerces_LIBS) $(xalan_LIBS)
 
 #
@@ -157,8 +157,8 @@
 libxml_security_c_la_CPPFLAGS = $(AM_CPPFLAGS) -DXSEC_BUILDING_LIBRARY
 
 libxml_security_c_la_CXXFLAGS = \
-   $(xalan_CFLAGS) \
-   $(xerces_CFLAGS) \
+   $(xalan_CXXFLAGS) \
+   $(xerces_CXXFLAGS) \
    $(openssl_CFLAGS) \
    $(nss_CFLAGS)