3 # Output a version_pm3.c file that includes information about the current build
4 # Normally a couple of lines of bash would be enough (see openpcd project, original firmware by Harald Welte and Milosch Meriac)
5 # but this will, at least in theory, also work on Windows with our current compile environment.
6 # -- Henryk Plötz <henryk@ploetzli.ch> 2009-09-28
7 # Modified april 2014 because of the move to github.
8 # --- Martin Holst Swende <martin@swende.se>
9 # Modified january 2016 to work with Travis-CI
10 # --- iceman <iceman@iuse.se>
12 # Clear environment locale so that git will not use localized strings
16 # if you are making your own fork, change this line to reflect your fork-name
17 my $fullgitinfo = 'RRG/Iceman';
19 # GIT status 0 = dirty, 1 = clean , 2 = undecided
21 my $undecided = (defined $ARGV[0]) && ($ARGV[0] =~ '--undecided');
22 # Do we have acces to git command?
24 # solves some bug on macos i.e:
26 # perl ../tools/mkversion.pl .. > version_pm3.c || cp ../common/default_version_pm3.c version_pm3.c
27 # /usr/bin/which: /usr/bin/which: cannot execute binary file
28 # fatal: No names found, cannot describe anything.
30 # anyway forcing any kind of shell is at least useless, at worst fatal.
31 my $commandGIT = "env which git";
33 if ( defined($commandGIT) ) {
35 # this goes on Internet and cause major slowdowns on poor connections or intranets, let's comment it
36 #my $githistory = `git fetch --all`;
37 # now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
38 my $gitversion = `git describe --dirty --always`;
39 my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
41 $clean = $gitversion =~ '-dirty' ?
0 : 1;
43 if ( defined($gitbranch) and defined($gitversion) ) {
44 $fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;
46 my @compiletime = localtime();
48 $compiletime[5] += 1900;
49 $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime);
51 $fullgitinfo = $fullgitinfo.'/master/release (git)';
54 $fullgitinfo = $fullgitinfo.'/master/release (no_git)';
55 my @dl_time = localtime( (stat('../README.md'))[10] );
58 $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @dl_time);
61 $fullgitinfo =~ s/(\s)//g;
63 # Crop so it fits within 50 characters
64 #$fullgitinfo =~ s/.{50}\K.*//s;
65 $fullgitinfo = substr $fullgitinfo, 0, 49;
69 /* Generated file, do not edit */
73 #define SECTVERSINFO __attribute__((section(".version_information")))
76 const struct version_information SECTVERSINFO version_information = {
77 VERSION_INFORMATION_MAGIC,