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',
|
|
|
|
|
2018-03-12 16:55:58 +02:00
|
|
|
'command/command.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',
|
2018-04-11 15:36:12 +02:00
|
|
|
'common/io/handle.c',
|
2018-07-19 22:04:20 +02:00
|
|
|
'common/io/io.c',
|
|
|
|
'common/io/read.c',
|
|
|
|
'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',
|
|
|
|
'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',
|
2018-08-14 20:56:59 +02:00
|
|
|
'compress/gzip.c',
|
|
|
|
'compress/gzipCompress.c',
|
|
|
|
'compress/gzipDecompress.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-06-11 16:53:16 +02:00
|
|
|
'crypto/cipherBlock.c',
|
|
|
|
'crypto/crypto.c',
|
2018-06-11 20:52:26 +02:00
|
|
|
'crypto/hash.c',
|
2018-02-14 16:49:01 +02:00
|
|
|
'perl/config.c',
|
2017-11-02 14:14:13 +02:00
|
|
|
'postgres/pageChecksum.c',
|
2018-09-14 00:58:22 +02:00
|
|
|
'storage/driver/posix/storage.c',
|
|
|
|
'storage/driver/posix/common.c',
|
|
|
|
'storage/driver/posix/fileRead.c',
|
|
|
|
'storage/driver/posix/fileWrite.c',
|
2018-04-23 23:26:27 +02:00
|
|
|
'storage/fileRead.c',
|
|
|
|
'storage/fileWrite.c',
|
2018-02-05 19:32:30 +02:00
|
|
|
'storage/helper.c',
|
|
|
|
'storage/storage.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
|
|
|
|
-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)',
|
|
|
|
);
|