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