autogen.sh |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 037de86626d2860969860d61d63f35e804f19c85
Author:     Christian Lohmaier <[email protected]>
AuthorDate: Tue Jul 8 12:14:32 2025 +0200
Commit:     Christian Lohmaier <[email protected]>
CommitDate: Wed Jul 9 11:21:51 2025 +0200

    improve builddir!=srcdir detection with case-preserving filesystems
    
    on Windows and macOS autogen.sh could misdetect the build directory as
    being different from the source directory if the filesystem is
    case-preserving but not case-sensitive. e.g.
    
    cd ~/BuildDir ; ~/builddir/autogen.sh
    
    It is the same directory, but treated as a different one and thus
    autogen would create the module/Makefile files and also a link to the
    include directory. That however then ends up being a include/include
    link and that then fails the skia build.
    
    So use the same method to get both paths to avoid the problem.
    Change from cwd() to getcwd() since despite the documentation saying it
    would be the same, getcwd is actually returning the actual name as
    stored in the filesystem. Also use the module's chdir so that the PWD
    environment variable doesn't need to be set manually.
    
    Change-Id: I705dc584a91be9f63052bd1f72d4a0c4ba73f3ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187536
    Reviewed-by: Christian Lohmaier <[email protected]>
    Reviewed-by: Regina Henschel <[email protected]>
    Tested-by: Jenkins

diff --git a/autogen.sh b/autogen.sh
index 6667c87c17f1..0ce8c343d2f1 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -17,19 +17,24 @@
         if 0;
 
 use strict;
-use Cwd ('cwd', 'realpath');
+# use Cwd's chdir to also set PWD environment variable
+use Cwd ('chdir', 'getcwd', 'realpath');
 use File::Basename;
 
 my $src_path=dirname(realpath($0));
-my $build_path=realpath(cwd());
+my $build_path=realpath(getcwd());
+
+# workaround for case-preserving filesystems to get the canonical name
+# otherwise the src_path may be different from the build_path by case only
+# and mess up the builddir != srcdir handling
+chdir($src_path);
+$src_path=getcwd();
+
 # since this looks crazy, if you have a symlink on a path up to and including
 # the current directory, we need our configure to run in the realpath of that
 # such that compiled (realpath'd) dependency filenames match the filenames
 # used in our makefiles - ie. this gets dependencies right via SRC_ROOT
 chdir ($build_path);
-# more amazingly, if you don't clobber 'PWD' shells will re-assert their
-# old path from the environment, not cwd.
-$ENV{PWD} = $build_path;
 
 my $aclocal;
 my $autoconf;

Reply via email to