Last change
on this file was
2749,
checked in by westram, 21 years ago
|
- checks whether target is uptodate (used to avoid unnecessary linking)
|
-
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 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | |
---|
6 | my $args = @ARGV; |
---|
7 | if ($args==0) { die "Usage: binuptodate.pl target [sources]+\n"; } |
---|
8 | my $target = $ARGV[0]; |
---|
9 | my $arbhome = $ENV{'ARBHOME'}; |
---|
10 | (-d $arbhome) || die "\$arbhome has to contain the name of a directory.\n"; |
---|
11 | my $target_date = -1; |
---|
12 | |
---|
13 | sub filedate($) { |
---|
14 | my $filename = $_[0]; |
---|
15 | my @stat_res = stat($filename); |
---|
16 | return($stat_res[9]); # the files modification date |
---|
17 | } |
---|
18 | |
---|
19 | sub ok_if_older($) { |
---|
20 | my $filename = $_[0]; |
---|
21 | |
---|
22 | } |
---|
23 | |
---|
24 | sub 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 | |
---|
34 | sub 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.'/LIBLINK/lib'.$libbase.'.a', |
---|
48 | $arbhome.'/LIBLINK/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 | |
---|
74 | eval { uptodate(); }; |
---|
75 | if ($@) { |
---|
76 | print STDERR "$@-> rebuilding $target (".localtime($target_date).")\n"; |
---|
77 | exit(1); |
---|
78 | } |
---|
79 | |
---|
80 | print STDERR "$target is up-to-date.\n"; |
---|
81 | exit(0); |
---|
82 | |
---|
Note: See
TracBrowser
for help on using the repository browser.