VS2010v11.patch

text/plain

Filename: VS2010v11.patch
Type: text/plain
Part: 0
Message: Re: Review of VS 2010 support patches

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
doc/src/sgml/install-windows.sgml 27 27
src/tools/msvc/builddoc.pl 2 2
src/tools/msvc/build.pl 6 2
src/tools/msvc/clean.bat 4 0
src/tools/msvc/Install.pm 46 21
src/tools/msvc/Mkvcbuild.pm 12 7
src/tools/msvc/MSBuildProject.pm 388 0
src/tools/msvc/Project.pm 24 208
src/tools/msvc/README 79 5
src/tools/msvc/Solution.pm 80 22
src/tools/msvc/VCBuildProject.pm 267 0
src/tools/msvc/VSObjectFactory.pm 122 0
diff -Napcdr -x .git postgresql/doc/src/sgml/install-windows.sgml postgresql_dev/doc/src/sgml/install-windows.sgml
*** postgresql/doc/src/sgml/install-windows.sgml	Sun Dec 25 20:45:34 2011
--- postgresql_dev/doc/src/sgml/install-windows.sgml	Mon Dec 26 11:02:25 2011
***************
*** 20,29 ****
    There are several different ways of building PostgreSQL on
    <productname>Windows</productname>. The simplest way to build with
    Microsoft tools is to install a supported version of the
!   <productname>Microsoft Platform SDK</productname> and use the included
    compiler. It is also possible to build with the full
!   <productname>Microsoft Visual C++ 2005 or 2008</productname>. In some cases
!   that requires the installation of the <productname>Platform SDK</productname>
    in addition to the compiler.
   </para>
  
--- 20,29 ----
    There are several different ways of building PostgreSQL on
    <productname>Windows</productname>. The simplest way to build with
    Microsoft tools is to install a supported version of the
!   <productname>Microsoft Windows SDK</productname> and use the included
    compiler. It is also possible to build with the full
!   <productname>Microsoft Visual C++ 2005, 2008 or 2010</productname>. In some cases
!   that requires the installation of the <productname>Windows SDK</productname>
    in addition to the compiler.
   </para>
  
***************
*** 69,100 ****
  
   <sect1 id="install-windows-full">
    <title>Building with <productname>Visual C++</productname> or the
!   <productname>Platform SDK</productname></title>
  
   <para>
    PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.
    These compilers can be either from <productname>Visual Studio</productname>,
    <productname>Visual Studio Express</productname> or some versions of the
!   <productname>Platform SDK</productname>. If you do not already have a
    <productname>Visual Studio</productname> environment set up, the easiest
!   way us to use the compilers in the <productname>Platform SDK</productname>,
    which is a free download from Microsoft.
   </para>
  
   <para>
!   PostgreSQL supports the compilers from
!   <productname>Visual Studio 2005</productname> and
!   <productname>Visual Studio 2008</productname>. When using the Platform SDK
!   only, or when building for 64-bit Windows, only
!   <productname>Visual Studio 2008</productname> is supported.
!   <productname>Visual Studio 2010</productname> is not yet supported.
!  </para>
! 
!  <para>
!   When building using the <productname>Platform SDK</productname>, versions
!   6.0 to 7.0 of the SDK are supported. Older or newer versions will not work.
!   In particular, versions from 7.0a and later will not work, since
!   they include compilers from <productname>Visual Studio 2010</productname>.
   </para>
  
   <para>
--- 69,94 ----
  
   <sect1 id="install-windows-full">
    <title>Building with <productname>Visual C++</productname> or the
!   <productname>Microsoft Windows SDK</productname></title>
  
   <para>
    PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.
    These compilers can be either from <productname>Visual Studio</productname>,
    <productname>Visual Studio Express</productname> or some versions of the
!   <productname>Microsoft Windows SDK</productname>. If you do not already have a
    <productname>Visual Studio</productname> environment set up, the easiest
!   way is to use the compilers in the <productname>Windows SDK</productname>,
    which is a free download from Microsoft.
   </para>
  
   <para>
!   PostgreSQL is known to support compilation using the compilers shipped with
!   <productname>Visual Studio 2005</productname> to
!   <productname>Visual Studio 2010</productname> (including Express editions),
!   as well as standalone Windows SDK releases 6.0 to 7.1.
!   64-bit PostgreSQL builds are only supported with
!   <productname>Microsoft Windows SDK</productname> version 6.0a and above or
!   <productname>Visual Studio 2008</productname> and above.
   </para>
  
   <para>
***************
*** 104,114 ****
    <productname>Cygwin</productname> present in your system PATH. Also, make
    sure you have all the required Visual C++ tools available in the PATH. In
    <productname>Visual Studio</productname>, start the
!   <application>Visual Studio Command Prompt</application>. In the
!   <productname>Platform SDK</productname>, start the
!   <application>CMD shell</application> listed under the SDK on the Start Menu.
    If you wish to build a 64-bit version, you must use the 64-bit version of
    the command, and vice versa.
    All commands should be run from the <filename>src\tools\msvc</filename>
    directory.
   </para>
--- 98,110 ----
    <productname>Cygwin</productname> present in your system PATH. Also, make
    sure you have all the required Visual C++ tools available in the PATH. In
    <productname>Visual Studio</productname>, start the
!   <application>Visual Studio Command Prompt</application>.
    If you wish to build a 64-bit version, you must use the 64-bit version of
    the command, and vice versa.
+   In the <productname>Microsoft Windows SDK</productname>, start the
+   <application>CMD shell</application> listed under the SDK on the Start Menu.
+   In recent SDK versions you can change the targeted CPU architecture by using
+   the <command>setenv</command> command.
    All commands should be run from the <filename>src\tools\msvc</filename>
    directory.
   </para>
*************** $ENV{PATH}=$ENV{PATH} . ';c:\some\where\
*** 148,164 ****
  
     <variablelist>
      <varlistentry>
!      <term><productname>Microsoft Platform SDK</productname></term>
       <listitem><para>
        It is recommended that you upgrade to the latest supported version
!       of the <productname>Microsoft Platform SDK</productname> (currently
!       version 7.0), available for download from
        <ulink url="http://www.microsoft.com/downloads/"></>.
       </para>
       <para>
        You must always include the
        <application>Windows Headers and Libraries</application> part of the SDK.
!       If you install the <productname>Platform SDK</productname>
        including the <application>Visual C++ Compilers</application>,
        you don't need <productname>Visual Studio</productname> to build.
       </para></listitem>
--- 144,160 ----
  
     <variablelist>
      <varlistentry>
!      <term><productname>Microsoft Windows SDK</productname></term>
       <listitem><para>
        It is recommended that you upgrade to the latest supported version
!       of the <productname>Microsoft Windows SDK</productname> (currently
!       version 7.1), available for download from
        <ulink url="http://www.microsoft.com/downloads/"></>.
       </para>
       <para>
        You must always include the
        <application>Windows Headers and Libraries</application> part of the SDK.
!       If you install the <productname>Windows SDK</productname>
        including the <application>Visual C++ Compilers</application>,
        you don't need <productname>Visual Studio</productname> to build.
       </para></listitem>
*************** $ENV{PATH}=$ENV{PATH} . ';c:\some\where\
*** 202,207 ****
--- 198,207 ----
        Bison can be downloaded from <ulink url="http://gnuwin32.sourceforge.net"></>.
        Flex can be downloaded from
        <ulink url="http://www.postgresql.org/ftp/misc/winflex/"></>.
+       If you are using <productname>msysGit</productname> for accessing the
+       PostgreSQL <productname>Git</productname> repository you probably already
+       have recent versions of bison and flex in your <productname>Git</productname>
+       binary directory.
       </para>
  
       <note>
*************** $ENV{DOCROOT}='c:\docbook';
*** 479,485 ****
    static library to link into an application. For normal use the
    <productname>MinGW</productname> or
    <productname>Visual Studio</productname> or
!   <productname>Platform SDK</productname> method is recommended.
   </para>
  
   <para>
--- 479,485 ----
    static library to link into an application. For normal use the
    <productname>MinGW</productname> or
    <productname>Visual Studio</productname> or
!   <productname>Windows SDK</productname> method is recommended.
   </para>
  
   <para>
diff -Napcdr -x .git postgresql/src/tools/msvc/Install.pm postgresql_dev/src/tools/msvc/Install.pm
*** postgresql/src/tools/msvc/Install.pm	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/Install.pm	Mon Dec 26 20:14:30 2011
*************** sub Install
*** 56,66 ****
      my $majorver = DetermineMajorVersion();
      print "Installing version $majorver for $conf in $target\n";
  
!     EnsureDirectories(
!         $target, 'bin', 'lib', 'share',
!         'share/timezonesets','share/extension', 'share/contrib','doc',
!         'doc/extension', 'doc/contrib','symbols', 'share/tsearch_data'
!     );
  
      CopySolutionOutput($conf, $target);
      lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
--- 56,63 ----
      my $majorver = DetermineMajorVersion();
      print "Installing version $majorver for $conf in $target\n";
  
!     EnsureDirectories($target, 'bin', 'lib', 'share','share/timezonesets','share/extension',
!         'share/contrib','doc','doc/extension', 'doc/contrib','symbols', 'share/tsearch_data');
  
      CopySolutionOutput($conf, $target);
      lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
*************** sub CopySolutionOutput
*** 186,191 ****
--- 183,195 ----
      my $rem = qr{Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"\) = "([^"]+)"};
  
      my $sln = read_file("pgsql.sln") || croak "Could not open pgsql.sln\n";
+ 
+     my $vcproj = 'vcproj';
+     if ($sln =~ /Microsoft Visual Studio Solution File, Format Version (\d+)\.\d+/ && $1 >= 11)
+     {
+         $vcproj = 'vcxproj';
+     }
+ 
      print "Copying build output files...";
      while ($sln =~ $rem)
      {
*************** sub CopySolutionOutput
*** 195,220 ****
  
          $sln =~ s/$rem//;
  
!         my $proj = read_file("$pf.vcproj") || croak "Could not open $pf.vcproj\n";
!         if ($proj !~ qr{ConfigurationType="([^"]+)"})
!         {
!             croak "Could not parse $pf.vcproj\n";
!         }
!         if ($1 == 1)
          {
!             $dir = "bin";
!             $ext = "exe";
          }
!         elsif ($1 == 2)
          {
!             $dir = "lib";
!             $ext = "dll";
          }
          else
          {
! 
!             # Static lib, such as libpgport, only used internally during build, don't install
!             next;
          }
          lcopy("$conf\\$pf\\$pf.$ext","$target\\$dir\\$pf.$ext")
            || croak "Could not copy $pf.$ext\n";
--- 199,246 ----
  
          $sln =~ s/$rem//;
  
!         my $proj = read_file("$pf.$vcproj") || croak "Could not open $pf.$vcproj\n";
!         if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"})
          {
!             if ($1 == 1)
!             {
!                 $dir = "bin";
!                 $ext = "exe";
!             }
!             elsif ($1 == 2)
!             {
!                 $dir = "lib";
!                 $ext = "dll";
!             }
!             else
!             {
! 
!                 # Static lib, such as libpgport, only used internally during build, don't install
!                 next;
!             }
          }
!         elsif ($vcproj eq 'vcxproj' && $proj =~ qr{<ConfigurationType>(\w+)</ConfigurationType>})
          {
!             if ($1 eq 'Application')
!             {
!                 $dir = "bin";
!                 $ext = "exe";
!             }
!             elsif ($1 eq 'DynamicLibrary')
!             {
!                 $dir = "lib";
!                 $ext = "dll";
!             }
!             else # 'StaticLibrary'
!             {
! 
!                 # Static lib, such as libpgport, only used internally during build, don't install
!                 next;
!             }
          }
          else
          {
!             croak "Could not parse $pf.$vcproj\n";
          }
          lcopy("$conf\\$pf\\$pf.$ext","$target\\$dir\\$pf.$ext")
            || croak "Could not copy $pf.$ext\n";
*************** sub CopyIncludeFiles
*** 470,477 ****
          $target . '/include/server/',
          'src/include/', 'pg_config.h', 'pg_config_os.h'
      );
!     CopyFiles('Grammar header', $target . '/include/server/parser/','src/backend/parser/',
!         'gram.h');
      CopySetOfFiles('',[ glob("src\\include\\*.h") ],$target . '/include/server/');
      my $D;
      opendir($D, 'src/include') || croak "Could not opendir on src/include!\n";
--- 496,502 ----
          $target . '/include/server/',
          'src/include/', 'pg_config.h', 'pg_config_os.h'
      );
!     CopyFiles('Grammar header', $target . '/include/server/parser/','src/backend/parser/','gram.h');
      CopySetOfFiles('',[ glob("src\\include\\*.h") ],$target . '/include/server/');
      my $D;
      opendir($D, 'src/include') || croak "Could not opendir on src/include!\n";
diff -Napcdr -x .git postgresql/src/tools/msvc/MSBuildProject.pm postgresql_dev/src/tools/msvc/MSBuildProject.pm
*** postgresql/src/tools/msvc/MSBuildProject.pm	Thu Jan  1 00:00:00 1970
--- postgresql_dev/src/tools/msvc/MSBuildProject.pm	Mon Dec 26 20:14:30 2011
***************
*** 0 ****
--- 1,388 ----
+ package MSBuildProject;
+ 
+ #
+ # Package that encapsulates a MSBuild (Visual C++ 2010) project file
+ #
+ # src/tools/msvc/MSBuildProject.pm
+ #
+ 
+ use Carp;
+ use strict;
+ use warnings;
+ use base qw(Project);
+ 
+ sub _new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{filenameExtension} = '.vcxproj';
+ 
+     return $self;
+ }
+ 
+ sub WriteHeader
+ {
+     my ($self, $f) = @_;
+ 
+     print $f <<EOF;
+ <?xml version="1.0" encoding="Windows-1252"?>
+ <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+   <ItemGroup Label="ProjectConfigurations">
+ EOF
+     $self->WriteConfigurationHeader($f, 'Debug');
+     $self->WriteConfigurationHeader($f, 'Release');
+     print $f <<EOF;
+   </ItemGroup>
+   <PropertyGroup Label="Globals">
+     <ProjectGuid>$self->{guid}</ProjectGuid>
+   </PropertyGroup>
+   <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
+ EOF
+     $self->WriteConfigurationPropertyGroup($f, 'Release',{ wholeopt=>'false' });
+     $self->WriteConfigurationPropertyGroup($f, 'Debug',{ wholeopt=>'false' });
+     print $f <<EOF;
+   <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" />
+   <ImportGroup Label="ExtensionSettings">
+   </ImportGroup>
+ EOF
+     $self->WritePropertySheetsPropertyGroup($f, 'Release');
+     $self->WritePropertySheetsPropertyGroup($f, 'Debug');
+     print $f <<EOF;
+   <PropertyGroup Label="UserMacros" />
+   <PropertyGroup>
+     <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ EOF
+     $self->WriteAdditionalProperties($f, 'Debug');
+     $self->WriteAdditionalProperties($f, 'Release');
+     print $f <<EOF;
+   </PropertyGroup>
+ EOF
+     $self->WriteItemDefinitionGroup(
+         $f, 'Debug',
+         {
+             defs=>'_DEBUG;DEBUG=1;',
+             opt=>'Disabled',
+             strpool=>'false',
+             runtime=>'MultiThreadedDebugDLL'
+         }
+     );
+     $self->WriteItemDefinitionGroup($f, 'Release',
+         { defs=>'', opt=>'Full', strpool=>'true', runtime=>'MultiThreadedDLL' });
+ }
+ 
+ sub AddDefine
+ {
+     my ($self, $def) = @_;
+ 
+     $self->{defines} .= $def . ';';
+ }
+ 
+ sub WriteReferences
+ {
+     my ($self, $f) = @_;
+ 
+     my @references = @{$self->{references}};
+ 
+     if (scalar(@references))
+     {
+         print $f <<EOF;
+   <ItemGroup>
+ EOF
+         foreach my $ref (@references)
+         {
+             print $f <<EOF;
+     <ProjectReference Include="$ref->{name}$ref->{filenameExtension}">
+       <Project>$ref->{guid}</Project>
+     </ProjectReference>
+ EOF
+         }
+         print $f <<EOF;
+   </ItemGroup>
+ EOF
+     }
+ }
+ 
+ sub WriteFiles
+ {
+     my ($self, $f) = @_;
+     print $f <<EOF;
+   <ItemGroup>
+ EOF
+     my @grammarFiles = ();
+     my @resourceFiles = ();
+     my %uniquefiles;
+     foreach my $fileNameWithPath (sort keys %{ $self->{files} })
+     {
+         confess "Bad format filename '$fileNameWithPath'\n"
+           unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/);
+         my $dir = $1;
+         my $fileName = $2;
+         if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/)
+         {
+             push @grammarFiles, $fileNameWithPath;
+         }
+         elsif ($fileNameWithPath =~ /\.rc$/)
+         {
+             push @resourceFiles, $fileNameWithPath;
+         }
+         elsif (defined($uniquefiles{$fileName}))
+         {
+ 
+             # File already exists, so fake a new name
+             my $obj = $dir;
+             $obj =~ s/\\/_/g;
+ 
+             print $f <<EOF;
+     <ClCompile Include="$fileNameWithPath">
+       <ObjectFileName Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">.\\debug\\$self->{name}\\${obj}_$fileName.obj</ObjectFileName>
+       <ObjectFileName Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">.\\release\\$self->{name}\\${obj}_$fileName.obj</ObjectFileName>
+     </ClCompile>
+ EOF
+         }
+         else
+         {
+             $uniquefiles{$fileName} = 1;
+             print $f <<EOF;
+     <ClCompile Include="$fileNameWithPath" />
+ EOF
+         }
+ 
+     }
+     print $f <<EOF;
+   </ItemGroup>
+ EOF
+     if (scalar(@grammarFiles))
+     {
+         print $f <<EOF;
+   <ItemGroup>
+ EOF
+         foreach my $grammarFile (@grammarFiles)
+         {
+             (my $outputFile = $grammarFile) =~ s/\.(y|l)$/.c/;
+             if ($grammarFile =~ /\.y$/)
+             {
+                 $outputFile =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c};
+                 print $f <<EOF;
+     <CustomBuild Include="$grammarFile">
+       <Message Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">Running bison on $grammarFile</Message>
+       <Command Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">perl "src\\tools\\msvc\\pgbison.pl" "$grammarFile"</Command>
+       <AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs>
+       <Outputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">$outputFile;%(Outputs)</Outputs>
+       <Message Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">Running bison on $grammarFile</Message>
+       <Command Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">perl "src\\tools\\msvc\\pgbison.pl" "$grammarFile"</Command>
+       <AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs>
+       <Outputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">$outputFile;%(Outputs)</Outputs>
+     </CustomBuild>
+ EOF
+             }
+             else #if ($grammarFile =~ /\.l$/)
+             {
+                 print $f <<EOF;
+     <CustomBuild Include="$grammarFile">
+       <Message Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">Running flex on $grammarFile</Message>
+       <Command Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">perl "src\\tools\\msvc\\pgflex.pl" "$grammarFile"</Command>
+       <AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs>
+       <Outputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">$outputFile;%(Outputs)</Outputs>
+       <Message Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">Running flex on $grammarFile</Message>
+       <Command Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">perl "src\\tools\\msvc\\pgflex.pl" "$grammarFile"</Command>
+       <AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs>
+       <Outputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">$outputFile;%(Outputs)</Outputs>
+     </CustomBuild>
+ EOF
+             }
+         }
+         print $f <<EOF;
+   </ItemGroup>
+ EOF
+     }
+     if (scalar(@resourceFiles))
+     {
+         print $f <<EOF;
+   <ItemGroup>
+ EOF
+         foreach my $rcFile (@resourceFiles)
+         {
+             print $f <<EOF;
+     <ResourceCompile Include="$rcFile" />
+ EOF
+         }
+         print $f <<EOF;
+   </ItemGroup>
+ EOF
+     }
+ }
+ 
+ sub WriteConfigurationHeader
+ {
+     my ($self, $f, $cfgname) = @_;
+     print $f <<EOF;
+     <ProjectConfiguration Include="$cfgname|$self->{platform}">
+       <Configuration>$cfgname</Configuration>
+       <Platform>$self->{platform}</Platform>
+     </ProjectConfiguration>
+ EOF
+ }
+ 
+ sub WriteConfigurationPropertyGroup
+ {
+     my ($self, $f, $cfgname, $p) = @_;
+     my $cfgtype =
+       ($self->{type} eq "exe")
+       ?'Application'
+       :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary');
+ 
+     print $f <<EOF;
+   <PropertyGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="Configuration">
+     <ConfigurationType>$cfgtype</ConfigurationType>
+     <UseOfMfc>false</UseOfMfc>
+     <CharacterSet>MultiByte</CharacterSet>
+     <WholeProgramOptimization>$p->{wholeopt}</WholeProgramOptimization>
+   </PropertyGroup>
+ EOF
+ }
+ 
+ sub WritePropertySheetsPropertyGroup
+ {
+     my ($self, $f, $cfgname) = @_;
+     print $f <<EOF;
+   <ImportGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="PropertySheets">
+     <Import Project="\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props" Condition="exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')" Label="LocalAppDataPlatform" />
+   </ImportGroup>
+ EOF
+ }
+ 
+ sub WriteAdditionalProperties
+ {
+     my ($self, $f, $cfgname) = @_;
+     print $f <<EOF;
+     <OutDir Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">.\\$cfgname\\$self->{name}\\</OutDir>
+     <IntDir Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">.\\$cfgname\\$self->{name}\\</IntDir>
+     <LinkIncremental Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">false</LinkIncremental>
+ EOF
+ }
+ 
+ sub WriteItemDefinitionGroup
+ {
+     my ($self, $f, $cfgname, $p) = @_;
+     my $cfgtype =
+       ($self->{type} eq "exe")
+       ?'Application'
+       :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary');
+     my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';');
+ 
+     my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
+ 
+     my $includes = $self->{includes};
+     unless ($includes eq '' or $includes =~ /;$/)
+     {
+         $includes .= ';';
+     }
+     print $f <<EOF;
+   <ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
+     <ClCompile>
+       <Optimization>$p->{opt}</Optimization>
+       <AdditionalIncludeDirectories>$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$includes\%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+       <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}\%(PreprocessorDefinitions)</PreprocessorDefinitions>
+       <StringPooling>$p->{strpool}</StringPooling>
+       <RuntimeLibrary>$p->{runtime}</RuntimeLibrary>
+       <DisableSpecificWarnings>$self->{disablewarnings};\%(DisableSpecificWarnings)</DisableSpecificWarnings>
+       <AdditionalOptions>/MP \%(AdditionalOptions)</AdditionalOptions>
+       <AssemblerOutput>
+       </AssemblerOutput>
+       <AssemblerListingLocation>.\\$cfgname\\$self->{name}\\</AssemblerListingLocation>
+       <ObjectFileName>.\\$cfgname\\$self->{name}\\</ObjectFileName>
+       <ProgramDataBaseFileName>.\\$cfgname\\$self->{name}\\</ProgramDataBaseFileName>
+       <BrowseInformation>false</BrowseInformation>
+       <WarningLevel>Level3</WarningLevel>
+       <SuppressStartupBanner>true</SuppressStartupBanner>
+       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+       <CompileAs>Default</CompileAs>
+     </ClCompile>
+     <Link>
+       <OutputFile>.\\$cfgname\\$self->{name}\\$self->{name}.$self->{type}</OutputFile>
+       <AdditionalDependencies>$libs;\%(AdditionalDependencies)</AdditionalDependencies>
+       <SuppressStartupBanner>true</SuppressStartupBanner>
+       <AdditionalLibraryDirectories>\%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+       <IgnoreSpecificDefaultLibraries>libc;\%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+       <StackReserveSize>4194304</StackReserveSize>
+       <GenerateDebugInformation>true</GenerateDebugInformation>
+       <ProgramDatabaseFile>.\\$cfgname\\$self->{name}\\$self->{name}.pdb</ProgramDatabaseFile>
+       <GenerateMapFile>false</GenerateMapFile>
+       <MapFileName>.\\$cfgname\\$self->{name}\\$self->{name}.map</MapFileName>
+       <SubSystem>Console</SubSystem>
+       <TargetMachine>$targetmachine</TargetMachine>
+ EOF
+     if ($self->{disablelinkerwarnings})
+     {
+         print $f
+ "      <AdditionalOptions>/ignore:$self->{disablelinkerwarnings} \%(AdditionalOptions)</AdditionalOptions>\n";
+     }
+     if ($self->{implib})
+     {
+         my $l = $self->{implib};
+         $l =~ s/__CFGNAME__/$cfgname/g;
+         print $f "      <ImportLibrary>$l</ImportLibrary>\n";
+     }
+     if ($self->{def})
+     {
+         my $d = $self->{def};
+         $d =~ s/__CFGNAME__/$cfgname/g;
+         print $f "      <ModuleDefinitionFile>$d</ModuleDefinitionFile>\n";
+     }
+     print $f <<EOF;
+     </Link>
+     <ResourceCompile>
+       <AdditionalIncludeDirectories>src\\include;\%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+     </ResourceCompile>
+ EOF
+     if ($self->{builddef})
+     {
+         print $f <<EOF;
+     <PreLinkEvent>
+       <Message>Generate DEF file</Message>
+       <Command>perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}</Command>
+     </PreLinkEvent>
+ EOF
+     }
+     print $f <<EOF;
+   </ItemDefinitionGroup>
+ EOF
+ }
+ 
+ sub Footer
+ {
+     my ($self, $f) = @_;
+     $self->WriteReferences($f);
+ 
+     print $f <<EOF;
+   <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" />
+   <ImportGroup Label="ExtensionTargets">
+   </ImportGroup>
+ </Project>
+ EOF
+ }
+ 
+ package VC2010Project;
+ 
+ #
+ # Package that encapsulates a Visual C++ 2010 project file
+ #
+ 
+ use strict;
+ use warnings;
+ use base qw(MSBuildProject);
+ 
+ sub new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{vcver} = '10.00';
+ 
+     return $self;
+ }
+ 
+ 1;
diff -Napcdr -x .git postgresql/src/tools/msvc/Mkvcbuild.pm postgresql_dev/src/tools/msvc/Mkvcbuild.pm
*** postgresql/src/tools/msvc/Mkvcbuild.pm	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/Mkvcbuild.pm	Mon Dec 26 20:14:30 2011
*************** use Solution;
*** 14,19 ****
--- 14,20 ----
  use Cwd;
  use File::Copy;
  use Config;
+ use VSObjectFactory;
  use List::Util qw(first);
  
  use Exporter;
*************** sub mkvcbuild
*** 47,53 ****
      chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
      die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');
  
!     $solution = new Solution($config);
  
      our @pgportfiles = qw(
        chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
--- 48,56 ----
      chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
      die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');
  
!     my $vsVersion = DetermineVisualStudioVersion();
! 
!     $solution = CreateSolution($vsVersion, $config);
  
      our @pgportfiles = qw(
        chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
*************** sub mkvcbuild
*** 344,355 ****
      $pgdump->AddFile('src\backend\parser\kwlookup.c');
  
      my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
! 	# pg_dumpall doesn't use the files in the Makefile's $(OBJS), unlike
! 	# pg_dump and pg_restore.
! 	# So remove their sources from the object, keeping the other setup that 
! 	# AddSimpleFrontend() has done.
!     my @nodumpall = grep  { m/src\\bin\\pg_dump\\.*\.c$/ } 
! 	keys %{$pgdumpall->{files}};
      delete @{$pgdumpall->{files}}{@nodumpall};
      $pgdumpall->{name} = 'pg_dumpall';
      $pgdumpall->AddIncludeDir('src\backend');
--- 347,359 ----
      $pgdump->AddFile('src\backend\parser\kwlookup.c');
  
      my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
! 
!     # pg_dumpall doesn't use the files in the Makefile's $(OBJS), unlike
!     # pg_dump and pg_restore.
!     # So remove their sources from the object, keeping the other setup that
!     # AddSimpleFrontend() has done.
!     my @nodumpall = grep  { m/src\\bin\\pg_dump\\.*\.c$/ }
!       keys %{$pgdumpall->{files}};
      delete @{$pgdumpall->{files}}{@nodumpall};
      $pgdumpall->{name} = 'pg_dumpall';
      $pgdumpall->AddIncludeDir('src\backend');
*************** sub mkvcbuild
*** 508,513 ****
--- 512,518 ----
      $pgregress->AddReference($libpgport);
  
      $solution->Save();
+     return $solution->{vcver};
  }
  
  #####################
diff -Napcdr -x .git postgresql/src/tools/msvc/Project.pm postgresql_dev/src/tools/msvc/Project.pm
*** postgresql/src/tools/msvc/Project.pm	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/Project.pm	Mon Dec 26 20:14:30 2011
*************** use strict;
*** 10,18 ****
  use warnings;
  use File::Basename;
  
! sub new
  {
!     my ($junk, $name, $type, $solution) = @_;
      my $good_types = {
          lib => 1,
          exe => 1,
--- 10,18 ----
  use warnings;
  use File::Basename;
  
! sub _new
  {
!     my ($classname, $name, $type, $solution) = @_;
      my $good_types = {
          lib => 1,
          exe => 1,
*************** sub new
*** 20,43 ****
      };
      confess("Bad project type: $type\n") unless exists $good_types->{$type};
      my $self = {
!         name            => $name,
!         type            => $type,
!         guid            => Win32::GuidGen(),
!         files           => {},
!         references      => [],
!         libraries       => [],
!         suffixlib       => [],
!         includes        => '',
!         prefixincludes  => '',
!         defines         => ';',
!         solution        => $solution,
!         disablewarnings => '4018;4244;4273;4102;4090;4267',
          disablelinkerwarnings => '',
!         vcver           => $solution->{vcver},
!         platform        => $solution->{platform},
      };
  
!     bless $self;
      return $self;
  }
  
--- 20,42 ----
      };
      confess("Bad project type: $type\n") unless exists $good_types->{$type};
      my $self = {
!         name                  => $name,
!         type                  => $type,
!         guid                  => Win32::GuidGen(),
!         files                 => {},
!         references            => [],
!         libraries             => [],
!         suffixlib             => [],
!         includes              => '',
!         prefixincludes        => '',
!         defines               => ';',
!         solution              => $solution,
!         disablewarnings       => '4018;4244;4273;4102;4090;4267',
          disablelinkerwarnings => '',
!         platform              => $solution->{platform},
      };
  
!     bless($self, $classname);
      return $self;
  }
  
*************** sub Save
*** 355,489 ****
      $self->DisableLinkerWarnings('4197') if ($self->{platform} eq 'x64');
  
      # Dump the project
!     open(F, ">$self->{name}.vcproj") || croak("Could not write to $self->{name}.vcproj\n");
      $self->WriteHeader(*F);
!     $self->WriteReferences(*F);
!     print F <<EOF;
!  <Files>
! EOF
!     my @dirstack = ();
!     my %uniquefiles;
!     foreach my $f (sort keys %{ $self->{files} })
!     {
!         confess "Bad format filename '$f'\n" unless ($f =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/);
!         my $dir = $1;
!         my $file = $2;
! 
!         # Walk backwards down the directory stack and close any dirs we're done with
!         while ($#dirstack >= 0)
!         {
!             if (join('\\',@dirstack) eq substr($dir, 0, length(join('\\',@dirstack))))
!             {
!                 last if (length($dir) == length(join('\\',@dirstack)));
!                 last if (substr($dir, length(join('\\',@dirstack)),1) eq '\\');
!             }
!             print F ' ' x $#dirstack . "  </Filter>\n";
!             pop @dirstack;
!         }
! 
!         # Now walk forwards and create whatever directories are needed
!         while (join('\\',@dirstack) ne $dir)
!         {
!             my $left = substr($dir, length(join('\\',@dirstack)));
!             $left =~ s/^\\//;
!             my @pieces = split /\\/, $left;
!             push @dirstack, $pieces[0];
!             print F ' ' x $#dirstack . "  <Filter Name=\"$pieces[0]\" Filter=\"\">\n";
!         }
! 
!         print F ' ' x $#dirstack . "   <File RelativePath=\"$f\"";
!         if ($f =~ /\.y$/)
!         {
!             my $of = $f;
!             $of =~ s/\.y$/.c/;
!             $of =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c};
!             print F '>'
!               . $self->GenerateCustomTool('Running bison on ' . $f,
!                 'cmd /V:ON /c src\tools\msvc\pgbison.bat ' . $f, $of)
!               . '</File>' . "\n";
!         }
!         elsif ($f =~ /\.l$/)
!         {
!             my $of = $f;
!             $of =~ s/\.l$/.c/;
!             print F '>'
!               . $self->GenerateCustomTool('Running flex on ' . $f,
!                 'src\tools\msvc\pgflex.bat ' . $f,$of)
!               . '</File>' . "\n";
!         }
!         elsif (defined($uniquefiles{$file}))
!         {
! 
!             # File already exists, so fake a new name
!             my $obj = $dir;
!             $obj =~ s/\\/_/g;
!             print F
! "><FileConfiguration Name=\"Debug|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\debug\\$self->{name}\\$obj"
!               . "_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj"
!               . "_$file.obj\" /></FileConfiguration></File>\n";
!         }
!         else
!         {
!             $uniquefiles{$file} = 1;
!             print F " />\n";
!         }
!     }
!     while ($#dirstack >= 0)
!     {
!         print F ' ' x $#dirstack . "  </Filter>\n";
!         pop @dirstack;
!     }
      $self->Footer(*F);
      close(F);
  }
  
! sub GenerateCustomTool
! {
!     my ($self, $desc, $tool, $output, $cfg) = @_;
!     if (!defined($cfg))
!     {
!         return $self->GenerateCustomTool($desc, $tool, $output, 'Debug')
!           .$self->GenerateCustomTool($desc, $tool, $output, 'Release');
!     }
!     return
! "<FileConfiguration Name=\"$cfg|$self->{platform}\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>";
! }
! 
! sub WriteReferences
! {
!     my ($self, $f) = @_;
!     print $f " <References>\n";
!     foreach my $ref (@{$self->{references}})
!     {
!         print $f
! "  <ProjectReference ReferencedProjectIdentifier=\"$ref->{guid}\" Name=\"$ref->{name}\" />\n";
!     }
!     print $f " </References>\n";
! }
! 
! sub WriteHeader
! {
!     my ($self, $f) = @_;
! 
!     print $f <<EOF;
! <?xml version="1.0" encoding="Windows-1252"?>
! <VisualStudioProject ProjectType="Visual C++" Version="$self->{vcver}" Name="$self->{name}" ProjectGUID="$self->{guid}">
!  <Platforms><Platform Name="$self->{platform}"/></Platforms>
!  <Configurations>
! EOF
!     $self->WriteConfiguration($f, 'Debug',
!         { defs=>'_DEBUG;DEBUG=1;', wholeopt=>0, opt=>0, strpool=>'false', runtime=>3 });
!     $self->WriteConfiguration($f, 'Release',
!         { defs=>'', wholeopt=>0, opt=>3, strpool=>'true', runtime=>2 });
!     print $f <<EOF;
!  </Configurations>
! EOF
! }
! 
! sub WriteConfiguration
  {
!     my ($self, $f, $cfgname, $p) = @_;
!     my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4);
      my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd";
      my $libs = '';
      foreach my $lib (@{$self->{libraries}})
--- 354,370 ----
      $self->DisableLinkerWarnings('4197') if ($self->{platform} eq 'x64');
  
      # Dump the project
!     open(F, ">$self->{name}$self->{filenameExtension}")
!       || croak("Could not write to $self->{name}$self->{filenameExtension}\n");
      $self->WriteHeader(*F);
!     $self->WriteFiles(*F);
      $self->Footer(*F);
      close(F);
  }
  
! sub GetAdditionalLinkerDependencies
  {
!     my ($self, $cfgname, $seperator) = @_;
      my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd";
      my $libs = '';
      foreach my $lib (@{$self->{libraries}})
*************** sub WriteConfiguration
*** 497,572 ****
                  last;
              }
          }
!         $libs .= $xlib . " ";
      }
!     $libs =~ s/ $//;
      $libs =~ s/__CFGNAME__/$cfgname/g;
! 
!     my $targetmachine = $self->{platform} eq 'Win32' ? 1 : 17;
! 
!     print $f <<EOF;
!   <Configuration Name="$cfgname|$self->{platform}" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}"
! 	ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}">
! 	<Tool Name="VCCLCompilerTool" Optimization="$p->{opt}"
! 		AdditionalIncludeDirectories="$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{includes}"
! 		PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}"
! 		StringPooling="$p->{strpool}"
! 		RuntimeLibrary="$p->{runtime}" DisableSpecificWarnings="$self->{disablewarnings}"
! 		AdditionalOptions="/MP"
! EOF
!     print $f <<EOF;
! 		AssemblerOutput="0" AssemblerListingLocation=".\\$cfgname\\$self->{name}\\" ObjectFile=".\\$cfgname\\$self->{name}\\"
! 		ProgramDataBaseFileName=".\\$cfgname\\$self->{name}\\" BrowseInformation="0"
! 		WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/>
! 	<Tool Name="VCLinkerTool" OutputFile=".\\$cfgname\\$self->{name}\\$self->{name}.$self->{type}"
! 		AdditionalDependencies="$libs"
! 		LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc"
! 		StackReserveSize="4194304" DisableSpecificWarnings="$self->{disablewarnings}"
! 		GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\$cfgname\\$self->{name}\\$self->{name}.pdb"
! 		GenerateMapFile="FALSE" MapFileName=".\\$cfgname\\$self->{name}\\$self->{name}.map"
! 		SubSystem="1" TargetMachine="$targetmachine"
! EOF
!     if ($self->{disablelinkerwarnings})
!     {
!         print $f "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n";
!     }
!     if ($self->{implib})
!     {
!         my $l = $self->{implib};
!         $l =~ s/__CFGNAME__/$cfgname/g;
!         print $f "\t\tImportLibrary=\"$l\"\n";
!     }
!     if ($self->{def})
!     {
!         my $d = $self->{def};
!         $d =~ s/__CFGNAME__/$cfgname/g;
!         print $f "\t\tModuleDefinitionFile=\"$d\"\n";
!     }
! 
!     print $f "\t/>\n";
!     print $f
! "\t<Tool Name=\"VCLibrarianTool\" OutputFile=\".\\$cfgname\\$self->{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n";
!     print $f
!       "\t<Tool Name=\"VCResourceCompilerTool\" AdditionalIncludeDirectories=\"src\\include\" />\n";
!     if ($self->{builddef})
!     {
!         print $f
! "\t<Tool Name=\"VCPreLinkEventTool\" Description=\"Generate DEF file\" CommandLine=\"perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}\" />\n";
!     }
!     print $f <<EOF;
!   </Configuration>
! EOF
! }
! 
! sub Footer
! {
!     my ($self, $f) = @_;
! 
!     print $f <<EOF;
!  </Files>
!  <Globals/>
! </VisualStudioProject>
! EOF
  }
  
  # Utility function that loads a complete file
--- 378,388 ----
                  last;
              }
          }
!         $libs .= $xlib . $seperator;
      }
!     $libs =~ s/.$//;
      $libs =~ s/__CFGNAME__/$cfgname/g;
!     return $libs;
  }
  
  # Utility function that loads a complete file
diff -Napcdr -x .git postgresql/src/tools/msvc/README postgresql_dev/src/tools/msvc/README
*** postgresql/src/tools/msvc/README	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/README	Mon Dec 26 22:57:05 2011
*************** MSVC build
*** 4,22 ****
  ==========
  
  This directory contains the tools required to build PostgreSQL using
! Microsoft Visual Studio 2005. This builds the whole backend, not just
  the libpq frontend library. For more information, see the documentation
! chapter "Installation on Windows".
  
  
  Notes about Visual Studio Express
  ---------------------------------
! To build PostgreSQL using Visual Studio Express, the Platform SDK
  has to be installed. Since this is not included in the product
  originally, extra steps are needed to make it work.
  
! First, download and install the latest Platform SDK from
! www.microsoft.com.
  
  Locate the files vcprojectengine.dll.express.config and
  vcprojectengine.dll.config in the vc\vcpackages directory of
--- 4,22 ----
  ==========
  
  This directory contains the tools required to build PostgreSQL using
! Microsoft Visual Studio 2005 - 2011. This builds the whole backend, not just
  the libpq frontend library. For more information, see the documentation
! chapter "Installation on Windows" and the description below.
  
  
  Notes about Visual Studio Express
  ---------------------------------
! To build PostgreSQL using Visual Studio Express, the Microsoft Windows SDK
  has to be installed. Since this is not included in the product
  originally, extra steps are needed to make it work.
  
! First, download and install a supported version of the Microsoft Windows SDK
! from www.microsoft.com (v6.0 or greater).
  
  Locate the files vcprojectengine.dll.express.config and
  vcprojectengine.dll.config in the vc\vcpackages directory of
*************** to add them to the beginning of the list
*** 26,28 ****
--- 26,102 ----
  
  This should work for both GUI and commandline builds, but a restart
  may be necessary.
+ 
+ If you are using a recent version of the Microsoft Windows SDK that includes
+ the compilers and build tools you probably don't even need Visual Studio
+ Express to build PostgreSQL.
+ 
+ 
+ Structure of the build tools
+ ----------------------------
+ The tools for building PostgreSQL using Microsoft Visual Studio currently
+ consist of the following files:
+ 
+ - Configuration files -
+ config_default.pl      default configuration arguments
+ 
+ A typical build environment has two more files, buildenv.pl and config.pl
+ that contain the user's build environment settings and configuration
+ arguments.
+ 
+ 
+ - User tools -
+ build.pl               tool to build the binaries
+ builddoc.pl            tool to build the docs
+ clean.bat              batch file for cleaning up generated files
+ install.pl             tool to install the generated files
+ mkvcbuild.pl           tool to generate the Visual Studio build files
+ vcregress.pl           tool to run the regression tests
+ 
+ 
+ - Internal tools -
+ gendef.pl              internal tool to generate .DEF files
+ pgbison.pl             internal tool to process .y files using bison
+ pgflex.pl              internal tool to process .l files using flex
+ 
+ Many of those .pl files also have a corresponding .bat-wrapper that doesn't
+ contain any additional logic.
+ 
+ 
+ - Internal modules -
+ Install.pm             module containing the install logic
+ Mkvcbuild.pm           module containing the code to generate the Visual
+                        Studio build (project/solution) files
+ MSBuildProject.pm      module containing the code to generate MSBuild based
+                        project files (Visual Studio 2010 or greater)
+ Project.pm             module containing the common code to generate the
+                        Visual Studio project files. Also provides the
+                        common interface of all project file generators
+ Solution.pm            module containing the code to generate the Visual
+                        Studio solution files.
+ VCBuildProject.pm      module containing the code to generate VCBuild based
+                        project files (Visual Studio 2005/2008)
+ VSObjectFactory.pm     factory module providing the code to create the 
+                        appropriate project/solution files for the current
+                        environment
+ 
+ 
+ Description of the internals of the Visual Studio build process
+ ---------------------------------------------------------------
+ By typing 'build' the user starts the build.bat wrapper which simply passes
+ it's arguments to build.pl.
+ In build.pl the user's buildenv.pl is used to set up the build environment
+ (i. e. path to bison and flex). In addtion his config.pl file is merged into
+ config_default.pl to create the configuration arguments.
+ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
+ (Mkvcbuild.pm) which creates the Visual Studio project and solution files.
+ It does this by using VSObjectFactory::CreateSolution to create an object
+ implementing the Solution interface (this could be either a VS2005Solution,
+ a VS2008Solution or a VS2010Solution, all in Solution.pm, depending on the
+ user's build environment) and adding objects implementing the corresponding
+ Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
+ VC2010Project from MSBuildProject.pm) to it.
+ When Solution::Save is called, the implementations of Solution and Project
+ save their content in the appropriate format.
+ The final step of starting the appropriate build program (msbuild or vcbuild)
+ is performed in build.pl again.
diff -Napcdr -x .git postgresql/src/tools/msvc/Solution.pm postgresql_dev/src/tools/msvc/Solution.pm
*** postgresql/src/tools/msvc/Solution.pm	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/Solution.pm	Mon Dec 26 20:14:31 2011
*************** package Solution;
*** 8,17 ****
  use Carp;
  use strict;
  use warnings;
  
! sub new
  {
!     my $junk = shift;
      my $options = shift;
      my $self = {
          projects => {},
--- 8,18 ----
  use Carp;
  use strict;
  use warnings;
+ use VSObjectFactory;
  
! sub _new
  {
!     my $classname = shift;
      my $options = shift;
      my $self = {
          projects => {},
*************** sub new
*** 21,27 ****
          vcver    => undef,
          platform => undef,
      };
!     bless $self;
  
      # integer_datetimes is now the default
      $options->{integer_datetimes} = 1
--- 22,28 ----
          vcver    => undef,
          platform => undef,
      };
!     bless($self, $classname);
  
      # integer_datetimes is now the default
      $options->{integer_datetimes} = 1
*************** sub new
*** 53,80 ****
      die "Bad wal_segsize $options->{wal_segsize}"
        unless grep {$_ == $options->{wal_segsize}} (1,2,4,8,16,32,64);
  
!     $self->DetermineToolVersions();
  
      return $self;
  }
  
! sub DetermineToolVersions
  {
      my $self = shift;
  
-     # Determine version of vcbuild command, to set proper verison of visual studio
-     open(P,"vcbuild /? |") || die "vcbuild command not found";
-     my $line = <P>;
-     close(P);
-     if ($line !~ /^Microsoft\s*\(R\) Visual C\+\+ [^-]+ - \D+(\d+)\.00\.\d+/)
-     {
-         die "Unable to determine vcbuild version from first line of output!";
-     }
-     if ($1 == 8) { $self->{vcver} = '8.00' }
-     elsif ($1 == 9) { $self->{vcver} = '9.00' }
-     else { die "Unsupported version of Visual Studio: $1" }
-     print "Detected Visual Studio version $self->{vcver}\n";
- 
      # Determine if we are in 32 or 64-bit mode. Do this by seeing if CL has
      # 64-bit only parameters.
      $self->{platform} = 'Win32';
--- 54,68 ----
      die "Bad wal_segsize $options->{wal_segsize}"
        unless grep {$_ == $options->{wal_segsize}} (1,2,4,8,16,32,64);
  
!     $self->DeterminePlatform();
  
      return $self;
  }
  
! sub DeterminePlatform
  {
      my $self = shift;
  
      # Determine if we are in 32 or 64-bit mode. Do this by seeing if CL has
      # 64-bit only parameters.
      $self->{platform} = 'Win32';
*************** sub AddProject
*** 428,434 ****
  {
      my ($self, $name, $type, $folder, $initialdir) = @_;
  
!     my $proj = new Project($name, $type, $self);
      push @{$self->{projects}->{$folder}}, $proj;
      $proj->AddDir($initialdir) if ($initialdir);
      if ($self->{options}->{zlib})
--- 416,422 ----
  {
      my ($self, $name, $type, $folder, $initialdir) = @_;
  
!     my $proj = VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self);
      push @{$self->{projects}->{$folder}}, $proj;
      $proj->AddDir($initialdir) if ($initialdir);
      if ($self->{options}->{zlib})
*************** sub Save
*** 488,495 ****
  
      open(SLN,">pgsql.sln") || croak "Could not write to pgsql.sln\n";
      print SLN <<EOF;
! Microsoft Visual Studio Solution File, Format Version 9.00
! # Visual Studio 2005
  EOF
  
      foreach my $fld (keys %{$self->{projects}})
--- 476,483 ----
  
      open(SLN,">pgsql.sln") || croak "Could not write to pgsql.sln\n";
      print SLN <<EOF;
! Microsoft Visual Studio Solution File, Format Version $self->{solutionFileVersion}
! # $self->{visualStudioName}
  EOF
  
      foreach my $fld (keys %{$self->{projects}})
*************** EOF
*** 497,503 ****
          foreach my $proj (@{$self->{projects}->{$fld}})
          {
              print SLN <<EOF;
! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}.vcproj", "$proj->{guid}"
  EndProject
  EOF
          }
--- 485,491 ----
          foreach my $proj (@{$self->{projects}->{$fld}})
          {
              print SLN <<EOF;
! Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}$proj->{filenameExtension}", "$proj->{guid}"
  EndProject
  EOF
          }
*************** sub GetFakeConfigure
*** 577,582 ****
--- 565,640 ----
      $cfg .= ' --with-python' if ($self->{options}->{python});
  
      return $cfg;
+ }
+ 
+ package VS2005Solution;
+ 
+ #
+ # Package that encapsulates a Visual Studio 2005 solution file
+ #
+ 
+ use strict;
+ use warnings;
+ use base qw(Solution);
+ 
+ sub new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{solutionFileVersion} = '9.00';
+     $self->{vcver} = '8.00';
+     $self->{visualStudioName} = 'Visual Studio 2005';
+ 
+     return $self;
+ }
+ 
+ package VS2008Solution;
+ 
+ #
+ # Package that encapsulates a Visual Studio 2008 solution file
+ #
+ 
+ use strict;
+ use warnings;
+ use base qw(Solution);
+ 
+ sub new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{solutionFileVersion} = '10.00';
+     $self->{vcver} = '9.00';
+     $self->{visualStudioName} = 'Visual Studio 2008';
+ 
+     return $self;
+ }
+ 
+ package VS2010Solution;
+ 
+ #
+ # Package that encapsulates a Visual Studio 2010 solution file
+ #
+ 
+ use Carp;
+ use strict;
+ use warnings;
+ use base qw(Solution);
+ 
+ sub new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{solutionFileVersion} = '11.00';
+     $self->{vcver} = '10.00';
+     $self->{visualStudioName} = 'Visual Studio 2010';
+ 
+     return $self;
  }
  
  1;
diff -Napcdr -x .git postgresql/src/tools/msvc/VCBuildProject.pm postgresql_dev/src/tools/msvc/VCBuildProject.pm
*** postgresql/src/tools/msvc/VCBuildProject.pm	Thu Jan  1 00:00:00 1970
--- postgresql_dev/src/tools/msvc/VCBuildProject.pm	Mon Dec 26 20:14:31 2011
***************
*** 0 ****
--- 1,267 ----
+ package VCBuildProject;
+ 
+ #
+ # Package that encapsulates a VCBuild (Visual C++ 2005/2008) project file
+ #
+ # src/tools/msvc/VCBuildProject.pm
+ #
+ 
+ use Carp;
+ use strict;
+ use warnings;
+ use base qw(Project);
+ 
+ sub _new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{filenameExtension} = '.vcproj';
+ 
+     return $self;
+ }
+ 
+ sub WriteHeader
+ {
+     my ($self, $f) = @_;
+ 
+     print $f <<EOF;
+ <?xml version="1.0" encoding="Windows-1252"?>
+ <VisualStudioProject ProjectType="Visual C++" Version="$self->{vcver}" Name="$self->{name}" ProjectGUID="$self->{guid}">
+  <Platforms><Platform Name="$self->{platform}"/></Platforms>
+  <Configurations>
+ EOF
+     $self->WriteConfiguration($f, 'Debug',
+         { defs=>'_DEBUG;DEBUG=1;', wholeopt=>0, opt=>0, strpool=>'false', runtime=>3 });
+     $self->WriteConfiguration($f, 'Release',
+         { defs=>'', wholeopt=>0, opt=>3, strpool=>'true', runtime=>2 });
+     print $f <<EOF;
+  </Configurations>
+ EOF
+     $self->WriteReferences($f);
+ }
+ 
+ sub WriteFiles
+ {
+     my ($self, $f) = @_;
+     print $f <<EOF;
+  <Files>
+ EOF
+     my @dirstack = ();
+     my %uniquefiles;
+     foreach my $fileNameWithPath (sort keys %{ $self->{files} })
+     {
+         confess "Bad format filename '$fileNameWithPath'\n"
+           unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/);
+         my $dir = $1;
+         my $file = $2;
+ 
+         # Walk backwards down the directory stack and close any dirs we're done with
+         while ($#dirstack >= 0)
+         {
+             if (join('\\',@dirstack) eq substr($dir, 0, length(join('\\',@dirstack))))
+             {
+                 last if (length($dir) == length(join('\\',@dirstack)));
+                 last if (substr($dir, length(join('\\',@dirstack)),1) eq '\\');
+             }
+             print $f ' ' x $#dirstack . "  </Filter>\n";
+             pop @dirstack;
+         }
+ 
+         # Now walk forwards and create whatever directories are needed
+         while (join('\\',@dirstack) ne $dir)
+         {
+             my $left = substr($dir, length(join('\\',@dirstack)));
+             $left =~ s/^\\//;
+             my @pieces = split /\\/, $left;
+             push @dirstack, $pieces[0];
+             print $f ' ' x $#dirstack . "  <Filter Name=\"$pieces[0]\" Filter=\"\">\n";
+         }
+ 
+         print $f ' ' x $#dirstack . "   <File RelativePath=\"$fileNameWithPath\"";
+         if ($fileNameWithPath =~ /\.y$/)
+         {
+             my $of = $fileNameWithPath;
+             $of =~ s/\.y$/.c/;
+             $of =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c};
+             print $f '>'
+               . $self->GenerateCustomTool('Running bison on ' . $fileNameWithPath,
+                 "perl src\\tools\\msvc\\pgbison.pl $fileNameWithPath", $of)
+               . '</File>' . "\n";
+         }
+         elsif ($fileNameWithPath =~ /\.l$/)
+         {
+             my $of = $fileNameWithPath;
+             $of =~ s/\.l$/.c/;
+             print $f '>'
+               . $self->GenerateCustomTool('Running flex on ' . $fileNameWithPath,
+                 "perl src\\tools\\msvc\\pgflex.pl $fileNameWithPath", $of)
+               . '</File>' . "\n";
+         }
+         elsif (defined($uniquefiles{$file}))
+         {
+ 
+             # File already exists, so fake a new name
+             my $obj = $dir;
+             $obj =~ s/\\/_/g;
+             print $f
+ "><FileConfiguration Name=\"Debug|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\debug\\$self->{name}\\$obj"
+               . "_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj"
+               . "_$file.obj\" /></FileConfiguration></File>\n";
+         }
+         else
+         {
+             $uniquefiles{$file} = 1;
+             print $f " />\n";
+         }
+     }
+     while ($#dirstack >= 0)
+     {
+         print $f ' ' x $#dirstack . "  </Filter>\n";
+         pop @dirstack;
+     }
+     print $f <<EOF;
+  </Files>
+ EOF
+ }
+ 
+ sub Footer
+ {
+     my ($self, $f) = @_;
+ 
+     print $f <<EOF;
+  <Globals/>
+ </VisualStudioProject>
+ EOF
+ }
+ 
+ sub WriteConfiguration
+ {
+     my ($self, $f, $cfgname, $p) = @_;
+     my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4);
+     my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ' ');
+ 
+     my $targetmachine = $self->{platform} eq 'Win32' ? 1 : 17;
+ 
+     print $f <<EOF;
+   <Configuration Name="$cfgname|$self->{platform}" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}"
+ 	ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}">
+ 	<Tool Name="VCCLCompilerTool" Optimization="$p->{opt}"
+ 		AdditionalIncludeDirectories="$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{includes}"
+ 		PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}"
+ 		StringPooling="$p->{strpool}"
+ 		RuntimeLibrary="$p->{runtime}" DisableSpecificWarnings="$self->{disablewarnings}"
+ 		AdditionalOptions="/MP"
+ EOF
+     print $f <<EOF;
+ 		AssemblerOutput="0" AssemblerListingLocation=".\\$cfgname\\$self->{name}\\" ObjectFile=".\\$cfgname\\$self->{name}\\"
+ 		ProgramDataBaseFileName=".\\$cfgname\\$self->{name}\\" BrowseInformation="0"
+ 		WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/>
+ 	<Tool Name="VCLinkerTool" OutputFile=".\\$cfgname\\$self->{name}\\$self->{name}.$self->{type}"
+ 		AdditionalDependencies="$libs"
+ 		LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc"
+ 		StackReserveSize="4194304" DisableSpecificWarnings="$self->{disablewarnings}"
+ 		GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\$cfgname\\$self->{name}\\$self->{name}.pdb"
+ 		GenerateMapFile="FALSE" MapFileName=".\\$cfgname\\$self->{name}\\$self->{name}.map"
+ 		SubSystem="1" TargetMachine="$targetmachine"
+ EOF
+     if ($self->{disablelinkerwarnings})
+     {
+         print $f "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n";
+     }
+     if ($self->{implib})
+     {
+         my $l = $self->{implib};
+         $l =~ s/__CFGNAME__/$cfgname/g;
+         print $f "\t\tImportLibrary=\"$l\"\n";
+     }
+     if ($self->{def})
+     {
+         my $d = $self->{def};
+         $d =~ s/__CFGNAME__/$cfgname/g;
+         print $f "\t\tModuleDefinitionFile=\"$d\"\n";
+     }
+ 
+     print $f "\t/>\n";
+     print $f
+ "\t<Tool Name=\"VCLibrarianTool\" OutputFile=\".\\$cfgname\\$self->{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n";
+     print $f
+       "\t<Tool Name=\"VCResourceCompilerTool\" AdditionalIncludeDirectories=\"src\\include\" />\n";
+     if ($self->{builddef})
+     {
+         print $f
+ "\t<Tool Name=\"VCPreLinkEventTool\" Description=\"Generate DEF file\" CommandLine=\"perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}\" />\n";
+     }
+     print $f <<EOF;
+   </Configuration>
+ EOF
+ }
+ 
+ sub WriteReferences
+ {
+     my ($self, $f) = @_;
+     print $f " <References>\n";
+     foreach my $ref (@{$self->{references}})
+     {
+         print $f
+ "  <ProjectReference ReferencedProjectIdentifier=\"$ref->{guid}\" Name=\"$ref->{name}\" />\n";
+     }
+     print $f " </References>\n";
+ }
+ 
+ sub GenerateCustomTool
+ {
+     my ($self, $desc, $tool, $output, $cfg) = @_;
+     if (!defined($cfg))
+     {
+         return $self->GenerateCustomTool($desc, $tool, $output, 'Debug')
+           .$self->GenerateCustomTool($desc, $tool, $output, 'Release');
+     }
+     return
+ "<FileConfiguration Name=\"$cfg|$self->{platform}\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>";
+ }
+ 
+ package VC2005Project;
+ 
+ #
+ # Package that encapsulates a Visual C++ 2005 project file
+ #
+ 
+ use strict;
+ use warnings;
+ use base qw(VCBuildProject);
+ 
+ sub new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{vcver} = '8.00';
+ 
+     return $self;
+ }
+ 
+ package VC2008Project;
+ 
+ #
+ # Package that encapsulates a Visual C++ 2008 project file
+ #
+ 
+ use strict;
+ use warnings;
+ use base qw(VCBuildProject);
+ 
+ sub new
+ {
+     my $classname = shift;
+     my $self = $classname->SUPER::_new(@_);
+     bless($self, $classname);
+ 
+     $self->{vcver} = '9.00';
+ 
+     return $self;
+ }
+ 
+ 1;
diff -Napcdr -x .git postgresql/src/tools/msvc/VSObjectFactory.pm postgresql_dev/src/tools/msvc/VSObjectFactory.pm
*** postgresql/src/tools/msvc/VSObjectFactory.pm	Thu Jan  1 00:00:00 1970
--- postgresql_dev/src/tools/msvc/VSObjectFactory.pm	Mon Dec 26 20:14:31 2011
***************
*** 0 ****
--- 1,122 ----
+ package VSObjectFactory;
+ 
+ #
+ # Package that creates Visual Studio wrapper objects for msvc build
+ #
+ # src/tools/msvc/VSObjectFactory.pm
+ #
+ 
+ use Carp;
+ use strict;
+ use warnings;
+ 
+ use Exporter;
+ use Project;
+ use Solution;
+ use VCBuildProject;
+ use MSBuildProject;
+ 
+ our (@ISA, @EXPORT);
+ @ISA = qw(Exporter);
+ @EXPORT = qw(CreateSolution CreateProject DetermineVisualStudioVersion);
+ 
+ sub CreateSolution
+ {
+     my $visualStudioVersion = shift;
+ 
+     if (!defined($visualStudioVersion))
+     {
+         $visualStudioVersion = DetermineVisualStudioVersion();
+     }
+ 
+     if ($visualStudioVersion eq '8.00')
+     {
+         return new VS2005Solution(@_);
+     }
+     elsif ($visualStudioVersion eq '9.00')
+     {
+         return new VS2008Solution(@_);
+     }
+     elsif ($visualStudioVersion eq '10.00')
+     {
+         return new VS2010Solution(@_);
+     }
+     else
+     {
+         croak "The requested Visual Studio version is not supported.";
+     }
+ }
+ 
+ sub CreateProject
+ {
+     my $visualStudioVersion = shift;
+ 
+     if (!defined($visualStudioVersion))
+     {
+         $visualStudioVersion = DetermineVisualStudioVersion();
+     }
+ 
+     if ($visualStudioVersion eq '8.00')
+     {
+         return new VC2005Project(@_);
+     }
+     elsif ($visualStudioVersion eq '9.00')
+     {
+         return new VC2008Project(@_);
+     }
+     elsif ($visualStudioVersion eq '10.00')
+     {
+         return new VC2010Project(@_);
+     }
+     else
+     {
+         croak "The requested Visual Studio version is not supported.";
+     }
+ }
+ 
+ sub DetermineVisualStudioVersion
+ {
+     my $nmakeVersion = shift;
+ 
+     if (!defined($nmakeVersion))
+     {
+ 
+         # Determine version of nmake command, to set proper verison of visual studio
+         # we use nmake as it has existed for a long time and still exists in visual studio 2010
+         open(P,"nmake /? 2>&1 |")
+           || croak "Unable to determine Visual Studio version: The nmake command wasn't found.";
+         while(<P>)
+         {
+             chomp;
+             if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/)
+             {
+                 return _GetVisualStudioVersion($1, $2);
+             }
+         }
+         close(P);
+     }
+     elsif($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/)
+     {
+         return _GetVisualStudioVersion($1, $2);
+     }
+     croak "Unable to determine Visual Studio version: The nmake version could not be determined.";
+ }
+ 
+ sub _GetVisualStudioVersion
+ {
+     my($major, $minor) = @_;
+     if ($major > 10)
+     {
+         carp
+ "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
+         return '10.00';
+     }
+     elsif ($major < 6)
+     {
+         croak
+ "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported.";
+     }
+     return "$major.$minor";
+ }
+ 
+ 1;
diff -Napcdr -x .git postgresql/src/tools/msvc/build.pl postgresql_dev/src/tools/msvc/build.pl
*** postgresql/src/tools/msvc/build.pl	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/build.pl	Mon Dec 26 20:14:29 2011
*************** our $config;
*** 33,39 ****
  require "config_default.pl";
  require "config.pl" if (-f "src/tools/msvc/config.pl");
  
! Mkvcbuild::mkvcbuild($config);
  
  # check what sort of build we are doing
  
--- 33,39 ----
  require "config_default.pl";
  require "config.pl" if (-f "src/tools/msvc/config.pl");
  
! my $vcver = Mkvcbuild::mkvcbuild($config);
  
  # check what sort of build we are doing
  
*************** elsif ($ARGV[0] ne "RELEASE")
*** 50,56 ****
  
  # ... and do it
  
! if ($buildwhat)
  {
      system("vcbuild $buildwhat.vcproj $bconf");
  }
--- 50,60 ----
  
  # ... and do it
  
! if ($buildwhat and $vcver eq '10.00')
! {
!     system("msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf");
! }
! elsif ($buildwhat)
  {
      system("vcbuild $buildwhat.vcproj $bconf");
  }
diff -Napcdr -x .git postgresql/src/tools/msvc/builddoc.pl postgresql_dev/src/tools/msvc/builddoc.pl
*** postgresql/src/tools/msvc/builddoc.pl	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/builddoc.pl	Mon Dec 26 20:14:29 2011
*************** $cmd =
*** 69,76 ****
    ."| findstr /V \"DTDDECL catalog entries are not supported\" ";
  system($cmd); # die "openjade" if $?;
  print "Running collateindex...\n";
! $cmd ="perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex "
!   ."-o bookindex.sgml HTML.index";
  system($cmd);
  die "collateindex" if $?;
  mkdir "html";
--- 69,76 ----
    ."| findstr /V \"DTDDECL catalog entries are not supported\" ";
  system($cmd); # die "openjade" if $?;
  print "Running collateindex...\n";
! $cmd =
!   "perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex "."-o bookindex.sgml HTML.index";
  system($cmd);
  die "collateindex" if $?;
  mkdir "html";
diff -Napcdr -x .git postgresql/src/tools/msvc/clean.bat postgresql_dev/src/tools/msvc/clean.bat
*** postgresql/src/tools/msvc/clean.bat	Sun Dec 25 20:45:58 2011
--- postgresql_dev/src/tools/msvc/clean.bat	Mon Dec 26 11:02:25 2011
*************** if exist ..\msvc if exist ..\..\..\src c
*** 10,17 ****
--- 10,21 ----
  if exist debug rd /s /q debug
  if exist release rd /s /q release
  for %%f in (*.vcproj) do del %%f
+ for %%f in (*.vcxproj) do del %%f
+ for %%f in (*.vcxproj.user) do del %%f
  if exist pgsql.sln del /q pgsql.sln
  if exist pgsql.sln.cache del /q pgsql.sln.cache
+ if exist pgsql.sdf del /q pgsql.sdf
+ if exist pgsql.suo del /q /a:H pgsql.suo
  del /s /q src\bin\win32ver.rc 2> NUL
  del /s /q src\interfaces\win32ver.rc 2> NUL
  if exist src\backend\win32ver.rc del /q src\backend\win32ver.rc