diff --git a/m4/xerces_curl_prefix.m4 b/m4/xerces_curl_prefix.m4
index 91be4a2fd1eae4811158b67aaf243281b5058fe3..221e76513322483293f714783ee00c13cdaf2ac2 100644
--- a/m4/xerces_curl_prefix.m4
+++ b/m4/xerces_curl_prefix.m4
@@ -13,29 +13,67 @@ AC_DEFUN([XERCES_CURL_PREFIX],
 	[
 	AC_ARG_WITH([curl],
 		[AS_HELP_STRING([--with-curl[[[[=DIR]]]]],[Specify location of libcurl])],
-		[with_curl=m4_if($with_curl, [yes], [], $with_curl)],
+		[
+                  if test x"$with_curl" = x"yes"; then
+                    with_curl=
+                  fi
+                ],
 		[with_curl=])
 
 	# Determine if curl is available
-	AC_CACHE_CHECK([for libcurl], [xerces_cv_curl_prefix],
-	[	
-		xerces_cv_curl_prefix=
+	AC_CACHE_VAL([xerces_cv_curl_present],
+	[
+		xerces_cv_curl_present=no
 		if test x"$with_curl" != x"no"; then
-			pfix=$prefix
-			if test x"$pfix" == x"NONE"; then
-				pfix=
-			fi
-			search_list="$with_curl $pfix /usr/local /usr"
-			for i in $search_list; do
-				if test -r "$i/include/curl/easy.h" -a -r "$i/include/curl/multi.h" -a -x "$i/bin/curl-config" ; then
-					xerces_cv_curl_prefix=$i
-					break
-				fi
-			done
+
+                  # See if we were given a prefix.
+                  #
+		  if test -n "$with_curl"; then
+                    AC_PATH_PROG([curl_config], [curl-config],[],[$with_curl/bin])
+                  else
+                    AC_PATH_PROG([curl_config], [curl-config],[])
+                  fi
+
+                  if test -n "$curl_config"; then
+                    curl_flags=`$curl_config --cflags`
+		    curl_libs=`$curl_config --libs`
+                  else
+                    if test -n "$with_curl"; then
+                      curl_flags="-I$with_curl/include"
+     		      curl_libs="-L$with_curl/lib -lcurl"
+                    else
+                      # Default compiler paths.
+                      #
+                      curl_flags=
+     		      curl_libs=-lcurl
+                    fi
+                  fi
+
+                  # Check that the headers exist and can be compiled.
+                  #
+                  orig_cppflags=$CPPFLAGS
+                  if test -n "$curl_flags"; then
+		    CPPFLAGS="$curl_flags $CPPFLAGS"
+                  fi
+                  AC_CHECK_HEADER([curl/curl.h], [xerces_cv_curl_present=yes])
+		  CPPFLAGS=$orig_cppflags
+
+                  if test x"$xerces_cv_curl_present" != x"no"; then
+                    # Check that the library can be linked.
+                    #
+                    orig_ldflags=$LDFLAGS
+		    LDFLAGS="$curl_libs $LDFLAGS"
+                    AC_CHECK_LIB([curl], [curl_multi_init], [], [xerces_cv_curl_present=no])
+		    LDFLAGS=$orig_ldflags
+                  fi
 		fi
 	])
 
-	AC_SUBST([CURL_PREFIX], [$xerces_cv_curl_prefix])
+        AC_CACHE_VAL([xerces_cv_curl_flags], [xerces_cv_curl_flags=$curl_flags])
+	AC_CACHE_VAL([xerces_cv_curl_libs], [xerces_cv_curl_libs=$curl_libs])
+
+	AC_SUBST([CURL_PRESENT], [$xerces_cv_curl_present])
+	AC_SUBST([CURL_FLAGS], [$xerces_cv_curl_flags])
+	AC_SUBST([CURL_LIBS], [$xerces_cv_curl_libs])
 	]
 )
-
diff --git a/m4/xerces_icu_prefix.m4 b/m4/xerces_icu_prefix.m4
index 6b809ca53b005a056eaa308a1ab55e6cbfba0db7..e0f576283ccdfbdff118a2f18ff0a92ea374fd17 100644
--- a/m4/xerces_icu_prefix.m4
+++ b/m4/xerces_icu_prefix.m4
@@ -13,29 +13,112 @@ AC_DEFUN([XERCES_ICU_PREFIX],
 	[
 	AC_ARG_WITH([icu],
 		[AS_HELP_STRING([--with-icu[[[[=DIR]]]]],[Specify location of icu])],
-		[with_icu=m4_if($with_icu, [yes], [], $with_icu)],
+		[
+                  if test x"$with_icu" = x"yes"; then
+                    with_icu=
+                  fi
+                ],
 		[with_icu=])
 
 	# Determine if icu is available
-	AC_CACHE_CHECK([for icu], [xerces_cv_icu_prefix],
-	[	
-		xerces_cv_icu_prefix=
+	AC_CACHE_VAL([xerces_cv_icu_present],
+	[
+		xerces_cv_icu_present=no
 		if test x"$with_icu" != x"no"; then
-			pfix=$prefix
-			if test x"$pfix" == x"NONE"; then
-				pfix=
-			fi
-			search_list="$with_icu $pfix /usr/local /usr"
-			for i in $search_list; do	
-				if test -r $i/include/unicode/ucnv.h; then
-					xerces_cv_icu_prefix=$i
-					break
-				fi
-			done
+
+                  # See if we were given a prefix.
+                  #
+		  if test -n "$with_icu"; then
+                    AC_PATH_PROG([icu_config], [icu-config],[],[$with_icu/bin])
+                  else
+                    AC_PATH_PROG([icu_config], [icu-config],[])
+                  fi
+
+                  # Add trailing slash to bin and sbin vars so that we
+                  # can use them uniformly whether they are empty or not.
+                  #
+                  if test -n "$icu_config"; then
+                    icu_flags=`$icu_config --cppflags-searchpath`
+		    icu_libs=`$icu_config --ldflags`
+		    icu_bin=`$icu_config --bindir`
+		    icu_sbin=`$icu_config --sbindir`
+
+                    if test -n "$icu_bin"; then
+                      icu_bin="$icu_bin/"
+                    fi
+
+                    if test -n "$icu_sbin"; then
+                      icu_sbin="$icu_sbin/"
+                    fi
+
+                  else
+                    if test -n "$with_icu"; then
+                      icu_flags="-I$with_icu/include"
+     		      icu_libs="-L$with_icu/lib -licuuc -licudata"
+		      icu_bin="$with_icu/bin/"
+		      icu_sbin="$with_icu/sbin/"
+                    else
+                      # Default compiler paths.
+                      #
+                      icu_flags=
+     		      icu_libs="-licuuc -licudata"
+		      icu_bin=
+		      icu_sbin=
+                    fi
+                  fi
+
+                  # Check that the headers exist and can be compiled.
+                  #
+                  orig_cppflags=$CPPFLAGS
+                  if test -n "$icu_flags"; then
+		    CPPFLAGS="$icu_flags $CPPFLAGS"
+                  fi
+                  AC_CHECK_HEADER([unicode/ucnv.h], [xerces_cv_icu_present=yes])
+
+
+                  if test x"$xerces_cv_icu_present" != x"no"; then
+
+                    # Check that the library can be linked.
+                    #
+                    AC_MSG_CHECKING([for ucnv_open in -licuuc])
+
+		    orig_ldflags=$LDFLAGS
+		    LDFLAGS="$icu_libs $LDFLAGS"
+
+                    AC_LINK_IFELSE(
+		    AC_LANG_SOURCE[[
+		    #include <unicode/ucnv.h>
+
+                    int main ()
+                    {
+                      ucnv_open (0, 0);
+                      return 0;
+                    }
+		    ]],
+		    [], [xerces_cv_icu_present=no])
+
+		    LDFLAGS=$orig_ldflags
+
+                    if test x"$xerces_cv_icu_present" != x"no"; then
+		      AC_MSG_RESULT([yes])
+                    else
+                      AC_MSG_RESULT([no])
+                    fi
+                  fi
+
+                  CPPFLAGS=$orig_cppflags
 		fi
 	])
-	
-	AC_SUBST([ICU_PREFIX], [$xerces_cv_icu_prefix])
+
+        AC_CACHE_VAL([xerces_cv_icu_flags], [xerces_cv_icu_flags=$icu_flags])
+	AC_CACHE_VAL([xerces_cv_icu_libs], [xerces_cv_icu_libs=$icu_libs])
+	AC_CACHE_VAL([xerces_cv_icu_bin], [xerces_cv_icu_bin=$icu_bin])
+	AC_CACHE_VAL([xerces_cv_icu_sbin], [xerces_cv_icu_sbin=$icu_sbin])
+
+	AC_SUBST([ICU_PRESENT], [$xerces_cv_icu_present])
+	AC_SUBST([ICU_FLAGS], [$xerces_cv_icu_flags])
+	AC_SUBST([ICU_LIBS], [$xerces_cv_icu_libs])
+	AC_SUBST([ICU_BIN], [$xerces_cv_icu_bin])
+	AC_SUBST([ICU_SBIN], [$xerces_cv_icu_sbin])
 	]
 )
-
diff --git a/m4/xerces_msgloader_selection.m4 b/m4/xerces_msgloader_selection.m4
index 7bb5dcfb05ea745ed7277718f39d5f1c6e306af0..e6de5bac7ae2d964004eb593ef8a9d356252fdf1 100644
--- a/m4/xerces_msgloader_selection.m4
+++ b/m4/xerces_msgloader_selection.m4
@@ -41,7 +41,7 @@ AC_DEFUN([XERCES_MSGLOADER_SELECTION],
 	AC_REQUIRE([XERCES_ICU_PREFIX])
 	AC_MSG_CHECKING([whether we support the ICU MsgLoader])
 	list_add=
-	AS_IF([test x"$xerces_cv_icu_prefix" != x -a -x $xerces_cv_icu_prefix/bin/genrb], [
+	AS_IF([test x"$xerces_cv_icu_present" != x"no"], [
 		AC_ARG_ENABLE([msgloader-icu],
 			AS_HELP_STRING([--enable-msgloader-icu],
 				[Enable ICU-based MsgLoader support]),
@@ -105,7 +105,7 @@ AC_DEFUN([XERCES_MSGLOADER_SELECTION],
 		*-icu-*)
 			AC_DEFINE([XERCES_USE_MSGLOADER_ICU], 1, [Define to use the ICU-based MsgLoader])
 			msgloader=icu
-			LIBS="${LIBS} -L${xerces_cv_icu_prefix}/lib -licuuc -licudata"
+			LIBS="${LIBS} ${xerces_cv_icu_libs}"
 			break
 			;;
 
diff --git a/m4/xerces_netaccessor_selection.m4 b/m4/xerces_netaccessor_selection.m4
index 7cf6566d9f26089d4719dbdce16bba2bd6b87381..0b088fcdbd82032c0922058e2ff125cf2a9063f7 100644
--- a/m4/xerces_netaccessor_selection.m4
+++ b/m4/xerces_netaccessor_selection.m4
@@ -29,8 +29,6 @@ AC_DEFUN([XERCES_NETACCESSOR_SELECTION],
 	AC_CHECK_LIB([socket], [socket])
 	AC_CHECK_LIB([nsl], [gethostbyname])
 
-        XERCES_CURL_PREFIX
-
 	######################################################
 	# Test for availability of each netaccessor on this host.
 	# For each netaccessor that's available, and hasn't been disabled, add it to our list.
@@ -41,7 +39,7 @@ AC_DEFUN([XERCES_NETACCESSOR_SELECTION],
 	AC_REQUIRE([XERCES_CURL_PREFIX])
 	AC_MSG_CHECKING([whether we can support the libcurl-based NetAccessor])
 	list_add=
-	AS_IF([test x"$xerces_cv_curl_prefix" != x], [
+	AS_IF([test x"$xerces_cv_curl_present" != x"no"], [
 		AC_ARG_ENABLE([netaccessor-curl],
 			AS_HELP_STRING([--enable-netaccessor-curl],
 				[Enable libcurl-based NetAccessor support]),
@@ -152,10 +150,7 @@ AC_DEFUN([XERCES_NETACCESSOR_SELECTION],
 		*-curl-*)
 			netaccessor=curl
 			AC_DEFINE([XERCES_USE_NETACCESSOR_CURL], 1, [Define to use the CURL NetAccessor])
-			CURL_LIBS=`${xerces_cv_curl_prefix}/bin/curl-config --libs`
-			CURL_CFLAGS=`${xerces_cv_curl_prefix}/bin/curl-config --cflags`
-			LIBS="${LIBS} $CURL_LIBS"
-			CXXFLAGS="${CXXFLAGS} ${CURL_CFLAGS}"
+			LIBS="${LIBS} ${xerces_cv_curl_libs}"
 			break
 			;;
 
diff --git a/m4/xerces_transcoder_selection.m4 b/m4/xerces_transcoder_selection.m4
index 765f2cf4920e49359880bff930d022700272a7f2..80f432a86e86259794b39c51730ea918e564a064 100644
--- a/m4/xerces_transcoder_selection.m4
+++ b/m4/xerces_transcoder_selection.m4
@@ -25,8 +25,8 @@ AC_DEFUN([XERCES_TRANSCODER_SELECTION],
 	no_GNUiconv=false
 	AC_CHECK_HEADERS([iconv.h wchar.h string.h stdlib.h stdio.h ctype.h locale.h errno.h], [], [no_GNUiconv=true])
         # The code in iconv needs just on of these include files
-	AC_CHECK_HEADER([endian.h], 
-                        [], 
+	AC_CHECK_HEADER([endian.h],
+                        [],
                         [
                          AC_CHECK_HEADER([machine/endian.h],
                                          [],
@@ -75,7 +75,7 @@ AC_DEFUN([XERCES_TRANSCODER_SELECTION],
 	AC_REQUIRE([XERCES_ICU_PREFIX])
 	AC_MSG_CHECKING([whether we can support the ICU Transcoder])
 	list_add=
-	AS_IF([test x"$xerces_cv_icu_prefix" != x], [
+	AS_IF([test x"$xerces_cv_icu_present" != x"no"], [
 		AC_ARG_ENABLE([transcoder-icu],
 			AS_HELP_STRING([--enable-transcoder-icu],
 				[Enable icu-based transcoder support]),
@@ -163,8 +163,7 @@ AC_DEFUN([XERCES_TRANSCODER_SELECTION],
 		*-icu-*)
 			transcoder=icu
 			AC_DEFINE([XERCES_USE_TRANSCODER_ICU], 1, [Define to use the ICU-based transcoder])
-			AC_SUBST([ICU_CXXFLAGS], [-I$xerces_cv_icu_prefix/include])
-			LIBS="${LIBS} -L${xerces_cv_icu_prefix}/lib -licuuc -licudata"
+			LIBS="${LIBS} ${xerces_cv_icu_libs}"
 			break
 			;;
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 701fe6bb3fbb45b9fb470493c3502d862febad5a..b2bf1eb09debbb02fe820eb004573087afb7006c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,7 +32,6 @@ lib_LTLIBRARIES = libxerces-c.la
 # make pretty-printing won't work.
 #
 AM_CPPFLAGS =
-AM_CXXFLAGS = $(ICU_CXXFLAGS)
 
 libxerces_c_la_LDFLAGS = -release ${INTERFACE_VER_D}
 
@@ -60,13 +59,12 @@ nodist_autoconfheaders_HEADERS = ${top_builddir}/src/xercesc/util/Xerces_autocon
 EXTRA_DIST = stricmp.h strnicmp.h towlower.h towupper.h
 libxerces_c_la_LIBADD = ${LTLIBOBJS}
 
-
 # NetAccessors, conditionally built based on settings from configure
 #
 if XERCES_USE_NETACCESSOR_CURL
 libxerces_c_la_SOURCES += ${curl_sources}
 nobase_libxerces_c_la_HEADERS += ${curl_headers}
-AM_CPPFLAGS += -I${CURL_PREFIX}/include/curl
+AM_CPPFLAGS += ${CURL_FLAGS}
 endif
 
 if XERCES_USE_NETACCESSOR_SOCKET
@@ -90,7 +88,7 @@ endif
 if XERCES_USE_TRANSCODER_ICU
 libxerces_c_la_SOURCES += ${icu_sources}
 nobase_libxerces_c_la_HEADERS += ${icu_headers}
-AM_CPPFLAGS += -I${ICU_PREFIX}/include
+AM_CPPFLAGS += ${ICU_FLAGS}
 endif
 
 if XERCES_USE_TRANSCODER_GNUICONV
@@ -125,7 +123,7 @@ if XERCES_USE_MSGLOADER_ICU
 libxerces_c_la_SOURCES += ${msgicu_sources}
 nodist_libxerces_c_la_SOURCES = ${msgicu_nodist_sources}
 nobase_libxerces_c_la_HEADERS += ${msgicu_headers}
-AM_CPPFLAGS += -I${ICU_PREFIX}/include
+AM_CPPFLAGS += ${ICU_FLAGS}
 
 EXTRA_DIST += xercesc/util/MsgLoaders/ICU/resources/res-file-list.txt \
 xercesc/util/MsgLoaders/ICU/resources/root.txt
@@ -136,12 +134,12 @@ PKGNAME=xercesc_messages_${INTERFACE_VER_U}
 CLEANFILES = xercesc_messages.c root_res.c root.res
 BUILT_SOURCES = xercesc_messages.c root_res.c
 xercesc_messages.c: ${top_srcdir}/src/xercesc/util/MsgLoaders/ICU/resources/res-file-list.txt
-	${ICU_PREFIX}/sbin/gencmn --name ${PKGNAME} -S ${PKGNAME}_dat.c -d . ${top_srcdir}/src/xercesc/util/MsgLoaders/ICU/resources/res-file-list.txt
+	${ICU_SBIN}gencmn --name ${PKGNAME} -S ${PKGNAME}_dat.c -d . ${top_srcdir}/src/xercesc/util/MsgLoaders/ICU/resources/res-file-list.txt
 	@mv ${PKGNAME}_dat.c xercesc_messages.c
 
 root_res.c: ${top_srcdir}/src/xercesc/util/MsgLoaders/ICU/resources/root.txt
-	${ICU_PREFIX}/bin/genrb -d . ${top_srcdir}/src/xercesc/util/MsgLoaders/ICU/resources/root.txt
-	${ICU_PREFIX}/sbin/genccode --name ${PKGNAME} -d . root.res
+	${ICU_BIN}genrb -d . ${top_srcdir}/src/xercesc/util/MsgLoaders/ICU/resources/root.txt
+	${ICU_SBIN}genccode --name ${PKGNAME} -d . root.res
 
 endif
 
diff --git a/src/xercesc/util/NetAccessors/Curl/CurlURLInputStream.hpp b/src/xercesc/util/NetAccessors/Curl/CurlURLInputStream.hpp
index dbee8633c874243877955366c040ed7dca9e73fa..ea528c1eb215333c7579f07a8577632530cabc13 100644
--- a/src/xercesc/util/NetAccessors/Curl/CurlURLInputStream.hpp
+++ b/src/xercesc/util/NetAccessors/Curl/CurlURLInputStream.hpp
@@ -22,9 +22,9 @@
 #if !defined(XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP)
 #define XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP
 
-#include <curl.h>
-#include <multi.h>
-#include <easy.h>
+#include <curl/curl.h>
+#include <curl/multi.h>
+#include <curl/easy.h>
 
 #include <xercesc/util/XMLURL.hpp>
 #include <xercesc/util/XMLExceptMsgs.hpp>