1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Auto-generate Makefile with dependencies.

This commit is contained in:
David Steele 2018-05-23 14:57:08 -04:00
parent 2f6017511f
commit 8eb9921c7c
5 changed files with 356 additions and 32 deletions

View File

@ -18,6 +18,10 @@
<release-item>
<p>Split log levels into separate header file. Many modules that use <code>debug.h</code> do not need to do logging so this reduces dependencies for those modules.</p>
</release-item>
<release-item>
<p>Auto-generate Makefile with dependencies.</p>
</release-item>
</release-development-list>
</release-core-list>
</release>

View File

@ -112,15 +112,156 @@ OBJS=$(SRCS:.c=.o)
pgbackrest: $(OBJS)
$(CC) -o pgbackrest $(OBJS) $(LDFLAGS)
postgres/pageChecksum.o:
$(CC) $(CFLAGS) -funroll-loops -ftree-vectorize -c postgres/pageChecksum.c -o postgres/pageChecksum.o
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
####################################################################################################################################
# Installation. DESTDIR can be used to modify the install location.
####################################################################################################################################
install: pgbackrest
install -d $(DESTDIR)/usr/bin
install -m 755 pgbackrest $(DESTDIR)/usr/bin
####################################################################################################################################
# Compile rules
####################################################################################################################################
cipher/block.o: cipher/block.c cipher/block.h cipher/cipher.h cipher/random.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c cipher/block.c -o cipher/block.o
cipher/cipher.o: cipher/cipher.c cipher/cipher.h common/debug.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c cipher/cipher.c -o cipher/cipher.o
cipher/random.o: cipher/random.c cipher/random.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c cipher/random.c -o cipher/random.o
command/archive/common.o: command/archive/common.c command/archive/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h postgres/version.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c command/archive/common.c -o command/archive/common.o
command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h postgres/info.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c command/archive/get/get.c -o command/archive/get/get.o
command/archive/push/push.o: command/archive/push/push.c command/archive/common.h command/command.h common/debug.h common/error.auto.h common/error.h common/fork.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c command/archive/push/push.c -o command/archive/push/push.o
command/command.o: command/command.c common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
$(CC) $(CFLAGS) -c command/command.c -o command/command.o
command/help/help.o: command/help/help.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/handle.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
$(CC) $(CFLAGS) -c command/help/help.c -o command/help/help.o
common/debug.o: common/debug.c common/debug.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/debug.c -o common/debug.o
common/encode.o: common/encode.c common/debug.h common/encode.h common/encode/base64.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/encode.c -o common/encode.o
common/encode/base64.o: common/encode/base64.c common/debug.h common/encode/base64.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/encode/base64.c -o common/encode/base64.o
common/error.o: common/error.c common/error.auto.c common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h
$(CC) $(CFLAGS) -c common/error.c -o common/error.o
common/exit.o: common/exit.c command/command.h common/debug.h common/error.auto.h common/error.h common/exit.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h perl/exec.h
$(CC) $(CFLAGS) -c common/exit.c -o common/exit.o
common/fork.o: common/fork.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/fork.c -o common/fork.o
common/ini.o: common/ini.c common/debug.h common/error.auto.h common/error.h common/ini.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c common/ini.c -o common/ini.o
common/io/handle.o: common/io/handle.c common/debug.h common/error.auto.h common/error.h common/io/handle.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
$(CC) $(CFLAGS) -c common/io/handle.c -o common/io/handle.o
common/lock.o: common/lock.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/handle.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c common/lock.c -o common/lock.o
common/log.o: common/log.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/time.h common/type/convert.h
$(CC) $(CFLAGS) -c common/log.c -o common/log.o
common/memContext.o: common/memContext.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/memContext.c -o common/memContext.o
common/regExp.o: common/regExp.c common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
$(CC) $(CFLAGS) -c common/regExp.c -o common/regExp.o
common/stackTrace.o: common/stackTrace.c common/assert.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h
$(CC) $(CFLAGS) -c common/stackTrace.c -o common/stackTrace.o
common/time.o: common/time.c common/debug.h common/logLevel.h common/stackTrace.h common/time.h common/type/convert.h
$(CC) $(CFLAGS) -c common/time.c -o common/time.o
common/type/buffer.o: common/type/buffer.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
$(CC) $(CFLAGS) -c common/type/buffer.c -o common/type/buffer.o
common/type/convert.o: common/type/convert.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/type/convert.c -o common/type/convert.o
common/type/keyValue.o: common/type/keyValue.c common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h
$(CC) $(CFLAGS) -c common/type/keyValue.c -o common/type/keyValue.o
common/type/list.o: common/type/list.c common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/list.h common/type/string.h
$(CC) $(CFLAGS) -c common/type/list.c -o common/type/list.o
common/type/string.o: common/type/string.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
$(CC) $(CFLAGS) -c common/type/string.c -o common/type/string.o
common/type/stringList.o: common/type/stringList.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h
$(CC) $(CFLAGS) -c common/type/stringList.c -o common/type/stringList.o
common/type/variant.o: common/type/variant.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
$(CC) $(CFLAGS) -c common/type/variant.c -o common/type/variant.o
common/type/variantList.o: common/type/variantList.c common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h
$(CC) $(CFLAGS) -c common/type/variantList.c -o common/type/variantList.o
common/wait.o: common/wait.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/convert.h common/wait.h
$(CC) $(CFLAGS) -c common/wait.c -o common/wait.o
config/config.o: config/config.c common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.c config/config.auto.h config/config.h config/define.auto.h config/define.h
$(CC) $(CFLAGS) -c config/config.c -o config/config.o
config/define.o: config/define.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h config/define.auto.c config/define.auto.h config/define.h
$(CC) $(CFLAGS) -c config/define.c -o config/define.o
config/load.o: config/load.c command/command.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h
$(CC) $(CFLAGS) -c config/load.c -o config/load.o
config/parse.o: config/parse.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/parse.auto.c config/parse.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c config/parse.c -o config/parse.o
main.o: main.c command/archive/get/get.h command/archive/push/push.h command/command.h command/help/help.h common/debug.h common/error.auto.h common/error.h common/exit.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h version.h
$(CC) $(CFLAGS) -c main.c -o main.o
perl/config.o: perl/config.c common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h
$(CC) $(CFLAGS) -c perl/config.c -o perl/config.o
perl/exec.o: perl/exec.c ../libc/LibC.h cipher/block.h cipher/cipher.h cipher/random.h common/debug.h common/encode.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/driver.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/info.h version.h ../libc/xs/cipher/block.xsh ../libc/xs/common/encode.xsh
$(CC) $(CFLAGS) -c perl/exec.c -o perl/exec.o
postgres/info.o: postgres/info.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h postgres/info.h postgres/type.h postgres/version.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c postgres/info.c -o postgres/info.o
postgres/pageChecksum.o: postgres/pageChecksum.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h postgres/pageChecksum.h postgres/type.h
$(CC) $(CFLAGS) -funroll-loops -ftree-vectorize -c postgres/pageChecksum.c -o postgres/pageChecksum.o
storage/driver/posix/driver.o: storage/driver/posix/driver.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driver.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c storage/driver/posix/driver.c -o storage/driver/posix/driver.o
storage/driver/posix/driverFile.o: storage/driver/posix/driverFile.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverFile.h
$(CC) $(CFLAGS) -c storage/driver/posix/driverFile.c -o storage/driver/posix/driverFile.o
storage/driver/posix/driverRead.o: storage/driver/posix/driverRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h
$(CC) $(CFLAGS) -c storage/driver/posix/driverRead.c -o storage/driver/posix/driverRead.o
storage/driver/posix/driverWrite.o: storage/driver/posix/driverWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/driver.h storage/driver/posix/driverFile.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileWrite.h storage/info.h version.h
$(CC) $(CFLAGS) -c storage/driver/posix/driverWrite.c -o storage/driver/posix/driverWrite.o
storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverRead.h storage/fileRead.h
$(CC) $(CFLAGS) -c storage/fileRead.c -o storage/fileRead.o
storage/fileWrite.o: storage/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/driverWrite.h storage/fileWrite.h version.h
$(CC) $(CFLAGS) -c storage/fileWrite.c -o storage/fileWrite.o
storage/helper.o: storage/helper.c common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c storage/helper.c -o storage/helper.o
storage/storage.o: storage/storage.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/driver.h storage/driver/posix/driverRead.h storage/driver/posix/driverWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c storage/storage.c -o storage/storage.o

View File

@ -1,8 +1,8 @@
/***********************************************************************************************************************************
Time Management
***********************************************************************************************************************************/
#include "stdio.h"
#include "sys/time.h"
#include <stdio.h>
#include <sys/time.h>
#include "common/debug.h"
#include "common/time.h"

View File

@ -54,4 +54,172 @@ sub buildLastModTime
push @EXPORT, qw(buildLastModTime);
####################################################################################################################################
# Build a dependency tree for C files
####################################################################################################################################
sub buildDependencyTree
{
my $oStorage = shift;
my $rhDependencyTree = {};
# Iterate all files
foreach my $strFile (sort(keys(%{$oStorage->manifest('src')})))
{
# Only process non-auto files
if ($strFile =~ /^[A-Za-z0-9\/]+\.(c|h)$/)
{
buildDependencyTreeSub($oStorage, $rhDependencyTree, $strFile);
}
}
return $rhDependencyTree;
}
push @EXPORT, qw(buildDependencyTree);
sub buildDependencyTreeSub
{
my $oStorage = shift;
my $rhDependencyTree = shift;
my $strFile = shift;
if (!defined($rhDependencyTree->{$strFile}))
{
$rhDependencyTree->{$strFile} = {};
# Load file contents
my $rstrContent = $oStorage->get($oStorage->openRead("src/${strFile}", {bIgnoreMissing => true}));
if (!defined($rstrContent))
{
$rstrContent = $oStorage->get("libc/${strFile}");
}
# Process includes
my $rhInclude = {};
foreach my $strInclude (sort($$rstrContent =~ /\#include \".*\"$/mg))
{
$strInclude = (split('"', $strInclude))[1];
$rhInclude->{$strInclude} = true;
buildDependencyTreeSub($oStorage, $rhDependencyTree, $strInclude);
foreach my $strIncludeSub (@{$rhDependencyTree->{$strInclude}{include}})
{
$rhInclude->{$strIncludeSub} = true;
}
}
my @stryInclude = sort(keys(%{$rhInclude}));
$rhDependencyTree->{$strFile}{include} = \@stryInclude;
# Find header files that map to C files -- these are required to compile this file
foreach my $strInclude (@stryInclude)
{
if ($strInclude =~ /^[A-Za-z0-9\/]+\.h$/)
{
my $strObject = substr($strInclude, 0, length($strInclude) - 1) . 'c';
if ($oStorage->exists("src/${strObject}"))
{
push(@{$rhDependencyTree->{$strFile}{object}}, $strObject);
}
}
}
}
}
####################################################################################################################################
# Build Makefile object compile rules
####################################################################################################################################
sub buildMakefileObjectCompile
{
# Assign function parameters, defaults, and log debug info
my
(
$strOperation,
$oStorage,
$rhOption,
) =
logDebugParam
(
__PACKAGE__ . '::buildMakefile', \@_,
{name => 'oStorage'},
{name => 'rhOption', optional => true},
);
my $rhDependencyTree = buildDependencyTree($oStorage);
my $strMakefile;
foreach my $strFile (sort(keys(%{$rhDependencyTree})))
{
if ($strFile =~ /^[A-Za-z0-9\/]+\.c$/)
{
my $strObject = substr($strFile, 0, length($strFile) - 1) . 'o';
my $strDepend = "${strFile}";
foreach my $strInclude (@{$rhDependencyTree->{$strFile}{include}})
{
$strDepend .= ' ' . ($oStorage->exists("src/${strInclude}") ? '' : '../libc/') . $strInclude;
}
$strMakefile .=
(defined($strMakefile) ? "\n" : '') .
"${strObject}: ${strDepend}\n" .
"\t\$(CC) \$(CFLAGS)" . (defined($rhOption->{$strObject}) ? ' ' . $rhOption->{$strObject} : '') .
" -c ${strFile} -o ${strObject}\n";
}
}
return $strMakefile;
}
push @EXPORT, qw(buildMakefileObjectCompile);
####################################################################################################################################
# Update a Makefile with object compile rules
####################################################################################################################################
sub buildMakefile
{
# Assign function parameters, defaults, and log debug info
my
(
$strOperation,
$oStorage,
$strMakefile,
$rhOption,
) =
logDebugParam
(
__PACKAGE__ . '::buildMakefile', \@_,
{name => 'oStorage'},
{name => 'strMakeFile'},
{name => 'rhOption', optional => true},
);
# Trim off the end where the object compile is
my $strHeader = 'Compile rules';
$strMakefile =~ s/^\#.*${strHeader}(.|\s)+//mg;
# Add object compile section
$strMakefile .=
"# $strHeader\n" .
('#' x 132) . "\n" .
buildMakefileObjectCompile($oStorage, {rhOption => $rhOption});
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'strMakefile', value => $strMakefile},
);
}
push @EXPORT, qw(buildMakefile);
1;

View File

@ -466,6 +466,21 @@ eval
buildAll("${strBackRestBase}/src", $rhBuild);
}
# Auto-generate C Makefile
#-----------------------------------------------------------------------------------------------------------------------
if (!$bSmart || buildLastModTime($oStorageBackRest, "${strBackRestBase}", ['libc', 'src']) >
buildLastModTime($oStorageBackRest, "${strBackRestBase}", ['src'], 'Makefile'))
{
&log(INFO, " autogenerate C Makefile");
$oStorageBackRest->put(
"src/Makefile",
buildMakefile(
$oStorageBackRest,
${$oStorageBackRest->get("src/Makefile")},
{rhOption => {'postgres/pageChecksum.o' => '-funroll-loops -ftree-vectorize'}}));
}
if ($bGenOnly)
{
exit 0;
@ -786,28 +801,11 @@ eval
if ($bBinRequired)
{
my $strBinPath = "${strVagrantPath}/bin";
my $strBinSmart = "${strBinPath}/build.timestamp";
my $bRebuild = !$bSmart;
my @stryBinSrcPath = ('src', 'libc');
# Find the lastest modified time for dirs that affect the bin build
$lTimestampLast = buildLastModTime($oStorageBackRest, $strBackRestBase, \@stryBinSrcPath);
# Rebuild if the modification time of the smart file does equal the last changes in source paths
if ($bSmart)
{
if (!$oStorageBackRest->exists($strBinSmart) || $oStorageBackRest->info($strBinSmart)->mtime < $lTimestampLast)
{
&log(INFO, ' bin dependencies have changed, rebuilding...');
$bRebuild = true;
}
}
else
{
executeTest("sudo rm -rf ${strBinPath}");
}
# Loop through VMs to do the C bin builds
my $bLogDetail = $strLogLevel eq 'detail';
my @stryBuildVm = $strVm eq VM_ALL ? VM_LIST : ($strVm);
@ -815,6 +813,21 @@ eval
foreach my $strBuildVM (@stryBuildVm)
{
my $strBuildPath = "${strBinPath}/${strBuildVM}/src";
my $bRebuild = !$bSmart;
# Rebuild if the modification time of the smart file does equal the last changes in source paths
if ($bSmart)
{
my $strBinSmart = "${strBuildPath}/pgbackrest";
if (!$oStorageBackRest->exists($strBinSmart) ||
$oStorageBackRest->info($strBinSmart)->mtime < $lTimestampLast)
{
&log(INFO, " bin dependencies have changed for ${strBuildVM}, rebuilding...");
$bRebuild = true;
}
}
if ($bRebuild)
{
@ -829,10 +842,13 @@ eval
{
$oStorageBackRest->pathCreate(
"${strBinPath}/${strBuildVM}/${strBinSrcPath}", {bIgnoreExists => true, bCreateParent => true});
executeTest(
"rsync -rt ${strBackRestBase}/${strBinSrcPath}/* ${strBinPath}/${strBuildVM}/${strBinSrcPath}");
}
executeTest(
"rsync -rt" . (!$bSmart ? " --delete-excluded" : '') .
" --include=" . join('/*** --include=', @stryBinSrcPath) . '/*** --exclude=*' .
" ${strBackRestBase}/ ${strBinPath}/${strBuildVM}");
if (vmCoverage($strVm) && !$bNoLint)
{
&log(INFO, " clang static analyzer ${strBuildVM} (${strBuildPath})");
@ -852,11 +868,6 @@ eval
executeTest("docker rm -f test-build");
}
}
# Write files to indicate the last time a build was successful
$oStorageBackRest->put($strBinSmart);
utime($lTimestampLast, $lTimestampLast, $strBinSmart) or
confess "unable to set time for ${strBinSmart}" . (defined($!) ? ":$!" : '');
}
# Build the package