Fix for PR automake/38:
authorTom Tromey <tromey@redhat.com>
Sun, 19 Mar 2000 22:25:13 +0000 (22:25 +0000)
committerTom Tromey <tromey@redhat.com>
Sun, 19 Mar 2000 22:25:13 +0000 (22:25 +0000)
* automake.in (require_file_internal): Check for and handle
dangling symlinks.  Fixes symlink2.test.

ChangeLog
automake.in

index 39b7b47..403b70d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2000-03-19  Tom Tromey  <tromey@cygnus.com>
 
+       Fix for PR automake/38:
+       * automake.in (require_file_internal): Check for and handle
+       dangling symlinks.  Fixes symlink2.test.
+
        Fix for PR automake/45:
        * automake.texi (configure): Mention requirement to run
        AM_INIT_AUTOMAKE.
index e6db433..87c2693 100755 (executable)
@@ -7432,7 +7432,7 @@ sub require_file_internal
 {
     local ($is_configure, $line, $mystrict, @files) = @_;
     local ($file, $fullfile);
-    local ($found_it, $errfile, $errdir);
+    local ($found_it, $dangling_sym, $errfile, $errdir);
     local ($save_dir);
 
     foreach $file (@files)
@@ -7442,6 +7442,7 @@ sub require_file_internal
        $require_file_found{$file} = 1;
 
        $found_it = 0;
+       $dangling_sym = 0;
        foreach $dir (@require_file_paths)
        {
            if ($dir eq '.')
@@ -7461,7 +7462,12 @@ sub require_file_internal
            # config_aux_path.
            $errfile = $errdir . '/' . $file;
 
-           if (-f $fullfile)
+           if (-l $fullfile && ! -f _)
+           {
+               $dangling_sym = 1;
+               last;
+           }
+           elsif (-f $fullfile)
            {
                $found_it = 1;
                &maybe_push_required_file ($dir, $file, $fullfile);
@@ -7479,6 +7485,11 @@ sub require_file_internal
        {
            if ($strictness >= $mystrict)
            {
+               if ($dangling_sym)
+               {
+                   unlink ($fullfile);
+               }
+
                local ($trailer) = '';
                local ($suppress) = 0;
 
@@ -7512,13 +7523,13 @@ sub require_file_internal
                            if (! symlink ($am_dir . '/' . $file, $errfile))
                            {
                                $suppress = 0;
-                               $trailer = "; error while making link: $!\n";
+                               $trailer = "; error while making link: $!";
                            }
                        }
                        elsif (system ('cp', $am_dir . '/' . $file, $errfile))
                        {
                            $suppress = 0;
-                           $trailer = "\n    error while copying\n";
+                           $trailer = "\n    error while copying";
                        }
                    }