2017-08-25 22:47:47 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Build Makefile and Auto-Generate Files Required for Build
|
2018-07-10 21:39:03 +02:00
|
|
|
#
|
|
|
|
# The C library is only used for Perl unit tests. For a production build all C library exports are built directly into the
|
|
|
|
# pgbackrest executable. See src/perl/libc.auto.c.
|
2017-08-25 22:47:47 +02:00
|
|
|
####################################################################################################################################
|
2016-12-13 01:54:07 +02:00
|
|
|
use 5.010001;
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
2017-08-25 22:47:47 +02:00
|
|
|
use English '-no_match_vars';
|
2016-12-13 01:54:07 +02:00
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
# Convert die to confess to capture the stack trace
|
|
|
|
$SIG{__DIE__} = sub { Carp::confess @_ };
|
|
|
|
|
2017-08-25 22:47:47 +02:00
|
|
|
use Cwd qw(abs_path);
|
2017-11-02 14:14:13 +02:00
|
|
|
use ExtUtils::MakeMaker;
|
2017-08-25 22:47:47 +02:00
|
|
|
use File::Basename qw(dirname);
|
2016-12-13 01:54:07 +02:00
|
|
|
|
2017-08-25 22:47:47 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Storage object to use for all file operations
|
|
|
|
####################################################################################################################################
|
2018-11-25 02:05:03 +02:00
|
|
|
use constant PROJECT_NAME => 'pgBackRest';
|
2017-08-25 22:47:47 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2018-07-10 21:39:03 +02:00
|
|
|
# Make sure the makefile is being created in an expected test directory. This should prevent users from building it in production.
|
|
|
|
####################################################################################################################################
|
|
|
|
if (dirname($0) !~ /\.vagrant\/bin\/[^\/]+\/libc$/)
|
|
|
|
{
|
|
|
|
confess
|
|
|
|
"LibC is not being built in a test directory (" . dirname($0) .
|
|
|
|
"). LibC should not be distributed for production builds. See build documentation for details.";
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2017-08-25 22:47:47 +02:00
|
|
|
# Create C Makefile
|
|
|
|
####################################################################################################################################
|
2017-11-02 14:14:13 +02:00
|
|
|
my $strBuildPath = dirname(dirname(abs_path($0)));
|
2017-08-25 22:47:47 +02:00
|
|
|
|
2017-09-17 20:49:23 +02:00
|
|
|
# Create C files array
|
2017-11-02 14:14:13 +02:00
|
|
|
my @stryCFile =
|
|
|
|
(
|
|
|
|
'LibC.c',
|
|
|
|
|
2019-06-26 14:24:58 +02:00
|
|
|
'command/backup/pageChecksum.c',
|
2018-03-12 16:55:58 +02:00
|
|
|
'command/command.c',
|
2019-03-10 13:11:20 +02:00
|
|
|
'common/compress/gzip/common.c',
|
|
|
|
'common/compress/gzip/compress.c',
|
|
|
|
'common/compress/gzip/decompress.c',
|
2019-03-10 13:27:30 +02:00
|
|
|
'common/crypto/cipherBlock.c',
|
|
|
|
'common/crypto/common.c',
|
|
|
|
'common/crypto/hash.c',
|
2018-05-18 17:57:32 +02:00
|
|
|
'common/debug.c',
|
2017-11-02 14:14:13 +02:00
|
|
|
'common/encode.c',
|
|
|
|
'common/encode/base64.c',
|
|
|
|
'common/error.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'common/ini.c',
|
2018-07-19 22:04:20 +02:00
|
|
|
'common/io/bufferRead.c',
|
2018-07-25 03:08:27 +02:00
|
|
|
'common/io/bufferWrite.c',
|
2018-08-14 20:21:53 +02:00
|
|
|
'common/io/filter/buffer.c',
|
2018-07-25 03:08:27 +02:00
|
|
|
'common/io/filter/filter.c',
|
|
|
|
'common/io/filter/group.c',
|
2018-08-14 20:21:53 +02:00
|
|
|
'common/io/filter/size.c',
|
2019-01-06 14:37:39 +02:00
|
|
|
'common/io/handleWrite.c',
|
2019-06-26 14:24:58 +02:00
|
|
|
'common/io/http/cache.c',
|
|
|
|
'common/io/http/client.c',
|
|
|
|
'common/io/http/common.c',
|
|
|
|
'common/io/http/header.c',
|
|
|
|
'common/io/http/query.c',
|
2018-07-19 22:04:20 +02:00
|
|
|
'common/io/io.c',
|
|
|
|
'common/io/read.c',
|
2019-06-26 14:24:58 +02:00
|
|
|
'common/io/tls/client.c',
|
2018-07-19 22:04:20 +02:00
|
|
|
'common/io/write.c',
|
2018-04-11 15:36:12 +02:00
|
|
|
'common/lock.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'common/log.c',
|
2017-11-02 14:14:13 +02:00
|
|
|
'common/memContext.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'common/regExp.c',
|
2018-05-18 17:57:32 +02:00
|
|
|
'common/stackTrace.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'common/time.c',
|
2018-05-18 17:57:32 +02:00
|
|
|
'common/type/convert.c',
|
2017-12-23 06:27:49 +02:00
|
|
|
'common/type/buffer.c',
|
2019-02-22 12:02:26 +02:00
|
|
|
'common/type/json.c',
|
2017-12-23 06:27:49 +02:00
|
|
|
'common/type/keyValue.c',
|
|
|
|
'common/type/list.c',
|
|
|
|
'common/type/string.c',
|
|
|
|
'common/type/stringList.c',
|
|
|
|
'common/type/variant.c',
|
|
|
|
'common/type/variantList.c',
|
2018-11-21 03:40:11 +02:00
|
|
|
'common/type/xml.c',
|
2018-04-03 18:25:21 +02:00
|
|
|
'common/wait.c',
|
2017-11-02 14:14:13 +02:00
|
|
|
'config/config.c',
|
|
|
|
'config/define.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'config/load.c',
|
|
|
|
'config/parse.c',
|
2018-02-14 16:49:01 +02:00
|
|
|
'perl/config.c',
|
2019-06-26 14:24:58 +02:00
|
|
|
'protocol/client.c',
|
|
|
|
'protocol/command.c',
|
|
|
|
'protocol/helper.c',
|
|
|
|
'protocol/parallel.c',
|
|
|
|
'protocol/parallelJob.c',
|
|
|
|
'protocol/server.c',
|
2017-11-02 14:14:13 +02:00
|
|
|
'postgres/pageChecksum.c',
|
2019-05-03 21:46:15 +02:00
|
|
|
'storage/posix/read.c',
|
|
|
|
'storage/posix/storage.c',
|
|
|
|
'storage/posix/write.c',
|
2019-06-26 14:24:58 +02:00
|
|
|
'storage/s3/read.c',
|
|
|
|
'storage/s3/storage.c',
|
|
|
|
'storage/s3/write.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'storage/helper.c',
|
2019-05-03 21:46:15 +02:00
|
|
|
'storage/read.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'storage/storage.c',
|
2019-05-03 21:46:15 +02:00
|
|
|
'storage/write.c',
|
2017-11-02 14:14:13 +02:00
|
|
|
);
|
2017-09-17 20:49:23 +02:00
|
|
|
|
2018-05-24 20:01:24 +02:00
|
|
|
# Add ../src for files that are outside libc
|
2017-11-02 14:14:13 +02:00
|
|
|
for (my $iFileIdx = 1; $iFileIdx < @stryCFile; $iFileIdx++)
|
2017-09-17 20:49:23 +02:00
|
|
|
{
|
2018-05-24 20:01:24 +02:00
|
|
|
$stryCFile[$iFileIdx] = '../src/' . $stryCFile[$iFileIdx];
|
2017-09-17 20:49:23 +02:00
|
|
|
}
|
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
# Write the makefile
|
2017-08-25 22:47:47 +02:00
|
|
|
WriteMakefile
|
|
|
|
(
|
2018-11-25 02:05:03 +02:00
|
|
|
NAME => PROJECT_NAME . '::LibC',
|
2018-05-22 18:53:08 +02:00
|
|
|
VERSION => '999',
|
2017-08-25 22:47:47 +02:00
|
|
|
AUTHOR => 'David Steele <david@pgbackrest.org>',
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
CCFLAGS => join(' ', qw)
|
|
|
|
-Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wno-missing-field-initializers
|
|
|
|
-o $@
|
|
|
|
-std=c99
|
2018-11-25 17:06:31 +02:00
|
|
|
-D_POSIX_C_SOURCE=200112L
|
2018-05-22 18:53:08 +02:00
|
|
|
-D_FILE_OFFSET_BITS=64
|
2018-11-21 03:40:11 +02:00
|
|
|
`xml2-config --cflags`
|
2018-05-22 18:53:08 +02:00
|
|
|
)),
|
2017-08-25 22:47:47 +02:00
|
|
|
|
|
|
|
INC => join(' ', qw(
|
|
|
|
-I.
|
|
|
|
-I../src
|
|
|
|
)),
|
|
|
|
|
2017-09-17 20:49:23 +02:00
|
|
|
C => \@stryCFile,
|
2017-08-25 22:47:47 +02:00
|
|
|
|
2018-11-22 01:43:25 +02:00
|
|
|
LIBS => '-lcrypto -lssl -lxml2',
|
2017-11-03 19:57:58 +02:00
|
|
|
|
2017-08-25 22:47:47 +02:00
|
|
|
OBJECT => '$(O_FILES)',
|
|
|
|
);
|