[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/8] automake: refactor, break up 'require_file_internal'
From: |
Stefano Lattarini |
Subject: |
[PATCH 6/8] automake: refactor, break up 'require_file_internal' |
Date: |
Sun, 9 Oct 2011 10:53:02 +0200 |
This refactoring is only required in view of future changes.
* automake.in (require_file_internal): Move the guts of this
function ...
(required_file_check_or_copy): ... into this new function. This
ensures that calls to `push_required_file' and code that copies
required files are placed in separate functions; this will be
very useful for reorganizing de-serialization of file installs
in future changes.
---
ChangeLog | 12 +++
automake.in | 215 ++++++++++++++++++++++++++++++-----------------------------
2 files changed, 122 insertions(+), 105 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3660fbb..299738f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2011-10-08 Stefano Lattarini <address@hidden>
+ automake: refactor, break up 'require_file_internal'
+ This refactoring is only required in view of future changes.
+ * automake.in (require_file_internal): Move the guts of this
+ function ...
+ (required_file_check_or_copy): ... into this new function. This
+ ensures that calls to `push_required_file' and code that copies
+ required files are placed in separate functions; this will be
+ very useful for reorganizing de-serialization of file installs
+ in future changes.
+
+2011-10-08 Stefano Lattarini <address@hidden>
+
dist: separate auxiliary file instantiation from DIST_COMMON update
This change simplifies the automake internals dealing with the
checking, copying and distributing of required auxiliary files.
diff --git a/automake.in b/automake.in
index 9d51b8d..d75bc0b 100644
--- a/automake.in
+++ b/automake.in
@@ -7666,125 +7666,130 @@ sub push_required_file
# than once.
my %required_file_not_found = ();
-# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES)
-# --------------------------------------------------------------
+# &required_file_check_or_copy ($WHERE, $DIRECTORY, $FILE)
+# --------------------------------------------------------
# Verify that the file must exist in $DIRECTORY, or install it.
-# $MYSTRICT is the strictness level at which this file becomes required.
-sub require_file_internal ($$$@)
+sub required_file_check_or_copy ($$$)
{
- my ($where, $mystrict, $dir, @files) = @_;
+ my ($where, $dir, $file) = @_;
- foreach my $file (@files)
+ my $fullfile = "$dir/$file";
+ my $found_it = 0;
+ my $dangling_sym = 0;
+
+ if (-l $fullfile && ! -f $fullfile)
{
- next
- unless $strictness >= $mystrict;
+ $dangling_sym = 1;
+ }
+ elsif (dir_has_case_matching_file ($dir, $file))
+ {
+ $found_it = 1;
+ }
- my $fullfile = "$dir/$file";
- my $found_it = 0;
- my $dangling_sym = 0;
+ # `--force-missing' only has an effect if `--add-missing' is
+ # specified.
+ return
+ if $found_it && (! $add_missing || ! $force_missing);
- push_required_file ($dir, $file, $fullfile);
+ # If we've already looked for it, we're done. You might
+ # wonder why we don't do this before searching for the
+ # file. If we do that, then something like
+ # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
+ # DIST_COMMON.
+ if (! $found_it)
+ {
+ return if defined $required_file_not_found{$fullfile};
+ $required_file_not_found{$fullfile} = 1;
+ }
+ if ($dangling_sym && $add_missing)
+ {
+ unlink ($fullfile);
+ }
- if (-l $fullfile && ! -f $fullfile)
- {
- $dangling_sym = 1;
- }
- elsif (dir_has_case_matching_file ($dir, $file))
- {
- $found_it = 1;
- }
+ my $trailer = '';
+ my $trailer2 = '';
+ my $suppress = 0;
- # `--force-missing' only has an effect if `--add-missing' is
- # specified.
- if ($found_it && (! $add_missing || ! $force_missing))
- {
- next;
- }
- else
- {
- # If we've already looked for it, we're done. You might
- # wonder why we don't do this before searching for the
- # file. If we do that, then something like
- # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
- # DIST_COMMON.
- if (! $found_it)
- {
- next if defined $required_file_not_found{$fullfile};
- $required_file_not_found{$fullfile} = 1;
- }
- # FIXME: re-indent this correctly
- if ($dangling_sym && $add_missing)
- {
- unlink ($fullfile);
- }
+ # Only install missing files according to our desired
+ # strictness level.
+ my $message = "required file `$fullfile' not found";
+ if ($add_missing)
+ {
+ if (-f "$libdir/$file")
+ {
+ $suppress = 1;
- my $trailer = '';
- my $trailer2 = '';
- my $suppress = 0;
+ # Install the missing file. Symlink if we
+ # can, copy if we must. Note: delete the file
+ # first, in case it is a dangling symlink.
+ $message = "installing `$fullfile'";
- # Only install missing files according to our desired
- # strictness level.
- my $message = "required file `$fullfile' not found";
- if ($add_missing)
- {
- if (-f "$libdir/$file")
- {
- $suppress = 1;
-
- # Install the missing file. Symlink if we
- # can, copy if we must. Note: delete the file
- # first, in case it is a dangling symlink.
- $message = "installing `$fullfile'";
-
- # The license file should not be volatile.
- if ($file eq "COPYING")
- {
- $message .= " using GNU General Public License v3
file";
- $trailer2 = "\n Consider adding the COPYING file"
- . " to the version control system"
- . "\n for your code, to avoid questions"
- . " about which license your project uses";
- }
+ # The license file should not be volatile.
+ if ($file eq "COPYING")
+ {
+ $message .= " using GNU General Public License v3 file";
+ $trailer2 = "\n Consider adding the COPYING file"
+ . " to the version control system"
+ . "\n for your code, to avoid questions"
+ . " about which license your project uses";
+ }
- # Windows Perl will hang if we try to delete a
- # file that doesn't exist.
- unlink ($fullfile) if -f $fullfile;
- if ($symlink_exists && ! $copy_missing)
- {
- if (! symlink ("$libdir/$file", $fullfile)
- || ! -e $fullfile)
- {
- $suppress = 0;
- $trailer = "; error while making link: $!";
- }
- }
- elsif (system ('cp', "$libdir/$file", $fullfile))
- {
- $suppress = 0;
- $trailer = "\n error while copying";
- }
- set_dir_cache_file ($dir, $file);
- }
- }
- else
- {
- $trailer = "\n `automake --add-missing' can install `$file'"
- if -f "$libdir/$file";
- }
+ # Windows Perl will hang if we try to delete a
+ # file that doesn't exist.
+ unlink ($fullfile) if -f $fullfile;
+ if ($symlink_exists && ! $copy_missing)
+ {
+ if (! symlink ("$libdir/$file", $fullfile)
+ || ! -e $fullfile)
+ {
+ $suppress = 0;
+ $trailer = "; error while making link: $!";
+ }
+ }
+ elsif (system ('cp', "$libdir/$file", $fullfile))
+ {
+ $suppress = 0;
+ $trailer = "\n error while copying";
+ }
+ set_dir_cache_file ($dir, $file);
+ }
+ }
+ else
+ {
+ $trailer = "\n `automake --add-missing' can install `$file'"
+ if -f "$libdir/$file";
+ }
- # If --force-missing was specified, and we have
- # actually found the file, then do nothing.
- next
- if $found_it && $force_missing;
+ # If --force-missing was specified, and we have
+ # actually found the file, then do nothing.
+ return
+ if $found_it && $force_missing;
- # If we couldn't install the file, but it is a target in
- # the Makefile, don't print anything. This allows files
- # like README, AUTHORS, or THANKS to be generated.
- next
- if !$suppress && rule $file;
+ # If we couldn't install the file, but it is a target in
+ # the Makefile, don't print anything. This allows files
+ # like README, AUTHORS, or THANKS to be generated.
+ return
+ if !$suppress && rule $file;
- msg ($suppress ? 'note' : 'error', $where,
"$message$trailer$trailer2");
- }
+ msg ($suppress ? 'note' : 'error', $where, "$message$trailer$trailer2");
+}
+
+
+# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES)
+# --------------------------------------------------------------
+# Verify that the file must exist in $DIRECTORY, or install it.
+# $MYSTRICT is the strictness level at which this file becomes required.
+sub require_file_internal ($$$@)
+{
+ my ($where, $mystrict, $dir, @files) = @_;
+
+ return
+ unless $strictness >= $mystrict;
+
+ foreach my $file (@files)
+ {
+ push_required_file ($dir, $file, "$dir/$file");
+ required_file_check_or_copy ($where, $dir, $file);
}
}
--
1.7.2.3
- [PATCH 0/8] Reorganize automake internals for distribution tarball creation, Stefano Lattarini, 2011/10/09
- [PATCH 4/8] refactor: rename a subroutine to a more proper name, Stefano Lattarini, 2011/10/09
- [PATCH 2/8] dist: simplify automake code accordingly to the previous changes, Stefano Lattarini, 2011/10/09
- [PATCH 3/8] dist: truly always distribute files in AC_REQUIRE_AUX_FILE, Stefano Lattarini, 2011/10/09
- [PATCH 1/8] dist: auxiliary files can be distributed from subdir Makefiles, Stefano Lattarini, 2011/10/09
- [PATCH 5/8] dist: separate auxiliary file instantiation from DIST_COMMON update, Stefano Lattarini, 2011/10/09
- [PATCH 8/8] tests: fix spurious failure with Solaris /bin/sh, Stefano Lattarini, 2011/10/09
- [PATCH 7/8] threaded-am: better serialization for required config files, Stefano Lattarini, 2011/10/09
- [PATCH 6/8] automake: refactor, break up 'require_file_internal',
Stefano Lattarini <=
- Re: [PATCH 0/8] Reorganize automake internals for distribution tarball creation, Stefano Lattarini, 2011/10/12
- [FYI 9/8] {dist-refactor} cosmetics: remove obsolete comment, Stefano Lattarini, 2011/10/17