diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 1ef6cdefe..10acf160e 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -23,6 +23,12 @@
Use time_t
instead of __time_t
for better portability.
+
+
+
+ Build libc using links rather than referencing the C files in src directly. The C library builds with different options which should not be reused for the C binary or vice versa.
+
+
diff --git a/libc/Makefile.PL b/libc/Makefile.PL
index 0405fa6ba..32065e325 100644
--- a/libc/Makefile.PL
+++ b/libc/Makefile.PL
@@ -13,7 +13,6 @@ $SIG{__DIE__} = sub { Carp::confess @_ };
use Cwd qw(abs_path);
use ExtUtils::MakeMaker;
use File::Basename qw(dirname);
-use File::Copy qw(copy);
use lib dirname($0) . '/lib';
use pgBackRest::LibCAuto;
@@ -112,10 +111,28 @@ my @stryCFile =
'storage/storage.c',
);
-# Add ../src for files that are outside libc
+# Link source files to build the C library. The library has different build options and we don't want the bin build to reuse any of
+# them. Also, this makes the output of the __FILE__ macro prettier.
for (my $iFileIdx = 1; $iFileIdx < @stryCFile; $iFileIdx++)
{
- $stryCFile[$iFileIdx] = '../src/' . $stryCFile[$iFileIdx];
+ # Make directory
+ system("mkdir -p " . dirname($stryCFile[$iFileIdx])) == 0
+ or die('unable to mkdir ' . dirname($stryCFile[$iFileIdx]));
+
+ # Link the file to the source directory
+ my @stryLink = split('/', $stryCFile[$iFileIdx]);
+ my $strLink;
+
+ for (my $iLinkIdx = 0; $iLinkIdx < @stryLink; $iLinkIdx++)
+ {
+ $strLink .= (defined($strLink) ? '/' : '') . '..';
+ }
+
+ if (!-l $stryCFile[$iFileIdx])
+ {
+ system("ln -s ${strLink}/src/$stryCFile[$iFileIdx] $stryCFile[$iFileIdx]") == 0
+ or die("unable to link ../src/$stryCFile[$iFileIdx] to $stryCFile[$iFileIdx]");
+ }
}
# Write the makefile
diff --git a/src/config/config.c b/src/config/config.c
index 47eb9bf29..cc75f6759 100644
--- a/src/config/config.c
+++ b/src/config/config.c
@@ -69,7 +69,7 @@ typedef struct ConfigOptionData
/***********************************************************************************************************************************
Include the automatically generated configuration data
***********************************************************************************************************************************/
-#include "config.auto.c"
+#include "config/config.auto.c"
/***********************************************************************************************************************************
Debug Asserts
diff --git a/src/config/define.c b/src/config/define.c
index 18a6de85e..e74cd0710 100644
--- a/src/config/define.c
+++ b/src/config/define.c
@@ -170,7 +170,7 @@ typedef enum
/***********************************************************************************************************************************
Include the automatically generated configuration data.
***********************************************************************************************************************************/
-#include "define.auto.c"
+#include "config/define.auto.c"
/***********************************************************************************************************************************
Find optional data for a command and option.
diff --git a/src/config/parse.c b/src/config/parse.c
index 33ccb5d32..6c6931055 100644
--- a/src/config/parse.c
+++ b/src/config/parse.c
@@ -47,7 +47,7 @@ Parse option flags
/***********************************************************************************************************************************
Include automatically generated data structure for getopt_long()
***********************************************************************************************************************************/
-#include "parse.auto.c"
+#include "config/parse.auto.c"
/***********************************************************************************************************************************
Struct to hold options parsed from the command line