diff options
author | Richard Levitte <levitte@openssl.org> | 2018-03-13 17:56:20 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-03-13 19:24:26 +0100 |
commit | 249b4e28a6c91074f2fe276a2b2b40eb6f9639a9 (patch) | |
tree | dd251c63fd0e390f45c635fd2163b1f21a8eaf93 /util/add-depends.pl | |
parent | 3b855b1f892bb26aca760b331afe506527fe369c (diff) |
Refactor the 'depend' target
With the help of the perl script util/add-depends.pl, which takes all
its information directly from configdata.pm, the dependency adding
procedure can be streamlined for all support platforms.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5606)
Diffstat (limited to 'util/add-depends.pl')
-rw-r--r-- | util/add-depends.pl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/util/add-depends.pl b/util/add-depends.pl new file mode 100644 index 0000000000..a7b07b64ac --- /dev/null +++ b/util/add-depends.pl @@ -0,0 +1,50 @@ +#! /usr/bin/env perl +# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy +# in the file LICENSE in the source distribution or at +# https://www.openssl.org/source/license.html + +use lib '.'; +use configdata; + +use File::Compare qw(compare_text); + +my $buildfile = $config{build_file}; +my $buildfile_new = "$buildfile.$$"; +my $depext = $target{dep_extension} || ".d"; +my @deps = + grep { print STDERR "$_ exists: ", -f $_ ? "yes" : "no", "\n"; -f $_ } + map { (my $x = $_) =~ s|\.o$|$depext|; $x; } + grep { $unified_info{sources}->{$_}->[0] =~ /\.cc?$/ } + keys %{$unified_info{sources}}; + +print STDERR "\@deps = ( ", join(", ", @deps), " )\n"; + +open IBF, $buildfile or die "Trying to read $buildfile: $!\n"; +open OBF, '>', $buildfile_new or die "Trying to write $buildfile_new: $!\n"; +while (<IBF>) { + $force_rewrite = 0; + last if /^# DO NOT DELETE THIS LINE/; + print OBF or die "$!\n"; + $force_rewrite = 1; +} +close IBF; + +print OBF "# DO NOT DELETE THIS LINE -- make depend depends on it.\n"; + +foreach (@deps) { + open IBF,$_ or die "Trying to read $_: $!\n"; + while (<IBF>) { + print OBF or die "$!\n"; + } + close IBF; +} +close OBF; + +if (compare_text($buildfile_new, $buildfile) != 0) { + rename $buildfile_new, $buildfile + or die "Trying to rename $buildfile_new -> $buildfile: $!\n"; +} + |