Linux-libre 4.9.30-gnu
[librecmc/linux-libre.git] / drivers / staging / vc04_services / interface / vchiq_arm / vchiq_genversion
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 #
6 # Generate a version from available information
7 #
8
9 my $prefix = shift @ARGV;
10 my $root = shift @ARGV;
11
12
13 if ( not defined $root ) {
14         die "usage: $0 prefix root-dir\n";
15 }
16
17 if ( ! -d $root ) {
18         die "root directory $root not found\n";
19 }
20
21 my $version = "unknown";
22 my $tainted = "";
23
24 if ( -d "$root/.git" ) {
25         # attempt to work out git version. only do so
26         # on a linux build host, as cygwin builds are
27         # already slow enough
28
29         if ( -f "/usr/bin/git" || -f "/usr/local/bin/git" ) {
30                 if (not open(F, "git --git-dir $root/.git rev-parse --verify HEAD|")) {
31                         $version = "no git version";
32                 }
33                 else {
34                         $version = <F>;
35                         $version =~ s/[ \r\n]*$//;     # chomp may not be enough (cygwin).
36                         $version =~ s/^[ \r\n]*//;     # chomp may not be enough (cygwin).
37                 }
38
39                 if (open(G, "git --git-dir $root/.git status --porcelain|")) {
40                         $tainted = <G>;
41                         $tainted =~ s/[ \r\n]*$//;     # chomp may not be enough (cygwin).
42                         $tainted =~ s/^[ \r\n]*//;     # chomp may not be enough (cygwin).
43                         if (length $tainted) {
44                         $version = join ' ', $version, "(tainted)";
45                 }
46                 else {
47                         $version = join ' ', $version, "(clean)";
48          }
49                 }
50         }
51 }
52
53 my $hostname = `hostname`;
54 $hostname =~ s/[ \r\n]*$//;     # chomp may not be enough (cygwin).
55 $hostname =~ s/^[ \r\n]*//;     # chomp may not be enough (cygwin).
56
57
58 print STDERR "Version $version\n";
59 print <<EOF;
60 #include "${prefix}_build_info.h"
61 #include <linux/broadcom/vc_debug_sym.h>
62
63 VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_hostname, "$hostname" );
64 VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_version, "$version" );
65 VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_time,    __TIME__ );
66 VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_date,    __DATE__ );
67
68 const char *vchiq_get_build_hostname( void )
69 {
70    return vchiq_build_hostname;
71 }
72
73 const char *vchiq_get_build_version( void )
74 {
75    return vchiq_build_version;
76 }
77
78 const char *vchiq_get_build_date( void )
79 {
80    return vchiq_build_date;
81 }
82
83 const char *vchiq_get_build_time( void )
84 {
85    return vchiq_build_time;
86 }
87 EOF