diff --git a/scripts/packageBinaries.pl b/scripts/packageBinaries.pl
index 5b1346cb7d005165b437bd58004accdf6d85df70..79eabecd70daec20c822b0a2e76f4261aef6c4d7 100644
--- a/scripts/packageBinaries.pl
+++ b/scripts/packageBinaries.pl
@@ -2,7 +2,7 @@
 #
 # The Apache Software License, Version 1.1
 #
-# Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
+# Copyright (c) 1999-2004 The Apache Software Foundation.  All rights
 # reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -62,20 +62,24 @@ require 5.0;
 
 $|=1;   # Force a flush after every print
 
-
-# Extract the source and target directories
+#
+# Setup global variables
+#
 &Getopt('sopcxmntrb');
-$XERCESCROOT = $opt_s;
-$targetdir = $opt_o;
-
+my $XERCESCROOT = $opt_s;
+my $targetdir              = $opt_o;
+my $ICUROOT           = $ENV{'ICUROOT'};
+my $ICUIsPresent      = (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && length($ICUROOT) > 0);
+my $ICUResourceDir = "$XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources";
+    
 # Check for the environment variables and exit if error
 if (!length($XERCESCROOT) || !length($targetdir) || (length($opt_h) > 0) ) {
     print ("Usage is: packageBinaries <options>\n");
     print ("  where options are:\n");
     print ("    -s <source_directory>\n");
     print ("    -o <target_directory>\n");
-    print ("    -c <C compiler name> (e.g. gcc, cc or xlc_r)\n");
-    print ("    -x <C++ compiler name> (e.g. g++, CC, aCC, c++, xlC_r, cl, ecl or ecc)\n");
+    print ("    -c <C compiler name> (e.g. gcc, cc, xlc_r, VC6, VC7, ecl or icl)\n");
+    print ("    -x <C++ compiler name> (e.g. g++, CC, aCC, c++, xlC_r, cl, ecl, ecc, icl, VC6 or VC7)\n");
     print ("    -m <message loader> can be 'inmem' \(default\), 'icu' or 'iconv'\n");
     print ("    -n <net accessor> can be 'fileonly' or 'socket' \(default\)\n");
     print ("    -t <transcoder> can be 'icu' or 'native' \(default\)\n");
@@ -98,17 +102,12 @@ if (!length($XERCESCROOT) || !length($targetdir) || (length($opt_h) > 0) ) {
     exit(-1);
 }
 
-# Set up the environment variables for ICU
-# As of Version 3, ICU is not a required component of XERCES-C
-$ICUROOT = $ENV{'ICUROOT'};
-$ICU_DATA = $ENV{'ICU_DATA'};
 if (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && (length($ICUROOT) == 0)) {
     print "You have specified an ICU build but you have not defined your ICU install directory.\n";
     print "To build with ICU, you must set an environment variable called ICUROOT\n";
     print "Cannot proceed any further.\n";
     exit(-1);
 }
-$ICUIsPresent = (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && length($ICUROOT) > 0);
 
 # Check if the source directory exists or not
 if (!(-e $XERCESCROOT)) {
@@ -123,27 +122,18 @@ if (-e $targetdir) {
     exit(1);
 }
 
+#
 # Find out the platform from 'uname -s'
+#
 open(PLATFORM, "uname -s|");
 $platform = <PLATFORM>;
 chomp($platform);
 close (PLATFORM);
 
-#
-
-#set platform variable if on windows 64bit
-my $return_code = system( "ls" );
-if ($return_code != 0)
-{  $platform = "win64bit";
-}
-
 #Fix the backslashes on the Windows platform
-if ($platform ne "win64bit")
-{
-    $XERCESCROOT =~ s/\\/\//g;
-    $ICUROOT =~ s/\\/\//g;
-    $targetdir =~ s/\\/\//g;
-}
+$XERCESCROOT =~ s/\\/\//g;
+$ICUROOT =~ s/\\/\//g;
+$targetdir =~ s/\\/\//g;
 
 print "Packaging binaries for \`" . $platform . "\` in " . $targetdir . " ...\n";   # "
 
@@ -152,478 +142,150 @@ $zipfiles = $targetdir;
 $zipfiles =~ s/.*(\/|\\)([\w-\.]*)$/$2/g;
 $zipfiles = $zipfiles . "/*";
 
-$buildmode = "Release";         # Universally, why do you want to package Debug builds anyway?
-
 #
-#   Architecture: Itanium
-#   OS:           Windows XP
-#   Compiler:     Intel's cl and/or ecl
-#   cygwin:       Not Available
+#   WINDOWS builds happen here, as long as they
+#     aren't using gcc...
+#
+#  Tasks:
+#
+#    Preparation
+#          Initialize Vars
+#          Make the target directory and its main subdirectories
+#          'FileOnly' NetAccessor
+#
+#   Build
+#          ICU and/or Resource bundle library for ICUMsgLoader
+#          Xerces-C libraries, samples and tests
+#
+#   Population
+#          include
+#          ICU and/or ICUMsgLoader
+#          Xerces-C libraries, samples and tests
+#          Documentation
 #
-if ($platform eq "win64bit" )
-{
-    if ($opt_x ne "" && $opt_x ne "cl" && $opt_x ne "ecl")
+if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/))) {
+#
+# Preparation Begin
+#
+#    Preparation::Initialize Vars
+#
+    my $PlatformName = 'Win32'; 
+    my $DevStudioVer = "6.0";
+    my $VCBuildDir     = "VC6";
+    my $Transcoder     = 0;
+    my $MsgLoader     = 0;
+
+    my $ReleaseBuildDir  = undef;
+    my $DebugBuildDir    = undef;
+    my $ProjectDir          = undef;
+                        
+    if ($opt_b eq "64") {
+        $PlatformName = 'Win64';
+    }
+      
+    if ($opt_x eq "" || $opt_x =~ m/VC6/ )
     {
-        print("Compiler on Itanium/WindowsXP must be \'cl\' or \'ecl\'\n");
-        exit(-1);
+        $DevStudioVer = "6.0";
+        $VCBuildDir     = "VC6"; 
+        $ProjectDir      = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all";
     }
-
-    if ($opt_x eq "")
+    elsif ($opt_x =~ m/VC7/ ) 
     {
-    	$opt_x = 'cl';
-    }
-
-    $platformname = 'Win64';    # Needed this way by nmake
-
-    if (-e "$targetdir.zip") {
-        print ("Deleting old target file \'$targetdir.zip\' \n");
-        unlink("$targetdir.zip");
-    }
-
-    # Make the target directory and its main subdirectories
-    psystem ("mkdir $targetdir");
-    psystem ("mkdir $targetdir\\bin");
-    psystem ("mkdir $targetdir\\lib");
-    if ( $opt_m =~ m/icu/i ) {
-        psystem ("mkdir $targetdir\\msg");
+        $DevStudioVer = "7.0";
+        $VCBuildDir     = "VC7"; 
+        $ProjectDir      = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all";
     }
-    psystem ("mkdir $targetdir\\etc");
-    psystem ("mkdir $targetdir\\include");
-    psystem ("mkdir $targetdir\\include\\xercesc");
-    psystem ("mkdir $targetdir\\samples");
-    psystem ("mkdir $targetdir\\samples\\Projects");
-    psystem ("mkdir $targetdir\\samples\\Projects\\Win32");
-    psystem ("mkdir $targetdir\\samples\\Projects\\Win32\\VC6");
-    psystem ("mkdir $targetdir\\samples\\data");
-    psystem ("mkdir $targetdir\\samples\\SAXCount");
-    psystem ("mkdir $targetdir\\samples\\SAX2Count");
-    psystem ("mkdir $targetdir\\samples\\SAXPrint");
-    psystem ("mkdir $targetdir\\samples\\SAX2Print");
-    psystem ("mkdir $targetdir\\samples\\DOMCount");
-    psystem ("mkdir $targetdir\\samples\\DOMPrint");
-    psystem ("mkdir $targetdir\\samples\\Redirect");
-    psystem ("mkdir $targetdir\\samples\\MemParse");
-    psystem ("mkdir $targetdir\\samples\\PParse");
-    psystem ("mkdir $targetdir\\samples\\StdInParse");
-    psystem ("mkdir $targetdir\\samples\\EnumVal");
-    psystem ("mkdir $targetdir\\samples\\SEnumVal");
-    psystem ("mkdir $targetdir\\samples\\CreateDOMDocument");
-    psystem ("mkdir $targetdir\\samples\\PSVIWriter");
-    psystem ("mkdir $targetdir\\samples\\SCMPrint");
-    psystem ("mkdir $targetdir\\scripts");
-    psystem ("mkdir $targetdir\\doc");
-    psystem ("mkdir $targetdir\\doc\\html");
-    psystem ("mkdir $targetdir\\doc\\html\\apiDocs");
-
-    # If 'FileOnly' NetAccessor has been specified, then the project files have to be
-    # changed.
-    #REVISIT: we are make from makefile, not from *.dsp
-    #         need to look at it later
-    if ($opt_n =~ m/fileonly/i) {
-        changeWindowsProjectForFileOnlyNA("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp");
+    elsif ($opt_x =~ m/ecl/ || $opt_x =~ m/icl/ )
+    {
+        $DevStudioVer = "6.1";
+        $VCBuildDir     = "VC6"; 
+        $PlatformName = "Win64";
+        $ProjectDir       = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all/all";
     }
-
-    #
-    #	ICU Build happens here, if one is required.
-    #
-    #REVISIT: icu
-    #
-    if ($ICUIsPresent) {
-
-        print ("Building ICU from $ICUROOT ...\n");
-
-        #Clean up all the dependency files, causes problems for nmake
-        pchdir ("$ICUROOT");
-        psystem ("del /s /f *.dep *.ncb *.plg *.opt");
-
-        # Make the icu dlls
-        pchdir ("$ICUROOT\\source\\allinone\\all");
-        if (!(length($opt_j) > 0)) {   # Optionally suppress ICU build, to speed up overlong builds while debugging.
- 	        #For XP 64 bit, we only ship release dlls
-            psystem("nmake -f all_win64_release.mak \"CFG=all - $platformname Release\" CPP=$opt_x.exe >buildlog.txt 2>&1");	    	
-	        psystem("type buildlog.txt");
-            #psystem("nmake -f all_win64_debug.mak \"CFG=all - $platformname Debug\" CPP=$opt_x.exe >buildlog.txt 2>&1");	    	
-	        #psystem("type buildlog.txt");
-        }
-
-        $transcoder = 0;
-        if ($opt_t =~ m/icu/i )
-        {
-            $transcoder = 1;
-        }
-
-        $msgloader = 0;
-        if ($opt_m =~ m/icu/i)
-        {
-            $msgloader = 1;
-        }
-
-        change_windows_makefile_for_ICU("$XERCESCROOT\\Projects\\Win32\\VC6\\xerces-all/XercesLib/XercesLib.mak", $transcoder, $msgloader);
+    else
+    {
+        print ("Error: Invalid compilers used \n");
+        print ("-x <C++ compiler name> VC6, CV7, ecl and icl \n");        
+        exit(1);            	    	
     }
 
-    # Build resource bundle library for ICUMsgLoader
-    if ($opt_m =~ m/icu/i) {
-        pchdir ("$XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources");    	
-        psystem( "nmake /f resources.mak > buildlog.txt 2>&1 ");
-        system("type buildlog.txt");       
+    $ReleaseBuildDir = "$XERCESCROOT/Build/$PlatformName/$VCBuildDir/Release";
+    $DebugBuildDir   = "$XERCESCROOT/Build/$PlatformName/$VCBuildDir/Debug";    
+        
+    if ($opt_t =~ m/icu/i ) {
+        $Transcoder = 1;
     }
-    
-    # Clean up all the dependency files, causes problems for nmake
-    # Also clean up all MSVC-generated project files that just cache the IDE state
-    pchdir ("$XERCESCROOT");
-    psystem ("del /s /f *.dep *.ncb *.plg *.opt");
-   
-    # Make all files in the Xerces-C system including libraries, samples and tests
-    pchdir ("$XERCESCROOT\\Projects\\Win32\\VC6\\xerces-all\\all");
-    psystem( "nmake -f all.mak \"CFG=all - $platformname Release\" CPP=$opt_x.exe >buildlog.txt 2>&1");
-    system("type buildlog.txt");
-
-    #For XP 64 bit, we only ship release dlls
-    #pchdir ("$XERCESCROOT\\Projects\\Win32\\VC6\\xerces-all\\XercesLib");
-    #psystem("nmake -f XercesLib.mak \"CFG=XercesLib - $platformname Debug\" CPP=$opt_x.exe > buildlog.txt 2>&1 ");
-    #system("type buildlog.txt");
-
-    # Decide where you want the build copied from
-    pchdir ($targetdir);
-    $BUILDDIR = $XERCESCROOT . "\\Build\\Win64\\VC6\\" . $buildmode;
-    print "\nBuild is being copied from \'" . $BUILDDIR . "\'";
 
     if ($opt_m =~ m/icu/i) {
-        pchdir ("$XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources");    	
-        psystem("copy XercesMessages*.DLL $BUILDDIR");
-        pchdir ($targetdir);        
-    }
-    
-    # Populate the include output directory
-    print ("\n\nCopying headers files ...\n");
-
-    @headerDirectories =
-     qw'sax
-		sax2
-        framework
-        framework\\psvi        
-        dom
-        dom\\deprecated
-        internal
-        parsers
-        util
-        util\\Compilers
-        util\\MsgLoaders
-        util\\MsgLoaders\\ICU
-        util\\MsgLoaders\\InMemory
-        util\\MsgLoaders\\MsgCatalog
-        util\\MsgLoaders\\Win32
-        util\\Platforms
-        util\\Platforms\\AIX
-        util\\Platforms\\HPUX
-        util\\Platforms\\BeOS
-        util\\Platforms\\Linux
-        util\\Platforms\\MacOS
-        util\\Platforms\\OS2
-        util\\Platforms\\OS390
-        util\\Platforms\\PTX
-        util\\Platforms\\Solaris
-        util\\Platforms\\Tandem
-        util\\Platforms\\Win32
-        util\\regx
-        util\\Transcoders
-        util\\Transcoders\\ICU
-        util\\Transcoders\\Iconv
-        util\\Transcoders\\Win32
-        validators
-        validators\\common
-        validators\\datatype
-        validators\\DTD
-        validators\\schema
-        validators\\schema\\identity';
-
-    foreach $dir (@headerDirectories) {
-        $inclDir = "include\\xercesc\\$dir";
-        if (! (-e $inclDir)) {
-            psystem("mkdir $inclDir");
-        }
-        $srcDir = "$XERCESCROOT\\src\\xercesc\\$dir";
-
-        # Weed out directories that have no files to copy, to avoid a bunch of
-        # warnings from the cp command in the build output.
-        opendir(dir, $srcDir);
-        @allfiles = readdir(dir);
-        closedir(dir);
-        foreach $fileKind ("hpp", "c") {
-            $matches = grep(/\.$fileKind$/, @allfiles);
-            if ($matches > 0) {
-                psystem("copy /y $srcDir\\*.$fileKind  $inclDir\\ ");
-            }
-        }
+        $MsgLoader = 1;
     }
-
-
-    #
-    #  Remove internal implementation headers from the DOM include directory.
-    #
-    psystem("del /s /f $targetdir\\include\\xercesc\\dom\\impl");
-    psystem("del  $targetdir\\include\\xercesc\\dom\\deprecated\\*Impl.hpp");
-    psystem("del  $targetdir\\include\\xercesc\\dom\\deprecated\\DS*.hpp");
-
-    if ($ICUIsPresent) {
-        psystem("xcopy /s /y $ICUROOT\\include\\* $targetdir\\include");
-    }
-
-    #
-    # Populate the binary output directory
-    #
-    print ("\n \nCopying binary outputs ...\n");
-    psystem("copy /y $BUILDDIR\\*.dll $targetdir\\bin");
-    psystem("copy /y $BUILDDIR\\*.exe $targetdir\\bin");
-
-    if ($ICUIsPresent) {
-
-        # Copy the ICU dlls and libs
-        psystem("copy /y $ICUROOT\\bin\\icuuc26.dll $targetdir\\bin");
-        psystem("copy /y $ICUROOT\\bin\\icuuc26d.dll $targetdir\\bin");
-
-        # it seems icudt26*.DLL is generated (upper case dll)
-        # but just case, try lower case .dll as well
-        psystem("copy /y $ICUROOT\\bin\\icudt26*.DLL $targetdir\\bin");
-        psystem("copy /y $ICUROOT\\bin\\icudt26*.dll $targetdir\\bin");
-
-        psystem("copy /y $ICUROOT\\lib\\icudata.lib $targetdir\\lib");
-
-        psystem("copy /y $ICUROOT\\lib\\icuuc.lib $targetdir\\lib");
-        psystem("copy /y $ICUROOT\\lib\\icuucd.lib $targetdir\\lib");
-
-        # Copy the Resouce Bundle for ICUMsgLoader
-        if ( $opt_m =~ m/icu/i) {
-            psystem("copy /y $XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources\\XercesMessage*.res $targetdir\\msg");
-            psystem("copy /y $XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources\\XercesMessages*.DLL $targetdir\\bin");
-            psystem("copy /y $XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources\\XercesMessages*.lib $targetdir\\lib");
-        }        	
-
-    }
-
-    psystem("copy /y $BUILDDIR\\xerces-c_*.lib $targetdir\\lib");
-    psystem("copy /y $BUILDDIR\\xerces-depdom_*.lib $targetdir\\lib");
-    
-    if ($buildmode ne "Debug") {
-        $DEBUGBUILDDIR = "$XERCESCROOT\\Build\\Win64\\VC6\\Debug";
-        psystem("copy /y $DEBUGBUILDDIR\\xerces-c_*D.lib $targetdir\\lib");
-        psystem("copy /y $DEBUGBUILDDIR\\xerces-depdom_*D.lib $targetdir\\lib");        
-        psystem("copy /y $DEBUGBUILDDIR\\xerces*D.dll $targetdir\\bin");
-    }
-
-    # Populate the etc output directory like config.status and the map file
-    print ("\n \nCopying misc output to etc ...\n");
-    psystem("copy /y $XERCESCROOT\\Build\\Win64\\VC6\\Release\\obj\\*.map $targetdir\\etc");
-
-
-    # Populate the samples directory
-    print ("\n \nCopying sample files ...\n");
-    psystem("copy $XERCESCROOT\\version.incl $targetdir");
-    psystem("xcopy /s /y $XERCESCROOT\\samples\\Projects\\Win32\\VC6\\* $targetdir\\samples\\Projects\\Win32\\VC6");
-
-    psystem("copy /y $XERCESCROOT\\samples\\SAXCount\\* $targetdir\\samples\\SAXCount");
-    psystem("del /f $targetdir\\samples\\SAXCount\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\SAX2Count\\* $targetdir\\samples\\SAX2Count");
-    psystem("del /f $targetdir\\samples\\SAX2Count\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\SAXPrint\\* $targetdir\\samples\\SAXPrint");
-    psystem("del /f $targetdir\\samples\\SAXPrint\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\SAX2Print\\* $targetdir\\samples\\SAX2Print");
-    psystem("del /f $targetdir\\samples\\SAX2Print\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\DOMCount\\* $targetdir\\samples\\DOMCount");
-    psystem("del /f $targetdir\\samples\\DOMCount\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\DOMPrint\\* $targetdir\\samples\\DOMPrint");
-    psystem("del /f $targetdir\\samples\\DOMPrint\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\Redirect\\* $targetdir\\samples\\Redirect");
-    psystem("del /f $targetdir\\samples\\Redirect\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\MemParse\\* $targetdir\\samples\\MemParse");
-    psystem("del /f $targetdir\\samples\\MemParse\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\PParse\\* $targetdir\\samples\\PParse");
-    psystem("del /f $targetdir\\samples\\PParse\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\StdInParse\\* $targetdir\\samples\\StdInParse");
-    psystem("del /f $targetdir\\samples\\StdInParse\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\EnumVal\\* $targetdir\\samples\\EnumVal");
-    psystem("del /f $targetdir\\samples\\EnumVal\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\SEnumVal\\* $targetdir\\samples\\SEnumVal");
-    psystem("del /f $targetdir\\samples\\SEnumVal\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\CreateDOMDocument\\* $targetdir\\samples\\CreateDOMDocument");
-    psystem("del /f $targetdir\\samples\\CreateDOMDocument\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\PSVIWriter\\* $targetdir\\samples\\PSVIWriter");
-    psystem("del /f $targetdir\\samples\\PSVIWriter\\Makefile.in");
-    psystem("copy /y $XERCESCROOT\\samples\\SCMPrint\\* $targetdir\\samples\\SCMPrint");
-    psystem("del /f $targetdir\\samples\\SCMPrint\\Makefile.in");
+                
+    print "PlatformName    =$PlatformName\n";
+    print "DevStudioVer    =$DevStudioVer\n";
+    print "VCBuildDir        =$VCBuildDir\n";
+    print "ReleaseBuildDir =$ReleaseBuildDir\n";
+    print "DebugBuildDir   =$DebugBuildDir\n";
+    print "ProjectDir          =$ProjectDir\n";
+    print "Transcoder        =$Transcoder\n";
+    print "MsgLoader        =$MsgLoader\n";
         
-    psystem("copy /y $XERCESCROOT\\samples\\data\\* $targetdir\\samples\\data");
-
-    # Populate the scripts directory
-    print ("\n \nCopying script files ...\n");
-    psystem("copy $XERCESCROOT\\scripts\\sanityTest* $targetdir\\scripts");
-
-    # Populate the docs directory
-    print ("\n \nCopying documentation ...\n");
-    psystem("xcopy /s /y $XERCESCROOT\\doc\\* $targetdir\\doc");
-    psystem("copy $XERCESCROOT\\Readme.html $targetdir");
-    psystem("copy $XERCESCROOT\\credits.txt $targetdir");
-    psystem("copy $XERCESCROOT\\LICENSE.txt $targetdir");
-
-    if ($ICUIsPresent) {
-        psystem("copy $XERCESCROOT\\license.html $targetdir");
-        psystem("copy $XERCESCROOT\\XLicense.html $targetdir");
-    }
-    psystem("del /f  $targetdir\\doc\\Doxyfile");
-    psystem("del /s /f $targetdir\\doc\\dtd");
-    psystem("del /f  $targetdir\\doc\\*.xml");
-    psystem("del /f  $targetdir\\doc\\*.ent");
-    psystem("del /f  $targetdir\\doc\\*.gif");
-
-    # Now package it all up using ZIP
-    pchdir ("$targetdir\\..");
-    print ("\n \nZIPping up all files ...\n");
-    $zipname = $targetdir . ".zip";
-    psystem ("zip -r $zipname $zipfiles");
-}
-#
-#     End of Itanium Builds.
-
-#
-#   WINDOWS builds happen here, as long as they
-#     aren't using gcc...
-#
-if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/))) {
-
-    if ($opt_b eq "64")
-    {
-        $platformname = 'Win64';
-    }
-    else
-    {
-        $platformname = 'Win32';
-    }
     if (-e "$targetdir.zip") {
         print ("Deleting old target file \'$targetdir.zip\' \n");
         unlink("$targetdir.zip");
     }
-
+            
     #
-    # AUTODETECT VISUAL STUDIO VERSION
+    # Preparation::Make the target directory and its main subdirectories
     #
+    createCommonDir();
 
-    $msc_response= `cl 2>&1`;
-
-    print "$ENV{PATH}\n";
-
-    chomp($msc_response);
-    print "-----------------------\n";
-    print "Detected: $msc_response\n";
-
-    $msc_response =~ /Version *([0-9.]+)/;
-    $msc_full_version = $1;
-    $msc_response =~ /Version *([0-9]+)\./;
-    $msc_major_version = $1;
-    $msc_response =~ /Version *[0-9]+\.([0-9]+)\./;
-    $msc_minor_version = $1;
-
-    print "-----------------------\n";
-    print "msc_full_version  =$msc_full_version\n";
-    print "msc_major_version =$msc_major_version\n";
-    print "msc_minor_version =$msc_minor_version\n";
-    print "-----------------------\n";
-
-    $DevStudioVer = "6.0"; #default
-    $VCBuildDir = "VC6"; #default
-    if ($msc_major_version eq "12") {
-        print "Configuring environment for Visual Studio 6.0\n";
-        $DevStudioVer = "6.0";
-    } elsif ($msc_major_version eq "13") {
-        print "Configuring environment for Visual Studio .NET\n";
-        $DevStudioVer = "7.0";
-        $VCBuildDir = "VC7"; #default
-    }
-    print "DevStudioVer =$DevStudioVer\n";
-    print "VCBuildDir   =$VCBuildDir\n";
-
-    # Make the target directory and its main subdirectories
-    psystem ("mkdir $targetdir");
-    psystem ("mkdir $targetdir/bin");
-    psystem ("mkdir $targetdir/lib");
-    if ( $opt_m =~ m/icu/i ) {
-        psystem ("mkdir $targetdir/msg");
-    }
-    psystem ("mkdir $targetdir/etc");
-    psystem ("mkdir $targetdir/include");
-    psystem ("mkdir $targetdir/include/xercesc");
-    psystem ("mkdir $targetdir/samples");
+    # windows specifics
     psystem ("mkdir $targetdir/samples/Projects");
     psystem ("mkdir $targetdir/samples/Projects/Win32");
-    if ($DevStudioVer eq "6.0") {
-    psystem ("mkdir $targetdir/samples/Projects/Win32/VC6");
-    } elsif ($DevStudioVer eq "7.0") {
-        psystem ("mkdir $targetdir/samples/Projects/Win32/VC7");
-    }
-    psystem ("mkdir $targetdir/samples/data");
-    psystem ("mkdir $targetdir/samples/SAXCount");
-    psystem ("mkdir $targetdir/samples/SAX2Count");
-    psystem ("mkdir $targetdir/samples/SAXPrint");
-    psystem ("mkdir $targetdir/samples/SAX2Print");
-    psystem ("mkdir $targetdir/samples/DOMCount");
-    psystem ("mkdir $targetdir/samples/DOMPrint");
-    psystem ("mkdir $targetdir/samples/Redirect");
-    psystem ("mkdir $targetdir/samples/MemParse");
-    psystem ("mkdir $targetdir/samples/PParse");
-    psystem ("mkdir $targetdir/samples/StdInParse");
-    psystem ("mkdir $targetdir/samples/EnumVal");
-    psystem ("mkdir $targetdir/samples/SEnumVal");
-    psystem ("mkdir $targetdir/samples/CreateDOMDocument");
-    psystem ("mkdir $targetdir/samples/PSVIWriter");    
-    psystem ("mkdir $targetdir/samples/SCMPrint");        
-    psystem ("mkdir $targetdir/scripts");
-    psystem ("mkdir $targetdir/doc");
-    psystem ("mkdir $targetdir/doc/html");
-    psystem ("mkdir $targetdir/doc/html/apiDocs");
+    psystem ("mkdir $targetdir/samples/Projects/Win32/$VCBuildDir");
 
-    # If 'FileOnly' NetAccessor has been specified, then the project files have to be
-    # changed.
+    #
+    # Preparation:: 'FileOnly' NetAccessor 
+    #                     has been specified, then the project files have to be changed.
+    # 
     if ($opt_n =~ m/fileonly/i) {
-        if ($DevStudioVer eq "6.0") {
+        if ($DevStudioVer eq "6.0") { 
             changeWindowsProjectForFileOnlyNA("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp");
         } elsif ($DevStudioVer eq "7.0") {
             changeWindowsProjectForFileOnlyNA_VC7("$XERCESCROOT/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj");
         }
+        #else: for now we do not build FO with ecl
     }
 
-
-    #
-    #	ICU Build happens here, if one is required.
-    #
+#
+# Build Begin
+#
+#        Build::ICU and/or Resource bundle library for ICUMsgLoader
+#
     if ($ICUIsPresent) {
-        print ("Building ICU from $ICUROOT ...\n");
-
-        #Clean up all the dependency files, causes problems for nmake
-        pchdir ("$ICUROOT");
-        psystem ("del /s /f *.dep *.ncb *.plg *.opt");
 
         # Make the icu dlls
-        if (!(length($opt_j) > 0)) {   # Optionally suppress ICU build, to speed up overlong builds while debugging.
-            #we ship both debug and release dlls
+        if (!(length($opt_j) > 0)) {  
+            #Clean up all the dependency files, causes problems for nmake
+            print ("Building ICU from $ICUROOT ...\n");
+            pchdir ("$ICUROOT");
+            psystem ("del /s /f *.dep *.ncb *.plg *.opt");
+
+            # we ship both debug and release dlls
             if ($DevStudioVer eq "6.0") {
                 pchdir ("$ICUROOT/source/allinone");
-                if ($platformname eq "Win64")
+                if ($PlatformName eq "Win64")
                 {
-                    psystem("msdev allinone.dsw /MAKE \"all - $platformname Release\" /USEENV /REBUILD /OUT buildlog.txt");
+                    psystem("msdev allinone.dsw /MAKE \"all - $PlatformName Release\" /USEENV /REBUILD /OUT buildlog_release.txt");
+                    psystem("msdev allinone.dsw /MAKE \"all - $PlatformName Debug\" /USEENV /REBUILD /OUT buildlog_debug.txt");
                 }
                 else
                 {
-                    psystem("msdev allinone.dsw /MAKE \"all - $platformname Release\" /REBUILD /OUT buildlog.txt");            	
-                }
-                psystem("type buildlog.txt");
-                if ($platformname eq "Win64")
-                {
-                    psystem("msdev allinone.dsw /MAKE \"all - $platformname Debug\" /USEENV /REBUILD /OUT buildlog.txt");
+                    psystem("msdev allinone.dsw /MAKE \"all - $PlatformName Release\" /REBUILD /OUT buildlog_release.txt");            	
+                    psystem("msdev allinone.dsw /MAKE \"all - $PlatformName Debug\" /REBUILD /OUT buildlog_debug.txt");            	
                 }
-                else
-                {
-                    psystem("msdev allinone.dsw /MAKE \"all - $platformname Debug\" /REBUILD /OUT buildlog.txt");            	
-                }	
-                psystem("type buildlog.txt");
+                psystem("type buildlog_release.txt");
+                psystem("type buildlog_debug.txt");
             } elsif ($DevStudioVer eq "7.0") {
                 pchdir ("$ICUROOT/source/allinone");
 
@@ -632,169 +294,103 @@ if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/)))
 
                 psystem("devenv /rebuild debug /out buildlog_debug.txt /project all allinone.sln");
                 psystem("type buildlog_debug.txt");                            	
-            }
-        }
+            } else { #"6.1"
+                pchdir ("$ICUROOT/source/allinone/all");            	
+ 	  #ship release dlls only
+                psystem("nmake -f all_win64_release.mak \"CFG=all - $PlatformName Release\" CPP=$opt_x.exe >buildlog_release.txt 2>&1");
+                psystem("type buildlog_release.txt");
+                
+                #debug is disabled
+                #psystem("nmake -f all_win64_debug.mak \"CFG=all - $PlatformName Debug\" CPP=$opt_x.exe >buildlog_debug.txt 2>&1");
+                #psystem("type buildlog_debug.txt");
+           }
 
-        $transcoder = 0;
-        if ($opt_t =~ m/icu/i )
-        {
-            $transcoder = 1;
-        }
+        } #$opt_j
 
-        $msgloader = 0;
-        if ($opt_m =~ m/icu/i)
-        {
-            $msgloader = 1;
+        #
+        # Build resource bundle library for ICUMsgLoader
+        # this can only be built when ICUIsPresent
+        if ($opt_m =~ m/icu/i) {
+            pchdir ("$ICUResourceDir");
+            # clean up intermediate files to make it rebuildable
+            psystem ("del /s /f *.DLL *.dll *.res *.DAT *.lib *.obj");            
+            psystem( "nmake /f resources.mak > buildlog.txt 2>&1 ");
+            system("type buildlog.txt");              
         }
 
+        #
+        # Adjust project file
+        #
         if ($DevStudioVer eq "6.0") {
-            change_windows_project_for_ICU("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp", $transcoder , $msgloader);
+            change_windows_project_for_ICU("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp", $Transcoder , $MsgLoader);
         } elsif ($DevStudioVer eq "7.0") {
-            change_windows_project_for_ICU_VC7("$XERCESCROOT/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj", $transcoder , $msgloader);
+            change_windows_project_for_ICU_VC7("$XERCESCROOT/Projects/Win32/VC7/xerces-all/XercesLib/XercesLib.vcproj", $Transcoder , $MsgLoader);
+        } else { # "6.1"
+            change_windows_makefile_for_ICU("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.mak", $Transcoder, $MsgLoader);
         }
-    }
+                
+    } #$ICUIsPresent
+
+    #
+    # Build::Make Xerces-C libraries, samples and tests
+    #        
 
-    # Build resource bundle library for ICUMsgLoader, before XercesLib
-    if ($opt_m =~ m/icu/i) {
-        pchdir ("$XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources");    	
-        psystem( "nmake /f resources.mak > buildlog.txt 2>&1 ");
-        system("type buildlog.txt");              
-    }
-    
     # Clean up all the dependency files, causes problems for nmake
     # Also clean up all MSVC-generated project files that just cache the IDE state
     pchdir ("$XERCESCROOT");
     psystem ("del /s /f *.dep *.ncb *.plg *.opt");
 
-    # Make all files in the Xerces-C system including libraries, samples and tests
-    pchdir ("$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all");
+    #
+    #                             release                       debug 
+    # ==========================================
+    #                  vc6      vc7     ecl        vc6       vc7      ecl
+    # ==========================================
+    # xercesc      yes     yes     yes       yes       yes      no
+    # depdom      yes     yes     yes       yes       yes      no
+    # samples      yes     yes     yes       no        no        no
+    # tests           yes     yes     yes       no        no        no
+    #
+    pchdir ("$ProjectDir");
+    
     if ($DevStudioVer eq "6.0") {
-        if ($platformname eq "Win64")
-        {
-            psystem( "msdev xerces-all.dsw /MAKE \"all - $platformname $buildmode\" /USEENV /REBUILD /OUT buildlog.txt");
+        if ($PlatformName eq "Win64") { # /USEENV
+            psystem("msdev xerces-all.dsw /MAKE \"all - $PlatformName Release\" /USEENV /REBUILD /OUT buildlog_release.txt");
+            psystem("msdev xerces-all.dsw /MAKE \"XercesLib - $PlatformName Debug\" /USEENV /REBUILD /OUT buildlog_debug.txt");            
+            psystem("msdev xerces-all.dsw /MAKE \"XercesDeprecatedDOMLib - $PlatformName Debug\" /USEENV /REBUILD /OUT buildlog_depdom_debug.txt");            
         }
-        else
-        {
-            psystem( "msdev xerces-all.dsw /MAKE \"all - $platformname $buildmode\" /REBUILD /OUT buildlog.txt");
+        else {
+            psystem("msdev xerces-all.dsw /MAKE \"all - $PlatformName Release\" /REBUILD /OUT buildlog_release.txt");
+            psystem("msdev xerces-all.dsw /MAKE \"XercesLib - $PlatformName Debug\" /REBUILD /OUT buildlog_debug.txt");
+            psystem("msdev xerces-all.dsw /MAKE \"XercesDeprecatedDOMLib - $PlatformName Debug\" /REBUILD /OUT buildlog_depdom_debug.txt");
         }	
     } elsif ($DevStudioVer eq "7.0") {
-        psystem( "devenv /rebuild Release /out buildlog.txt /project all xerces-all.sln");
+        psystem("devenv /rebuild Release /out buildlog_release.txt /project all xerces-all.sln");
+        psystem("devenv /rebuild debug /out buildlog_debug.txt /project XercesLib xerces-all.sln");        
+        psystem("devenv /rebuild debug /out buildlog_depdom_debug.txt /project XercesDeprecatedDOMLib xerces-all.sln");                
+    } else { # "6.1"
+        psystem( "nmake -f all.mak \"CFG=all - $PlatformName Release\" CPP=$opt_x.exe >buildlog_release.txt 2>&1");
     }
-    system("type buildlog.txt");
 
-    # Build the debug xerces dll.  Both debug and release DLLs
-    #   are in the standard binary distribution of Xerces.
-    if ($buildmode ne "Debug") {
-        if ($DevStudioVer eq "6.0") {
-            if ($platformname eq "Win64")
-            {
-                psystem("msdev xerces-all.dsw /MAKE \"XercesLib - $platformname Debug\" /USEENV /REBUILD /OUT buildlog.txt");
-            }
-            else
-            {
-                psystem("msdev xerces-all.dsw /MAKE \"XercesLib - $platformname Debug\" /REBUILD /OUT buildlog.txt");        	
-            }
-        } elsif ($DevStudioVer eq "7.0") {
-            psystem( "devenv /rebuild debug /out buildlog.txt /project XercesLib xerces-all.sln");
-        }
-        system("type buildlog.txt");
-    }
+    system("type buildlog_release.txt");
+    system("type buildlog_debug.txt");
+    system("type buildlog_depdom_debug.txt");
 
-    # Decide where you want the build copied from
+#
+# Population Begin
+#
+#    Population::include
+#      
     pchdir ($targetdir);
-    $BUILDDIR = $XERCESCROOT . "/Build/Win32/$VCBuildDir/" . $buildmode;
-    print "\nBuild is being copied from \'" . $BUILDDIR . "\'";
-
-    if ($opt_m =~ m/icu/i) {
-        pchdir ("$XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources");    	
-        psystem("cp -fv XercesMessages*.DLL $BUILDDIR");
-        psystem("cp -fv XercesMessages*.lib $BUILDDIR");
-        pchdir ($targetdir);                
-    }
+    print "\nBuild is being copied from \'" . $ReleaseBuildDir . "\'";
     
-    # Populate the include output directory
-    print ("\n\nCopying headers files ...\n");
-
-    @headerDirectories =
-     qw'sax
-		sax2
-        framework
-        framework/psvi        
-        dom
-        dom/deprecated
-        internal
-        parsers
-        util
-        util/Compilers
-        util/MsgLoaders
-        util/MsgLoaders/ICU
-        util/MsgLoaders/InMemory
-        util/MsgLoaders/MsgCatalog
-        util/MsgLoaders/Win32
-        util/Platforms
-        util/Platforms/AIX
-        util/Platforms/HPUX
-        util/Platforms/BeOS
-        util/Platforms/Linux
-        util/Platforms/MacOS
-        util/Platforms/OS2
-        util/Platforms/OS390
-        util/Platforms/PTX
-        util/Platforms/Solaris
-        util/Platforms/Tandem
-        util/Platforms/Win32
-        util/regx
-        util/Transcoders
-        util/Transcoders/ICU
-        util/Transcoders/Iconv
-        util/Transcoders/Win32
-        validators
-        validators/common
-        validators/datatype
-        validators/DTD
-        validators/schema
-        validators/schema/identity';
-
-    foreach $dir (@headerDirectories) {
-        $inclDir = "include/xercesc/$dir";
-        if (! (-e $inclDir)) {
-            psystem("mkdir $inclDir");
-        }
-        $srcDir = "$XERCESCROOT/src/xercesc/$dir";
-
-        # Weed out directories that have no files to copy, to avoid a bunch of
-        # warnings from the cp command in the build output.
-        opendir(dir, $srcDir);
-        @allfiles = readdir(dir);
-        closedir(dir);
-        foreach $fileKind ("hpp", "c") {
-            $matches = grep(/\.$fileKind$/, @allfiles);
-            if ($matches > 0) {
-                psystem("cp -f $srcDir/*.$fileKind  $inclDir/");
-            }
-        }
-    }
-
-
-    #
-    #  Remove internal implementation headers from the DOM include directory.
-    #
-    psystem ("rm -rf $targetdir/include/xercesc/dom/impl");
-    psystem ("rm  $targetdir/include/xercesc/dom/deprecated/*Impl.hpp");
-    psystem ("rm  $targetdir/include/xercesc/dom/deprecated/DS*.hpp");
-
-    if ($ICUIsPresent) {
-        psystem("cp -Rfv $ICUROOT/include/* $targetdir/include");
-    }
-
-    #
-    # Populate the binary output directory
-    #
-    print ("\n\nCopying binary outputs ...\n");
-    psystem("cp -fv $BUILDDIR/*.dll $targetdir/bin");
-    psystem("cp -fv $BUILDDIR/*.exe $targetdir/bin");
+    populateInclude();
 
+#
+#    Population::ICU and/or ICUMsgLoader    
+#
     if ($ICUIsPresent) {    	
+    	
+        print ("\n\nCopying icu outputs ...\n");        	
         # Copy the ICU dlls and libs
         psystem("cp -fv $ICUROOT/bin/icuuc26.dll $targetdir/bin");
         psystem("cp -fv $ICUROOT/bin/icuuc26d.dll $targetdir/bin");
@@ -809,89 +405,47 @@ if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/)))
         psystem("cp -fv $ICUROOT/lib/icuuc.lib $targetdir/lib");
         psystem("cp -fv $ICUROOT/lib/icuucd.lib $targetdir/lib");
 
+        psystem("cp -Rfv $ICUROOT/include/* $targetdir/include");
+            
         # Copy the Resouce Bundle for ICUMsgLoader
-        if ( $opt_m =~ m/icu/i) {
-            psystem("cp -fv $XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources/XercesMessages*.res $targetdir/msg");
-            psystem("cp -fv $XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources/XercesMessages*.DLL $targetdir/bin");
-            psystem("cp -fv $XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources/XercesMessages*.lib $targetdir/lib");
+        if ( $opt_m =~ m/icu/i) {           
+            pchdir ("$ICUResourceDir");    	
+            psystem("cp -fv XercesMessages*.DLL $ReleaseBuildDir");
+            psystem("cp -fv XercesMessages*.lib    $ReleaseBuildDir");
+
+            psystem("cp -fv XercesMessages*.res   $targetdir/msg");
+            psystem("cp -fv XercesMessages*.DLL $targetdir/bin");
+            psystem("cp -fv XercesMessages*.lib    $targetdir/lib");                               
         }        	
 
-    }
-    psystem("cp -fv $BUILDDIR/xerces-c_*.lib $targetdir/lib");
-    psystem("cp -fv $BUILDDIR/xerces-depdom_*.lib $targetdir/lib");
-        
-    if ($buildmode ne "Debug") {
-        $DEBUGBUILDDIR = "$XERCESCROOT/Build/Win32/$VCBuildDir/Debug";
-        psystem("cp -fv $DEBUGBUILDDIR/xerces-c_*D.lib $targetdir/lib");
-        psystem("cp -fv $DEBUGBUILDDIR/xerces-depdom_*D.lib $targetdir/lib");        
-        psystem("cp -fv $DEBUGBUILDDIR/xerces-c*D.dll $targetdir/bin");
-    }
+    } #ICUIsPresent
 
+    #
+    # Population::Xerces-c
+    # 
+    print ("\n\nCopying Xerces-c outputs ...\n");            
+    psystem("cp -fv $ReleaseBuildDir/*.dll   $targetdir/bin");
+    psystem("cp -fv $ReleaseBuildDir/*.exe $targetdir/bin");    
+    psystem("cp -fv $ReleaseBuildDir/xerces-c_*.lib $targetdir/lib");
+    psystem("cp -fv $ReleaseBuildDir/xerces-depdom_*.lib $targetdir/lib");
+           
+    psystem("cp -fv $DebugBuildDir/xerces-c_*D.lib $targetdir/lib");
+    psystem("cp -fv $DebugBuildDir/xerces-depdom_*D.lib $targetdir/lib");        
+    psystem("cp -fv $DebugBuildDir/xerces-c*D.dll $targetdir/bin");
 
     # Populate the etc output directory like config.status and the map file
     print ("\n\nCopying misc output to etc ...\n");
     psystem("cp -fv $XERCESCROOT/Build/Win32/$VCBuildDir/Release/obj/*.map $targetdir/etc");
 
-
-    # Populate the samples directory
-    print ("\n\nCopying sample files ...\n");
-    psystem("cp $XERCESCROOT/version.incl $targetdir");
-    psystem("cp -Rfv $XERCESCROOT/samples/Projects/Win32/$VCBuildDir/* $targetdir/samples/Projects/Win32/$VCBuildDir");
-
-    psystem("cp -Rfv $XERCESCROOT/samples/SAXCount/* $targetdir/samples/SAXCount");
-    psystem("rm -f $targetdir/samples/SAXCount/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/SAX2Count/* $targetdir/samples/SAX2Count");
-    psystem("rm -f $targetdir/samples/SAX2Count/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/SAXPrint/* $targetdir/samples/SAXPrint");
-    psystem("rm -f $targetdir/samples/SAXPrint/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/SAX2Print/* $targetdir/samples/SAX2Print");
-    psystem("rm -f $targetdir/samples/SAX2Print/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/DOMCount/* $targetdir/samples/DOMCount");
-    psystem("rm -f $targetdir/samples/DOMCount/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/DOMPrint/* $targetdir/samples/DOMPrint");
-    psystem("rm -f $targetdir/samples/DOMPrint/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/Redirect/* $targetdir/samples/Redirect");
-    psystem("rm -f $targetdir/samples/Redirect/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/MemParse/* $targetdir/samples/MemParse");
-    psystem("rm -f $targetdir/samples/MemParse/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/PParse/* $targetdir/samples/PParse");
-    psystem("rm -f $targetdir/samples/PParse/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/StdInParse/* $targetdir/samples/StdInParse");
-    psystem("rm -f $targetdir/samples/StdInParse/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/EnumVal/* $targetdir/samples/EnumVal");
-    psystem("rm -f $targetdir/samples/EnumVal/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/SEnumVal/* $targetdir/samples/SEnumVal");
-    psystem("rm -f $targetdir/samples/SEnumVal/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/CreateDOMDocument/* $targetdir/samples/CreateDOMDocument");
-    psystem("rm -f $targetdir/samples/CreateDOMDocument/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/PSVIWriter/* $targetdir/samples/PSVIWriter");
-    psystem("rm -f $targetdir/samples/PSVIWriter/Makefile");
-    psystem("cp -Rfv $XERCESCROOT/samples/SCMPrint/* $targetdir/samples/SCMPrint");
-    psystem("rm -f $targetdir/samples/SCMPrint/Makefile");
-        
-    psystem("cp -Rfv $XERCESCROOT/samples/data/* $targetdir/samples/data");
-
-    # Populate the scripts directory
-    print ("\n\nCopying script files ...\n");
-    psystem("cp $XERCESCROOT/scripts/sanityTest* $targetdir/scripts");
-
-    # Populate the docs directory
-    print ("\n\nCopying documentation ...\n");
-    psystem("cp -Rfv $XERCESCROOT/doc/* $targetdir/doc");
-    psystem("cp $XERCESCROOT/Readme.html $targetdir");
-    psystem("cp $XERCESCROOT/credits.txt $targetdir");
-    psystem("cp $XERCESCROOT/LICENSE.txt $targetdir");
-
-    if ($ICUIsPresent) {
-        psystem("cp $XERCESCROOT/license.html $targetdir");
-        psystem("cp $XERCESCROOT/XLicense.html $targetdir");
-    }
-    psystem("rm -f $targetdir/doc/Doxyfile");
-    psystem("rm -rf $targetdir/doc/style");
-    psystem("rm -f $targetdir/doc/*.xml");
-    psystem("rm -f $targetdir/doc/*.ent");
-    psystem("rm -f $targetdir/doc/*.gif");
-
+    # Populate the samples directory
+    populateSamples();
+
+    # windows specifics: sample projects
+    psystem("cp -Rfv $XERCESCROOT/samples/Projects/Win32/$VCBuildDir/* $targetdir/samples/Projects/Win32/$VCBuildDir");
+   
+    # Populate the scripts and docs directory
+    populateMisc();
+    
     # Now package it all up using ZIP
     pchdir ("$targetdir/..");
     print ("\n\nZIPping up all files ...\n");
@@ -901,14 +455,38 @@ if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/)))
 #
 #     End of Windows Builds.
 
-
-
 #
 #  UNIX builds happen here ...
 #
-if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeOS/i) ||
-     ($platform =~ m/SunOS/i) || ($platform =~ m/Linux/i) || ($platform =~ m/ptx/i) ||
-	 ($platform =~ m/Darwin/i)  || ($platform =~ m/CYGWIN/ && ($opt_c =~ m/gcc/))) {
+#  Tasks:
+#
+#    Preparation
+#          Initialize Vars
+#          Make the target directory and its main subdirectories
+#
+#   Build
+#          ICU and/or Resource bundle library for ICUMsgLoader
+#          Xerces-C libraries, samples and tests
+#
+#   Population
+#          include
+#          ICU and/or ICUMsgLoader
+#          Xerces-C libraries, samples and tests
+#          Documentation
+#
+if ( ($platform =~ m/AIX/i)      || 
+     ($platform =~ m/HP-UX/i) || 
+     ($platform =~ m/BeOS/i)   ||
+     ($platform =~ m/SunOS/i) || 
+     ($platform =~ m/Linux/i)    || 
+     ($platform =~ m/ptx/i)        ||
+     ($platform =~ m/Darwin/i)  || 
+     ($platform =~ m/CYGWIN/ && ($opt_c =~ m/gcc/))) {
+#
+# Preparation Begin
+#
+#    Population::Initialize Vars
+#
 
     # Echo the current PATH to see what compiler it picks up
     psystem ("echo PATH=$ENV{'PATH'}");
@@ -928,20 +506,27 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         }
         psystem ("echo LIBPATH=$ENV{'LIBPATH'}");
     }
-	#	Mac OS X
+
+    # Mac OS X
     if ($platform =~ m/Darwin/i) {
         $platform = "macosx";
 		
-		# Set option defaults
+        # Set option defaults
         if ($opt_c eq "")	{$opt_c = 'cc'; }
         if ($opt_x eq "")	{$opt_x = 'g++'; }
         if ($opt_n eq "") 	{$opt_n = 'native'; }		# native net accessor
         if ($opt_t eq "")	{$opt_t = 'native'; }		# native transcoder
 		
-		# Code for mac os specific tools
-		if ($TAR eq "")		{ $TAR = 'gnutar'; }
-		if ($MAKE eq "")	{ $MAKE = 'make'; }
-    }
+        # Code for mac os specific tools
+        if ($TAR eq "") {
+            $TAR = 'gnutar'; 
+        }
+
+        if ($MAKE eq "") {
+            $MAKE = 'make'; 
+        }
+    } # Mac OS
+    
     if ($platform eq 'HP-UX') {
         # Find out the operating system version from 'uname -r'
         open(OSVERSION, "uname -r|");
@@ -971,7 +556,8 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         }
 
         psystem ("echo SHLIB_PATH=$ENV{'SHLIB_PATH'}");
-    }
+    }# HP-UX
+    
     if ($platform =~ m/BeOS/i) {
         $platform = "beos";
         if ($opt_c eq "") {$opt_c = "gcc";}
@@ -979,7 +565,8 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         $icu_cxxflags = '"-w -O"';
         $icu_cflags = '"-w -O"';
         psystem ("echo LIBRARY_PATH=$ENV{'LIBRARY_PATH'}");
-    }
+    }# BeOS
+    
     if ($platform =~ m/Linux/i) {
         $platform = "linux";
         if ($opt_c eq "") {$opt_c = "gcc";}
@@ -993,11 +580,11 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         }
 
         psystem ("echo LD_LIBRARY_PATH=$ENV{'LD_LIBRARY_PATH'}");
-    }
+    } # Linux
 
     if ($platform =~ m/SunOS/i) {
         $platform = "solaris";
-        if ($opt_c eq "") {$opt_c = "cc";}
+        if ($opXt_c eq "") {$opt_c = "cc";}
         if ($opt_x eq "") {$opt_x = "CC";}
 
         if ($opt_m =~ m/icu/i) {
@@ -1009,7 +596,7 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         $icu_cflags = '"-w -xO3"'; 
 
         psystem ("echo LD_LIBRARY_PATH=$ENV{'LD_LIBRARY_PATH'}");
-    }
+    } # SunOS
 
     if ($platform =~ m/ptx/i) {
         # Check if the patches have been applied or not
@@ -1038,7 +625,8 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
             $ENV{'XMLINSTALL'} = $targetdir;
         }
         $XMLINSTALL = $ENV{'XMLINSTALL'};
-    }
+    } #ptx
+    
     if(($platform =~ m/CYGWIN/) && ($opt_c =~ m/gcc/)) {
         $MAKE = "make";
         $platform = "CYGWIN";
@@ -1050,9 +638,14 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
     if ($opt_t eq "")	{$opt_t = "native"; }  # Native transcoding service.
     if ($opt_b eq "")	{$opt_b = "32"; }      # bitstobuild.
 	
-	# Set defaults for platform tools
-	if ($TAR eq "")		{ $TAR = 'tar'; }
-	if ($MAKE eq "")	{ $MAKE = 'gmake'; }
+    # Set defaults for platform tools
+    if ($TAR eq "") { 
+        $TAR = 'tar'; 
+    }
+        
+    if ($MAKE eq "")	{ 
+        $MAKE = 'gmake'; 
+    }
 
     # Check if the target directories already exist or not
     if (-e $targetdir.".tar") {
@@ -1067,135 +660,78 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         exit(1);
     }
 
+    #
+    # Preparation::Make the target directory and its main subdirectories    
+    #
+    createCommonDir();
+  
+#
+# Build Begin
+#
+#        Build::ICU and/or Resource bundle library for ICUMsgLoader
+#    
+    if ($ICUIsPresent ) {
 
-    # Make the target directory and its main subdirectories
-    psystem ("mkdir $targetdir");
-    psystem ("mkdir $targetdir/bin");
-    psystem ("mkdir $targetdir/etc");
-    psystem ("mkdir $targetdir/lib");
-    if ( $opt_m =~ m/iconv/i || $opt_m =~ m/icu/i ) {
-        psystem ("mkdir $targetdir/msg");
-    }
-    psystem ("mkdir $targetdir/include");
-    psystem ("mkdir $targetdir/include/xercesc");
-    if ($ICUIsPresent) {
-        psystem ("mkdir $targetdir/include/unicode");
-    }
-    psystem ("mkdir $targetdir/include/xercesc/sax");
-    psystem ("mkdir $targetdir/include/xercesc/sax2");
-    psystem ("mkdir $targetdir/include/xercesc/framework");
-    psystem ("mkdir $targetdir/include/xercesc/framework/psvi");    
-    psystem ("mkdir $targetdir/include/xercesc/internal");
-    psystem ("mkdir $targetdir/include/xercesc/parsers");
-    psystem ("mkdir $targetdir/include/xercesc/util");
-    psystem ("mkdir $targetdir/include/xercesc/util/Compilers");
-    psystem ("mkdir $targetdir/include/xercesc/util/MsgLoaders");
-    psystem ("mkdir $targetdir/include/xercesc/util/MsgLoaders/ICU");
-    psystem ("mkdir $targetdir/include/xercesc/util/MsgLoaders/InMemory");
-    psystem ("mkdir $targetdir/include/xercesc/util/MsgLoaders/MsgCatalog");
-    psystem ("mkdir $targetdir/include/xercesc/util/MsgLoaders/Win32");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/AIX");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/HPUX");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/Linux");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/MacOS");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/OS2");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/OS390");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/PTX");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/Solaris");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/Tandem");
-    psystem ("mkdir $targetdir/include/xercesc/util/Platforms/Win32");
-    psystem ("mkdir $targetdir/include/xercesc/util/regx");
-    psystem ("mkdir $targetdir/include/xercesc/util/Transcoders");
-    psystem ("mkdir $targetdir/include/xercesc/util/Transcoders/ICU");
-    psystem ("mkdir $targetdir/include/xercesc/util/Transcoders/Iconv");
-    psystem ("mkdir $targetdir/include/xercesc/util/Transcoders/Win32");
-    psystem ("mkdir $targetdir/include/xercesc/dom");
-    psystem ("mkdir $targetdir/include/xercesc/dom/impl");
-    psystem ("mkdir $targetdir/include/xercesc/dom/deprecated");
-    psystem ("mkdir $targetdir/include/xercesc/validators");
-    psystem ("mkdir $targetdir/include/xercesc/validators/common");
-    psystem ("mkdir $targetdir/include/xercesc/validators/datatype");
-    psystem ("mkdir $targetdir/include/xercesc/validators/DTD");
-    psystem ("mkdir $targetdir/include/xercesc/validators/schema");
-    psystem ("mkdir $targetdir/include/xercesc/validators/schema/identity");
-    psystem ("mkdir $targetdir/samples");
-    psystem ("mkdir $targetdir/samples/data");
-    psystem ("mkdir $targetdir/samples/SAXCount");
-    psystem ("mkdir $targetdir/samples/SAX2Count");
-    psystem ("mkdir $targetdir/samples/SAXPrint");
-    psystem ("mkdir $targetdir/samples/SAX2Print");
-    psystem ("mkdir $targetdir/samples/DOMCount");
-    psystem ("mkdir $targetdir/samples/DOMPrint");
-    psystem ("mkdir $targetdir/samples/Redirect");
-    psystem ("mkdir $targetdir/samples/MemParse");
-    psystem ("mkdir $targetdir/samples/PParse");
-    psystem ("mkdir $targetdir/samples/StdInParse");
-    psystem ("mkdir $targetdir/samples/EnumVal");
-    psystem ("mkdir $targetdir/samples/SEnumVal");
-    psystem ("mkdir $targetdir/samples/CreateDOMDocument");
-    psystem ("mkdir $targetdir/samples/PSVIWriter");    
-    psystem ("mkdir $targetdir/samples/SCMPrint");        
-    psystem ("mkdir $targetdir/scripts");
-    psystem ("mkdir $targetdir/doc");
-    psystem ("mkdir $targetdir/doc/html");
-    psystem ("mkdir $targetdir/doc/html/apiDocs");
-
-    # Build ICU if needed
-    if (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && !(length($opt_j) > 0))
-    {
-        print("\n\nBuild ICU with \'$opt_b\' bit ...\n");
-
-        # First make the ICU files executable
-        pchdir ("$ICUROOT/source");
-        psystem ("chmod +x configure config.*");
-        psystem ("chmod +x install-sh");
-        $ENV{'ICU_DATA'} = "$ICUROOT/data";
-        if ($platform =~ m/ptx/i) {
-            psystem ("chmod +x runConfigureICU");
-            psystem ("./runConfigureICU PTX");
-        } else {
-        # set the 32 bit or 64 bit
-            if ($opt_b eq "32") {
-                psystem ("CC=$opt_c CXX=$opt_x CXXFLAGS=$icu_cxxflags CFLAGS=$icu_cflags configure --prefix=$ICUROOT --disable-64bit-libs");
-            }
-            else {
-                psystem ("CC=$opt_c CXX=$opt_x CXXFLAGS=$icu_cxxflags CFLAGS=$icu_cflags configure --prefix=$ICUROOT");
+        # Make the icu dlls
+        if (!(length($opt_j) > 0)) {      	
+            print ("Building ICU from $ICUROOT ...\n");
+
+            # First make the ICU files executable
+            pchdir ("$ICUROOT/source");
+            psystem ("chmod +x configure config.*");
+            psystem ("chmod +x install-sh");
+            $ENV{'ICU_DATA'} = "$ICUROOT/data";
+
+            if ($platform =~ m/ptx/i) {
+                psystem ("chmod +x runConfigureICU");
+                psystem ("./runConfigureICU PTX");
+            } else {
+            # set the 32 bit or 64 bit
+                if ($opt_b eq "32") {
+                    psystem ("CC=$opt_c CXX=$opt_x CXXFLAGS=$icu_cxxflags CFLAGS=$icu_cflags configure --prefix=$ICUROOT --disable-64bit-libs");
+                }
+                else {
+                    psystem ("CC=$opt_c CXX=$opt_x CXXFLAGS=$icu_cxxflags CFLAGS=$icu_cflags configure --prefix=$ICUROOT");
+                }
             }
-        }
-        psystem ("$MAKE clean"); # Clean up the build, may want to comment this line out!
-        psystem ("rm -f $ICUROOT/data/*.o"); # make clean is not enough
-        psystem ("rm -f $ICUROOT/data/*.c"); # same for .c files
-        psystem ("$MAKE");       # This will take a long time!
-        psystem ("$MAKE install"); # Make this separate since this breaks on Solaris
-
-        # Please check if the following needs any change in Version 1.5
-        # For the antiquated CC compiler under HPUX, we need to invoke
-        # make one extra time to generate the .cnv files.
-        # if ( ($platform =~ m/hp-/i) && ($opt_x eq 'CC') ) {
-        #   system ("$MAKE");
-        # }
         
-        # on AIX, create '.a' version for building libxerces-c
-        if ( $platform eq "aix") {
-            psystem("ln -s $ICUROOT/lib/libicudata26.1.so $ICUROOT/lib/libicudata26.a");
-            psystem("ln -s $ICUROOT/lib/libicuuc26.1.so   $ICUROOT/lib/libicuuc26.a");
+            psystem ("$MAKE clean");                  # Clean up the build, may want to comment this line out!
+            psystem ("rm -f $ICUROOT/data/*.o"); # make clean is not enough
+            psystem ("rm -f $ICUROOT/data/*.c"); # same for .c files
+            psystem ("$MAKE");                           # This will take a long time!
+            psystem ("$MAKE install");                  # Make this separate since this breaks on Solaris
+       
+            # on AIX, create '.a' version for building libxerces-c
+            if ( $platform eq "aix") {
+                psystem("ln -s $ICUROOT/lib/libicudata26.1.so $ICUROOT/lib/libicudata26.a");
+                psystem("ln -s $ICUROOT/lib/libicuuc26.1.so   $ICUROOT/lib/libicuuc26.a");
+            }
+
+        } #opt_j
+
+        #
+        # resource bundle library for ICUMsgLoader is built by Makefile
+        # clean up intermediate files to make it rebuildable  
+        # 
+        if ($opt_m =~ m/icu/i) {
+            pchdir ("$ICUResourceDir");
+            psystem ("rm -f *.o *.res *.c *.lst *dll.mak");            
         }
-        
-    }
+            
+    }  #$ICUIsPresent
 
     # For ptx, ICUROOT must now be set to XMLINSTALL for further work.
     if ($platform =~ m/ptx/i) {
         $ENV{'ICUROOT'} = $ENV{'XMLINSTALL'};
     }
 
-    # make the source files
+    #
+    # Build::Make Xerces-C libraries, samples and tests
+    #        
     print("\n\nBuild the xerces-c library ...\n");
     pchdir ("$XERCESCROOT/src/xercesc");
-
-
     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 -b$opt_b");
     } else {
@@ -1205,61 +741,17 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
     psystem ("$MAKE clean");     # May want to comment this line out to speed up
     psystem ("$MAKE");
                 
-    # Move ICU libs into lib dir, so samples will link.  This matches the structure of
+    #                
+    #   Move ICU libs into lib dir, so samples will link.  This matches the structure of
     #   the eventual binary packaging, even though we are doing it in the build directory.
     #
     if ($ICUIsPresent) {
-        pchdir ("$XERCESCROOT/lib");
-
-        #
-        # copy icudata dll
-        # For ICU 2.4:
-        # on AIX, it is called libicudata26.1.so
-        # on Solaris/Linux, it is called libicudata.so.26.1
-        # on HP, it is called libicudata.sl.26.1
-        #
-        psystem("rm -f libicudata*");
-        psystem("cp -f $ICUROOT/lib/libicudata26.1.so .");
-        psystem("cp -f $ICUROOT/lib/libicudata.so.26.1 .");
-        psystem("cp -f $ICUROOT/lib/libicudata.sl.26.1 .");
-        
-        psystem("find . -name 'libicudata26.1.so' -exec ln -s {} libicudata.so \\;");
-        psystem("find . -name 'libicudata26.1.so' -exec ln -s {} libicudata26.so \\;");
-
-        psystem("find . -name 'libicudata.so.26.1' -exec ln -s {} libicudata.so \\;");
-        psystem("find . -name 'libicudata.so.26.1' -exec ln -s {} libicudata.so.26 \\;");
-
-        psystem("find . -name 'libicudata.sl.26.1' -exec ln -s {} libicudata.sl \\;");
-        psystem("find . -name 'libicudata.sl.26.1' -exec ln -s {} libicudata.sl.26 \\;");
-
-        #
-        # copy icuuc dll
-        # on AIX, it is called libicuuc26.1.so
-        # on Solaris/Linux, it is called libicuuc.so.26.1
-        # on HP, it is called libicuuc.sl.26.1
-        #
-        psystem("rm -f libicuuc*");
-        psystem("cp -f $ICUROOT/lib/libicuuc26.1.so .");
-        psystem("cp -f $ICUROOT/lib/libicuuc.so.26.1  .");
-        psystem("cp -f $ICUROOT/lib/libicuuc.sl.26.1  .");
-        
-        psystem("find . -name 'libicuuc26.1.so' -exec ln -s {} libicuuc.so \\;");
-        psystem("find . -name 'libicuuc26.1.so' -exec ln -s {} libicuuc26.so \\;");
-        
-        psystem("find . -name 'libicuuc.so.26.1' -exec ln -s {} libicuuc.so \\;");
-        psystem("find . -name 'libicuuc.so.26.1' -exec ln -s {} libicuuc.so.26 \\;");
-
-        psystem("find . -name 'libicuuc.sl.26.1' -exec ln -s {} libicuuc.sl \\;");
-        psystem("find . -name 'libicuuc.sl.26.1' -exec ln -s {} libicuuc.sl.26 \\;");
-        
-        # on AIX, copy '.a' version
-        if ( $platform eq "aix") {
-            psystem("ln -s libicudata26.so libicudata26.a");
-            psystem("ln -s libicuuc26.so   libicuuc26.a");
-        }        
-    }
+        copyICUOnUNIX("$XERCESCROOT/lib");
+        # src/xercesc/util/MsgLoader/ICU/resources/Makefile has built and 
+        # copied the message library to $XERCESCROOT/lib, we need copy over here.
+    }# $ICUIsPresent
 
-    # Now build the samples
+    # build the samples
     print("\n\nBuild the samples ...\n");
     pchdir ("$XERCESCROOT/samples");
     psystem ("chmod +x run* con* install-sh");
@@ -1267,7 +759,7 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
     psystem ("$MAKE clean");     # May want to comment this line out to speed up
     psystem ("$MAKE");
 
-    # Next build the tests
+    # build the tests
     print("\n\nBuild the tests ...\n");
     pchdir ("$XERCESCROOT/tests");
     psystem ("chmod +x run* con* install-sh");
@@ -1277,62 +769,61 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
 
     pchdir ($targetdir);
 
-    # Populate the include output directory
-    print ("\n\nCopying headers files ...\n");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/sax/*.hpp $targetdir/include/xercesc/sax");
-	psystem("cp -Rf $XERCESCROOT/src/xercesc/sax2/*.hpp $targetdir/include/xercesc/sax2");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/framework/*.hpp $targetdir/include/xercesc/framework");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/framework/psvi/*.hpp $targetdir/include/xercesc/framework/psvi");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/framework/psvi/*.c $targetdir/include/xercesc/framework/psvi");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/dom/*.hpp $targetdir/include/xercesc/dom");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/dom/deprecated/*.hpp $targetdir/include/xercesc/dom/deprecated");
-
-    psystem("cp -Rf $XERCESCROOT/version.incl $targetdir");
-
-    psystem("rm -rf $targetdir/include/xercesc/dom/impl");
-    psystem("rm  $targetdir/include/xercesc/dom/deprecated/*Impl.hpp");
-    psystem("rm  $targetdir/include/xercesc/dom/deprecated/DS*.hpp");
-
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/internal/*.hpp $targetdir/include/xercesc/internal");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/internal/*.c $targetdir/include/xercesc/internal");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/parsers/*.hpp $targetdir/include/xercesc/parsers");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/parsers/*.c $targetdir/include/xercesc/parsers");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/*.hpp $targetdir/include/xercesc/util");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/*.c $targetdir/include/xercesc/util");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Compilers/*.hpp $targetdir/include/xercesc/util/Compilers");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/MsgLoaders/*.hpp $targetdir/include/xercesc/util/MsgLoaders");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/*.hpp $targetdir/include/xercesc/util/MsgLoaders/ICU");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/MsgLoaders/InMemory/*.hpp $targetdir/include/xercesc/util/MsgLoaders/InMemory");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/MsgLoaders/MsgCatalog/*.hpp $targetdir/include/xercesc/util/MsgLoaders/MsgCatalog");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/MsgLoaders/Win32/*.hpp $targetdir/include/xercesc/util/MsgLoaders/Win32");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/*.hpp $targetdir/include/xercesc/util/Platforms");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/AIX/*.hpp $targetdir/include/xercesc/util/Platforms/AIX");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/HPUX/*.hpp $targetdir/include/xercesc/util/Platforms/HPUX");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/Linux/*.hpp $targetdir/include/xercesc/util/Platforms/Linux");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/MacOS/*.hpp $targetdir/include/xercesc/util/Platforms/MacOS");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/OS2/*.hpp $targetdir/include/xercesc/util/Platforms/OS2");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/OS390/*.hpp $targetdir/include/xercesc/util/Platforms/OS390");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/PTX/*.hpp $targetdir/include/xercesc/util/Platforms/PTX");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/Solaris/*.hpp $targetdir/include/xercesc/util/Platforms/Solaris");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/Tandem/*.hpp $targetdir/include/xercesc/util/Platforms/Tandem");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Platforms/Win32/*.hpp $targetdir/include/xercesc/util/Platforms/Win32");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/regx/*.hpp $targetdir/include/xercesc/util/regx");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Transcoders/*.hpp $targetdir/include/xercesc/util/Transcoders");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Transcoders/ICU/*.hpp $targetdir/include/xercesc/util/Transcoders/ICU");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Transcoders/Iconv/*.hpp $targetdir/include/xercesc/util/Transcoders/Iconv");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/util/Transcoders/Win32/*.hpp $targetdir/include/xercesc/util/Transcoders/Win32");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/validators/common/*.hpp $targetdir/include/xercesc/validators/common");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/validators/datatype/*.hpp $targetdir/include/xercesc/validators/datatype");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/validators/DTD/*.hpp $targetdir/include/xercesc/validators/DTD");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/validators/schema/*.hpp $targetdir/include/xercesc/validators/schema");
-    psystem("cp -Rf $XERCESCROOT/src/xercesc/validators/schema/identity/*.hpp $targetdir/include/xercesc/validators/schema/identity");
+#
+# Population Begin
+#
+#    Population::include
+#
+    populateInclude();   
 
     if ($ICUIsPresent) {
         print "\nICU files are being copied from \'$ICUROOT\'";
         psystem("cp -Rf $ICUROOT/include/* $targetdir/include");
     }
 
-    # Populate the binary output directory
+#
+#    Population::ICU and/or ICUMsgLoader    
+#
+
+    #
+    # Create symbolic link for those ICU libraries
+    #
+    if ($ICUIsPresent) {
+        # ICU
+        copyICUOnUNIX("$targetdir/lib");
+                     
+        # Copy the Resouce Bundle for ICUMsgLoader
+        if ( $opt_m =~ m/icu/i) {
+            print ("\n\nCopying ICU message bundles ...\n");        	
+            psystem("cp -f $XERCESCROOT/msg/XercesMessages*.res $targetdir/msg");
+           
+            psystem("cp -f $XERCESCROOT/lib/libXercesMessages25.0.so .");
+            psystem("find . -name 'libXercesMessages25.0.so' -exec ln -s {} libXercesMessages25.so \\;");
+            psystem("find . -name 'libXercesMessages25.so'   -exec ln -s {} libXercesMessages.so \\;");
+                    
+            psystem("cp -f $XERCESCROOT/lib/libXercesMessages.so.25.0 .");
+            psystem("find . -name 'libXercesMessages.so.25.0' -exec ln -s {} libXercesMessages.so.25 \\;");
+            psystem("find . -name 'libXercesMessages.so.25'   -exec ln -s {} libXercesMessages.so \\;");
+            
+            psystem("cp -f $XERCESCROOT/lib/libXercesMessages.sl.25.0 .");
+            psystem("find . -name 'libXercesMessages.sl.25.0' -exec ln -s {} libXercesMessages.sl.25 \\;");
+            psystem("find . -name 'libXercesMessages.sl.25'   -exec ln -s {} libXercesMessages.sl \\;");            
+
+            # on AIX            
+            if ( $platform eq "aix") {
+                psystem("cp -f $XERCESCROOT/lib/libXercesMessages25.0.a .");
+                psystem("ln -s libXercesMessages25.0.a libXercesMessages25.a ");
+                psystem("ln -s libXercesMessages25.a   libXercesMessages.a   ");
+            }        
+                    
+        }        	
+
+    }
+  
+    #
+    # Population::Xerces-c
+    # 
+        
     print ("\n\nCopying binary outputs ...\n");
     psystem("cp -Rf $XERCESCROOT/bin/* $targetdir/bin");
     psystem("rm -rf $targetdir/bin/obj");
@@ -1386,102 +877,23 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
         
     if ((-e "$XERCESCROOT/lib/libxerces-depdom25.0.a" )) {
         psystem("cp -f $XERCESCROOT/lib/libxerces-depdom25.0.a . ");
-        psystem("ln -s libxerces-depdom25.0.a  libxerces-depdom25.a ");
-        psystem("ln -s libxerces-depdom25.a    libxerces-depdom.a ");         
-    }        
-	# Mac OS X
-    if ((-e "$XERCESCROOT/lib/libxerces-c.25.0.dylib" )) {
-        psystem("cp -f $XERCESCROOT/lib/libxerces-c.25.0.dylib .");
-        psystem("ln -s libxerces-c.25.0.dylib libxerces-c.25.dylib ");
-        psystem("ln -s libxerces-c.25.dylib   libxerces-c.dylib    ");
-    }
-
-    # Populate the Message Catalog Files
-    if ( $opt_m =~ m/iconv/i ) {
-        print ("\n\nCopying Message Catalog Files ...\n");
-        pchdir ("$targetdir/msg");
-        psystem("rm -f XercesMessages* ");    	
-        psystem("cp -f $XERCESCROOT/msg/XercesMessages*.cat .");
-    }
-
-    #
-    # Create symbolic link for those ICU libraries
-    #
-    if ($ICUIsPresent) {
-        pchdir ("$targetdir/lib");
-
-        #
-        # copy icudata dll
-        # on AIX, it is called libicudata26.1.so
-        # on Solaris/Linux, it is called libicudata.so.26.1
-        # on HP, it is called libicudata.sl.26.1
-        #
-        psystem("rm -f libicudata*");
-        psystem("cp -f $XERCESCROOT/lib/libicudata26.1.so .");
-        psystem("cp -f $XERCESCROOT/lib/libicudata.so.26.1 .");
-        psystem("cp -f $XERCESCROOT/lib/libicudata.sl.26.1 .");
-
-        psystem("find . -name 'libicudata26.1.so' -exec ln -s {} libicudata.so \\;");
-        psystem("find . -name 'libicudata26.1.so' -exec ln -s {} libicudata26.so \\;");
-
-        psystem("find . -name 'libicudata.so.26.1' -exec ln -s {} libicudata.so \\;");
-        psystem("find . -name 'libicudata.so.26.1' -exec ln -s {} libicudata.so.26 \\;");
-
-        psystem("find . -name 'libicudata.sl.26.1' -exec ln -s {} libicudata.sl \\;");
-        psystem("find . -name 'libicudata.sl.26.1' -exec ln -s {} libicudata.sl.26 \\;");
-
-        #
-        # copy icuuc dll
-        # on AIX, it is called libicuuc26.1.so
-        # on Solaris/Linux, it is called libicuuc.so.26.1
-        # on HP, it is called libicuuc.sl.26.1
-        #
-        psystem("rm -f libicuuc*");
-        psystem("cp -f $XERCESCROOT/lib/libicuuc26.1.so .");
-        psystem("cp -f $XERCESCROOT/lib/libicuuc.so.26.1  .");
-        psystem("cp -f $XERCESCROOT/lib/libicuuc.sl.26.1  .");
-
-        psystem("find . -name 'libicuuc26.1.so' -exec ln -s {} libicuuc.so \\;");
-        psystem("find . -name 'libicuuc26.1.so' -exec ln -s {} libicuuc26.so \\;");
-
-        psystem("find . -name 'libicuuc.so.26.1' -exec ln -s {} libicuuc.so \\;");
-        psystem("find . -name 'libicuuc.so.26.1' -exec ln -s {} libicuuc.so.26 \\;");
-
-        psystem("find . -name 'libicuuc.sl.26.1' -exec ln -s {} libicuuc.sl \\;");
-        psystem("find . -name 'libicuuc.sl.26.1' -exec ln -s {} libicuuc.sl.26 \\;");
-
-        # on AIX, copy '.a' version
-        if ( $platform eq "aix") {
-            psystem("ln -s libicudata26.so libicudata26.a");
-            psystem("ln -s libicuuc26.so   libicuuc26.a");
-        }        
-                
-        # Copy the Resouce Bundle for ICUMsgLoader
-        if ( $opt_m =~ m/icu/i) {
-            print ("\n\nCopying ICU message bundles ...\n");        	
-            psystem("cp -f $XERCESCROOT/msg/XercesMessages*.res $targetdir/msg");
-           
-            psystem("cp -f $XERCESCROOT/lib/libXercesMessages25.0.so .");
-            psystem("find . -name 'libXercesMessages25.0.so' -exec ln -s {} libXercesMessages25.so \\;");
-            psystem("find . -name 'libXercesMessages25.so'   -exec ln -s {} libXercesMessages.so \\;");
-                    
-            psystem("cp -f $XERCESCROOT/lib/libXercesMessages.so.25.0 .");
-            psystem("find . -name 'libXercesMessages.so.25.0' -exec ln -s {} libXercesMessages.so.25 \\;");
-            psystem("find . -name 'libXercesMessages.so.25'   -exec ln -s {} libXercesMessages.so \\;");
-            
-            psystem("cp -f $XERCESCROOT/lib/libXercesMessages.sl.25.0 .");
-            psystem("find . -name 'libXercesMessages.sl.25.0' -exec ln -s {} libXercesMessages.sl.25 \\;");
-            psystem("find . -name 'libXercesMessages.sl.25'   -exec ln -s {} libXercesMessages.sl \\;");            
-
-            # on AIX            
-            if ( $platform eq "aix") {
-                psystem("cp -f $XERCESCROOT/lib/libXercesMessages25.0.a .");
-                psystem("ln -s libXercesMessages25.0.a libXercesMessages25.a ");
-                psystem("ln -s libXercesMessages25.a   libXercesMessages.a   ");
-            }        
-                    
-        }        	
+        psystem("ln -s libxerces-depdom25.0.a  libxerces-depdom25.a ");
+        psystem("ln -s libxerces-depdom25.a    libxerces-depdom.a ");         
+    }        
+    
+    # Mac OS X
+    if ((-e "$XERCESCROOT/lib/libxerces-c.25.0.dylib" )) {
+        psystem("cp -f $XERCESCROOT/lib/libxerces-c.25.0.dylib .");
+        psystem("ln -s libxerces-c.25.0.dylib libxerces-c.25.dylib ");
+        psystem("ln -s libxerces-c.25.dylib   libxerces-c.dylib    ");
+    }
 
+    # Populate the Message Catalog Files
+    if ( $opt_m =~ m/iconv/i ) {
+        print ("\n\nCopying Message Catalog Files ...\n");
+        pchdir ("$targetdir/msg");
+        psystem("rm -f XercesMessages* ");    	
+        psystem("cp -f $XERCESCROOT/msg/XercesMessages*.cat .");
     }
 
     # Populate the etc output directory like config.status and the map file
@@ -1490,44 +902,191 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
     psystem("cp -Rf $XERCESCROOT/obj/*.map $targetdir/etc");
 
     # Populate the samples directory
-    print ("\n\nCopying sample files ...\n");
+    populateSamples();
+    
+    # UNIX specifics
     foreach $iii ('config.guess', 'config.h.in', 'config.sub', 'configure', 'configure.in',
                   'install-sh', 'runConfigure', 'Makefile.in', 'Makefile.incl', 'Makefile') {
         psystem("cp -f $XERCESCROOT/samples/$iii $targetdir/samples");
     }
 
-    psystem("cp -Rf $XERCESCROOT/samples/data/* $targetdir/samples/data");
-    psystem("cp -Rf $XERCESCROOT/samples/SAXCount/* $targetdir/samples/SAXCount");
+    # Populate the scripts and docs directory
+    populateMisc();
+   
+    # Change the directory permissions
+    psystem ("chmod 644 `find $targetdir -type f`");
+    psystem ("chmod 755 $targetdir/bin/* $targetdir/lib/*");
+    psystem ("chmod +x $targetdir/samples/runConfigure $targetdir/samples/configure $targetdir/samples/install-sh");
+    psystem ("chmod +x $targetdir/samples/config.sub $targetdir/samples/config.guess $targetdir/samples/config.status");
+    psystem ("chmod 755 `find $targetdir -type d`");
+
+    # Now package it all up using tar
+    print ("\n\nTARing up all files ...\n");
+    pchdir ("$targetdir/..");
+    $zipname = $targetdir . ".tar";
+    $platformzipname = $zipname;
+
+    psystem ("$TAR -cvf $platformzipname $zipfiles");
+
+    # Finally compress the files
+    print ("Compressing $platformzipname ...\n");
+    psystem ("gzip $platformzipname");
+} # end of UNIX build
+
+sub createCommonDir() {
+    	
+    print ("\n\nCreating  directories ...\n");
+        	
+    psystem ("mkdir $targetdir");
+    psystem ("mkdir $targetdir/bin");
+    psystem ("mkdir $targetdir/lib");
+    psystem ("mkdir $targetdir/msg");
+    psystem ("mkdir $targetdir/etc");
+
+    psystem ("mkdir $targetdir/include");
+    psystem ("mkdir $targetdir/include/xercesc");
+
+    psystem ("mkdir $targetdir/samples");
+    psystem ("mkdir $targetdir/samples/data");
+    psystem ("mkdir $targetdir/samples/SAXCount");
+    psystem ("mkdir $targetdir/samples/SAX2Count");
+    psystem ("mkdir $targetdir/samples/SAXPrint");
+    psystem ("mkdir $targetdir/samples/SAX2Print");
+    psystem ("mkdir $targetdir/samples/DOMCount");
+    psystem ("mkdir $targetdir/samples/DOMPrint");
+    psystem ("mkdir $targetdir/samples/Redirect");
+    psystem ("mkdir $targetdir/samples/MemParse");
+    psystem ("mkdir $targetdir/samples/PParse");
+    psystem ("mkdir $targetdir/samples/StdInParse");
+    psystem ("mkdir $targetdir/samples/EnumVal");
+    psystem ("mkdir $targetdir/samples/SEnumVal");
+    psystem ("mkdir $targetdir/samples/CreateDOMDocument");
+    psystem ("mkdir $targetdir/samples/PSVIWriter");    
+    psystem ("mkdir $targetdir/samples/SCMPrint");        
+
+    psystem ("mkdir $targetdir/scripts");
+
+    psystem ("mkdir $targetdir/doc");
+    psystem ("mkdir $targetdir/doc/html");
+    psystem ("mkdir $targetdir/doc/html/apiDocs");
+
+}
+
+sub populateInclude() {
+      
+    print ("\n\nCopying headers files ...\n");
+
+    @headerDirectories =
+     qw'sax
+        sax2
+        framework
+        framework/psvi        
+        dom
+        dom/deprecated
+        internal
+        parsers
+        util
+        util/Compilers
+        util/MsgLoaders
+        util/MsgLoaders/ICU
+        util/MsgLoaders/InMemory
+        util/MsgLoaders/MsgCatalog
+        util/MsgLoaders/Win32
+        util/Platforms
+        util/Platforms/AIX
+        util/Platforms/HPUX
+        util/Platforms/BeOS
+        util/Platforms/Linux
+        util/Platforms/MacOS
+        util/Platforms/OS2
+        util/Platforms/OS390
+        util/Platforms/PTX
+        util/Platforms/Solaris
+        util/Platforms/Tandem
+        util/Platforms/Win32
+        util/regx
+        util/Transcoders
+        util/Transcoders/ICU
+        util/Transcoders/Iconv
+        util/Transcoders/Win32
+        validators
+        validators/common
+        validators/datatype
+        validators/DTD
+        validators/schema
+        validators/schema/identity';
+
+    foreach $dir (@headerDirectories) {
+        $inclDir = "include/xercesc/$dir";
+        if (! (-e $inclDir)) {
+            psystem("mkdir $inclDir");
+        }
+        $srcDir = "$XERCESCROOT/src/xercesc/$dir";
+
+        # Weed out directories that have no files to copy, to avoid a bunch of
+        # warnings from the cp command in the build output.
+        opendir(dir, $srcDir);
+        @allfiles = readdir(dir);
+        closedir(dir);
+        foreach $fileKind ("hpp", "c") {
+            $matches = grep(/\.$fileKind$/, @allfiles);
+            if ($matches > 0) {
+                psystem("cp -f $srcDir/*.$fileKind  $inclDir/");
+            }
+        }
+    }
+
+    psystem("cp -Rf $XERCESCROOT/version.incl $targetdir");
+    
+    #
+    #  Remove internal implementation headers from the DOM include directory.
+    #
+    psystem ("rm -rf $targetdir/include/xercesc/dom/impl");
+    psystem ("rm -f  $targetdir/include/xercesc/dom/deprecated/*Impl.hpp");
+    psystem ("rm -f  $targetdir/include/xercesc/dom/deprecated/DS*.hpp");
+     
+}
+    	
+sub populateSamples() {
+
+    print ("\n\nCopying sample files ...\n");    
+    
+    psystem("cp -Rfv $XERCESCROOT/samples/SAXCount/* $targetdir/samples/SAXCount");
     psystem("rm -f $targetdir/samples/SAXCount/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/SAX2Count/* $targetdir/samples/SAX2Count");
+    psystem("cp -Rfv $XERCESCROOT/samples/SAX2Count/* $targetdir/samples/SAX2Count");
     psystem("rm -f $targetdir/samples/SAX2Count/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/SAXPrint/* $targetdir/samples/SAXPrint");
+    psystem("cp -Rfv $XERCESCROOT/samples/SAXPrint/* $targetdir/samples/SAXPrint");
     psystem("rm -f $targetdir/samples/SAXPrint/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/SAX2Print/* $targetdir/samples/SAX2Print");
+    psystem("cp -Rfv $XERCESCROOT/samples/SAX2Print/* $targetdir/samples/SAX2Print");
     psystem("rm -f $targetdir/samples/SAX2Print/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/DOMCount/* $targetdir/samples/DOMCount");
+    psystem("cp -Rfv $XERCESCROOT/samples/DOMCount/* $targetdir/samples/DOMCount");
     psystem("rm -f $targetdir/samples/DOMCount/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/DOMPrint/* $targetdir/samples/DOMPrint");
+    psystem("cp -Rfv $XERCESCROOT/samples/DOMPrint/* $targetdir/samples/DOMPrint");
     psystem("rm -f $targetdir/samples/DOMPrint/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/Redirect/* $targetdir/samples/Redirect");
+    psystem("cp -Rfv $XERCESCROOT/samples/Redirect/* $targetdir/samples/Redirect");
     psystem("rm -f $targetdir/samples/Redirect/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/MemParse/* $targetdir/samples/MemParse");
+    psystem("cp -Rfv $XERCESCROOT/samples/MemParse/* $targetdir/samples/MemParse");
     psystem("rm -f $targetdir/samples/MemParse/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/PParse/* $targetdir/samples/PParse");
+    psystem("cp -Rfv $XERCESCROOT/samples/PParse/* $targetdir/samples/PParse");
     psystem("rm -f $targetdir/samples/PParse/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/StdInParse/* $targetdir/samples/StdInParse");
+    psystem("cp -Rfv $XERCESCROOT/samples/StdInParse/* $targetdir/samples/StdInParse");
     psystem("rm -f $targetdir/samples/StdInParse/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/EnumVal/* $targetdir/samples/EnumVal");
+    psystem("cp -Rfv $XERCESCROOT/samples/EnumVal/* $targetdir/samples/EnumVal");
     psystem("rm -f $targetdir/samples/EnumVal/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/SEnumVal/* $targetdir/samples/SEnumVal");
+    psystem("cp -Rfv $XERCESCROOT/samples/SEnumVal/* $targetdir/samples/SEnumVal");
     psystem("rm -f $targetdir/samples/SEnumVal/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/CreateDOMDocument/* $targetdir/samples/CreateDOMDocument");
+    psystem("cp -Rfv $XERCESCROOT/samples/CreateDOMDocument/* $targetdir/samples/CreateDOMDocument");
     psystem("rm -f $targetdir/samples/CreateDOMDocument/Makefile");
-    psystem("cp -Rf $XERCESCROOT/samples/PSVIWriter/* $targetdir/samples/PSVIWriter");
-    psystem("rm -f $targetdir/samples/PSVIWriter/Makefile");    
-    psystem("cp -Rf $XERCESCROOT/samples/SCMPrint/* $targetdir/samples/SCMPrint");
-    psystem("rm -f $targetdir/samples/SCMPrint/Makefile");        
-    psystem("rm -f $targetdir/samples/Makefile");
+    psystem("cp -Rfv $XERCESCROOT/samples/PSVIWriter/* $targetdir/samples/PSVIWriter");
+    psystem("rm -f $targetdir/samples/PSVIWriter/Makefile");
+    psystem("cp -Rfv $XERCESCROOT/samples/SCMPrint/* $targetdir/samples/SCMPrint");
+    psystem("rm -f $targetdir/samples/SCMPrint/Makefile");
+        
+    psystem("cp -Rfv $XERCESCROOT/samples/data/* $targetdir/samples/data");	
+           
+}
+
+sub populateMisc() {
 
     # Populate the scripts directory
     print ("\n\nCopying script files ...\n");
@@ -1535,60 +1094,78 @@ if ( ($platform =~ m/AIX/i)   || ($platform =~ m/HP-UX/i) || ($platform =~ m/BeO
 
     # Populate the docs directory
     print ("\n\nCopying documentation ...\n");
-    psystem("cp -Rf $XERCESCROOT/doc/* $targetdir/doc");
+    psystem("cp -Rfv $XERCESCROOT/doc/* $targetdir/doc");
     psystem("cp $XERCESCROOT/Readme.html $targetdir");
     psystem("cp $XERCESCROOT/credits.txt $targetdir");
     psystem("cp $XERCESCROOT/LICENSE.txt $targetdir");
-    if ($ICUIsPresent) {
-        psystem("cp $XERCESCROOT/license.html $targetdir");
-        psystem("cp $XERCESCROOT/XLicense.html $targetdir");
-    }
+   
     psystem("rm -f $targetdir/doc/Doxyfile");
     psystem("rm -rf $targetdir/doc/style");
     psystem("rm -f $targetdir/doc/*.xml");
     psystem("rm -f $targetdir/doc/*.ent");
     psystem("rm -f $targetdir/doc/*.gif");
-
-    # Change the directory permissions
-    psystem ("chmod 644 `find $targetdir -type f`");
-    psystem ("chmod 755 $targetdir/bin/* $targetdir/lib/*");
-    psystem ("chmod +x $targetdir/samples/runConfigure $targetdir/samples/configure $targetdir/samples/install-sh");
-    psystem ("chmod +x $targetdir/samples/config.sub $targetdir/samples/config.guess $targetdir/samples/config.status");
-    psystem ("chmod 755 `find $targetdir -type d`");
-
-    # Now package it all up using tar
-    print ("\n\nTARing up all files ...\n");
-    pchdir ("$targetdir/..");
-    $zipname = $targetdir . ".tar";
-    $platformzipname = $zipname;
-
-    psystem ("$TAR -cvf $platformzipname $zipfiles");
-
-    # Finally compress the files
-    print ("Compressing $platformzipname ...\n");
-    psystem ("gzip $platformzipname");
+       
 }
 
 #
-#  psystem subroutine both prints and executes a system command.
-#
-sub psystem() {
-    print("$_[0]\n");
-    system($_[0]);
-    }
+# copy ICU file to the directory specified
+#	
+sub copyICUOnUNIX() {
+	
+        pchdir ("$_[0]");
 
+        #
+        # copy icudata dll
+        # For ICU 2.6:
+        # on AIX,              it is called libicudata26.1.so
+        # on Solaris/Linux, it is called libicudata.so.26.1
+        # on HP,               it is called libicudata.sl.26.1
+        #
+        psystem("rm -f libicudata*");
+        psystem("cp -f $ICUROOT/lib/libicudata26.1.so .");
+        psystem("cp -f $ICUROOT/lib/libicudata.so.26.1 .");
+        psystem("cp -f $ICUROOT/lib/libicudata.sl.26.1 .");
+        
+        psystem("find . -name 'libicudata26.1.so' -exec ln -s {} libicudata.so \\;");
+        psystem("find . -name 'libicudata26.1.so' -exec ln -s {} libicudata26.so \\;");
 
-#
-#  chdir subroutine both prints and executes a chdir
-#
-sub pchdir() {
-    print("chdir $_[0]\n");
-    chdir $_[0];
-    }
+        psystem("find . -name 'libicudata.so.26.1' -exec ln -s {} libicudata.so \\;");
+        psystem("find . -name 'libicudata.so.26.1' -exec ln -s {} libicudata.so.26 \\;");
+
+        psystem("find . -name 'libicudata.sl.26.1' -exec ln -s {} libicudata.sl \\;");
+        psystem("find . -name 'libicudata.sl.26.1' -exec ln -s {} libicudata.sl.26 \\;");
+
+        #
+        # copy icuuc dll
+        # on AIX,              it is called libicuuc26.1.so
+        # on Solaris/Linux, it is called libicuuc.so.26.1
+        # on HP,               it is called libicuuc.sl.26.1
+        #
+        psystem("rm -f libicuuc*");
+        psystem("cp -f $ICUROOT/lib/libicuuc26.1.so .");
+        psystem("cp -f $ICUROOT/lib/libicuuc.so.26.1  .");
+        psystem("cp -f $ICUROOT/lib/libicuuc.sl.26.1  .");
+        
+        psystem("find . -name 'libicuuc26.1.so' -exec ln -s {} libicuuc.so \\;");
+        psystem("find . -name 'libicuuc26.1.so' -exec ln -s {} libicuuc26.so \\;");
+        
+        psystem("find . -name 'libicuuc.so.26.1' -exec ln -s {} libicuuc.so \\;");
+        psystem("find . -name 'libicuuc.so.26.1' -exec ln -s {} libicuuc.so.26 \\;");
 
+        psystem("find . -name 'libicuuc.sl.26.1' -exec ln -s {} libicuuc.sl \\;");
+        psystem("find . -name 'libicuuc.sl.26.1' -exec ln -s {} libicuuc.sl.26 \\;");
+        
+        # on AIX, copy '.a' version
+        if ( $platform eq "aix") {
+            psystem("ln -s libicudata26.so libicudata26.a");
+            psystem("ln -s libicuuc26.so   libicuuc26.a");
+        }        	
+        
+}
 
+	
 sub change_windows_project_for_ICU() {
-    my ($thefile, $transcoder, $msgloader) = @_;
+    my ($thefile, $Transcoder, $MsgLoader) = @_;
 
     print "\nConverting Windows Xerces library project ($thefile) for ICU usage...";
     my $thefiledotbak = $thefile . ".bak";
@@ -1608,23 +1185,23 @@ sub change_windows_project_for_ICU() {
         $line =~ s[Debug/xerces-c_2D.lib"][Debug/xerces-c_2D.lib" /libpath:"$ICUROOT\\lib" /libpath:"$ICUROOT\\source\\data" /libpath:"$XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources"];
         $line =~ s[Release/xerces-c_2.lib"][Release/xerces-c_2.lib" /libpath:"$ICUROOT\\lib" /libpath:"$ICUROOT\\source\\data" /libpath:"$XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources"];       
        
-        if ($msgloader)
+        if ($MsgLoader)
         {
             $line =~ s/user32.lib/user32.lib $icuuc.lib icudata.lib XercesMessages2_5_0.lib/g;
         }        
-        elsif ($transcoder)
+        elsif ($Transcoder)
         {
             $line =~ s/user32.lib/user32.lib $icuuc.lib icudata.lib/g;
         }
         
-        if ($transcoder)
+        if ($Transcoder)
         {
             $line =~ s/XML_USE_WIN32_TRANSCODER/XML_USE_ICU_TRANSCODER/g;
             $line =~ s/Transcoders\\Win32\\Win32TransService.cpp/Transcoders\\ICU\\ICUTransService.cpp/g;
             $line =~ s/Transcoders\\Win32\\Win32TransService.hpp/Transcoders\\ICU\\ICUTransService.hpp/g;
         }
 
-        if ($msgloader)
+        if ($MsgLoader)
         {
             $line =~ s/XML_USE_WIN32_MSGLOADER/XML_USE_ICU_MESSAGELOADER/g;
             $line =~ s/MsgLoaders\\Win32\\Win32MsgLoader.cpp/MsgLoaders\\ICU\\ICUMsgLoader.cpp/g;
@@ -1639,7 +1216,7 @@ sub change_windows_project_for_ICU() {
 }
 
 sub change_windows_makefile_for_ICU() {
-    my ($thefile, $transcoder, $msgloader) = @_;
+    my ($thefile, $Transcoder, $MsgLoader) = @_;
     print "\nConverting Windows Xerces library makefile ($thefile) for ICU usage...";
     my $thefiledotbak = $thefile . ".bak";
     rename ($thefile, $thefiledotbak);
@@ -1657,22 +1234,22 @@ sub change_windows_makefile_for_ICU() {
         $line =~ s[/D "PROJ_XMLPARSER"][/I "$ICUROOT\\include" /D "PROJ_XMLPARSER"];
         $line =~ s[/machine:IA64][/libpath:"$ICUROOT\\lib" /libpath:"$ICUROOT\\source\\data" /libpath:"$XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources" /machine:IA64];
 
-        if ($msgloader)
+        if ($MsgLoader)
         {
             $line =~ s/user32.lib/user32.lib $icuuc.lib icudata.lib XercesMessages2_5_0.lib/g;
         }        
-        elsif ($transcoder)
+        elsif ($Transcoder)
         {
             $line =~ s/user32.lib/user32.lib $icuuc.lib icudata.lib/g;
         }
             
-        if ($transcoder) {
+        if ($Transcoder) {
             $line =~ s/XML_USE_WIN32_TRANSCODER/XML_USE_ICU_TRANSCODER/g;
             $line =~ s/Transcoders\\Win32\\Win32TransService/Transcoders\\ICU\\ICUTransService/g;
             $line =~ s/Win32TransService/ICUTransService/g;
         }
 
-        if ($msgloader)
+        if ($MsgLoader)
         {
             $line =~ s/XML_USE_WIN32_MSGLOADER/XML_USE_ICU_MESSAGELOADER/g;
             $line =~ s/MsgLoaders\\Win32\\Win32MsgLoader/MsgLoaders\\ICU\\ICUMsgLoader/g;
@@ -1687,7 +1264,7 @@ sub change_windows_makefile_for_ICU() {
 }
 
 sub change_windows_project_for_ICU_VC7() {
-    my ($thefile, $transcoder, $msgloader) = @_;
+    my ($thefile, $Transcoder, $MsgLoader) = @_;
     print "\nConverting Windows Xerces library project ($thefile) for ICU usage...";
     my $thefiledotbak = $thefile . ".bak";
     rename ($thefile, $thefiledotbak);
@@ -1704,22 +1281,22 @@ sub change_windows_project_for_ICU_VC7() {
         $line =~ s/AdditionalIncludeDirectories=\"([^"]*)/AdditionalIncludeDirectories=\"$ICUROOT\\include;$1/;
         $line =~ s/AdditionalLibraryDirectories=\"([^"]*)/AdditionalLibraryDirectories=\"$ICUROOT\\lib;$ICUROOT\\source\\data;$XERCESCROOT\\src\\xercesc\\util\\MsgLoaders\\ICU\\resources;$1/;
         
-        if ($msgloader)
+        if ($MsgLoader)
         {
             $line =~ s/AdditionalDependencies=\"([^"]*)/AdditionalDependencies=\"$icuuc.lib icudata.lib XercesMessages2_5_0.lib $1/;
         }        
-        elsif ($transcoder)
+        elsif ($Transcoder)
         {
             $line =~ s/AdditionalDependencies=\"([^"]*)/AdditionalDependencies=\"$icuuc.lib icudata.lib $1/;
         }
 
-        if ($transcoder) {
+        if ($Transcoder) {
             $line =~ s/XML_USE_WIN32_TRANSCODER/XML_USE_ICU_TRANSCODER/g;
             $line =~ s/Transcoders\\Win32\\Win32TransService.cpp/Transcoders\\ICU\\ICUTransService.cpp/g;
             $line =~ s/Transcoders\\Win32\\Win32TransService.hpp/Transcoders\\ICU\\ICUTransService.hpp/g;
         }
 
-        if ($msgloader)
+        if ($MsgLoader)
         {
             $line =~ s/XML_USE_WIN32_MSGLOADER/XML_USE_ICU_MESSAGELOADER/g;
             $line =~ s/MsgLoaders\\Win32\\Win32MsgLoader/MsgLoaders\\ICU\\ICUMsgLoader/g;
@@ -1838,3 +1415,19 @@ sub changeWindowsProjectForFileOnlyNA_VC7() {
     close (PROJFILEIN);
     unlink ($thefiledotbak);
 }
+
+#
+#  psystem subroutine both prints and executes a system command.
+#
+sub psystem() {
+    print("$_[0]\n");
+    system($_[0]);
+    }
+
+#
+#  chdir subroutine both prints and executes a chdir
+#
+sub pchdir() {
+    print("chdir $_[0]\n");
+    chdir $_[0];
+    }
\ No newline at end of file