xref: /netbsd-src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_genversion (revision abf21415a7404dd49aa33199e3b0032c46c388e5)
1#!/usr/bin/perl -w
2
3use strict;
4
5#
6# Generate a version from available information
7#
8
9my $prefix = shift @ARGV;
10my $root = shift @ARGV;
11
12
13if ( not defined $root ) {
14	die "usage: $0 prefix root-dir\n";
15}
16
17if ( ! -d $root ) {
18	die "root directory $root not found\n";
19}
20
21my $version = "unknown";
22my $tainted = "";
23
24if ( -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
53my $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
58print STDERR "Version $version\n";
59print <<EOF;
60#include "${prefix}_build_info.h"
61#include <linux/broadcom/vc_debug_sym.h>
62
63VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_hostname, "$hostname" );
64VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_version, "$version" );
65VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_time,    __TIME__ );
66VC_DEBUG_DECLARE_STRING_VAR( ${prefix}_build_date,    __DATE__ );
67
68const char *vchiq_get_build_hostname( void )
69{
70   return vchiq_build_hostname;
71}
72
73const char *vchiq_get_build_version( void )
74{
75   return vchiq_build_version;
76}
77
78const char *vchiq_get_build_date( void )
79{
80   return vchiq_build_date;
81}
82
83const char *vchiq_get_build_time( void )
84{
85   return vchiq_build_time;
86}
87EOF
88