diff --git a/samples/Makefile.incl b/samples/Makefile.incl
index b16061e048432a8564d3d57b197821579ed268b9..654baeea47995de5d8f10231bb4444fa47cd3120 100644
--- a/samples/Makefile.incl
+++ b/samples/Makefile.incl
@@ -235,6 +235,21 @@ ifeq (${PLATFORM}, FREEBSD)
   SHLIBSUFFIX=.so
 endif
 
+#=============== NETBSD SPECIFIC OPTIONS =========================
+ifeq (${PLATFORM}, NETBSD)
+  CMP= -c ${CXXFLAGS}
+  CC= ${COMPILER} -c -D${PLATFORM} -fPIC
+  LINK = ${COMPILER} -D${PLATFORM} -fPIC ${LDFLAGS}
+  PLATFORM_LIB_LINK_OPTIONS=-Wl,-rpath,${XERCESCROOT}/lib
+  ifdef ICUROOT
+    PLATFORM_LIB_LINK_OPTIONS+=-L${ICUROOT} -Wl,-rpath,${ICUROOT}
+    EXTRA_LINK_OPTIONS=-licudata -lstdc++ ${EXTRA_LIBS}
+  else
+    EXTRA_LINK_OPTIONS=${EXTRA_LIBS} -lstdc++
+  endif
+  SHLIBSUFFIX=.so
+endif
+
 #================= HP SPECIFIC OPTIONS ===========================
 ifeq (${PLATFORM}, HPUX)
   ifeq (${COMPILER}, aCC)
diff --git a/samples/configure.in b/samples/configure.in
index aa9a55dd67ca6d63d6dd5a1dffe2b00e20504297..ca2a751779a642f1bfc82727e4e3d24e34af6b11 100644
--- a/samples/configure.in
+++ b/samples/configure.in
@@ -40,6 +40,7 @@ case "${host}" in
         *-*-linux*)     platform=LINUX ;;
         *-*-nto*)       platform=QNX ;;
         *-*-freebsd*)   platform=FREEBSD ;;
+        *-*-netbsd*)    platform=NETBSD ;;
         *-*-irix*)      platform=IRIX ;;
         *-*-aix*)       platform=AIX ;;
         *-*-hp*)        platform=HPUX ;
diff --git a/samples/runConfigure b/samples/runConfigure
index bcaf9cb2862598a4efeb04c9facea8bfa9f380e7..ca0d0778c844bb3b9f3029de69c9b550c6cfb88e 100755
--- a/samples/runConfigure
+++ b/samples/runConfigure
@@ -82,7 +82,7 @@ usage()
     echo "runConfigure: Helper script to run \"configure\" for one of the supported platforms"
     echo "Usage: runConfigure \"options\""
     echo "       where options may be any of the following:"
-    echo "       -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'solaris',
+    echo "       -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'netbsd', 'solaris',
                  'hp-10', 'hp-11', 'openserver', 'unixware', 'os400', 'irix',
                  'ptx', 'tru64', 'macosx', 'cygwin')"
     echo "       -c <C compiler name> (e.g. gcc, cc, xlc_r, icc or ecc)"
@@ -196,7 +196,7 @@ echo "Extra link options: $linkeroptions"
 # Now check if the options are correct or not, bail out if incorrect
 #
 case $platform in
-   aix | openserver | unixware | beos | linux | freebsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx | cygwin)
+   aix | openserver | unixware | beos | linux | freebsd | netbsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx | cygwin)
        # platform has been recognized
        ;;
    *)
@@ -264,6 +264,9 @@ else
     elif test $platform = "freebsd"; then
         threadingLibs="-pthread -lc_r"
         threadingDefines="-D_THREAD_SAFE -DXML_USE_PTHREADS"
+    elif test $platform = "netbsd"; then
+        threadingLibs="-pthread"
+        threadingDefines="-D_THREAD_SAFE -DXML_USE_PTHREADS"
     elif test $platform = "aix"; then
         aix_version=`./config.guess`;
         echo Found host system to be $aix_version
@@ -343,7 +346,7 @@ export THREADS
 
 #
 #  aix | beos | linux | hp-11 | solaris |
-#  hp-10 | freebsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
+#  hp-10 | freebsd | netbsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
 #
 if test $bitsToBuild = 64; then
     bitstobuildDefines=" -DXML_BITSTOBUILD_64 "
diff --git a/src/xercesc/Makefile.incl b/src/xercesc/Makefile.incl
index 2219ec3f9b5596588b6db1b9c2d91df819da2da7..12eb60f2a803d2571c0927648e455483c9191187 100644
--- a/src/xercesc/Makefile.incl
+++ b/src/xercesc/Makefile.incl
@@ -373,6 +373,22 @@ SHLIBSUFFIX=.so
 LD_SONAME = -Wl,-soname,${SO_NAME}
 endif
 
+#=============== NETBSD SPECIFIC OPTIONS =========================
+ifeq (${PLATFORM}, NETBSD)
+MAKE_SHARED = ${CXX} -D${PLATFORM} -shared -fPIC ${LDFLAGS}
+MAKE_SHARED_C = ${CC} -D${PLATFORM} -shared -fPIC ${LDFLAGS}
+ifeq (${TRANSCODER}, ICU)
+    PLATFORM_COMPILE_OPTIONS = -fPIC -D${PLATFORM} -I/usr/local/include
+    ALLLIBS = ${LIBS} -L/usr/local/lib -licuuc -L${ICUROOT} -licudata -lgcc
+else
+    PLATFORM_COMPILE_OPTIONS = -fPIC -D${PLATFORM}
+    ALLLIBS = ${LIBS}
+endif
+SHLIBSUFFIX=.so
+## Compiler switch to embed a library name
+LD_SONAME = -Wl,-soname,${SO_NAME}
+endif
+
 #=============== IRIX SPECIFIC OPTIONS ============================
 ifeq (${PLATFORM}, IRIX)
 PLATFORM_COMPILE_OPTIONS = -LANG:pch -LANG:std -O2 \
diff --git a/src/xercesc/configure.in b/src/xercesc/configure.in
index ffdf4317332e231f5044b8a0ed56a8b97918d9ea..f1f9a1891eddf4e05200fd7877565d49d3836b37 100644
--- a/src/xercesc/configure.in
+++ b/src/xercesc/configure.in
@@ -36,6 +36,7 @@ case "${host}" in
         *-*-nto*)       platform=QNX ;;
         *-*-linux*)     platform=LINUX ;;
         *-*-freebsd*)   platform=FREEBSD ;;
+        *-*-netbsd*)    platform=NETBSD ;;
         *-*-irix*)      platform=IRIX ;;
         *-*-aix*)       platform=AIX
                       case "${host}" in
@@ -127,6 +128,7 @@ util/Platforms/BeOS/Makefile \
 util/Platforms/QNX/Makefile \
 util/Platforms/Linux/Makefile \
 util/Platforms/FreeBSD/Makefile \
+util/Platforms/NetBSD/Makefile \
 util/Platforms/HPUX/Makefile \
 util/Platforms/OS390/Makefile \
 util/Platforms/OS400/Makefile \
diff --git a/src/xercesc/runConfigure b/src/xercesc/runConfigure
index f3da8320f8c73a6f615937a57e4500beda5c11d2..6940c50e664d4d4f8c2363cf30da611e83b5803a 100755
--- a/src/xercesc/runConfigure
+++ b/src/xercesc/runConfigure
@@ -84,7 +84,7 @@ usage()
     echo "runConfigure: Helper script to run \"configure\" for one of the supported platforms"
     echo "Usage: runConfigure \"options\""
     echo "       where options may be any of the following:"
-    echo "       -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'solaris',
+    echo "       -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'netbsd', 'solaris',
             'hp-10', 'hp-11', 'openserver', 'unixware', 'os400', 'irix',
             'ptx', 'tru64', 'macosx', 'cygwin', 'qnx')"
     echo "       -c <C compiler name> (e.g. gcc, cc, xlc_r, qcc, icc or ecc)"
@@ -227,7 +227,7 @@ echo "Extra configure options: $configureoptions"
 #
 
 case $platform in
-   aix | openserver | unixware | beos | linux | freebsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx | cygwin | qnx)
+   aix | openserver | unixware | beos | linux | freebsd | netbsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx | cygwin | qnx)
        # platform has been recognized
        ;;
    *)
@@ -305,6 +305,9 @@ else
     elif test $platform = "freebsd"; then
         threadingLibs="-pthread -lc_r"
         threadingDefines="-D_THREAD_SAFE -DXML_USE_PTHREADS"
+    elif test $platform = "netbsd"; then
+        threadingLibs="-pthread -lpthread"
+        threadingDefines="-D_THREAD_SAFE -DXML_USE_PTHREADS"
     elif test $platform = "aix"; then
         aix_version=`./config.guess`;
         echo Found host system to be $aix_version
@@ -385,7 +388,7 @@ export THREADS
 
 #
 #  aix | beos | linux | hp-11 | solaris |
-#  hp-10 | freebsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
+#  hp-10 | freebsd | netbsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
 #
 if test $bitsToBuild = 64; then
     bitstobuildDefines=" -DXML_BITSTOBUILD_64 "
diff --git a/src/xercesc/util/AutoSense.hpp b/src/xercesc/util/AutoSense.hpp
index 0483f58217853abd85d55e03559e16cab2605863..3535d6e6810dc4d88a9e30b890481732449d6e86 100644
--- a/src/xercesc/util/AutoSense.hpp
+++ b/src/xercesc/util/AutoSense.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.11  2003/05/12 09:44:19  gareth
+ * Port to NetBSD. Patch by Hiramatsu Yoshifumi.
+ *
  * Revision 1.10  2003/03/27 16:16:43  tng
  * use __IBMCPP__ instead of __xlC__ to determine xlC compiler
  *
@@ -253,6 +256,8 @@
     #define XML_MACOS
 #elif defined(__alpha) && defined(__osf__)
     #define XML_TRU64
+#elif defined(__NetBSD__)
+    #define XML_NETBSD
 #else
     #error Code requires port to host OS!
 #endif
diff --git a/src/xercesc/util/Compilers/Makefile.in b/src/xercesc/util/Compilers/Makefile.in
index 771be88a9babe3a8d54a156a91eefad5c9df7b86..da9acec1a0b55cdd8dece9c94f8337e61fa78d11 100644
--- a/src/xercesc/util/Compilers/Makefile.in
+++ b/src/xercesc/util/Compilers/Makefile.in
@@ -147,6 +147,9 @@ ifeq (${CXX},c++)
     ifeq (${PLATFORM},FREEBSD)
         CPP_OBJECTS = GCCDefs.$(TO)
     endif
+    ifeq (${PLATFORM},NETBSD)
+        CPP_OBJECTS = GCCDefs.$(TO)
+    endif
     ifeq (${PLATFORM},MACOSX)
         CPP_OBJECTS = GCCDefs.$(TO)
     endif
diff --git a/src/xercesc/util/Platforms/Makefile.in b/src/xercesc/util/Platforms/Makefile.in
index 0b5f94bbbdc5c112e6fcf26c6087a80f3a08b457..e0768ac7935146ac54e07e4ff9fb6f7f91d31d24 100644
--- a/src/xercesc/util/Platforms/Makefile.in
+++ b/src/xercesc/util/Platforms/Makefile.in
@@ -55,6 +55,9 @@
 #
 #
 # $Log$
+# Revision 1.8  2003/05/12 09:44:19  gareth
+# Port to NetBSD. Patch by Hiramatsu Yoshifumi.
+#
 # Revision 1.7  2003/03/13 22:11:28  tng
 # [Bug 17858] Support for QNX/Neutrino.  Patch from Chris McKillop.
 #
@@ -169,6 +172,9 @@ endif
 ifeq (${PLATFORM}, FREEBSD)
     SUBMODULE = FreeBSD
 endif
+ifeq (${PLATFORM}, NETBSD)
+    SUBMODULE = NetBSD
+endif
 ifeq (${PLATFORM}, HPUX)
     SUBMODULE = HPUX
 endif
diff --git a/src/xercesc/util/XercesDefs.hpp b/src/xercesc/util/XercesDefs.hpp
index 4999beca81d45c041ad38ac06cd3b0f8bf55e26e..28ddb69f8c2931cb08451ef2b20713a33b80fe0f 100644
--- a/src/xercesc/util/XercesDefs.hpp
+++ b/src/xercesc/util/XercesDefs.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.14  2003/05/12 09:44:19  gareth
+ * Port to NetBSD. Patch by Hiramatsu Yoshifumi.
+ *
  * Revision 1.13  2003/03/13 22:11:46  tng
  * [Bug 17858] Support for QNX/Neutrino.  Patch from Chris McKillop.
  *
@@ -416,6 +419,9 @@ typedef XMLUInt32           UCS4Ch;
   #endif
 #endif
 
+#if defined(XML_NETBSD)
+#include       <xercesc/util/Platforms/NetBSD/NetBSDDefs.hpp>
+#endif
 
 // ---------------------------------------------------------------------------
 //  According to whether the compiler suports L"" type strings, we define
diff --git a/tests/Makefile.incl b/tests/Makefile.incl
index b46221e1d67ec6cf726811149236732a0e810f15..2b79e68abdb8aa3ebf71ac21376a876c701210dd 100644
--- a/tests/Makefile.incl
+++ b/tests/Makefile.incl
@@ -234,6 +234,21 @@ ifeq (${PLATFORM}, FREEBSD)
   SHLIBSUFFIX=.so
 endif
 
+#=============== NETBSD SPECIFIC OPTIONS =========================
+ifeq (${PLATFORM}, NETBSD)
+  CMP= -c ${CXXFLAGS}
+  CC= ${COMPILER} -c -D${PLATFORM} -fPIC
+  LINK = ${COMPILER} -D${PLATFORM} -fPIC ${LDFLAGS}
+  PLATFORM_LIB_LINK_OPTIONS=-Wl,-rpath,${XERCESCROOT}/lib
+  ifdef ICUROOT
+    PLATFORM_LIB_LINK_OPTIONS+=-L${ICUROOT} -Wl,-rpath,${ICUROOT}
+    EXTRA_LINK_OPTIONS=-licudata -lstdc++ ${EXTRA_LIBS}
+  else
+    EXTRA_LINK_OPTIONS=${EXTRA_LIBS} -lstdc++
+  endif
+  SHLIBSUFFIX=.so
+endif
+
 #================= HP SPECIFIC OPTIONS ===========================
 ifeq (${PLATFORM}, HPUX)
   ifeq (${COMPILER}, aCC)
diff --git a/tests/configure b/tests/configure
index 6ca4ff200f7c4c5f580be329efb487cab734395b..6a1d8619d196a57f2877e76995aee7f0345a3c6d 100755
--- a/tests/configure
+++ b/tests/configure
@@ -1312,6 +1312,7 @@ case "${host}" in
         *-*-nto*)       platform=QNX ;;
         *-*-linux*)     platform=LINUX ;;
         *-*-freebsd*)   platform=FREEBSD ;;
+        *-*-netbsd*)    platform=NETBSD ;;
         *-*-irix*)      platform=IRIX ;;
         *-*-aix*)       platform=AIX ;;
         *-*-hp*)        platform=HPUX ;
@@ -1333,9 +1334,9 @@ esac
 compiler=${CXX}
 
 
-# prefix=${prefix}
 
 
+# prefix=${prefix}
 
 
 cxxflags=${CXXFLAGS}
@@ -1531,8 +1532,8 @@ s%@cxxflags@%$cxxflags%g
 s%@cflags@%$cflags%g
 s%@ldflags@%$ldflags%g
 s%@threads@%$threads%g
-s%@extra_libs@%$extra_libs%g
 s%@bitstobuild@%$bitstobuild%g
+s%@extra_libs@%$extra_libs%g
 
 CEOF
 EOF
diff --git a/tests/configure.in b/tests/configure.in
index e0dd42d7adf4f9f3ff276235e4e38b0497dd5a74..858f136cc975d4aa92b4aeee3ae027ded4332c8e 100644
--- a/tests/configure.in
+++ b/tests/configure.in
@@ -40,6 +40,7 @@ case "${host}" in
         *-*-linux*)     platform=LINUX ;;
         *-*-nto*)       platform=QNX ;;
         *-*-freebsd*)   platform=FREEBSD ;;
+        *-*-netbsd*)    platform=NETBSD ;;
         *-*-irix*)      platform=IRIX ;;
         *-*-aix*)       platform=AIX ;;
         *-*-hp*)        platform=HPUX ;
diff --git a/tests/runConfigure b/tests/runConfigure
index bdf0dc75f7de213c867d3393b38f132f604abb1e..39ef3d8e17c550d8dac495567d25143802d4d7b2 100755
--- a/tests/runConfigure
+++ b/tests/runConfigure
@@ -82,7 +82,7 @@ usage()
     echo "runConfigure: Helper script to run \"configure\" for one of the supported platforms"
     echo "Usage: runConfigure \"options\""
     echo "       where options may be any of the following:"
-    echo "       -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'solaris',
+    echo "       -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'netbsd', 'solaris',
                  'hp-10', 'hp-11', 'openserver', 'unixware', 'os400', 'irix',
                  'ptx', 'tru64', 'macosx', 'cygwin')"
     echo "       -c <C compiler name> (e.g. gcc, cc, xlc_r, icc or ecc)"
@@ -196,7 +196,7 @@ echo "Extra link options: $linkeroptions"
 # Now check if the options are correct or not, bail out if incorrect
 #
 case $platform in
-   aix | openserver | unixware | beos | linux | freebsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx | cygwin | qnx)
+   aix | openserver | unixware | beos | linux | freebsd | netbsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx | cygwin | qnx)
        # platform has been recognized
        ;;
    *)
@@ -264,6 +264,9 @@ else
     elif test $platform = "freebsd"; then
         threadingLibs="-pthread -lc_r"
         threadingDefines="-D_THREAD_SAFE -DXML_USE_PTHREADS"
+    elif test $platform = "netbsd"; then
+        threadingLibs="-pthread"
+        threadingDefines="-D_THREAD_SAFE -DXML_USE_PTHREADS"
     elif test $platform = "aix"; then
         aix_version=`./config.guess`;
         echo Found host system to be $aix_version
@@ -343,7 +346,7 @@ export THREADS
 
 #
 #  aix | beos | linux | hp-11 | solaris |
-#  hp-10 | freebsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
+#  hp-10 | freebsd | netbsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
 #
 if test $bitsToBuild = 64; then
     bitstobuildDefines=" -DXML_BITSTOBUILD_64 "