diff --git a/obj/Makefile.in b/obj/Makefile.in
index 83d461ab8deebf9a186e6115b03f907924132ace..7dafd8a8cce123d71712393127f1dc3cd2ded0ce 100644
--- a/obj/Makefile.in
+++ b/obj/Makefile.in
@@ -75,6 +75,7 @@ LDFLAGS = @ldflags@
 LIBS = @libs@
 OSVER = @osver@
 TRANSCODER = @transcoder@
+BITSTOBUILD = @bitstobuild@
 
 include ../version.incl
 include ../src/xercesc/Makefile.incl
diff --git a/samples/Makefile.in b/samples/Makefile.in
index ecf0f92f07d6a706d0a9ad2a3938a8493bf3d849..206dfe791f4dbc37ed45d22ddfe19492c10b7e8e 100644
--- a/samples/Makefile.in
+++ b/samples/Makefile.in
@@ -80,6 +80,7 @@ COMPILER = @compiler@
 CXXFLAGS = @cxxflags@
 CFLAGS = @cflags@
 PREFIX = @prefix@
+BITSTOBUILD = @bitstobuild@
 
 all::	saxprint sax2print saxcount sax2count domprint domcount idomprint idomcount redirect memparse pparse stdinparse enumval senumval createdomdocument
 
diff --git a/samples/configure b/samples/configure
index b6556571310264c901c0a9d132b6c8a649f358ef..4177f1a26f4988726dc3185804ad5f8473828338 100755
--- a/samples/configure
+++ b/samples/configure
@@ -1293,6 +1293,8 @@ cflags=${CFLAGS}
 
 ldflags=${LDFLAGS}
 
+bitstobuild=${BITSTOBUILD}
+
 
 trap '' 1 2 15
 cat > confcache <<\EOF
@@ -1472,6 +1474,7 @@ s%@compiler@%$compiler%g
 s%@cxxflags@%$cxxflags%g
 s%@cflags@%$cflags%g
 s%@ldflags@%$ldflags%g
+s%@bitstobuild@%$bitstobuild%g
 
 CEOF
 EOF
diff --git a/samples/configure.in b/samples/configure.in
index 93adeaa4e737fc7742be146a5f03d1359e2a2cbf..53081c670c4aac2e227d2b502b378c1a5a22c065 100644
--- a/samples/configure.in
+++ b/samples/configure.in
@@ -67,6 +67,9 @@ AC_SUBST(cflags)
 ldflags=${LDFLAGS}
 AC_SUBST(ldflags)
 
+bitstobuild=${BITSTOBUILD}
+AC_SUBST(bitstobuild)
+
 dnl output the Makefiles
 AC_OUTPUT([Makefile \
 SAXCount/Makefile \
diff --git a/samples/runConfigure b/samples/runConfigure
index e90460b297188cd7756d1c276bf14f6391856d8a..999257d0bd9333c4c8b4049322462090179775f8 100755
--- a/samples/runConfigure
+++ b/samples/runConfigure
@@ -74,6 +74,7 @@ usage()
     echo "       -c <C compiler name> (e.g. gcc, xlc or icc)"
     echo "       -x <C++ compiler name> (e.g. g++, xlC, or icc)"
     echo "       -d (specifies that you want to build debug version)"
+    echo "       -b <bitsToBuild> (accepts '64', '32')"    
     echo "       -l <extra linker options>"
     echo "       -z <extra compiler options>"
     echo "       -h (get help on the above commands)"
@@ -103,9 +104,9 @@ fi
 
 # Check the command line parameters
 if test -x /usr/bin/getopt; then
-getoptErr=`getopt p:c:x:dm:n:t:r:l:z:h $*`
+getoptErr=`getopt p:c:x:dm:n:t:r:l:b:z:h $*`
 else
-getoptErr=`getopts p:c:x:dm:n:t:r:l:z:h `$*``
+getoptErr=`getopts p:c:x:dm:n:t:r:l:b:z:h `$*``
 fi
 if [ $? != 0 ]
    then
@@ -115,14 +116,15 @@ fi
 
 # Now get the command line parameters
 if test -x /usr/bin/getopt; then
-set -- `getopt p:c:x:dm:n:t:r:l:z:h $*`
+set -- `getopt p:c:x:dm:n:t:r:l:b:z:h $*`
 else
-set --`getopts p:c:x:dm:n:t:r:l:z:h `$*``
+set --`getopts p:c:x:dm:n:t:r:l:b:z:h `$*``
 fi
 
 # Set up the default values for each parameter
 debug=off                # by default debug is off
 compileroptions=""
+bitsToBuild=32           # by default 32 bit build assumed
 while [ $# -gt 0 ]
    do
    case $1 in
@@ -137,6 +139,9 @@ while [ $# -gt 0 ]
 
    -d)
         debug=on; shift;;
+        
+   -b)
+        bitsToBuild=$2; shift 2;;                  
 
    -z)
         compileroptions="$compileroptions $2"; shift 2;;
@@ -169,6 +174,7 @@ echo "Generating makefiles with the following options ..."
 echo "Platform: $platform"
 echo "C Compiler: $ccompiler"
 echo "C++ Compiler: $cppcompiler"
+echo "bitsToBuild option: $bitsToBuild"
 echo "Extra compile options: $compileroptions"
 echo "Extra link options: $linkeroptions"
 
@@ -221,14 +227,54 @@ export CC
 CXX="$cppcompiler"
 export CXX
 
+#
+# Check for the bitsToBuild option
+#
+
+#
+#  aix | linux | hp-11 | solaris | 
+#  hp-10 | freebsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
+#
+if test $bitsToBuild = 64; then
+    bitstobuildDefines=" -DXML_BITSTOBUILD_64 " 
+    if test $platform; then
+        case $platform in
+           solaris)
+              bitstobuildDefines=" $bitstobuildDefines -xarch=v9 " ;;
+           aix)
+              bitstobuildDefines=" $bitstobuildDefines -q64 -qwarn64 " ;;
+           hp-11)
+              bitstobuildDefines=" $bitstobuildDefines +DD64 " ;;
+           linux)
+              bitstobuildDefines=" $bitstobuildDefines " ;;
+           *)
+            ;;
+        esac
+    fi
+elif test $bitsToBuild = 32; then
+    bitstobuildDefines=" "
+else
+    echo "I do not recognize the bitsToBuild '$bitsToBuild'. Please type '${0} -h' for help."
+    exit ${ERROR_EXIT_CODE};
+fi
+
+#
+# to export in case it is needed in Makefile.in/Makefine.incl
+#
+BITSTOBUILD=$bitsToBuild
+export BITSTOBUILD
+
 #
 # Set the extra C and C++ compiler flags
 #
 # include the user defined CXXFLAGS/CFLAGS first in case they have
 # set an platform spefic flags
 #
-CXXFLAGS="$CXXFLAGS $compileroptions $debugflag"; export CXXFLAGS
-CFLAGS="$CFLAGS $compileroptions $debugflag"; export CFLAGS
+CXXFLAGS="$CXXFLAGS $compileroptions $debugflag $bitstobuildDefines"; 
+export CXXFLAGS
+
+CFLAGS="$CFLAGS $compileroptions $debugflag $bitstobuildDefines"; 
+export CFLAGS
 
 # gcc crashes if optimisation is turned on in a Tru64 environment
 if [ $platform = "tru64" -a $CXX = "g++" ]; then
@@ -237,7 +283,7 @@ if [ $platform = "tru64" -a $CXX = "g++" ]; then
     export CXXFLAGS CFLAGS
 fi
 
-LDFLAGS="$LDFLAGS $linkeroptions"; export LDFLAGS
+LDFLAGS="$LDFLAGS $linkeroptions $bitstobuildDefines"; export LDFLAGS
 
 echo
 rm -f config.cache
@@ -263,6 +309,7 @@ echo export CXX=$CXX
 echo export CXXFLAGS=$CXXFLAGS
 echo export CFLAGS=$CFLAGS
 echo export LIBS=$LIBS
+echo export BITSTOBUILD=$BITSTOBUILD
 echo export LDFLAGS=$LDFLAGS
 echo configure
 
diff --git a/scripts/packageBinaries.pl b/scripts/packageBinaries.pl
index a4ce18c6c659a009774c05d28e1c23822ff4c21a..997e957dfaec4ee88aa7df0c37904863deda5ef4 100644
--- a/scripts/packageBinaries.pl
+++ b/scripts/packageBinaries.pl
@@ -9,7 +9,7 @@ $|=1;   # Force a flush after every print
 
 
 # Extract the source and target directories
-&Getopt('sopcxmntrj');
+&Getopt('sopcxmntrjb');
 $XERCESCROOT = $opt_s;
 $targetdir = $opt_o;
 
@@ -25,7 +25,8 @@ if (!length($XERCESCROOT) || !length($targetdir) || (length($opt_h) > 0) ) {
     print ("    -n <net accessor> can be 'fileonly' or 'socket' \(default\)\n");
     print ("    -t <transcoder> can be 'icu' or 'native' \(default\)\n");
     print ("    -r <thread option> can be 'pthread' \(default\)or 'dce' (only used on HP-11)\n");
-    print ("    -j suppress building of ICU (speeds up builds when debugging)\n");
+    print ("    -b <bitsToBuild> (accepts '64', '32')\n");
+    print ("    -j suppress building of ICU (speeds up builds when debugging)\n");   
     print ("    -h to get help on these commands\n\n");
     print ("Example: Under unix's\n");
     print ("    perl packageBinaries.pl -s \$HOME/xerces-c-src_1_7_0");
@@ -375,7 +376,8 @@ if ( ($platform =~ m/AIX/i)    || ($platform =~ m/HP-UX/i) ||
     }
     if ($opt_t eq "") {$opt_t = "native";  # Native transcoding service.
     }
-
+    if ($opt_b eq "") {$opt_b = "32";      # bitstobuild.
+    }
 
     # Set defaults for platform-specific options.
     if ($platform =~ m/AIX/i) {
@@ -584,9 +586,9 @@ if ( ($platform =~ m/AIX/i)    || ($platform =~ m/HP-UX/i) ||
     psystem ("chmod +x run* con* install-sh");
 
     if (length($opt_r) > 0) {
-        psystem ("runConfigure -p$platform -c$opt_c -x$opt_x -m$opt_m -n$opt_n -t$opt_t -r$opt_r");
+        psystem ("runConfigure -p$platform -c$opt_c -x$opt_x -m$opt_m -n$opt_n -t$opt_t -r$opt_r -b$opt_b");
     } else {
-        psystem ("runConfigure -p$platform -c$opt_c -x$opt_x -m$opt_m -n$opt_n -t$opt_t");
+        psystem ("runConfigure -p$platform -c$opt_c -x$opt_x -m$opt_m -n$opt_n -t$opt_t -b$opt_b");
     }
 
     psystem ("gmake clean");     # May want to comment this line out to speed up
@@ -638,7 +640,7 @@ if ( ($platform =~ m/AIX/i)    || ($platform =~ m/HP-UX/i) ||
     print("\n\nBuild the samples ...\n");
     pchdir ("$XERCESCROOT/samples");
     psystem ("chmod +x run* con* install-sh");
-    psystem ("runConfigure -p$platform -c$opt_c -x$opt_x");
+    psystem ("runConfigure -p$platform -c$opt_c -x$opt_x -b$opt_b");
     psystem ("gmake clean");     # May want to comment this line out to speed up
     psystem ("gmake");
 
@@ -646,7 +648,7 @@ if ( ($platform =~ m/AIX/i)    || ($platform =~ m/HP-UX/i) ||
     print("\n\nBuild the tests ...\n");
     pchdir ("$XERCESCROOT/tests");
     psystem ("chmod +x run* con* install-sh");
-    psystem ("runConfigure -p$platform -c$opt_c -x$opt_x");
+    psystem ("runConfigure -p$platform -c$opt_c -x$opt_x -b$opt_b");
     psystem ("gmake clean");     # May want to comment this line out to speed up
     psystem ("gmake");
 
diff --git a/src/xercesc/Makefile.incl b/src/xercesc/Makefile.incl
index fcc668c41cb22525bc5cb10e14d56872e30df7f0..a4eddef02ca45e44b07b084c48c943e1add1cf0e 100644
--- a/src/xercesc/Makefile.incl
+++ b/src/xercesc/Makefile.incl
@@ -229,8 +229,9 @@ else
     ALLLIBS = ${LIBS} -L/usr/lpp/xlC/lib
 endif
 PLATFORM_COMPILE_OPTIONS = -qnotempinc -D_THREAD_SAFE
-MAKE_SHARED = makeC++SharedLib_r -p 5000 -brtl ${LDFLAGS}
-MAKE_SHARED_C = makeC++SharedLib_r -p 5000 -brtl ${LDFLAGS}
+
+MAKE_SHARED = makeC++SharedLib_r -p 5000 -brtl ${LDFLAGS} -X${BITSTOBUILD}
+MAKE_SHARED_C = makeC++SharedLib_r -p 5000 -brtl ${LDFLAGS} -X${BITSTOBUILD}
 
 EXTRA_LINK_OPTIONS = -bmap:$(XML_OBJ)/${LIBNAME}${SO_TARGET_VERSION}.${SO_TARGET_VERSION_MAJOR}.map
 SHLIBSUFFIX=.so
diff --git a/src/xercesc/configure b/src/xercesc/configure
index 6398c1b4afe6015345324dfaa7e488f5834c3368..fb74c1617f5f855c99bba1e61b5f283bbdfb33ae 100755
--- a/src/xercesc/configure
+++ b/src/xercesc/configure
@@ -1321,6 +1321,7 @@ netaccessor=${NETACCESSOR}
 
 threads=${THREADS}
 
+bitstobuild=${BITSTOBUILD}
 
 trap '' 1 2 15
 cat > confcache <<\EOF
@@ -1536,6 +1537,7 @@ s%@libs@%$libs%g
 s%@uselibwww@%$uselibwww%g
 s%@messageloader@%$messageloader%g
 s%@transcoder@%$transcoder%g
+s%@bitstobuild@%$bitstobuild%g
 s%@netaccessor@%$netaccessor%g
 s%@threads@%$threads%g
 
diff --git a/src/xercesc/configure.in b/src/xercesc/configure.in
index 3c7cea353bc111e6dfb85a69550a47f59939c129..0ce49a753de5303f43387ab28827fd417f802f14 100644
--- a/src/xercesc/configure.in
+++ b/src/xercesc/configure.in
@@ -100,6 +100,9 @@ AC_SUBST(netaccessor)
 threads=${THREADS}
 AC_SUBST(threads)
 
+bitstobuild=${BITSTOBUILD}
+AC_SUBST(bitstobuild)
+
 dnl output the Makefiles
 AC_OUTPUT([Makefile \
 util/Makefile \
diff --git a/src/xercesc/runConfigure b/src/xercesc/runConfigure
index 8acac13b584d7d12c9f9f691a102a9f9125aa3ba..c312eaea4cd1abf22d57fa6e776d5ecdd26f73e0 100755
--- a/src/xercesc/runConfigure
+++ b/src/xercesc/runConfigure
@@ -71,6 +71,7 @@
 # LDFLAGS
 # CXXFLAGS
 # TRANSCODER
+# BITSTOBUILD
 #
 
 usage()
@@ -96,6 +97,7 @@ usage()
     echo "       -l <extra linker options>"
     echo "       -z <extra compiler options>"
     echo "       -P <install-prefix>"
+    echo "       -b <bitsToBuild> (accepts '64', '32')"
     echo "       -C <any one extra configure options>"
     echo "       -h (to get help on the above commands)"
 }
@@ -124,9 +126,9 @@ fi
 
 # Check the command line parameters
 if test -x /usr/bin/getopt; then
-getoptErr=`getopt p:c:x:dm:n:t:r:l:z:P:C:h $*`
+getoptErr=`getopt p:c:x:dm:n:t:r:b:l:z:P:C:h $*`
 else
-getoptErr=`getopts p:c:x:dm:n:t:r:l:z:P:C:h `$*``
+getoptErr=`getopts p:c:x:dm:n:t:r:b:l:z:P:C:h `$*``
 fi
 if [ $? != 0 ]
    then
@@ -136,9 +138,9 @@ fi
 
 # Now get the command line parameters
 if test -x /usr/bin/getopt; then
-set -- `getopt p:c:x:dm:n:t:r:l:z:P:C:h $*`
+set -- `getopt p:c:x:dm:n:t:r:b:l:z:P:C:h $*`
 else
-set -- `getopts p:c:x:dm:n:t:r:l:z:P:C:h `$*``
+set -- `getopts p:c:x:dm:n:t:r:b:l:z:P:C:h `$*``
 fi
 
 # Set up the default values for each parameter
@@ -148,6 +150,7 @@ msgloader=inmem          # by default use inmem message loader
 netaccessor=socket       # by default use socket (can do HTTP URL's)
 thread=pthread           # by default use POSIX threads
 configureoptions=""
+bitsToBuild=32            # by default 32 bit build assumed
 
 while [ $# -gt 0 ]
    do
@@ -175,6 +178,9 @@ while [ $# -gt 0 ]
 
    -r)
         thread=$2; shift 2;;
+        
+   -b)
+        bitsToBuild=$2; shift 2;;           
 
    -l)
         linkeroptions="$linkeroptions $2"; shift 2;;
@@ -212,6 +218,7 @@ echo "Message Loader: $msgloader"
 echo "Net Accessor: $netaccessor"
 echo "Transcoder: $transcoder"
 echo "Thread option: $thread"
+echo "bitsToBuild option: $bitsToBuild"
 echo "Extra configure options: $configureoptions"
 
 
@@ -370,6 +377,42 @@ fi
 
 export THREADS
 
+#
+# Check for the bitsToBuild option
+#
+
+#
+#  aix | linux | hp-11 | solaris | 
+#  hp-10 | freebsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
+#
+if test $bitsToBuild = 64; then
+    bitstobuildDefines=" -DXML_BITSTOBUILD_64 " 
+    if test $platform; then
+        case $platform in
+           solaris)
+              bitstobuildDefines=" $bitstobuildDefines -xarch=v9 " ;;
+           aix)
+              bitstobuildDefines=" $bitstobuildDefines -q64 -qwarn64 " ;;
+           hp-11)
+              bitstobuildDefines=" $bitstobuildDefines +DD64 " ;;
+           linux)
+              bitstobuildDefines=" $bitstobuildDefines " ;;
+           *)
+            ;;
+        esac
+    fi
+elif test $bitsToBuild = 32; then
+    bitstobuildDefines=" "
+else
+    echo "I do not recognize the bitsToBuild '$bitsToBuild'. Please type '${0} -h' for help."
+    exit ${ERROR_EXIT_CODE};
+fi
+
+#
+# to export in case it is needed in Makefile.in/Makefine.incl
+#
+BITSTOBUILD=$bitsToBuild
+export BITSTOBUILD
 
 #
 # Now check for what kind of transcoding service is desired.
@@ -499,7 +542,7 @@ case $netaccessor in
            echo "netaccessor option '$netaccessor' is supported on 'macosx' only."
            exit ${ERROR_EXIT_CODE}
        fi
-
+       
        ;;
 
    *)
@@ -538,10 +581,10 @@ export CXX
 # include the user defined CXXFLAGS/CFLAGS first in case they have
 # set an platform spefic flags
 #
-CXXFLAGS="$CXXFLAGS $compileroptions $debugflag $transcodingDefines $msgloaderDefines $threadingDefines $netaccessorDefines"
+CXXFLAGS="$CXXFLAGS $compileroptions $debugflag $transcodingDefines $msgloaderDefines $threadingDefines $netaccessorDefines $bitstobuildDefines"
 export CXXFLAGS
 
-CFLAGS="$CFLAGS $compileroptions $debugflag $transcodingDefines $msgloaderDefines $threadingDefines $netaccessorDefines"
+CFLAGS="$CFLAGS $compileroptions $debugflag $transcodingDefines $msgloaderDefines $threadingDefines $netaccessorDefines "
 export CFLAGS
 
 # gcc crashes if optimisation is turned on in a Tru64 environment
@@ -581,6 +624,7 @@ echo export TRANSCODER=\"$TRANSCODER\"
 echo export MESSAGELOADER=\"$MESSAGELOADER\"
 echo export NETACCESSOR=\"$NETACCESSOR\"
 echo export THREADS=\"$THREADS\"
+echo export BITSTOBUILD=\"$BITSTOBUILD\"
 echo export CC=\"$CC\"
 echo export CXX=\"$CXX\"
 echo export CXXFLAGS=\"$CXXFLAGS\"
diff --git a/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp b/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp
index 68f15d8e7e6964d1ff4c1e663ea2f5c031bf07ab..b22f6b04ddaf530e930ff233820e2938a0a7862c 100644
--- a/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp
@@ -573,7 +573,12 @@ void* XMLPlatformUtils::compareAndSwap ( void**      toFill ,
                     const void* const newValue ,
                     const void* const toCompare)
 {
+#if defined (XML_BITSTOBUILD_64)
+    boolean_t boolVar = compare_and_swaplp((atomic_l)toFill, (long*)&toCompare, (long)newValue );
+#else
     boolean_t boolVar = compare_and_swap((atomic_p)toFill, (int *)&toCompare, (int)newValue );
+#endif
+
     return (void *)toCompare;
 }
 
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 2a78345f4e5b80b4db383695435484d3657267fd..6cd7445caf3d7773d67c4013943dd9db9c2f4ad0 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -79,6 +79,7 @@ CFLAGS = @cflags@
 PREFIX = @prefix@
 THREADS = @threads@
 EXTRA_LIBS = @extra_libs@
+BITSTOBUILD = @bitstobuild@
 
 ifeq (${PLATFORM},HPUX)
   ifeq (${OSVER}, HPUX10)
diff --git a/tests/configure b/tests/configure
index 839dd8645835214b478530d74f6fae1a12ea1180..7c76d953b84b7eb59ff44a373f37c4123857b79f 100755
--- a/tests/configure
+++ b/tests/configure
@@ -1343,6 +1343,7 @@ ldflags=${LDFLAGS}
 
 threads=${THREADS}
 
+bitstobuild=${BITSTOBUILD}
 
 extra_libs=${EXTRA_LIBS}
 
@@ -1524,6 +1525,7 @@ s%@cflags@%$cflags%g
 s%@ldflags@%$ldflags%g
 s%@threads@%$threads%g
 s%@extra_libs@%$extra_libs%g
+s%@bitstobuild@%$bitstobuild%g
 
 CEOF
 EOF
diff --git a/tests/configure.in b/tests/configure.in
index 8f9011bf13c2f623331935385347b2acd09dd2fa..15efcb4d2cfda287eaac06382c99cf5f79b8dd8c 100644
--- a/tests/configure.in
+++ b/tests/configure.in
@@ -72,6 +72,9 @@ AC_SUBST(ldflags)
 threads=${THREADS}
 AC_SUBST(threads)
 
+bitstobuild=${BITSTOBUILD}
+AC_SUBST(bitstobuild)
+
 extra_libs=${EXTRA_LIBS}
 AC_SUBST(extra_libs)
 
diff --git a/tests/runConfigure b/tests/runConfigure
index c722331410817302f59ac1339b985d188811411e..b86b30c9270734588db96bd3f64d511b1b7a768c 100755
--- a/tests/runConfigure
+++ b/tests/runConfigure
@@ -74,6 +74,7 @@ usage()
     echo "       -x <C++ compiler name> (e.g. g++, xlC, or icc)"
     echo "       -d (specifies that you want to build debug version)"
     echo "       -r <thread option> can be 'pthread' or 'dce' (only used on aix, HP-11 and solaris) or 'sproc' (only on IRIX) or 'none'"
+    echo "       -b <bitsToBuild> (accepts '64', '32')"
     echo "       -l <extra linker options>"
     echo "       -z <extra compiler options>"
     echo "       -h (get help on the above commands)"
@@ -103,9 +104,9 @@ fi
 
 # Check the command line parameters
 if test -x /usr/bin/getopt; then
-getoptErr=`getopt p:c:x:dm:n:t:r:l:z:h $*`
+getoptErr=`getopt p:c:x:dm:n:t:r:b:l:z:h $*`
 else
-getoptErr=`getopts p:c:x:dm:n:t:r:l:z:h `$*``
+getoptErr=`getopts p:c:x:dm:n:t:r:b:l:z:h `$*``
 fi
 if [ $? != 0 ]
    then
@@ -115,9 +116,9 @@ fi
 
 # Now get the command line parameters
 if test -x /usr/bin/getopt; then
-set -- `getopt p:c:x:dm:n:t:r:l:z:h $*`
+set -- `getopt p:c:x:dm:n:t:r:b:l:z:h $*`
 else
-set -- `getopts p:c:x:dm:n:t:r:l:z:h `$*``
+set -- `getopts p:c:x:dm:n:t:r:b:l:z:h `$*``
 fi
 
 # Set up the default values for each parameter
@@ -127,6 +128,8 @@ msgloader=iconv          # by default use native transcoder
 netaccessor=fileonly     # by default use fileonly
 thread=pthread           # by default use POSIX threads
 compileroptions=""
+bitsToBuild=32            # by default 32 bit build assumed
+
 while [ $# -gt 0 ]
    do
    case $1 in
@@ -145,6 +148,9 @@ while [ $# -gt 0 ]
    -r)
         thread=$2; shift 2;;
 
+   -b)
+        bitsToBuild=$2; shift 2;;           
+
    -z)
         compileroptions="$compileroptions $2"; shift 2;;
 
@@ -179,6 +185,7 @@ echo "C++ Compiler: $cppcompiler"
 echo "Extra compile options: $compileroptions"
 echo "Extra link options: $linkeroptions"
 echo "Thread option: $thread"
+echo "bitsToBuild option: $bitsToBuild"
 
 #
 # Now check if the options are correct or not, bail out if incorrect
@@ -313,6 +320,43 @@ fi
 
 export THREADS
 
+#
+# Check for the bitsToBuild option
+#
+
+#
+#  aix | linux | hp-11 | solaris | 
+#  hp-10 | freebsd | irix | openserver | unixware | os400 | ptx | tru64 | macosx
+#
+if test $bitsToBuild = 64; then
+    bitstobuildDefines=" -DXML_BITSTOBUILD_64 " 
+    if test $platform; then
+        case $platform in
+           solaris)
+              bitstobuildDefines=" $bitstobuildDefines -xarch=v9 " ;;
+           aix)
+              bitstobuildDefines=" $bitstobuildDefines -q64 -qwarn64 " ;;
+           hp-11)
+              bitstobuildDefines=" $bitstobuildDefines +DD64 " ;;
+           linux)
+              bitstobuildDefines=" $bitstobuildDefines " ;;
+           *)
+            ;;
+        esac
+    fi
+elif test $bitsToBuild = 32; then
+    bitstobuildDefines=" "
+else
+    echo "I do not recognize the bitsToBuild '$bitsToBuild'. Please type '${0} -h' for help."
+    exit ${ERROR_EXIT_CODE};
+fi
+
+#
+# to export in case it is needed in Makefile.in/Makefine.incl
+#
+BITSTOBUILD=$bitsToBuild
+export BITSTOBUILD
+
 #
 # Set the C compiler and C++ compiler environment variables
 #
@@ -368,8 +412,11 @@ fi
 # include the user defined CXXFLAGS/CFLAGS first in case they have
 # set an platform spefic flags
 #
-CXXFLAGS="$CXXFLAGS $compileroptions $debugflag $threadingDefines $transcodingDefines"; export CXXFLAGS
-CFLAGS="$CFLAGS $compileroptions $debugflag $threadingDefines $transcodingDefines"; export CFLAGS
+CXXFLAGS="$CXXFLAGS $compileroptions $debugflag $threadingDefines $transcodingDefines $bitstobuildDefines"; 
+export CXXFLAGS
+
+CFLAGS="$CFLAGS $compileroptions $debugflag $threadingDefines $transcodingDefines $bitstobuildDefines"; 
+export CFLAGS
 
 # gcc crashes if optimisation is turned on in a Tru64 environment
 if [ $platform = "tru64" -a $CXX = "g++" ]; then
@@ -378,7 +425,7 @@ if [ $platform = "tru64" -a $CXX = "g++" ]; then
     export CXXFLAGS CFLAGS
 fi
 
-LDFLAGS="$LDFLAGS $linkeroptions"; export LDFLAGS
+LDFLAGS="$LDFLAGS $linkeroptions $bitstobuildDefines"; export LDFLAGS
 EXTRA_LIBS="$threadingLibs $transcodingLibs"; export EXTRA_LIBS
 
 echo
@@ -407,6 +454,7 @@ echo export CXXFLAGS=$CXXFLAGS
 echo export CFLAGS=$CFLAGS
 echo export EXTRA_LIBS=$EXTRA_LIBS
 echo export LDFLAGS=$LDFLAGS
+echo export BITSTOBUILD=$BITSTOBUILD
 echo configure
 
 echo