work around a make bug in define/endef handling
[openwrt.git] / scripts / timestamp.pl
1 #!/usr/bin/perl
2 use strict;
3
4 sub get_ts($$) {
5 my $path = shift;
6 my $options = shift;
7 my $ts = 0;
8 my $fn = "";
9 -d "$path" and $path .= "/*";
10 open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
11 while (<FIND>) {
12 chomp;
13 my $file = $_;
14 open FILE, "<$file";
15 my @stat = stat FILE;
16 close FILE;
17 if ($stat[9] > $ts) {
18 $ts = $stat[9];
19 $fn = $file;
20 }
21 }
22 close FIND;
23 return ($ts, $fn);
24 }
25
26 (@ARGV > 0) or push @ARGV, ".";
27 my $ts = 0;
28 my $n = ".";
29 my %options;
30 while (@ARGV > 0) {
31 my $path = shift @ARGV;
32 if ($path =~ /^-x/) {
33 my $str = shift @ARGV;
34 $options{"-x"} .= " -and -not -path \\*".$str."\\*"
35 } elsif ($path =~ /^-/) {
36 $options{$path} = 1;
37 } else {
38 my ($tmp, $fname) = get_ts($path, $options{"-x"});
39 if ($tmp > $ts) {
40 if ($options{'-f'}) {
41 $n = $fname;
42 } else {
43 $n = $path;
44 }
45 $ts = $tmp;
46 }
47 }
48 }
49
50 if ($options{"-p"}) {
51 print "$n\n";
52 } elsif ($options{"-t"}) {
53 print "$ts\n";
54 } else {
55 print "$n\t$ts\n";
56 }
This page took 0.048036 seconds and 5 git commands to generate.