mklink: Do not needlessly overwrite linked files...
authorOrgad Shaneh <orgads@gmail.com>
Sun, 31 Jul 2016 06:18:22 +0000 (09:18 +0300)
committerOrgad Shaneh <orgads@gmail.com>
Wed, 16 Nov 2016 07:08:27 +0000 (09:08 +0200)
... on systems with symlinks.

Creating or overwriting a symlink sets the file ctime to the current time.
This causes needless rebuilds because the time of all the headers is
changed, and apparently make considers the link's time rather than the
time of the target.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1370)

util/mklink.pl

index 2df0453a17a3a1e9e6bfe74101240a831867743d..a937606ea5c2319cdcacfa03a1f4f7d5454d24af 100755 (executable)
@@ -55,8 +55,10 @@ if ($^O eq "msys") { $symlink_exists=0 };
 foreach $file (@files) {
     my $err = "";
     if ($symlink_exists) {
-       unlink "$from/$file";
-       symlink("$to/$file", "$from/$file") or $err = " [$!]";
+        if (!-l "$from/$file") {
+           unlink "$from/$file";
+           symlink("$to/$file", "$from/$file") or $err = " [$!]";
+       }
     } elsif (-d "$from" && (!-f "$from/$file" || ((stat("$file"))[9] > (stat("$from/$file"))[9]))) {
        unlink "$from/$file"; 
        open (OLD, "<$file") or die "Can't open $file: $!";