From 693c85d954890ceb4f0a892cd12e718fb4902128 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Wed, 24 Jan 2007 19:24:28 +0000
Subject: [PATCH] When using MSVC, disable the building of ecpg if pthreads is
 not specified.

Magnus Hagander
---
 src/tools/msvc/Project.pm   |  4 ++-
 src/tools/msvc/Solution.pm  |  1 -
 src/tools/msvc/mkvcbuild.pl | 49 ++++++++++++++++++++-----------------
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 4b84c98ea2e..362611114a0 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -367,11 +367,13 @@ sub WriteConfiguration
 	}
 	$libs =~ s/ $//;
 	$libs =~ s/__CFGNAME__/$cfgname/g;
+	my $pth = $self->{solution}->{options}->{pthread};
+	$pth = '' unless $pth;
 	print $f <<EOF;
   <Configuration Name="$cfgname|Win32" 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="src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{solution}->{options}->{pthread};$self->{includes}"
+		AdditionalIncludeDirectories="src/include;src/include/port/win32;src/include/port/win32_msvc;$pth;$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}"
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 4086f428f5b..588f8c92a0d 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -6,7 +6,6 @@ use warnings;
 sub new {
 	my $junk = shift;
 	my $options = shift;
-	die "Pthreads is required.\n" unless $options->{pthread};
 	my $self = {
         projects => {},
         options  => $options,
diff --git a/src/tools/msvc/mkvcbuild.pl b/src/tools/msvc/mkvcbuild.pl
index c87420b0dc8..2cb88c14b8d 100644
--- a/src/tools/msvc/mkvcbuild.pl
+++ b/src/tools/msvc/mkvcbuild.pl
@@ -90,28 +90,33 @@ $pgtypes->AddDefine('FRONTEND');
 $pgtypes->AddReference($postgres,$libpgport);
 $pgtypes->AddIncludeDir('src\interfaces\ecpg\include');
 
-my $libecpg = $solution->AddProject('libecpg','dll','interfaces','src\interfaces\ecpg\ecpglib');
-$libecpg->AddDefine('FRONTEND');
-$libecpg->AddIncludeDir('src\interfaces\ecpg\include');
-$libecpg->AddIncludeDir('src\interfaces\libpq');
-$libecpg->AddIncludeDir('src\port');
-$libecpg->AddLibrary('wsock32.lib');
-$libecpg->AddLibrary($config->{'pthread'} . '\pthreadVC2.lib');
-$libecpg->AddReference($libpq,$pgtypes);
-
-my $libecpgcompat = $solution->AddProject('libecpg_compat','dll','interfaces','src\interfaces\ecpg\compatlib');
-$libecpgcompat->AddIncludeDir('src\interfaces\ecpg\include');
-$libecpgcompat->AddIncludeDir('src\interfaces\libpq');
-$libecpgcompat->AddReference($pgtypes,$libecpg);
-
-my $ecpg = $solution->AddProject('ecpg','exe','interfaces','src\interfaces\ecpg\preproc');
-$ecpg->AddIncludeDir('src\interfaces\ecpg\include');
-$ecpg->AddIncludeDir('src\interfaces\libpq');
-$ecpg->AddFiles('src\interfaces\ecpg\preproc','pgc.l','preproc.y');
-$ecpg->AddDefine('MAJOR_VERSION=4');
-$ecpg->AddDefine('MINOR_VERSION=2');
-$ecpg->AddDefine('PATCHLEVEL=1');
-$ecpg->AddReference($libpgport);
+if ($config->{pthread}) {
+   my $libecpg = $solution->AddProject('libecpg','dll','interfaces','src\interfaces\ecpg\ecpglib');
+   $libecpg->AddDefine('FRONTEND');
+   $libecpg->AddIncludeDir('src\interfaces\ecpg\include');
+   $libecpg->AddIncludeDir('src\interfaces\libpq');
+   $libecpg->AddIncludeDir('src\port');
+   $libecpg->AddLibrary('wsock32.lib');
+   $libecpg->AddLibrary($config->{'pthread'} . '\pthreadVC2.lib');
+   $libecpg->AddReference($libpq,$pgtypes);
+
+   my $libecpgcompat = $solution->AddProject('libecpg_compat','dll','interfaces','src\interfaces\ecpg\compatlib');
+   $libecpgcompat->AddIncludeDir('src\interfaces\ecpg\include');
+   $libecpgcompat->AddIncludeDir('src\interfaces\libpq');
+   $libecpgcompat->AddReference($pgtypes,$libecpg);
+
+   my $ecpg = $solution->AddProject('ecpg','exe','interfaces','src\interfaces\ecpg\preproc');
+   $ecpg->AddIncludeDir('src\interfaces\ecpg\include');
+   $ecpg->AddIncludeDir('src\interfaces\libpq');
+   $ecpg->AddFiles('src\interfaces\ecpg\preproc','pgc.l','preproc.y');
+   $ecpg->AddDefine('MAJOR_VERSION=4');
+   $ecpg->AddDefine('MINOR_VERSION=2');
+   $ecpg->AddDefine('PATCHLEVEL=1');
+   $ecpg->AddReference($libpgport);
+}
+else {
+   print "Not building ecpg due to lack of pthreads.\n";
+}   
 
 
 # src/bin
-- 
GitLab