From: Ralf Wildenhues Date: Wed, 9 Sep 2009 05:27:39 +0000 (+0200) Subject: Allow to work on systems without Fcntl::flock implementation. X-Git-Tag: v2.65~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b5d0c58422905f2cd1202cd685060a82e1e0673;p=thirdparty%2Fautoconf.git Allow to work on systems without Fcntl::flock implementation. * configure.ac (PERL_FLOCK): New substitution variable with test whether Fcntl::flock is implemented by the system. * bin/Makefile.am (edit): Substitute @PERL_FLOCK@. * bin/autom4te.in: Call XFile::lock only if flock is implemented. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index d074681b1..a6e453db2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-09-09 Ralf Wildenhues + + Allow to work on systems without Fcntl::flock implementation. + * configure.ac (PERL_FLOCK): New substitution variable with test + whether Fcntl::flock is implemented by the system. + * bin/Makefile.am (edit): Substitute @PERL_FLOCK@. + * bin/autom4te.in: Call XFile::lock only if flock is + implemented. + 2009-09-04 Reuben Thomas (tiny change) Mention the Autoconf archive. diff --git a/bin/Makefile.am b/bin/Makefile.am index da65b85ff..c84f5ae89 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -38,6 +38,7 @@ RELEASE_YEAR = \ edit = sed \ -e 's|@SHELL[@]|$(SHELL)|g' \ -e 's|@PERL[@]|$(PERL)|g' \ + -e 's|@PERL_FLOCK[@]|$(PERL_FLOCK)|g' \ -e 's|@bindir[@]|$(bindir)|g' \ -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ -e 's|@prefix[@]|$(prefix)|g' \ diff --git a/bin/autom4te.in b/bin/autom4te.in index 3103369c7..d1aae949f 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -68,6 +68,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; @@ -981,7 +983,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/configure.ac b/configure.ac index 0d579f8cb..124126417 100644 --- a/configure.ac +++ b/configure.ac @@ -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. ##