2 # -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
6 # get all of the values we want out of the autoMakefile
7 sub read_autoMakefile() {
9 my $file = new IO::File;
10 my ($line, $dir, $objdir, $modules, $version, $local_version, $buildid);
11 if (!$file->open("autoMakefile")) {
12 die "Run ./configure first\n";
15 while (defined($line = <$file>)) {
17 if ($line =~ /^LINUX :?= (.*)/) {
19 } elsif ($line =~ /^LINUX_OBJ :?= (.*)/) {
21 } elsif ($line =~ /^MODULES_TRUE = #/ ||
22 $line =~ /^MODULE_TARGET = $/) {
23 # modules are not being built
25 } elsif ($line =~ /^VERSION = (.*)/) {
27 } elsif ($line =~ /^DOWNSTREAM_RELEASE = (.*)/ && $1 ne "") {
28 $local_version = "$1";
29 } elsif ($line =~ /^BUILDID = (.*)/ && $1 ne "") {
35 return ($dir, $objdir, $modules, $version, $local_version, $buildid);
45 my $ver = new IO::File;
46 if (!$ver->open("$objdir/include/linux/utsrelease.h") &&
47 !$ver->open("$objdir/include/linux/version.h") &&
48 !$ver->open("$dir/include/linux/utsrelease.h") &&
49 !$ver->open("$dir/include/linux/version.h")) {
50 die "Run make dep on '$dir'\n";
53 while(defined($line = <$ver>)) {
54 $line =~ /\#define UTS_RELEASE "(.*)"/;
66 sub generate_ver($$$$$$$)
70 my $local_version = shift;
77 print "#define BUILD_VERSION \"$tag";
80 print "-$env_vers\"\n";
84 if ($local_version ne "") {
85 print "-$local_version";
89 # if we want to get rid of the PRISTINE/CHANGED thing, get rid of these
90 # lines. maybe we only want to print -CHANGED when something is changed
91 # and print nothing when it's pristine
107 $progname =~ s/.*\///;
109 chomp(my $cwd = `pwd`);
112 $path =~ s/(.+)\/.*/\1/;
113 push(@INC, $cwd . "/" . $path);
121 # need to be in srcdir
128 require "version_tag-git.pl";
131 require "version_tag-cvs.pl";
133 die("a tree status can only be determined in an source code control system checkout\n")
134 if ($progname eq "make_META.pl");
135 require "version_tag-none.pl";
138 ($am_linuxdir, $am_linuxobjdir, $am_modules, $am_version, $local_version,
139 $am_buildid) = read_autoMakefile();
142 my $pristine = is_pristine();
143 my $buildid = get_buildid();
145 if ($progname eq "version_tag.pl") {
147 $kernver = get_kernver($am_linuxdir, $am_linuxobjdir)
148 if ($am_linuxdir ne "");
150 my $linuxdir =~ s/\//\./g;
151 generate_ver($tag, $local_version, $buildid, $linuxdir, $pristine, $kernver,
153 } elsif ($progname eq "make_META.pl") {
154 print "TAG = $tag\n";
155 print "VERSION = $am_version\n";
156 print "BUILDID = $buildid\n";
157 print "PRISTINE = $pristine\n";
158 print "LOCAL_VERSION = $local_version\n";