]> git.zerfleddert.de Git - proxmark3-svn/blob - tools/mkversion.pl
FIX: that time.h issue is different on POSIX systems and WINDOWS system and in C...
[proxmark3-svn] / tools / mkversion.pl
1 #!/usr/bin/perl
2 # Output a version.c file that includes information about the current build
3 # Normally a couple of lines of bash would be enough (see openpcd project, original firmware by Harald Welte and Milosch Meriac)
4 # but this will, at least in theory, also work on Windows with our current compile environment.
5 # -- Henryk Plötz <henryk@ploetzli.ch> 2009-09-28
6 # Modified april 2014 because of the move to github.
7 # --- Martin Holst Swende <martin@swende.se>
8 # Modified january 2016 to work with Travis-CI
9 # --- iceman <iceman@iuse.se>
10
11 # Clear environment locale so that git will not use localized strings
12 $ENV{'LC_ALL'} = "C";
13 $ENV{'LANG'} = "C";
14
15 my $githistory = `git fetch --all`;
16 my $gitversion = `git describe --dirty`;
17 my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
18 my $clean = 2;
19 my @compiletime = localtime();
20
21 my $fullgitinfo = 'iceman';
22
23 if ( defined $gitbranch and defined $gitversion ) {
24 $fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;
25 } else {
26 $fullgitinfo = $fullgitinfo.'/master/release-build (no_git)';
27 }
28
29 $fullgitinfo =~ s/(\s)//g;
30
31 # Crop so it fits within 50 characters
32 $fullgitinfo =~ s/.{50}\K.*//s;
33
34 $compiletime[4] += 1;
35 $compiletime[5] += 1900;
36 my $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime);
37
38
39 print <<EOF
40 #include "proxmark3.h"
41 /* Generated file, do not edit */
42 const struct version_information __attribute__((section(".version_information"))) version_information = {
43 VERSION_INFORMATION_MAGIC,
44 1,
45 1,
46 $clean,
47 "$fullgitinfo",
48 "$ctime",
49 };
50 EOF
Impressum, Datenschutz