2017-08-25 16:47:47 -04:00
|
|
|
####################################################################################################################################
|
|
|
|
# Build Makefile and Auto-Generate Files Required for Build
|
2018-07-10 15:39:03 -04: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 16:47:47 -04:00
|
|
|
####################################################################################################################################
|
2016-12-12 18:54:07 -05:00
|
|
|
use 5.010001;
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
2017-08-25 16:47:47 -04:00
|
|
|
use English '-no_match_vars';
|
2016-12-12 18:54:07 -05:00
|
|
|
|
2017-11-02 08:14:13 -04:00
|
|
|
# Convert die to confess to capture the stack trace
|
|
|
|
$SIG{__DIE__} = sub { Carp::confess @_ };
|
|
|
|
|
2017-08-25 16:47:47 -04:00
|
|
|
use Cwd qw(abs_path);
|
2017-11-02 08:14:13 -04:00
|
|
|
use ExtUtils::MakeMaker;
|
2017-08-25 16:47:47 -04:00
|
|
|
use File::Basename qw(dirname);
|
2016-12-12 18:54:07 -05:00
|
|
|
|
2017-08-25 16:47:47 -04:00
|
|
|
####################################################################################################################################
|
|
|
|
# Storage object to use for all file operations
|
|
|
|
####################################################################################################################################
|
2018-11-24 19:05:03 -05:00
|
|
|
use constant PROJECT_NAME => 'pgBackRest';
|
2017-08-25 16:47:47 -04:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2018-07-10 15:39:03 -04: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 16:47:47 -04:00
|
|
|
# Create C Makefile
|
|
|
|
####################################################################################################################################
|
2017-11-02 08:14:13 -04:00
|
|
|
my $strBuildPath = dirname(dirname(abs_path($0)));
|
2017-08-25 16:47:47 -04:00
|
|
|
|
2017-09-17 14:49:23 -04:00
|
|
|
# Create C files array
|
2017-11-02 08:14:13 -04:00
|
|
|
my @stryCFile =
|
|
|
|
(
|
|
|
|
'LibC.c',
|
|
|
|
|
2018-03-12 10:55:58 -04: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',
|
2018-05-18 11:57:32 -04:00
|
|
|
'common/debug.c',
|
2017-11-02 08:14:13 -04:00
|
|
|
'common/encode.c',
|
|
|
|
'common/encode/base64.c',
|
|
|
|
'common/error.c',
|
2018-02-05 12:32:30 -05:00
|
|
|
'common/ini.c',
|
2018-07-19 16:04:20 -04:00
|
|
|
'common/io/bufferRead.c',
|
2018-07-24 21:08:27 -04:00
|
|
|
'common/io/bufferWrite.c',
|
2018-08-14 14:21:53 -04:00
|
|
|
'common/io/filter/buffer.c',
|
2018-07-24 21:08:27 -04:00
|
|
|
'common/io/filter/filter.c',
|
|
|
|
'common/io/filter/group.c',
|
2018-08-14 14:21:53 -04:00
|
|
|
'common/io/filter/size.c',
|
2019-01-06 14:37:39 +02:00
|
|
|
'common/io/handleWrite.c',
|
2018-07-19 16:04:20 -04:00
|
|
|
'common/io/io.c',
|
|
|
|
'common/io/read.c',
|
|
|
|
'common/io/write.c',
|
2018-04-11 09:36:12 -04:00
|
|
|
'common/lock.c',
|
2018-02-05 12:32:30 -05:00
|
|
|
'common/log.c',
|
2017-11-02 08:14:13 -04:00
|
|
|
'common/memContext.c',
|
2018-02-05 12:32:30 -05:00
|
|
|
'common/regExp.c',
|
2018-05-18 11:57:32 -04:00
|
|
|
'common/stackTrace.c',
|
2018-02-05 12:32:30 -05:00
|
|
|
'common/time.c',
|
2018-05-18 11:57:32 -04:00
|
|
|
'common/type/convert.c',
|
2017-12-22 23:27:49 -05:00
|
|
|
'common/type/buffer.c',
|
2019-02-22 12:02:26 +02:00
|
|
|
'common/type/json.c',
|
2017-12-22 23:27:49 -05: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-20 20:40:11 -05:00
|
|
|
'common/type/xml.c',
|
2018-04-03 12:25:21 -04:00
|
|
|
'common/wait.c',
|
2017-11-02 08:14:13 -04:00
|
|
|
'config/config.c',
|
|
|
|
'config/define.c',
|
2018-02-05 12:32:30 -05:00
|
|
|
'config/load.c',
|
|
|
|
'config/parse.c',
|
2018-06-11 10:53:16 -04:00
|
|
|
'crypto/cipherBlock.c',
|
|
|
|
'crypto/crypto.c',
|
2018-06-11 14:52:26 -04:00
|
|
|
'crypto/hash.c',
|
2018-02-14 09:49:01 -05:00
|
|
|
'perl/config.c',
|
2017-11-02 08:14:13 -04:00
|
|
|
'postgres/pageChecksum.c',
|
2018-09-13 18:58:22 -04:00
|
|
|
'storage/driver/posix/storage.c',
|
|
|
|
'storage/driver/posix/common.c',
|
|
|
|
'storage/driver/posix/fileRead.c',
|
|
|
|
'storage/driver/posix/fileWrite.c',
|
2018-04-23 17:26:27 -04:00
|
|
|
'storage/fileRead.c',
|
|
|
|
'storage/fileWrite.c',
|
2018-02-05 12:32:30 -05:00
|
|
|
'storage/helper.c',
|
|
|
|
'storage/storage.c',
|
2017-11-02 08:14:13 -04:00
|
|
|
);
|
2017-09-17 14:49:23 -04:00
|
|
|
|
2018-05-24 14:01:24 -04:00
|
|
|
# Add ../src for files that are outside libc
|
2017-11-02 08:14:13 -04:00
|
|
|
for (my $iFileIdx = 1; $iFileIdx < @stryCFile; $iFileIdx++)
|
2017-09-17 14:49:23 -04:00
|
|
|
{
|
2018-05-24 14:01:24 -04:00
|
|
|
$stryCFile[$iFileIdx] = '../src/' . $stryCFile[$iFileIdx];
|
2017-09-17 14:49:23 -04:00
|
|
|
}
|
|
|
|
|
2017-11-02 08:14:13 -04:00
|
|
|
# Write the makefile
|
2017-08-25 16:47:47 -04:00
|
|
|
WriteMakefile
|
|
|
|
(
|
2018-11-24 19:05:03 -05:00
|
|
|
NAME => PROJECT_NAME . '::LibC',
|
2018-05-22 12:53:08 -04:00
|
|
|
VERSION => '999',
|
2017-08-25 16:47:47 -04:00
|
|
|
AUTHOR => 'David Steele <david@pgbackrest.org>',
|
|
|
|
|
2018-05-22 12:53:08 -04:00
|
|
|
CCFLAGS => join(' ', qw)
|
|
|
|
-Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wno-missing-field-initializers
|
|
|
|
-o $@
|
|
|
|
-std=c99
|
2018-11-25 10:06:31 -05:00
|
|
|
-D_POSIX_C_SOURCE=200112L
|
2018-05-22 12:53:08 -04:00
|
|
|
-D_FILE_OFFSET_BITS=64
|
2018-11-20 20:40:11 -05:00
|
|
|
`xml2-config --cflags`
|
2018-05-22 12:53:08 -04:00
|
|
|
)),
|
2017-08-25 16:47:47 -04:00
|
|
|
|
|
|
|
INC => join(' ', qw(
|
|
|
|
-I.
|
|
|
|
-I../src
|
|
|
|
)),
|
|
|
|
|
2017-09-17 14:49:23 -04:00
|
|
|
C => \@stryCFile,
|
2017-08-25 16:47:47 -04:00
|
|
|
|
2018-11-21 18:43:25 -05:00
|
|
|
LIBS => '-lcrypto -lssl -lxml2',
|
2017-11-03 13:57:58 -04:00
|
|
|
|
2017-08-25 16:47:47 -04:00
|
|
|
OBJECT => '$(O_FILES)',
|
|
|
|
);
|