2 # -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
12 # Use the CVS tag first otherwise use the portals version
18 my $tagfile = new IO::File;
19 if (!$tagfile->open("lustre/CVS/Tag")) {
20 my $verfile = new IO::File;
21 if (!$verfile->open("config.h")) {
24 while(defined($line = <$verfile>)) {
25 $line =~ /\#define VERSION "(.*)"/;
42 sub get_latest_mtime()
44 my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
45 "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
46 "Nov" => 10, "Dec" => 11);
49 my @entries = `find . -name Entries`;
51 foreach $entry_file (@entries) {
53 my $entry = new IO::File;
54 if (!$entry->open($entry_file)) {
55 die "unable to open $entry_file: $!\n";
58 while (defined($line = <$entry>)) {
60 #print "line: $line\n";
61 my ($junk, $file, $version, $date) = split(/\//, $line);
63 #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
64 #print "last_mtime: " . localtime($last_mtime) . "\n";
67 $file eq "lustre.spec.in" ||
68 $file !~ m/\.(c|h|am|in)$/) {
72 my $cur_dir = $entry_file;
73 $cur_dir =~ s/\/CVS\/Entries$//;
74 my @statbuf = stat("$cur_dir/$file");
75 my $mtime = $statbuf[9];
76 if (!defined($mtime)) {
79 my $local_date = gmtime($mtime);
80 if ($local_date ne $date &&
81 $file ne "lustre.spec.in") {
82 #print "$file : " . localtime($mtime) . "\n";
86 if ($mtime > $last_mtime) {
91 my @t = split(/ +/, $date);
93 #print "skipping: $date\n";
96 my ($hours, $min, $sec) = split(/:/, $t[3]);
97 my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
100 $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
101 if ($secs > $last_mtime) {
113 my $config = new IO::File;
115 if (!$config->open("Makefile")) {
116 die "Run ./configure first\n";
118 while (defined($line = <$config>)) {
120 if ($line =~ /LINUX :?= (.*)/) {
126 my $ver = new IO::File;
127 if (!$ver->open("$dir/include/linux/version.h")) {
128 die "Run make dep on $dir\n";
130 while(defined($line = <$ver>)) {
131 $line =~ /\#define UTS_RELEASE "(.*)"/;
143 sub generate_ver($$$)
147 my $linuxdir = shift;
149 #print "localtime: " . localtime($mtime) . "\n";
151 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
155 my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
158 print "#define BUILD_VERSION \"";
160 my $lustre_vers = $ENV{LUSTRE_VERS};
163 print "$tag-$lustre_vers\"\n";
164 } elsif ($pristine) {
165 print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
167 print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
170 chomp(my $cwd = `pwd`);
175 # for get_latest_mtime and get_tag you need to be in srcdir
181 my $mtime = get_latest_mtime();
183 # for get_linuxdir you need to be in builddir
189 #my $linuxdir = get_linuxdir();
191 my $linuxdir = '@LINUX@';
192 $linuxdir =~ s/\//\./g;
193 $kernver = '@LINUXRELEASE@';
195 generate_ver($tag, $mtime, $linuxdir);