From af322a8a3ef28d9b0425238353a8bffa94bfaa47 Mon Sep 17 00:00:00 2001
From: Magnus Hagander <magnus@hagander.net>
Date: Tue, 5 Jan 2010 13:31:58 +0000
Subject: [PATCH] Move the default configuration for the MSVC build system to
 config_default.pl, and allow using config.pl to override the defaults.
 config.pl is removed from the repository, so changes there will no longer
 show up when doing diff, and will not prevent switching branches and such
 things.

config.pl would normally be used to override single values, but if an
old-style config.pl is read, it will override the entire default configuration,
making it backwards compatible.
---
 src/tools/msvc/Install.pm                     |  5 +++--
 src/tools/msvc/Solution.pm                    |  7 +++---
 src/tools/msvc/build.pl                       |  5 +++--
 .../msvc/{config.pl => config_default.pl}     | 22 +++++++++----------
 src/tools/msvc/mkvcbuild.pl                   |  8 ++++---
 5 files changed, 26 insertions(+), 21 deletions(-)
 rename src/tools/msvc/{config.pl => config_default.pl} (53%)

diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index 7bdc2b8cbdf..bffad8f2a7d 100644
--- a/src/tools/msvc/Install.pm
+++ b/src/tools/msvc/Install.pm
@@ -3,7 +3,7 @@ package Install;
 #
 # Package that provides 'make install' functionality for msvc builds
 #
-# $PostgreSQL: pgsql/src/tools/msvc/Install.pm,v 1.33 2009/04/20 08:38:00 mha Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/Install.pm,v 1.34 2010/01/05 13:31:58 mha Exp $
 #
 use strict;
 use warnings;
@@ -38,7 +38,8 @@ sub Install
 
     my $target = shift;
     our $config;
-    require 'config.pl';
+    require "config_default.pl";
+    require "config.pl" if (-f "config.pl");
 
     chdir("../../..") if (-f "../../../configure");
     chdir("../../../..") if (-f "../../../../configure");
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 9cd8ce557fa..084d107a935 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -3,7 +3,7 @@ package Solution;
 #
 # Package that encapsulates a Visual C++ solution file generation
 #
-# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.52 2010/01/05 01:06:57 tgl Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.53 2010/01/05 13:31:58 mha Exp $
 #
 use Carp;
 use strict;
@@ -93,9 +93,10 @@ sub DetermineToolVersions
 sub IsNewer
 {
     my ($newfile, $oldfile) = @_;
-    if ($oldfile ne 'src\tools\msvc\config.pl')
+    if ($oldfile ne 'src\tools\msvc\config.pl' && $oldfile ne 'src\tools\msvc\config_default.pl')
     {
-        return 1 if IsNewer($newfile, 'src\tools\msvc\config.pl');
+        return 1 if (-f 'src\tools\msvc\config.pl') && IsNewer($newfile, 'src\tools\msvc\config.pl');
+        return 1 if (-f 'src\tools\msvc\config_default.pl') && IsNewer($newfile, 'src\tools\msvc\config_default.pl');
     }
     return 1 if (!(-e $newfile));
     my @nstat = stat($newfile);
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index 534492b9eb0..d3c299e2138 100644
--- a/src/tools/msvc/build.pl
+++ b/src/tools/msvc/build.pl
@@ -1,7 +1,7 @@
 
 # -*-perl-*- hey - emacs - this is a perl file
 
-# $PostgreSQL: pgsql/src/tools/msvc/build.pl,v 1.1 2007/09/23 21:52:56 adunstan Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/build.pl,v 1.2 2010/01/05 13:31:58 mha Exp $
 
 BEGIN
 {
@@ -32,7 +32,8 @@ elsif (-e "./buildenv.pl" )
 
 # set up the project
 our $config;
-require "config.pl";
+require "config_default.pl";
+require "config.pl" if (-f "src/tools/msvc/config.pl");
 
 Mkvcbuild::mkvcbuild($config);
 
diff --git a/src/tools/msvc/config.pl b/src/tools/msvc/config_default.pl
similarity index 53%
rename from src/tools/msvc/config.pl
rename to src/tools/msvc/config_default.pl
index 1e3750535de..eea4a70fe76 100644
--- a/src/tools/msvc/config.pl
+++ b/src/tools/msvc/config_default.pl
@@ -10,18 +10,18 @@ our $config = {
     # blocksize => 8,         # --with-blocksize, 8kB by default
     # wal_blocksize => 8,     # --with-wal-blocksize, 8kb by default
     # wal_segsize => 16,      # --with-wal-segsize, 16MB by default
+    ldap=>1,				# --with-ldap
     nls=>undef,				# --enable-nls=<path>
-    tcl=>'c:\tcl',		# --with-tls=<path>
-    perl=>'c:\perl', 			# --with-perl
-    python=>'c:\python24', # --with-python=<path>
-    krb5=>'c:\prog\pgsql\depend\krb5', # --with-krb5=<path>
-    ldap=>1,			# --with-ldap
-    openssl=>'c:\openssl', # --with-ssl=<path>
-    uuid=>'c:\prog\pgsql\depend\ossp-uuid', #--with-ossp-uuid
-    xml=>'c:\prog\pgsql\depend\libxml2',
-    xslt=>'c:\prog\pgsql\depend\libxslt',
-    iconv=>'c:\prog\pgsql\depend\iconv',
-    zlib=>'c:\prog\pgsql\depend\zlib'# --with-zlib=<path>
+    tcl=>undef,				# --with-tls=<path>
+    perl=>undef, 			# --with-perl
+    python=>undef,			# --with-python=<path>
+    krb5=>undef,			# --with-krb5=<path>
+    openssl=>undef,			# --with-ssl=<path>
+    uuid=>undef,			# --with-ossp-uuid
+    xml=>undef,				# --with-libxml=<path>
+    xslt=>undef,			# --with-libxslt=<path>
+    iconv=>undef,			# (not in configure, path to iconv)
+    zlib=>undef				# --with-zlib=<path>
 };
 
 1;
diff --git a/src/tools/msvc/mkvcbuild.pl b/src/tools/msvc/mkvcbuild.pl
index 81ff7485cf7..bdb1cc4d822 100644
--- a/src/tools/msvc/mkvcbuild.pl
+++ b/src/tools/msvc/mkvcbuild.pl
@@ -2,7 +2,7 @@
 # Script that parses Unix style build environment and generates build files
 # for building with Visual Studio.
 #
-# $PostgreSQL: pgsql/src/tools/msvc/mkvcbuild.pl,v 1.18 2007/03/17 14:01:01 mha Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/mkvcbuild.pl,v 1.19 2010/01/05 13:31:58 mha Exp $
 #
 use strict;
 use warnings;
@@ -12,9 +12,11 @@ use Mkvcbuild;
 chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
 die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');
 
-die 'Could not find config.pl' unless (-f 'src/tools/msvc/config.pl');
+die 'Could not find config_default.pl' unless (-f 'src/tools/msvc/config_default.pl');
+print "Warning: no config.pl found, using default.\n" unless (-f 'src/tools/msvc/config.pl');
 
 our $config;
-require 'src/tools/msvc/config.pl';
+require 'src/tools/msvc/config_default.pl';
+require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
 
 Mkvcbuild::mkvcbuild($config);
-- 
GitLab