Skip to content

Commit 84fa653

Browse files
committed
Fixes to win32 build system
1 parent 46b727b commit 84fa653

File tree

8 files changed

+200
-67
lines changed

8 files changed

+200
-67
lines changed

configure.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.6
2323
Untested combinations of 'autoconf' and PostgreSQL versions are not
2424
recommended. You can remove the check from 'configure.in' but it is then
2525
your responsibility whether the result works or not.])])
26-
AC_COPYRIGHT([Copyright (c) 1996-2016, PostgreSQL Global Development Group])
26+
AC_COPYRIGHT([Copyright (c) 1996-2016, PostgreSQL Global Development Group
27+
Copyright (c) 2015-2016, Postgres Professional])
2728
AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
2829
AC_CONFIG_AUX_DIR(config)
2930
AC_PREFIX_DEFAULT(/usr/local/pgsql)
@@ -36,7 +37,12 @@ AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major versio
3637
PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
3738
[PG_VERSION="$PACKAGE_VERSION$withval"],
3839
[PG_VERSION="$PACKAGE_VERSION"])
40+
PGPRO_VERSION="$PACKAGE_VERSION.1"
41+
PGPRO_PACKAGE_NAME="PostgresPro"
42+
AC_SUBST(PGPRO_PACKAGE_NAME)
3943
AC_DEFINE_UNQUOTED(PG_VERSION, "$PG_VERSION", [PostgreSQL version as a string])
44+
AC_DEFINE_UNQUOTED(PGPRO_PACKAGE_NAME, "$PGPRO_PACKAGE_NAME", [PostgresPro name as a string])
45+
AC_DEFINE_UNQUOTED(PGPRO_VERSION, "$PGPRO_VERSION", [PostgresPro version as a string])
4046

4147
AC_CANONICAL_HOST
4248

src/tools/msvc/Install.pm

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ my @client_program_files = (
2727
'pg_isready', 'pg_receivexlog', 'pg_restore', 'psql',
2828
'reindexdb', 'vacuumdb', @client_contribs);
2929

30+
sub SubstituteMakefileVariables {
31+
local $_ = shift; # Line to substitue
32+
my $mf = shift; # Makefile text
33+
while (/\$\((\w+)\)/) {
34+
my $varname = $1;
35+
if ($mf =~ /^$varname\s*=\s*(.*)$/mg) {
36+
my $varvalue=$1;
37+
s/\$\($varname\)/$varvalue/g;
38+
}
39+
}
40+
return $_;
41+
}
3042
sub lcopy
3143
{
3244
my $src = shift;
@@ -80,7 +92,8 @@ sub Install
8092
my @client_dirs = ('bin', 'lib', 'share', 'symbols');
8193
my @all_dirs = (
8294
@client_dirs, 'doc', 'doc/contrib', 'doc/extension', 'share/contrib',
83-
'share/extension', 'share/timezonesets', 'share/tsearch_data');
95+
'share/extension', 'share/timezonesets', 'share/tsearch_data',
96+
'share/pgpro-upgrade');
8497
if ($insttype eq "client")
8598
{
8699
EnsureDirectories($target, @client_dirs);
@@ -163,6 +176,12 @@ sub Install
163176
@pldirs);
164177
CopySetOfFiles('PL Extension files',
165178
$pl_extension_files, $target . '/share/extension/');
179+
CopySetOfFiles('Catalog upgrade scripts',
180+
[ glob("src\\pgpro-upgrade\\*.sql"),
181+
glob("src\\pgpro-upgrade\\*.test")],
182+
$target . "/share/pgpro-upgrade/");
183+
CopyFiles("Upgrade driver script", $target . "/bin/",
184+
"src/pgpro-upgrade/", "pgpro_upgrade");
166185
}
167186

168187
GenerateNLSFiles($target, $config->{nls}, $majorver) if ($config->{nls});
@@ -459,6 +478,7 @@ sub CopyContribFiles
459478
next if ($d eq "hstore_plpython" && !defined($config->{python}));
460479
next if ($d eq "ltree_plpython" && !defined($config->{python}));
461480
next if ($d eq "sepgsql");
481+
next if ($d eq 'pg_arman');
462482

463483
CopySubdirFiles($subdir, $d, $config, $target);
464484
}
@@ -501,8 +521,8 @@ sub CopySubdirFiles
501521
}
502522

503523
$flist = '';
504-
if ($mf =~ /^DATA_built\s*=\s*(.*)$/m) { $flist .= $1 }
505-
if ($mf =~ /^DATA\s*=\s*(.*)$/m) { $flist .= " $1" }
524+
if ($mf =~ /^DATA_built\s*=\s*(.*)$/m) { $flist .= $1; }
525+
if ($mf =~ /^DATA\s*=\s*(.*)$/m) { $flist .= " $1"; }
506526
$flist =~ s/^\s*//; # Remove leading spaces if we had only DATA_built
507527

508528
if ($flist ne '')
@@ -523,7 +543,7 @@ sub CopySubdirFiles
523543
if ($flist ne '')
524544
{
525545
$flist = ParseAndCleanRule($flist, $mf);
526-
546+
print STDERR "Installing TSEARCH data for module $module: $flist\n";
527547
foreach my $f (split /\s+/, $flist)
528548
{
529549
lcopy("$subdir/$module/$f",
@@ -575,7 +595,7 @@ sub ParseAndCleanRule
575595
substr($flist, 0, index($flist, '$(addsuffix '))
576596
. substr($flist, $i + 1);
577597
}
578-
return $flist;
598+
return SubstituteMakefileVariables($flist,$mf);
579599
}
580600

581601
sub CopyIncludeFiles

src/tools/msvc/MSBuildProject.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ EOF
345345
$d =~ s/__CFGNAME__/$cfgname/g;
346346
print $f " <ModuleDefinitionFile>$d</ModuleDefinitionFile>\n";
347347
}
348+
if ($self->{name} =~ /plperl/ and $self->{platform} eq 'Win32') {
349+
print $f " <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>\n";
350+
}
348351
print $f <<EOF;
349352
</Link>
350353
<ResourceCompile>

src/tools/msvc/Mkvcbuild.pm

Lines changed: 92 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
3636
my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
3737
my $contrib_extralibs = undef;
3838
my $contrib_extraincludes =
39-
{ 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] };
39+
{ 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'],
40+
'jsquery' => ['contrib/jsquery' ] };
4041
my $contrib_extrasource = {
4142
'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
42-
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ], };
43+
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
44+
'jsquery' => [ 'contrib/jsquery/jsquery_scan.l', 'contrib/jsquery/jsquery_gram.y'] };
4345
my @contrib_excludes = (
4446
'commit_ts', 'hstore_plperl',
4547
'hstore_plpython', 'intagg',
4648
'ltree_plpython', 'pgcrypto',
4749
'sepgsql', 'brin',
4850
'test_extensions', 'test_pg_dump',
51+
'pg_arman',
4952
'snapshot_too_old');
5053

5154
# Set of variables for frontend modules
@@ -579,8 +582,8 @@ sub mkvcbuild
579582
}
580583
$plperl->AddReference($postgres);
581584
my @perl_libs =
582-
grep { /perl\d+.lib$/ }
583-
glob($solution->{options}->{perl} . '\lib\CORE\perl*.lib');
585+
grep { /perl\d+\.(lib|a)$/ }
586+
glob($solution->{options}->{perl} . '\lib\CORE\*.*');
584587
if (@perl_libs == 1)
585588
{
586589
$plperl->AddLibrary($perl_libs[0]);
@@ -782,6 +785,10 @@ sub AddContrib
782785
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
783786
AdjustContribProj($proj);
784787
}
788+
elsif ($mf =~ /^DATA_TSEARCH\s*=\s*(.*)$/mg)
789+
{
790+
# This is ispell dictionary project
791+
}
785792
else
786793
{
787794
croak "Could not determine contrib module type for $n\n";
@@ -791,50 +798,91 @@ sub AddContrib
791798
GenerateContribSqlFiles($n, $mf);
792799
}
793800

794-
sub GenerateContribSqlFiles
795-
{
796-
my $n = shift;
797-
my $mf = shift;
798-
$mf =~ s{\\\r?\n}{}g;
799-
if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
800-
{
801-
my $l = $1;
802-
803-
# Strip out $(addsuffix) rules
804-
if (index($l, '$(addsuffix ') >= 0)
805-
{
806-
my $pcount = 0;
807-
my $i;
808-
for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++)
809-
{
810-
$pcount++ if (substr($l, $i, 1) eq '(');
811-
$pcount-- if (substr($l, $i, 1) eq ')');
812-
last if ($pcount < 0);
801+
sub SubstituteMakefileVariables {
802+
local $_ = shift; # Line to substitue
803+
my $mf = shift; # Makefile text
804+
while (/\$\((\w+)\)/) {
805+
my $varname = $1;
806+
if ($mf =~ /^$varname\s*=\s*(.*)$/mg) {
807+
my $varvalue=$1;
808+
s/\$\($varname\)/$varvalue/g;
813809
}
814-
$l =
815-
substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i + 1);
816-
}
817-
818-
foreach my $d (split /\s+/, $l)
819-
{
820-
my $in = "$d.in";
821-
my $out = "$d";
810+
}
811+
return $_;
812+
}
822813

823-
if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
824-
{
825-
print "Building $out from $in (contrib/$n)...\n";
826-
my $cont = Project::read_file("contrib/$n/$in");
827-
my $dn = $out;
828-
$dn =~ s/\.sql$//;
829-
$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
814+
sub GenerateContribSqlFiles
815+
{
816+
my $n = shift;
817+
my $mf = shift;
818+
$mf =~ s{\\\r?\n}{}g;
819+
if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
820+
{
821+
my $l = $1;
822+
# Strip out $(addsuffix) rules
823+
if (index($l, '$(addsuffix ') >= 0)
824+
{
825+
my $pcount = 0;
826+
my $i;
827+
for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++)
828+
{
829+
$pcount++ if (substr($l, $i, 1) eq '(');
830+
$pcount-- if (substr($l, $i, 1) eq ')');
831+
last if ($pcount < 0);
832+
}
833+
$l =
834+
substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i + 1);
835+
}
836+
# perform variable substitutions in the makefile
837+
$l = SubstituteMakefileVariables($l,$mf);
838+
foreach my $d (split /\s+/, $l)
839+
{
840+
print STDERR "Generating file $d\n";
841+
if ( -f "$d.in" ) {
842+
my $in = "$d.in";
843+
my $out = "$d";
844+
if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
845+
{
846+
print "Building $out from $in (contrib/$n)...\n";
847+
my $cont = Project::read_file("contrib/$n/$in");
848+
my $dn = $out;
849+
$dn =~ s/\.sql$//;
850+
$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
851+
my $o;
852+
open($o, ">contrib/$n/$out")
853+
|| croak "Could not write to contrib/$n/$d";
854+
print $o $cont;
855+
close($o);
856+
}
857+
} else {
858+
# Search for makefile rule.
859+
# For now we do not process rule command and assume
860+
# that we should just concatenate all prerequisites
861+
#
862+
my @prereq = ();
863+
my $target;
864+
my @rules = $mf =~ /^(\S+)\s*:\s*([^=].*)$/mg;
865+
RULE:
866+
while (@rules) {
867+
$target = SubstituteMakefileVariables(shift @rules,$mf);
868+
@prereq = split(/\s+/,SubstituteMakefileVariables(shift @rules,$mf));
869+
last RULE if ($target eq $d);
870+
@prereq = ();
871+
}
872+
croak "Don't know how to build contrib/$n/$d" unless @prereq;
873+
print STDERR "building $d from @prereq\n";
830874
my $o;
831-
open($o, ">contrib/$n/$out")
832-
|| croak "Could not write to contrib/$n/$d";
833-
print $o $cont;
834-
close($o);
875+
open $o, ">contrib/$n/$d"
876+
or croak("Couldn't write to contrib/$n/$d:$!");
877+
for my $in (@prereq) {
878+
my $data = Project::read_file("contrib/$n/$in");
879+
print $o $data;
880+
}
881+
close $o;
882+
835883
}
836-
}
837-
}
884+
}
885+
}
838886
}
839887

840888
sub AdjustContribProj

src/tools/msvc/Solution.pm

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ sub _new
1919
options => $options,
2020
numver => '',
2121
strver => '',
22+
pgprover => '',
2223
VisualStudioVersion => undef,
2324
MinimumVisualStudioVersion => undef,
2425
vcver => undef,
@@ -131,17 +132,20 @@ sub GenerateFiles
131132
if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/)
132133
{
133134
$self->{strver} = $1;
134-
if ($self->{strver} !~ /^(\d+)\.(\d+)(?:\.(\d+))?/)
135+
if ($self->{strver} !~ /^(\d+)\.(\d+)(?:\.(\d+))*/)
135136
{
136137
confess "Bad format of version: $self->{strver}\n";
137138
}
138139
$self->{numver} = sprintf("%d%02d%02d", $1, $2, $3 ? $3 : 0);
139140
$self->{majorver} = sprintf("%d.%d", $1, $2);
140141
}
142+
if ( /^PGPRO_VERSION="\$PACKAGE_VERSION\.(\d+)"/) {
143+
$self->{pgprover} = $1;
144+
}
141145
}
142146
close(C);
143147
confess "Unable to parse configure.in for all variables!"
144-
if ($self->{strver} eq '' || $self->{numver} eq '');
148+
if ($self->{strver} eq '' || $self->{numver} eq '' || $self->{pgprover} eq '');
145149

146150
if (IsNewer("src/include/pg_config_os.h", "src/include/port/win32.h"))
147151
{
@@ -162,12 +166,17 @@ sub GenerateFiles
162166
{
163167
s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}$extraver"};
164168
s{PG_VERSION_NUM \d+}{PG_VERSION_NUM $self->{numver}};
165-
s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ", $bits-bit"};
169+
s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ", $bits-bit"};
170+
s{PGPRO_PACKAGE_VERSION "[^"]+"}{PGRPO_PACKAGE_VERSION "$self->{strver}.$self->{pgprover}"};
171+
s{PGPRO_PACKAGE_STR "[^"]+"}{PGPRO_PACKAGE_STR "PostgresPro $self->{strver}.$self->{pgprover}"};
172+
s{#define PGPRO_VERSION_STR "[^"]+"}{#define PGPRO_VERSION_STR PGPRO_PACKAGE_STR " compiled by Visual C++ build" __STRINGIFY2(_MSC_VER) ", $bits-bit"};
166173
print O;
167174
}
168175
print O "#define PG_MAJORVERSION \"$self->{majorver}\"\n";
169176
print O "#define LOCALEDIR \"/share/locale\"\n"
170177
if ($self->{options}->{nls});
178+
print O "#define LC_MESSAGES 6\n"
179+
if ($self->{options}->{nls});
171180
print O "/* defines added by config steps */\n";
172181
print O "#ifndef IGNORE_CONFIGURED_SETTINGS\n";
173182
print O "#define USE_ASSERT_CHECKING 1\n"
@@ -234,6 +243,10 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
234243
print O "#define DEF_PGPORT $port\n";
235244
print O "#define DEF_PGPORT_STR \"$port\"\n";
236245
}
246+
if ($self->{options}->{icu})
247+
{
248+
print O "#define USE_ICU\n";
249+
}
237250
print O "#define VAL_CONFIGURE \""
238251
. $self->GetFakeConfigure() . "\"\n";
239252
print O "#endif /* IGNORE_CONFIGURED_SETTINGS */\n";
@@ -555,6 +568,14 @@ sub AddProject
555568
$proj->AddIncludeDir($self->{options}->{xslt} . '\include');
556569
$proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib');
557570
}
571+
if ($self->{options}->{icu})
572+
{
573+
my $libdir = $self->{options}->{icu}.'\lib';
574+
$libdir .= '\lib64' if $self->{platform} eq 'x64' and -d $libdir.'\lib64';
575+
$proj->AddIncludeDir($self->{options}->{icu} . '\include');
576+
$proj->AddLibrary($libdir.'\icuin.lib');
577+
$proj->AddLibrary($libdir.'\icuuc.lib');
578+
}
558579
return $proj;
559580
}
560581

@@ -666,7 +687,7 @@ sub GetFakeConfigure
666687
$cfg .= ' --with-tcl' if ($self->{options}->{tcl});
667688
$cfg .= ' --with-perl' if ($self->{options}->{perl});
668689
$cfg .= ' --with-python' if ($self->{options}->{python});
669-
690+
$cfg .=' --with-icu' if ($self->{options}->{icu});
670691
return $cfg;
671692
}
672693

src/tools/msvc/clean.bat

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ if exist src\test\regress\autoinc.dll del /q src\test\regress\autoinc.dll
9393
if exist src\bin\initdb\tmp_check rd /s /q src\bin\initdb\tmp_check
9494
if exist src\bin\pg_basebackup\tmp_check rd /s /q src\bin\pg_basebackup\tmp_check
9595
if exist src\bin\pg_config\tmp_check rd /s /q src\bin\pg_config\tmp_check
96-
if exist src\bin\pg_controldata\tmp_check rd /s /q src\bin\pg_controldata\tmp_check
9796
if exist src\bin\pg_ctl\tmp_check rd /s /q src\bin\pg_ctl\tmp_check
9897
if exist src\bin\pg_rewind\tmp_check rd /s /q src\bin\pg_rewind\tmp_check
99-
if exist src\bin\pgbench\tmp_check rd /s /q src\bin\pgbench\tmp_check
10098
if exist src\bin\scripts\tmp_check rd /s /q src\bin\scripts\tmp_check
10199
if exist src\test\recovery\tmp_check rd /s /q src\test\recovery\tmp_check
102100

src/tools/msvc/config_default.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
xml => undef, # --with-libxml=<path>
2727
xslt => undef, # --with-libxslt=<path>
2828
iconv => undef, # (not in configure, path to iconv)
29-
zlib => undef # --with-zlib=<path>
29+
zlib => undef, # --with-zlib=<path>
30+
icu => undef # --with-icu=<path>
3031
};
3132

3233
1;

0 commit comments

Comments
 (0)