2 # SPDX-License-Identifier: GPL-2.0
7 # Generate a version from available information
10 my $prefix = shift @ARGV;
11 my $root = shift @ARGV;
14 if ( not defined $root ) {
15 die "usage: $0 prefix root-dir\n";
19 die "root directory $root not found\n";
22 my $version = "unknown";
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
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";
36 $version =~ s/[ \r\n]*$//; # chomp may not be enough (cygwin).
37 $version =~ s/^[ \r\n]*//; # chomp may not be enough (cygwin).
40 if (open(G, "git --git-dir $root/.git status --porcelain|")) {
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)";
48 $version = join ' ', $version, "(clean)";
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).
59 print STDERR "Version $version\n";
61 #include "${prefix}_build_info.h"
62 #include <linux/broadcom/vc_debug_sym.h>
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__ );
69 const char *vchiq_get_build_hostname( void )
71 return vchiq_build_hostname;
74 const char *vchiq_get_build_version( void )
76 return vchiq_build_version;
79 const char *vchiq_get_build_date( void )
81 return vchiq_build_date;
84 const char *vchiq_get_build_time( void )
86 return vchiq_build_time;