source: branches/profile/SOURCE_TOOLS/binuptodate.pl

Last change on this file was 8567, checked in by epruesse, 12 years ago

remove LIBLINK

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6my $args = @ARGV;
7if ($args==0) { die "Usage: binuptodate.pl target [sources]+\n"; }
8my $target = $ARGV[0];
9my $arbhome = $ENV{'ARBHOME'};
10(-d $arbhome) || die "\$arbhome has to contain the name of a directory.\n";
11my $target_date = -1;
12
13sub filedate($) {
14  my $filename = $_[0];
15  my @stat_res = stat($filename);
16  return($stat_res[9]); # the files modification date
17}
18
19sub ok_if_older($) {
20  my $filename = $_[0];
21
22}
23
24sub first_existing(@) {
25  my $idx = 0;
26  my $count = @_;
27  while ($idx<$count) {
28    if (-f $_[$idx]) { return($_[$idx]); }
29    $idx++;
30  }
31  return undef;
32}
33
34sub uptodate() {
35  print STDERR "-------------------- Checking $target\n";
36  (-f $target) || die "Target '$target' not found\n";
37
38  my $source_idx = 1;
39  $target_date = filedate($target);
40
41  while ($source_idx<$args) {
42    my $source = $ARGV[$source_idx];
43
44    if ($source =~ /^\-l/) { # handle libs specified with -l
45      my $libbase = $';
46      my $fulllib = first_existing((
47                                    $arbhome.'/lib/lib'.$libbase.'.a',
48                                    $arbhome.'/lib/lib'.$libbase.'.so',
49                                   ));
50
51      if (not defined $fulllib) {
52        # print STDERR "can't detect where '$source' resides -- ignoring this dependency\n";
53        $source = undef;
54      }
55      else {
56        # print STDERR "fulllib='$fulllib'\n";
57        $source=$fulllib;
58      }
59    }
60    elsif ($source =~ /^\-L/) {
61      $source = undef;
62    }
63
64    if (defined $source) {
65      (-f $source) || die "Source missing: $source\n";
66      my $source_date = filedate($source);
67      ($source_date <= $target_date) || die "Changed source: $source (".localtime($source_date).")\n";
68    }
69    $source_idx++;
70  }
71
72}
73
74eval { uptodate(); };
75if ($@) {
76  print STDERR "$@-> rebuilding $target (".localtime($target_date).")\n";
77  exit(1);
78}
79
80print STDERR "$target is up-to-date.\n";
81exit(0);
82
Note: See TracBrowser for help on using the repository browser.