2007-03-17 14:50:42 +01:00
|
|
|
package Mkvcbuild;
|
2007-03-23 10:53:33 +01:00
|
|
|
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
|
|
|
# Package that generates build files for msvc build
|
|
|
|
#
|
2010-09-20 22:08:53 +02:00
|
|
|
# src/tools/msvc/Mkvcbuild.pm
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
2007-03-17 14:50:42 +01:00
|
|
|
use Carp;
|
|
|
|
use Win32;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Project;
|
|
|
|
use Solution;
|
2010-01-09 15:45:47 +01:00
|
|
|
use Cwd;
|
|
|
|
use File::Copy;
|
2011-11-26 21:22:32 +01:00
|
|
|
use Config;
|
2012-01-03 14:44:26 +01:00
|
|
|
use VSObjectFactory;
|
2011-11-26 21:22:32 +01:00
|
|
|
use List::Util qw(first);
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
use Exporter;
|
|
|
|
our (@ISA, @EXPORT_OK);
|
2012-07-05 03:47:49 +02:00
|
|
|
@ISA = qw(Exporter);
|
2007-03-17 14:50:42 +01:00
|
|
|
@EXPORT_OK = qw(Mkvcbuild);
|
|
|
|
|
|
|
|
my $solution;
|
|
|
|
my $libpgport;
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
my $libpgcommon;
|
2016-03-24 20:55:44 +01:00
|
|
|
my $libpgfeutils;
|
2007-03-17 14:50:42 +01:00
|
|
|
my $postgres;
|
|
|
|
my $libpq;
|
|
|
|
|
2015-04-16 20:17:26 +02:00
|
|
|
# Set of variables for modules in contrib/ and src/test/modules/
|
2012-07-05 03:47:49 +02:00
|
|
|
my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
|
2015-05-24 03:35:49 +02:00
|
|
|
my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
|
|
|
|
my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
|
|
|
|
my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
|
|
|
|
my $contrib_extralibs = undef;
|
2012-07-05 03:47:49 +02:00
|
|
|
my $contrib_extraincludes =
|
|
|
|
{ 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] };
|
2007-03-17 14:50:42 +01:00
|
|
|
my $contrib_extrasource = {
|
2015-04-25 14:52:03 +02:00
|
|
|
'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
|
2015-05-24 03:35:49 +02:00
|
|
|
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ], };
|
2015-04-28 17:47:08 +02:00
|
|
|
my @contrib_excludes = (
|
2016-06-12 10:19:56 +02:00
|
|
|
'commit_ts', 'hstore_plperl',
|
|
|
|
'hstore_plpython', 'intagg',
|
|
|
|
'ltree_plpython', 'pgcrypto',
|
|
|
|
'sepgsql', 'brin',
|
|
|
|
'test_extensions', 'test_pg_dump',
|
|
|
|
'snapshot_too_old');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
2015-03-11 14:21:01 +01:00
|
|
|
# Set of variables for frontend modules
|
|
|
|
my $frontend_defines = { 'initdb' => 'FRONTEND' };
|
2016-08-20 22:53:25 +02:00
|
|
|
my @frontend_uselibpq = ('pg_ctl', 'pg_upgrade', 'pgbench', 'psql', 'initdb');
|
2015-05-24 03:35:49 +02:00
|
|
|
my @frontend_uselibpgport = (
|
|
|
|
'pg_archivecleanup', 'pg_test_fsync',
|
|
|
|
'pg_test_timing', 'pg_upgrade',
|
|
|
|
'pg_xlogdump', 'pgbench');
|
|
|
|
my @frontend_uselibpgcommon = (
|
|
|
|
'pg_archivecleanup', 'pg_test_fsync',
|
|
|
|
'pg_test_timing', 'pg_upgrade',
|
|
|
|
'pg_xlogdump', 'pgbench');
|
2015-03-11 14:21:01 +01:00
|
|
|
my $frontend_extralibs = {
|
|
|
|
'initdb' => ['ws2_32.lib'],
|
|
|
|
'pg_restore' => ['ws2_32.lib'],
|
2015-03-11 03:33:24 +01:00
|
|
|
'pgbench' => ['ws2_32.lib'],
|
2015-03-11 14:21:01 +01:00
|
|
|
'psql' => ['ws2_32.lib'] };
|
|
|
|
my $frontend_extraincludes = {
|
2015-04-25 14:52:03 +02:00
|
|
|
'initdb' => ['src/timezone'],
|
2016-06-12 10:19:56 +02:00
|
|
|
'psql' => ['src/backend'] };
|
2015-03-11 03:33:24 +01:00
|
|
|
my $frontend_extrasource = {
|
2016-06-12 10:19:56 +02:00
|
|
|
'psql' => ['src/bin/psql/psqlscanslash.l'],
|
2015-03-11 03:33:24 +01:00
|
|
|
'pgbench' =>
|
2016-03-25 01:28:47 +01:00
|
|
|
[ 'src/bin/pgbench/exprscan.l', 'src/bin/pgbench/exprparse.y' ] };
|
2015-05-24 03:35:49 +02:00
|
|
|
my @frontend_excludes = (
|
|
|
|
'pgevent', 'pg_basebackup', 'pg_rewind', 'pg_dump',
|
2016-03-25 01:28:47 +01:00
|
|
|
'pg_xlogdump', 'scripts');
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
sub mkvcbuild
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
our $config = shift;
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
chdir('../../..') if (-d '../msvc' && -d '../../../src');
|
2012-07-05 03:47:49 +02:00
|
|
|
die 'Must run from root or msvc directory'
|
2015-04-25 14:52:03 +02:00
|
|
|
unless (-d 'src/tools/msvc' && -d 'src');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
my $vsVersion = DetermineVisualStudioVersion();
|
|
|
|
|
|
|
|
$solution = CreateSolution($vsVersion, $config);
|
|
|
|
|
|
|
|
our @pgportfiles = qw(
|
2013-10-23 00:42:13 +02:00
|
|
|
chklocale.c crypt.c fls.c fseeko.c getrusage.c inet_aton.c random.c
|
2012-06-10 21:20:04 +02:00
|
|
|
srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
|
2013-10-18 03:52:54 +02:00
|
|
|
erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
|
2015-02-09 21:13:50 +01:00
|
|
|
pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c pqsignal.c
|
2014-06-14 15:41:13 +02:00
|
|
|
mkdtemp.c qsort.c qsort_arg.c quotes.c system.c
|
Revert error-throwing wrappers for the printf family of functions.
This reverts commit 16304a013432931e61e623c8d85e9fe24709d9ba, except
for its changes in src/port/snprintf.c; as well as commit
cac18a76bb6b08f1ecc2a85e46c9d2ab82dd9d23 which is no longer needed.
Fujii Masao reported that the previous commit caused failures in psql on
OS X, since if one exits the pager program early while viewing a query
result, psql sees an EPIPE error from fprintf --- and the wrapper function
thought that was reason to panic. (It's a bit surprising that the same
does not happen on Linux.) Further discussion among the security list
concluded that the risk of other such failures was far too great, and
that the one-size-fits-all approach to error handling embodied in the
previous patch is unlikely to be workable.
This leaves us again exposed to the possibility of the type of failure
envisioned in CVE-2015-3166. However, that failure mode is strictly
hypothetical at this point: there is no concrete reason to believe that
an attacker could trigger information disclosure through the supposed
mechanism. In the first place, the attack surface is fairly limited,
since so much of what the backend does with format strings goes through
stringinfo.c or psprintf(), and those already had adequate defenses.
In the second place, even granting that an unprivileged attacker could
control the occurrence of ENOMEM with some precision, it's a stretch to
believe that he could induce it just where the target buffer contains some
valuable information. So we concluded that the risk of non-hypothetical
problems induced by the patch greatly outweighs the security risks.
We will therefore revert, and instead undertake closer analysis to
identify specific calls that may need hardening, rather than attempt a
universal solution.
We have kept the portion of the previous patch that improved snprintf.c's
handling of errors when it calls the platform's sprintf(). That seems to
be an unalloyed improvement.
Security: CVE-2015-3166
2015-05-20 00:14:52 +02:00
|
|
|
sprompt.c tar.c thread.c getopt.c getopt_long.c dirent.c
|
2016-01-07 15:59:08 +01:00
|
|
|
win32env.c win32error.c win32security.c win32setlocale.c);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2014-01-26 15:49:10 +01:00
|
|
|
push(@pgportfiles, 'rint.c') if ($vsVersion < '12.00');
|
|
|
|
|
Use Intel SSE 4.2 CRC instructions where available.
Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.
Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)
Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.
2015-04-14 16:05:03 +02:00
|
|
|
if ($vsVersion >= '9.00')
|
|
|
|
{
|
|
|
|
push(@pgportfiles, 'pg_crc32c_choose.c');
|
|
|
|
push(@pgportfiles, 'pg_crc32c_sse42.c');
|
|
|
|
push(@pgportfiles, 'pg_crc32c_sb8.c');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-24 03:35:49 +02:00
|
|
|
push(@pgportfiles, 'pg_crc32c_sb8.c');
|
Use Intel SSE 4.2 CRC instructions where available.
Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.
Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)
Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.
2015-04-14 16:05:03 +02:00
|
|
|
}
|
|
|
|
|
2013-02-22 02:46:17 +01:00
|
|
|
our @pgcommonallfiles = qw(
|
2016-09-02 12:49:59 +02:00
|
|
|
config_info.c controldata_utils.c exec.c ip.c keywords.c
|
|
|
|
md5.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
|
2016-03-24 01:22:08 +01:00
|
|
|
string.c username.c wait_error.c);
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
|
2015-05-24 03:35:49 +02:00
|
|
|
our @pgcommonfrontendfiles = (
|
|
|
|
@pgcommonallfiles, qw(fe_memutils.c
|
|
|
|
restricted_token.c));
|
2013-02-22 02:46:17 +01:00
|
|
|
|
|
|
|
our @pgcommonbkndfiles = @pgcommonallfiles;
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
|
2016-03-24 20:55:44 +01:00
|
|
|
our @pgfeutilsfiles = qw(
|
2016-03-25 01:28:47 +01:00
|
|
|
mbprint.c print.c psqlscan.l psqlscan.c simple_list.c string_utils.c);
|
2016-03-24 20:55:44 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$libpgport = $solution->AddProject('libpgport', 'lib', 'misc');
|
2012-06-10 21:20:04 +02:00
|
|
|
$libpgport->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpgport->AddFiles('src/port', @pgportfiles);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
$libpgcommon = $solution->AddProject('libpgcommon', 'lib', 'misc');
|
|
|
|
$libpgcommon->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpgcommon->AddFiles('src/common', @pgcommonfrontendfiles);
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
|
2016-03-24 20:55:44 +01:00
|
|
|
$libpgfeutils = $solution->AddProject('libpgfeutils', 'lib', 'misc');
|
|
|
|
$libpgfeutils->AddDefine('FRONTEND');
|
2016-03-24 22:12:40 +01:00
|
|
|
$libpgfeutils->AddIncludeDir('src/interfaces/libpq');
|
2016-03-24 20:55:44 +01:00
|
|
|
$libpgfeutils->AddFiles('src/fe_utils', @pgfeutilsfiles);
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres = $solution->AddProject('postgres', 'exe', '', 'src/backend');
|
|
|
|
$postgres->AddIncludeDir('src/backend');
|
|
|
|
$postgres->AddDir('src/backend/port/win32');
|
|
|
|
$postgres->AddFile('src/backend/utils/fmgrtab.c');
|
2012-07-05 03:47:49 +02:00
|
|
|
$postgres->ReplaceFile(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/port/dynloader.c',
|
|
|
|
'src/backend/port/dynloader/win32.c');
|
|
|
|
$postgres->ReplaceFile('src/backend/port/pg_sema.c',
|
|
|
|
'src/backend/port/win32_sema.c');
|
|
|
|
$postgres->ReplaceFile('src/backend/port/pg_shmem.c',
|
|
|
|
'src/backend/port/win32_shmem.c');
|
|
|
|
$postgres->AddFiles('src/port', @pgportfiles);
|
|
|
|
$postgres->AddFiles('src/common', @pgcommonbkndfiles);
|
|
|
|
$postgres->AddDir('src/timezone');
|
|
|
|
|
|
|
|
# We need source files from src/timezone, but that directory's resource
|
2014-08-19 04:59:53 +02:00
|
|
|
# file pertains to "zic", not to the backend.
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres->RemoveFile('src/timezone/win32ver.rc');
|
|
|
|
$postgres->AddFiles('src/backend/parser', 'scan.l', 'gram.y');
|
|
|
|
$postgres->AddFiles('src/backend/bootstrap', 'bootscanner.l',
|
2012-07-05 03:47:49 +02:00
|
|
|
'bootparse.y');
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres->AddFiles('src/backend/utils/misc', 'guc-file.l');
|
2016-06-12 10:19:56 +02:00
|
|
|
$postgres->AddFiles(
|
|
|
|
'src/backend/replication', 'repl_scanner.l',
|
|
|
|
'repl_gram.y', 'syncrep_scanner.l',
|
|
|
|
'syncrep_gram.y');
|
2012-06-10 21:20:04 +02:00
|
|
|
$postgres->AddDefine('BUILDING_DLL');
|
|
|
|
$postgres->AddLibrary('secur32.lib');
|
2014-07-15 14:18:39 +02:00
|
|
|
$postgres->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
$postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
|
|
|
|
$postgres->FullExportDLL('postgres.lib');
|
2015-03-11 14:21:01 +01:00
|
|
|
|
|
|
|
# The OBJS scraper doesn't know about ifdefs, so remove be-secure-openssl.c
|
|
|
|
# if building without OpenSSL
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres->RemoveFile('src/backend/libpq/be-secure-openssl.c');
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $snowball = $solution->AddProject('dict_snowball', 'dll', '',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/snowball');
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2014-08-19 04:59:53 +02:00
|
|
|
# This Makefile uses VPATH to find most source files in a subdirectory.
|
2012-06-10 21:20:04 +02:00
|
|
|
$snowball->RelocateFiles(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/snowball/libstemmer',
|
2012-06-10 21:20:04 +02:00
|
|
|
sub {
|
2014-08-19 04:59:53 +02:00
|
|
|
return shift !~ /(dict_snowball.c|win32ver.rc)$/;
|
2012-07-05 03:47:49 +02:00
|
|
|
});
|
2015-04-25 14:52:03 +02:00
|
|
|
$snowball->AddIncludeDir('src/include/snowball');
|
2012-06-10 21:20:04 +02:00
|
|
|
$snowball->AddReference($postgres);
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $plpgsql =
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->AddProject('plpgsql', 'dll', 'PLs', 'src/pl/plpgsql/src');
|
|
|
|
$plpgsql->AddFiles('src/pl/plpgsql/src', 'pl_gram.y');
|
2012-06-10 21:20:04 +02:00
|
|
|
$plpgsql->AddReference($postgres);
|
|
|
|
|
|
|
|
if ($solution->{options}->{tcl})
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pltcl =
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->AddProject('pltcl', 'dll', 'PLs', 'src/pl/tcl');
|
|
|
|
$pltcl->AddIncludeDir($solution->{options}->{tcl} . '/include');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pltcl->AddReference($postgres);
|
2015-04-25 14:52:03 +02:00
|
|
|
if (-e $solution->{options}->{tcl} . '/lib/tcl85.lib')
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
$pltcl->AddLibrary(
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->{options}->{tcl} . '/lib/tcl85.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
$pltcl->AddLibrary(
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->{options}->{tcl} . '/lib/tcl84.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$libpq = $solution->AddProject('libpq', 'dll', 'interfaces',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/libpq');
|
2012-06-10 21:20:04 +02:00
|
|
|
$libpq->AddDefine('FRONTEND');
|
|
|
|
$libpq->AddDefine('UNSAFE_STAT_OK');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpq->AddIncludeDir('src/port');
|
2012-06-10 21:20:04 +02:00
|
|
|
$libpq->AddLibrary('secur32.lib');
|
|
|
|
$libpq->AddLibrary('ws2_32.lib');
|
|
|
|
$libpq->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpq->UseDef('src/interfaces/libpq/libpqdll.def');
|
|
|
|
$libpq->ReplaceFile('src/interfaces/libpq/libpqrc.c',
|
|
|
|
'src/interfaces/libpq/libpq.rc');
|
2012-06-10 21:20:04 +02:00
|
|
|
$libpq->AddReference($libpgport);
|
2015-03-11 14:21:01 +01:00
|
|
|
|
|
|
|
# The OBJS scraper doesn't know about ifdefs, so remove fe-secure-openssl.c
|
|
|
|
# if building without OpenSSL
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpq->RemoveFile('src/interfaces/libpq/fe-secure-openssl.c');
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $libpqwalreceiver =
|
|
|
|
$solution->AddProject('libpqwalreceiver', 'dll', '',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/replication/libpqwalreceiver');
|
|
|
|
$libpqwalreceiver->AddIncludeDir('src/interfaces/libpq');
|
2012-07-05 03:47:49 +02:00
|
|
|
$libpqwalreceiver->AddReference($postgres, $libpq);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgtypes = $solution->AddProject(
|
|
|
|
'libpgtypes', 'dll',
|
2015-04-25 14:52:03 +02:00
|
|
|
'interfaces', 'src/interfaces/ecpg/pgtypeslib');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgtypes->AddDefine('FRONTEND');
|
|
|
|
$pgtypes->AddReference($libpgport);
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgtypes->UseDef('src/interfaces/ecpg/pgtypeslib/pgtypeslib.def');
|
|
|
|
$pgtypes->AddIncludeDir('src/interfaces/ecpg/include');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $libecpg = $solution->AddProject('libecpg', 'dll', 'interfaces',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/ecpg/ecpglib');
|
2012-06-10 21:20:04 +02:00
|
|
|
$libecpg->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libecpg->AddIncludeDir('src/interfaces/ecpg/include');
|
|
|
|
$libecpg->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$libecpg->AddIncludeDir('src/port');
|
|
|
|
$libecpg->UseDef('src/interfaces/ecpg/ecpglib/ecpglib.def');
|
2014-07-15 14:18:39 +02:00
|
|
|
$libecpg->AddLibrary('ws2_32.lib');
|
2012-07-05 03:47:49 +02:00
|
|
|
$libecpg->AddReference($libpq, $pgtypes, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $libecpgcompat = $solution->AddProject(
|
|
|
|
'libecpg_compat', 'dll',
|
2015-04-25 14:52:03 +02:00
|
|
|
'interfaces', 'src/interfaces/ecpg/compatlib');
|
2015-04-25 01:29:02 +02:00
|
|
|
$libecpgcompat->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libecpgcompat->AddIncludeDir('src/interfaces/ecpg/include');
|
|
|
|
$libecpgcompat->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$libecpgcompat->UseDef('src/interfaces/ecpg/compatlib/compatlib.def');
|
2012-07-05 03:47:49 +02:00
|
|
|
$libecpgcompat->AddReference($pgtypes, $libecpg, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $ecpg = $solution->AddProject('ecpg', 'exe', 'interfaces',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/ecpg/preproc');
|
|
|
|
$ecpg->AddIncludeDir('src/interfaces/ecpg/include');
|
|
|
|
$ecpg->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$ecpg->AddPrefixInclude('src/interfaces/ecpg/preproc');
|
|
|
|
$ecpg->AddFiles('src/interfaces/ecpg/preproc', 'pgc.l', 'preproc.y');
|
2012-06-10 21:20:04 +02:00
|
|
|
$ecpg->AddDefine('ECPG_COMPILE');
|
2013-10-18 14:15:20 +02:00
|
|
|
$ecpg->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgregress_ecpg =
|
|
|
|
$solution->AddProject('pg_regress_ecpg', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_ecpg->AddFile('src/interfaces/ecpg/test/pg_regress_ecpg.c');
|
|
|
|
$pgregress_ecpg->AddFile('src/test/regress/pg_regress.c');
|
|
|
|
$pgregress_ecpg->AddIncludeDir('src/port');
|
|
|
|
$pgregress_ecpg->AddIncludeDir('src/test/regress');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-12-25 19:52:03 +01:00
|
|
|
$pgregress_ecpg->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_ecpg->AddDirResourceFile('src/interfaces/ecpg/test');
|
2013-10-18 14:15:20 +02:00
|
|
|
$pgregress_ecpg->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $isolation_tester =
|
|
|
|
$solution->AddProject('isolationtester', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$isolation_tester->AddFile('src/test/isolation/isolationtester.c');
|
|
|
|
$isolation_tester->AddFile('src/test/isolation/specparse.y');
|
|
|
|
$isolation_tester->AddFile('src/test/isolation/specscanner.l');
|
|
|
|
$isolation_tester->AddFile('src/test/isolation/specparse.c');
|
|
|
|
$isolation_tester->AddIncludeDir('src/test/isolation');
|
|
|
|
$isolation_tester->AddIncludeDir('src/port');
|
|
|
|
$isolation_tester->AddIncludeDir('src/test/regress');
|
|
|
|
$isolation_tester->AddIncludeDir('src/interfaces/libpq');
|
2012-06-10 21:20:04 +02:00
|
|
|
$isolation_tester->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-07-15 14:18:39 +02:00
|
|
|
$isolation_tester->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$isolation_tester->AddDirResourceFile('src/test/isolation');
|
2013-10-18 15:54:41 +02:00
|
|
|
$isolation_tester->AddReference($libpq, $libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgregress_isolation =
|
|
|
|
$solution->AddProject('pg_isolation_regress', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_isolation->AddFile('src/test/isolation/isolation_main.c');
|
|
|
|
$pgregress_isolation->AddFile('src/test/regress/pg_regress.c');
|
|
|
|
$pgregress_isolation->AddIncludeDir('src/port');
|
|
|
|
$pgregress_isolation->AddIncludeDir('src/test/regress');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-12-25 19:52:03 +01:00
|
|
|
$pgregress_isolation->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_isolation->AddDirResourceFile('src/test/isolation');
|
2013-10-18 14:15:20 +02:00
|
|
|
$pgregress_isolation->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
# src/bin
|
2015-03-11 14:21:01 +01:00
|
|
|
my $D;
|
|
|
|
opendir($D, 'src/bin') || croak "Could not opendir on src/bin!\n";
|
|
|
|
while (my $d = readdir($D))
|
|
|
|
{
|
|
|
|
next if ($d =~ /^\./);
|
|
|
|
next unless (-f "src/bin/$d/Makefile");
|
|
|
|
next if (grep { /^$d$/ } @frontend_excludes);
|
|
|
|
AddSimpleFrontend($d);
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
my $pgbasebackup = AddSimpleFrontend('pg_basebackup', 1);
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/pg_basebackup.c');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgbasebackup->AddLibrary('ws2_32.lib');
|
|
|
|
|
|
|
|
my $pgreceivexlog = AddSimpleFrontend('pg_basebackup', 1);
|
|
|
|
$pgreceivexlog->{name} = 'pg_receivexlog';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgreceivexlog->AddFile('src/bin/pg_basebackup/pg_receivexlog.c');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgreceivexlog->AddLibrary('ws2_32.lib');
|
|
|
|
|
2014-05-06 18:12:18 +02:00
|
|
|
my $pgrecvlogical = AddSimpleFrontend('pg_basebackup', 1);
|
2014-04-24 09:30:44 +02:00
|
|
|
$pgrecvlogical->{name} = 'pg_recvlogical';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgrecvlogical->AddFile('src/bin/pg_basebackup/pg_recvlogical.c');
|
2014-04-24 09:30:44 +02:00
|
|
|
$pgrecvlogical->AddLibrary('ws2_32.lib');
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
my $pgrewind = AddSimpleFrontend('pg_rewind', 1);
|
|
|
|
$pgrewind->{name} = 'pg_rewind';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgrewind->AddFile('src/backend/access/transam/xlogreader.c');
|
2015-03-23 18:47:52 +01:00
|
|
|
$pgrewind->AddLibrary('ws2_32.lib');
|
2015-03-23 19:25:35 +01:00
|
|
|
$pgrewind->AddDefine('FRONTEND');
|
2015-03-23 18:47:52 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgevent = $solution->AddProject('pgevent', 'dll', 'bin');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgevent->AddFiles('src/bin/pgevent', 'pgevent.c', 'pgmsgevent.rc');
|
|
|
|
$pgevent->AddResourceFile('src/bin/pgevent', 'Eventlog message formatter',
|
2014-07-14 20:07:41 +02:00
|
|
|
'win32');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgevent->RemoveFile('src/bin/pgevent/win32ver.rc');
|
|
|
|
$pgevent->UseDef('src/bin/pgevent/pgevent.def');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgevent->DisableLinkerWarnings('4104');
|
|
|
|
|
|
|
|
my $pgdump = AddSimpleFrontend('pg_dump', 1);
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgdump->AddIncludeDir('src/backend');
|
|
|
|
$pgdump->AddFile('src/bin/pg_dump/pg_dump.c');
|
|
|
|
$pgdump->AddFile('src/bin/pg_dump/common.c');
|
|
|
|
$pgdump->AddFile('src/bin/pg_dump/pg_dump_sort.c');
|
2013-03-24 16:27:20 +01:00
|
|
|
$pgdump->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
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.
|
2015-04-25 14:52:03 +02:00
|
|
|
my @nodumpall = grep { m!src/bin/pg_dump/.*\.c$! }
|
2012-07-05 03:47:49 +02:00
|
|
|
keys %{ $pgdumpall->{files} };
|
|
|
|
delete @{ $pgdumpall->{files} }{@nodumpall};
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgdumpall->{name} = 'pg_dumpall';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgdumpall->AddIncludeDir('src/backend');
|
|
|
|
$pgdumpall->AddFile('src/bin/pg_dump/pg_dumpall.c');
|
|
|
|
$pgdumpall->AddFile('src/bin/pg_dump/dumputils.c');
|
2013-03-24 16:27:20 +01:00
|
|
|
$pgdumpall->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
my $pgrestore = AddSimpleFrontend('pg_dump', 1);
|
|
|
|
$pgrestore->{name} = 'pg_restore';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgrestore->AddIncludeDir('src/backend');
|
|
|
|
$pgrestore->AddFile('src/bin/pg_dump/pg_restore.c');
|
2013-03-24 16:27:20 +01:00
|
|
|
$pgrestore->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $zic = $solution->AddProject('zic', 'exe', 'utils');
|
2016-03-28 22:02:07 +02:00
|
|
|
$zic->AddFiles('src/timezone', 'zic.c');
|
2015-04-25 14:52:03 +02:00
|
|
|
$zic->AddDirResourceFile('src/timezone');
|
2013-10-18 14:15:20 +02:00
|
|
|
$zic->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
if ($solution->{options}->{xml})
|
|
|
|
{
|
|
|
|
$contrib_extraincludes->{'pgxml'} = [
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->{options}->{xml} . '/include',
|
|
|
|
$solution->{options}->{xslt} . '/include',
|
|
|
|
$solution->{options}->{iconv} . '/include' ];
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
$contrib_extralibs->{'pgxml'} = [
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->{options}->{xml} . '/lib/libxml2.lib',
|
|
|
|
$solution->{options}->{xslt} . '/lib/libxslt.lib' ];
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
push @contrib_excludes, 'xml2';
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
push @contrib_excludes, 'sslinfo';
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($solution->{options}->{uuid})
|
|
|
|
{
|
|
|
|
$contrib_extraincludes->{'uuid-ossp'} =
|
2015-04-25 14:52:03 +02:00
|
|
|
[ $solution->{options}->{uuid} . '/include' ];
|
2012-06-10 21:20:04 +02:00
|
|
|
$contrib_extralibs->{'uuid-ossp'} =
|
2015-04-25 14:52:03 +02:00
|
|
|
[ $solution->{options}->{uuid} . '/lib/uuid.lib' ];
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
push @contrib_excludes, 'uuid-ossp';
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2014-07-14 20:07:21 +02:00
|
|
|
# AddProject() does not recognize the constructs used to populate OBJS in
|
|
|
|
# the pgcrypto Makefile, so it will discover no files.
|
|
|
|
my $pgcrypto =
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->AddProject('pgcrypto', 'dll', 'crypto', 'contrib/pgcrypto');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgcrypto->AddFiles(
|
2015-04-25 14:52:03 +02:00
|
|
|
'contrib/pgcrypto', 'pgcrypto.c',
|
2012-07-05 03:47:49 +02:00
|
|
|
'px.c', 'px-hmac.c',
|
|
|
|
'px-crypt.c', 'crypt-gensalt.c',
|
|
|
|
'crypt-blowfish.c', 'crypt-des.c',
|
|
|
|
'crypt-md5.c', 'mbuf.c',
|
|
|
|
'pgp.c', 'pgp-armor.c',
|
|
|
|
'pgp-cfb.c', 'pgp-compress.c',
|
|
|
|
'pgp-decrypt.c', 'pgp-encrypt.c',
|
|
|
|
'pgp-info.c', 'pgp-mpi.c',
|
|
|
|
'pgp-pubdec.c', 'pgp-pubenc.c',
|
|
|
|
'pgp-pubkey.c', 'pgp-s2k.c',
|
|
|
|
'pgp-pgsql.c');
|
2012-06-10 21:20:04 +02:00
|
|
|
if ($solution->{options}->{openssl})
|
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgcrypto->AddFiles('contrib/pgcrypto', 'openssl.c',
|
2012-07-05 03:47:49 +02:00
|
|
|
'pgp-mpi-openssl.c');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pgcrypto->AddFiles(
|
2015-04-25 14:52:03 +02:00
|
|
|
'contrib/pgcrypto', 'md5.c',
|
2012-07-05 03:47:49 +02:00
|
|
|
'sha1.c', 'sha2.c',
|
|
|
|
'internal.c', 'internal-sha2.c',
|
|
|
|
'blf.c', 'rijndael.c',
|
|
|
|
'fortuna.c', 'random.c',
|
|
|
|
'pgp-mpi-internal.c', 'imath.c');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
$pgcrypto->AddReference($postgres);
|
2014-07-15 14:18:39 +02:00
|
|
|
$pgcrypto->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
my $mf = Project::read_file('contrib/pgcrypto/Makefile');
|
|
|
|
GenerateContribSqlFiles('pgcrypto', $mf);
|
|
|
|
|
2015-04-16 20:17:26 +02:00
|
|
|
foreach my $subdir ('contrib', 'src/test/modules')
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-04-16 20:17:26 +02:00
|
|
|
opendir($D, $subdir) || croak "Could not opendir on $subdir!\n";
|
|
|
|
while (my $d = readdir($D))
|
|
|
|
{
|
|
|
|
next if ($d =~ /^\./);
|
|
|
|
next unless (-f "$subdir/$d/Makefile");
|
|
|
|
next if (grep { /^$d$/ } @contrib_excludes);
|
|
|
|
AddContrib($subdir, $d);
|
|
|
|
}
|
|
|
|
closedir($D);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
# Build Perl and Python modules after contrib/ modules to satisfy some
|
|
|
|
# dependencies with transform contrib modules, like hstore_plpython
|
|
|
|
# ltree_plpython and hstore_plperl.
|
|
|
|
if ($solution->{options}->{python})
|
|
|
|
{
|
2015-05-24 03:35:49 +02:00
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
# Attempt to get python version and location.
|
|
|
|
# Assume python.exe in specified dir.
|
2015-05-24 03:35:49 +02:00
|
|
|
my $pythonprog = "import sys;print(sys.prefix);"
|
|
|
|
. "print(str(sys.version_info[0])+str(sys.version_info[1]))";
|
|
|
|
my $prefixcmd =
|
|
|
|
$solution->{options}->{python} . "\\python -c \"$pythonprog\"";
|
2015-04-28 17:47:08 +02:00
|
|
|
my $pyout = `$prefixcmd`;
|
|
|
|
die "Could not query for python version!\n" if $?;
|
2015-05-24 03:35:49 +02:00
|
|
|
my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
|
2015-04-28 17:47:08 +02:00
|
|
|
|
|
|
|
# Sometimes (always?) if python is not present, the execution
|
|
|
|
# appears to work, but gives no data...
|
|
|
|
die "Failed to query python for version information\n"
|
|
|
|
if (!(defined($pyprefix) && defined($pyver)));
|
|
|
|
|
|
|
|
my $pymajorver = substr($pyver, 0, 1);
|
|
|
|
my $plpython = $solution->AddProject('plpython' . $pymajorver,
|
|
|
|
'dll', 'PLs', 'src/pl/plpython');
|
|
|
|
$plpython->AddIncludeDir($pyprefix . '/include');
|
|
|
|
$plpython->AddLibrary($pyprefix . "/Libs/python$pyver.lib");
|
|
|
|
$plpython->AddReference($postgres);
|
|
|
|
|
|
|
|
# Add transform modules dependent on plpython
|
2015-05-24 03:35:49 +02:00
|
|
|
AddTransformModule(
|
|
|
|
'hstore_plpython' . $pymajorver, 'contrib/hstore_plpython',
|
|
|
|
'plpython' . $pymajorver, 'src/pl/plpython',
|
|
|
|
'hstore', 'contrib/hstore');
|
|
|
|
AddTransformModule(
|
|
|
|
'ltree_plpython' . $pymajorver, 'contrib/ltree_plpython',
|
|
|
|
'plpython' . $pymajorver, 'src/pl/plpython',
|
|
|
|
'ltree', 'contrib/ltree');
|
2015-04-28 17:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($solution->{options}->{perl})
|
|
|
|
{
|
|
|
|
my $plperlsrc = "src/pl/plperl/";
|
|
|
|
my $plperl =
|
|
|
|
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
|
|
|
|
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
|
|
|
|
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
|
|
|
|
foreach my $xs ('SPI.xs', 'Util.xs')
|
|
|
|
{
|
|
|
|
(my $xsc = $xs) =~ s/\.xs/.c/;
|
|
|
|
if (Solution::IsNewer("$plperlsrc$xsc", "$plperlsrc$xs"))
|
|
|
|
{
|
|
|
|
my $xsubppdir = first { -e "$_/ExtUtils/xsubpp" } @INC;
|
|
|
|
print "Building $plperlsrc$xsc...\n";
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. "$xsubppdir/ExtUtils/xsubpp -typemap "
|
|
|
|
. $solution->{options}->{perl}
|
|
|
|
. '/lib/ExtUtils/typemap '
|
|
|
|
. "$plperlsrc$xs "
|
|
|
|
. ">$plperlsrc$xsc");
|
|
|
|
if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc")
|
|
|
|
{
|
|
|
|
unlink("$plperlsrc$xsc"); # if zero size
|
|
|
|
die "Failed to create $xsc.\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Solution::IsNewer(
|
|
|
|
'src/pl/plperl/perlchunks.h',
|
|
|
|
'src/pl/plperl/plc_perlboot.pl')
|
|
|
|
|| Solution::IsNewer(
|
|
|
|
'src/pl/plperl/perlchunks.h',
|
|
|
|
'src/pl/plperl/plc_trusted.pl'))
|
|
|
|
{
|
|
|
|
print 'Building src/pl/plperl/perlchunks.h ...' . "\n";
|
|
|
|
my $basedir = getcwd;
|
|
|
|
chdir 'src/pl/plperl';
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. 'text2macro.pl '
|
|
|
|
. '--strip="^(\#.*|\s*)$$" '
|
|
|
|
. 'plc_perlboot.pl plc_trusted.pl '
|
|
|
|
. '>perlchunks.h');
|
|
|
|
chdir $basedir;
|
|
|
|
if ((!(-f 'src/pl/plperl/perlchunks.h'))
|
|
|
|
|| -z 'src/pl/plperl/perlchunks.h')
|
|
|
|
{
|
|
|
|
unlink('src/pl/plperl/perlchunks.h'); # if zero size
|
|
|
|
die 'Failed to create perlchunks.h' . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Solution::IsNewer(
|
|
|
|
'src/pl/plperl/plperl_opmask.h',
|
|
|
|
'src/pl/plperl/plperl_opmask.pl'))
|
|
|
|
{
|
|
|
|
print 'Building src/pl/plperl/plperl_opmask.h ...' . "\n";
|
|
|
|
my $basedir = getcwd;
|
|
|
|
chdir 'src/pl/plperl';
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. 'plperl_opmask.pl '
|
|
|
|
. 'plperl_opmask.h');
|
|
|
|
chdir $basedir;
|
|
|
|
if ((!(-f 'src/pl/plperl/plperl_opmask.h'))
|
|
|
|
|| -z 'src/pl/plperl/plperl_opmask.h')
|
|
|
|
{
|
|
|
|
unlink('src/pl/plperl/plperl_opmask.h'); # if zero size
|
|
|
|
die 'Failed to create plperl_opmask.h' . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$plperl->AddReference($postgres);
|
|
|
|
my @perl_libs =
|
|
|
|
grep { /perl\d+.lib$/ }
|
|
|
|
glob($solution->{options}->{perl} . '\lib\CORE\perl*.lib');
|
|
|
|
if (@perl_libs == 1)
|
|
|
|
{
|
|
|
|
$plperl->AddLibrary($perl_libs[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
die "could not identify perl library version";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add transform module dependent on plperl
|
2015-05-24 03:35:49 +02:00
|
|
|
my $hstore_plperl = AddTransformModule(
|
|
|
|
'hstore_plperl', 'contrib/hstore_plperl',
|
|
|
|
'plperl', 'src/pl/plperl',
|
|
|
|
'hstore', 'contrib/hstore');
|
2015-04-28 17:47:08 +02:00
|
|
|
$hstore_plperl->AddDefine('PLPERL_HAVE_UID_GID');
|
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$mf =
|
2015-04-25 14:52:03 +02:00
|
|
|
Project::read_file('src/backend/utils/mb/conversion_procs/Makefile');
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
2012-07-05 03:47:49 +02:00
|
|
|
$mf =~ m{SUBDIRS\s*=\s*(.*)$}m
|
|
|
|
|| die 'Could not match in conversion makefile' . "\n";
|
|
|
|
foreach my $sub (split /\s+/, $1)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
my $dir = 'src/backend/utils/mb/conversion_procs/' . $sub;
|
2014-07-14 20:07:21 +02:00
|
|
|
my $p = $solution->AddProject($sub, 'dll', 'conversion procs', $dir);
|
2015-04-25 14:52:03 +02:00
|
|
|
$p->AddFile("$dir/$sub.c"); # implicit source file
|
2012-06-10 21:20:04 +02:00
|
|
|
$p->AddReference($postgres);
|
|
|
|
}
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
$mf = Project::read_file('src/bin/scripts/Makefile');
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
2012-07-05 03:47:49 +02:00
|
|
|
$mf =~ m{PROGRAMS\s*=\s*(.*)$}m
|
2015-04-25 14:52:03 +02:00
|
|
|
|| die 'Could not match in bin/scripts/Makefile' . "\n";
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $prg (split /\s+/, $1)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $proj = $solution->AddProject($prg, 'exe', 'bin');
|
|
|
|
$mf =~ m{$prg\s*:\s*(.*)$}m
|
|
|
|
|| die 'Could not find script define for $prg' . "\n";
|
|
|
|
my @files = split /\s+/, $1;
|
2012-06-10 21:20:04 +02:00
|
|
|
foreach my $f (@files)
|
|
|
|
{
|
|
|
|
$f =~ s/\.o$/\.c/;
|
2016-03-24 23:27:28 +01:00
|
|
|
if ($f =~ /\.c$/)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddFile('src/bin/scripts/' . $f);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddIncludeDir('src/interfaces/libpq');
|
2016-06-12 10:19:56 +02:00
|
|
|
$proj->AddReference($libpq, $libpgfeutils, $libpgcommon, $libpgport);
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddDirResourceFile('src/bin/scripts');
|
2013-03-24 16:27:20 +01:00
|
|
|
$proj->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Regression DLL and EXE
|
2012-07-05 03:47:49 +02:00
|
|
|
my $regress = $solution->AddProject('regress', 'dll', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$regress->AddFile('src/test/regress/regress.c');
|
|
|
|
$regress->AddDirResourceFile('src/test/regress');
|
2012-06-10 21:20:04 +02:00
|
|
|
$regress->AddReference($postgres);
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgregress = $solution->AddProject('pg_regress', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress->AddFile('src/test/regress/pg_regress.c');
|
|
|
|
$pgregress->AddFile('src/test/regress/pg_regress_main.c');
|
|
|
|
$pgregress->AddIncludeDir('src/port');
|
2012-06-10 21:20:04 +02:00
|
|
|
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-12-25 19:52:03 +01:00
|
|
|
$pgregress->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress->AddDirResourceFile('src/test/regress');
|
2013-10-18 14:15:20 +02:00
|
|
|
$pgregress->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2013-02-25 18:00:53 +01:00
|
|
|
# fix up pg_xlogdump once it's been set up
|
|
|
|
# files symlinked on Unix are copied on windows
|
2015-03-11 03:33:24 +01:00
|
|
|
my $pg_xlogdump = AddSimpleFrontend('pg_xlogdump');
|
2013-02-25 02:28:42 +01:00
|
|
|
$pg_xlogdump->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
foreach my $xf (glob('src/backend/access/rmgrdesc/*desc.c'))
|
2013-02-25 18:00:53 +01:00
|
|
|
{
|
2015-05-24 03:35:49 +02:00
|
|
|
$pg_xlogdump->AddFile($xf);
|
2013-02-25 18:00:53 +01:00
|
|
|
}
|
2015-04-25 14:52:03 +02:00
|
|
|
$pg_xlogdump->AddFile('src/backend/access/transam/xlogreader.c');
|
2013-02-25 02:28:42 +01:00
|
|
|
|
2012-06-10 21:20:04 +02:00
|
|
|
$solution->Save();
|
|
|
|
return $solution->{vcver};
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Utility functions #
|
|
|
|
#####################
|
|
|
|
|
|
|
|
# Add a simple frontend project (exe)
|
|
|
|
sub AddSimpleFrontend
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $n = shift;
|
|
|
|
my $uselibpq = shift;
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $p = $solution->AddProject($n, 'exe', 'bin');
|
2015-04-25 14:52:03 +02:00
|
|
|
$p->AddDir('src/bin/' . $n);
|
2016-03-24 20:55:44 +01:00
|
|
|
$p->AddReference($libpgfeutils, $libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
if ($uselibpq)
|
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$p->AddIncludeDir('src/interfaces/libpq');
|
2012-06-10 21:20:04 +02:00
|
|
|
$p->AddReference($libpq);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2015-04-09 14:15:39 +02:00
|
|
|
# Adjust module definition using frontend variables
|
2015-03-11 14:21:01 +01:00
|
|
|
AdjustFrontendProj($p);
|
|
|
|
|
2012-06-10 21:20:04 +02:00
|
|
|
return $p;
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
# Add a simple transform module
|
|
|
|
sub AddTransformModule
|
|
|
|
{
|
2015-05-24 03:35:49 +02:00
|
|
|
my $n = shift;
|
|
|
|
my $n_src = shift;
|
|
|
|
my $pl_proj_name = shift;
|
|
|
|
my $pl_src = shift;
|
2015-04-28 17:47:08 +02:00
|
|
|
my $transform_name = shift;
|
2015-05-24 03:35:49 +02:00
|
|
|
my $transform_src = shift;
|
2015-04-28 17:47:08 +02:00
|
|
|
|
|
|
|
my $transform_proj = undef;
|
|
|
|
foreach my $proj (@{ $solution->{projects}->{'contrib'} })
|
|
|
|
{
|
|
|
|
if ($proj->{name} eq $transform_name)
|
|
|
|
{
|
|
|
|
$transform_proj = $proj;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
die "could not find base module $transform_name for transform module $n"
|
2015-05-24 03:35:49 +02:00
|
|
|
if (!defined($transform_proj));
|
2015-04-28 17:47:08 +02:00
|
|
|
|
|
|
|
my $pl_proj = undef;
|
|
|
|
foreach my $proj (@{ $solution->{projects}->{'PLs'} })
|
|
|
|
{
|
|
|
|
if ($proj->{name} eq $pl_proj_name)
|
|
|
|
{
|
|
|
|
$pl_proj = $proj;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
die "could not find PL $pl_proj_name for transform module $n"
|
2015-05-24 03:35:49 +02:00
|
|
|
if (!defined($pl_proj));
|
2015-04-28 17:47:08 +02:00
|
|
|
|
|
|
|
my $p = $solution->AddProject($n, 'dll', 'contrib', $n_src);
|
|
|
|
for my $file (glob("$n_src/*.c"))
|
|
|
|
{
|
|
|
|
$p->AddFile($file);
|
|
|
|
}
|
|
|
|
$p->AddReference($postgres);
|
|
|
|
|
|
|
|
# Add PL dependencies
|
|
|
|
$p->AddIncludeDir($pl_src);
|
|
|
|
$p->AddReference($pl_proj);
|
|
|
|
$p->AddIncludeDir($pl_proj->{includes});
|
2015-05-24 03:35:49 +02:00
|
|
|
foreach my $pl_lib (@{ $pl_proj->{libraries} })
|
2015-04-28 17:47:08 +02:00
|
|
|
{
|
|
|
|
$p->AddLibrary($pl_lib);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add base module dependencies
|
|
|
|
$p->AddIncludeDir($transform_src);
|
|
|
|
$p->AddIncludeDir($transform_proj->{includes});
|
2015-05-24 03:35:49 +02:00
|
|
|
foreach my $trans_lib (@{ $transform_proj->{libraries} })
|
2015-04-28 17:47:08 +02:00
|
|
|
{
|
|
|
|
$p->AddLibrary($trans_lib);
|
|
|
|
}
|
|
|
|
$p->AddReference($transform_proj);
|
|
|
|
|
|
|
|
return $p;
|
|
|
|
}
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
# Add a simple contrib project
|
|
|
|
sub AddContrib
|
|
|
|
{
|
2015-04-16 20:17:26 +02:00
|
|
|
my $subdir = shift;
|
2015-05-24 03:35:49 +02:00
|
|
|
my $n = shift;
|
|
|
|
my $mf = Project::read_file("$subdir/$n/Makefile");
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
my $dn = $1;
|
2015-05-24 03:35:49 +02:00
|
|
|
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
|
2012-06-10 21:20:04 +02:00
|
|
|
$proj->AddReference($postgres);
|
|
|
|
AdjustContribProj($proj);
|
|
|
|
}
|
|
|
|
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $mod (split /\s+/, $1)
|
|
|
|
{
|
2014-07-14 20:07:21 +02:00
|
|
|
my $proj =
|
2015-04-16 20:17:26 +02:00
|
|
|
$solution->AddProject($mod, 'dll', 'contrib', "$subdir/$n");
|
|
|
|
my $filename = $mod . '.c';
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddFile("$subdir/$n/$filename");
|
2012-06-10 21:20:04 +02:00
|
|
|
$proj->AddReference($postgres);
|
|
|
|
AdjustContribProj($proj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
|
|
|
|
{
|
2015-05-24 03:35:49 +02:00
|
|
|
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
|
2012-06-10 21:20:04 +02:00
|
|
|
AdjustContribProj($proj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
croak "Could not determine contrib module type for $n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Are there any output data files to build?
|
|
|
|
GenerateContribSqlFiles($n, $mf);
|
2007-03-23 10:53:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub GenerateContribSqlFiles
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $n = shift;
|
2012-06-10 21:20:04 +02:00
|
|
|
my $mf = shift;
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
2012-06-10 21:20:04 +02:00
|
|
|
if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
my $l = $1;
|
|
|
|
|
|
|
|
# Strip out $(addsuffix) rules
|
|
|
|
if (index($l, '$(addsuffix ') >= 0)
|
|
|
|
{
|
|
|
|
my $pcount = 0;
|
|
|
|
my $i;
|
|
|
|
for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++)
|
|
|
|
{
|
|
|
|
$pcount++ if (substr($l, $i, 1) eq '(');
|
|
|
|
$pcount-- if (substr($l, $i, 1) eq ')');
|
2012-07-05 03:47:49 +02:00
|
|
|
last if ($pcount < 0);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2012-07-05 03:47:49 +02:00
|
|
|
$l =
|
|
|
|
substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i + 1);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $d (split /\s+/, $l)
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $in = "$d.in";
|
2012-06-10 21:20:04 +02:00
|
|
|
my $out = "$d";
|
|
|
|
|
|
|
|
if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
|
|
|
|
{
|
|
|
|
print "Building $out from $in (contrib/$n)...\n";
|
|
|
|
my $cont = Project::read_file("contrib/$n/$in");
|
2012-07-05 03:47:49 +02:00
|
|
|
my $dn = $out;
|
2015-05-24 03:35:49 +02:00
|
|
|
$dn =~ s/\.sql$//;
|
2012-06-10 21:20:04 +02:00
|
|
|
$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
|
|
|
|
my $o;
|
2012-07-05 03:47:49 +02:00
|
|
|
open($o, ">contrib/$n/$out")
|
2012-06-10 21:20:04 +02:00
|
|
|
|| croak "Could not write to contrib/$n/$d";
|
|
|
|
print $o $cont;
|
|
|
|
close($o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub AdjustContribProj
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my $proj = shift;
|
2015-03-11 14:21:01 +01:00
|
|
|
AdjustModule(
|
|
|
|
$proj, $contrib_defines,
|
|
|
|
\@contrib_uselibpq, \@contrib_uselibpgport,
|
|
|
|
\@contrib_uselibpgcommon, $contrib_extralibs,
|
|
|
|
$contrib_extrasource, $contrib_extraincludes);
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2015-03-11 14:21:01 +01:00
|
|
|
sub AdjustFrontendProj
|
|
|
|
{
|
|
|
|
my $proj = shift;
|
2015-05-24 03:35:49 +02:00
|
|
|
AdjustModule(
|
|
|
|
$proj, $frontend_defines,
|
|
|
|
\@frontend_uselibpq, \@frontend_uselibpgport,
|
|
|
|
\@frontend_uselibpgcommon, $frontend_extralibs,
|
|
|
|
$frontend_extrasource, $frontend_extraincludes);
|
2015-03-11 14:21:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub AdjustModule
|
|
|
|
{
|
|
|
|
my $proj = shift;
|
|
|
|
my $module_defines = shift;
|
|
|
|
my $module_uselibpq = shift;
|
|
|
|
my $module_uselibpgport = shift;
|
|
|
|
my $module_uselibpgcommon = shift;
|
|
|
|
my $module_extralibs = shift;
|
|
|
|
my $module_extrasource = shift;
|
|
|
|
my $module_extraincludes = shift;
|
|
|
|
my $n = $proj->{name};
|
|
|
|
|
|
|
|
if ($module_defines->{$n})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $d ($module_defines->{$n})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
$proj->AddDefine($d);
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if (grep { /^$n$/ } @{$module_uselibpq})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
$proj->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$proj->AddReference($libpq);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if (grep { /^$n$/ } @{$module_uselibpgport})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
$proj->AddReference($libpgport);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if (grep { /^$n$/ } @{$module_uselibpgcommon})
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
{
|
|
|
|
$proj->AddReference($libpgcommon);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if ($module_extralibs->{$n})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $l (@{ $module_extralibs->{$n} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
$proj->AddLibrary($l);
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if ($module_extraincludes->{$n})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $i (@{ $module_extraincludes->{$n} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($i);
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if ($module_extrasource->{$n})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $i (@{ $module_extrasource->{$n} })
|
|
|
|
{
|
|
|
|
print "Files $i\n";
|
|
|
|
$proj->AddFile($i);
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|