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/generated/utsrelease.h") &&
47 !$ver->open("$objdir/include/linux/utsrelease.h") &&
48 !$ver->open("$objdir/include/linux/version.h") &&
49 !$ver->open("$dir/include/generated/utsrelease.h") &&
50 !$ver->open("$dir/include/linux/utsrelease.h") &&
51 !$ver->open("$dir/include/linux/version.h")) {
52 die "Run make dep on '$dir'\n";
55 while(defined($line = <$ver>)) {
56 $line =~ /\#define UTS_RELEASE "(.*)"/;
68 sub generate_ver($$$$$$$)
72 my $local_version = shift;
79 print "#define BUILD_VERSION \"$tag";
82 print "-$env_vers\"\n";
86 if ($local_version ne "") {
87 print "-$local_version";
91 # if we want to get rid of the PRISTINE/CHANGED thing, get rid of these
92 # lines. maybe we only want to print -CHANGED when something is changed
93 # and print nothing when it's pristine
100 if ($kernver ne "") {
109 $progname =~ s/.*\///;
111 chomp(my $cwd = `pwd`);
114 $path =~ s/(.+)\/.*/\1/;
115 push(@INC, $cwd . "/" . $path);
117 # The _first_ argument on the command line may be --make_META
118 # Remove it from ARGV if found
119 if ($ARGV[0] eq "--make_META") {
127 # need to be in srcdir
133 require "version_tag-git.pl";
135 die("a tree status can only be determined in an source code control system checkout\n")
137 require "version_tag-none.pl";
140 ($am_linuxdir, $am_linuxobjdir, $am_modules, $am_version, $local_version,
141 $am_buildid) = read_autoMakefile();
144 my $pristine = is_pristine();
145 my $buildid = get_buildid();
149 $kernver = get_kernver($am_linuxdir, $am_linuxobjdir)
150 if ($am_linuxdir ne "");
152 my $linuxdir =~ s/\//\./g;
153 generate_ver($tag, $local_version, $buildid, $linuxdir, $pristine, $kernver,
156 print "TAG = $tag\n";
157 print "VERSION = $am_version\n";
158 print "BUILDID = $buildid\n";
159 print "PRISTINE = $pristine\n";
160 print "LOCAL_VERSION = $local_version\n";