[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Allow to work on systems without Fcntl::flock implementation.

From: Ralf Wildenhues
Subject: Allow to work on systems without Fcntl::flock implementation.
Date: Tue, 8 Sep 2009 07:05:51 +0200
User-agent: Mutt/1.5.20 (2009-08-09)

This allows to configure git Autoconf on DJGPP, which doesn't provide
file locking.

Note the workaround isn't checking whether flock works on this
particular file system -- the code should already treat that
error condition correctly.  DJGPP perl just barfs when it sees flock,
the code never returns.

The patch is a bit of a hack, as it would be cleaner to put this right
into  However, that would require us to either fork from the
Automake copy of the file, or also integrate this there.  WDYT?

(For a subsequent 'make' to work, it needs disabling frozen files;
TBD in a later patch.)


   Allow to work on systems without Fcntl::flock implementation.
   * (PERL_FLOCK): New substitution variable with test
   whether Fcntl::flock is implemented by the system.
   * bin/ (edit): Substitute @address@hidden
   * bin/ Call XFile::lock only if flock is

diff --git a/bin/ b/bin/
index da65b85..c84f5ae 100644
--- a/bin/
+++ b/bin/
@@ -38,6 +38,7 @@ RELEASE_YEAR = \
 edit = sed \
        -e 's|@address@hidden|$(SHELL)|g' \
        -e 's|@address@hidden|$(PERL)|g' \
+       -e 's|@address@hidden|$(PERL_FLOCK)|g' \
        -e 's|@address@hidden|$(bindir)|g' \
        -e 's|@address@hidden|$(pkgdatadir)|g' \
        -e 's|@address@hidden|$(prefix)|g' \
diff --git a/bin/ b/bin/
index 9f8faa3..6202a47 100644
--- a/bin/
+++ b/bin/
@@ -66,6 +66,8 @@ my $tcache;
 my $ocache;
 my $icache_file;
+my $flock_implemented = '@PERL_FLOCK@';
 # The macros to trace mapped to their format, as specified by the
 # user.
 my %trace;
@@ -978,7 +980,8 @@ if (! -d "$cache")
 # files, but the index is the first and last file to be updated, so
 # locking it is sufficient.
 $icache_file = new Autom4te::XFile $icache, O_RDWR|O_CREAT;
-$icache_file->lock (LOCK_EX);
+$icache_file->lock (LOCK_EX)
+  if ($flock_implemented eq "yes");
 # Read the cache index if available and older than autom4te itself.
 # If autom4te is younger, then some structures such as C4che might
diff --git a/ b/
index 0d579f8..1241264 100644
--- a/
+++ b/
@@ -137,6 +137,22 @@ $PERL -e 'require 5.005_03;' || {
    AC_MSG_ERROR([Perl 5.005_03 or better is required])
+# Find out whether the system supports flock
+# Note this test does not try to find out whether it works with this
+# particular file system.  It merely avoids us running flock on systems
+# where that bails out.
+AC_CACHE_CHECK([whether $PERL Fcntl::flock is implemented],
+  [ac_cv_perl_flock_implemented],
+  [echo lock me > conftest.fil
+   if $PERL -e 'use Fcntl ":flock"; flock("conftest.fil", LOCK_EX); 1;'; then
+     ac_cv_perl_flock_implemented=yes
+   else
+     ac_cv_perl_flock_implemented=no
+   fi
+   rm -f conftest.fil
+  ])
+AC_SUBST([PERL_FLOCK], [$ac_cv_perl_flock_implemented])
 ## ------- ##
 ## Emacs.  ##

reply via email to

[Prev in Thread] Current Thread [Next in Thread]