madwifi: fix cflags for generic mips hal
[openwrt.git] / scripts / timestamp.pl
1 #!/usr/bin/perl
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 use strict;
10
11 sub get_ts($$) {
12 my $path = shift;
13 my $options = shift;
14 my $ts = 0;
15 my $fn = "";
16 open FIND, "find $path -type f -and -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
17 while (<FIND>) {
18 chomp;
19 my $file = $_;
20 next if -l $file;
21 my @stat = stat $file;
22 if ($stat[9] > $ts) {
23 $ts = $stat[9];
24 $fn = $file;
25 }
26 }
27 close FIND;
28 return ($ts, $fn);
29 }
30
31 (@ARGV > 0) or push @ARGV, ".";
32 my $ts = 0;
33 my $n = ".";
34 my %options;
35 while (@ARGV > 0) {
36 my $path = shift @ARGV;
37 if ($path =~ /^-x/) {
38 my $str = shift @ARGV;
39 $options{"findopts"} .= " -and -not -path '".$str."'"
40 } elsif ($path =~ /^-f/) {
41 $options{"findopts"} .= " -follow";
42 } elsif ($path =~ /^-n/) {
43 my $arg = $ARGV[0];
44 $options{$path} = $arg;
45 } elsif ($path =~ /^-/) {
46 $options{$path} = 1;
47 } else {
48 my ($tmp, $fname) = get_ts($path, $options{"findopts"});
49 if ($tmp > $ts) {
50 if ($options{'-F'}) {
51 $n = $fname;
52 } else {
53 $n = $path;
54 }
55 $ts = $tmp;
56 }
57 }
58 }
59
60 if ($options{"-n"}) {
61 exit ($n eq $options{"-n"} ? 0 : 1);
62 } elsif ($options{"-p"}) {
63 print "$n\n";
64 } elsif ($options{"-t"}) {
65 print "$ts\n";
66 } else {
67 print "$n\t$ts\n";
68 }
This page took 0.055699 seconds and 5 git commands to generate.