]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/mkversion.pl
minor code cleanup
[proxmark3-svn] / tools / mkversion.pl
CommitLineData
8a6aec16 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
e3ac0d70
MHS
6# Modified april 2014 because of the move to github.
7# --- Martin Holst Swende <martin@swende.se>
8a6aec16 8
8a6aec16 9
9c683716 10# Clear environment locale so that git will not use localized strings
8a6aec16 11$ENV{'LC_ALL'} = "C";
12$ENV{'LANG'} = "C";
13
e3ac0d70
MHS
14my $gitversion = `git describe --dirty`;
15my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
8a6aec16 16my $clean = 2;
17my @compiletime = gmtime();
18
9c683716 19my $fullgitinfo = $gitbranch . '/' . $gitversion;
49b35ff9 20
9c683716 21$fullgitinfo =~ s/(\s)//g;
49b35ff9 22
e3ac0d70
MHS
23# Crop so it fits within 50 characters
24$fullgitinfo =~ s/.{50}\K.*//s;
8a6aec16 25
26$compiletime[4] += 1;
27$compiletime[5] += 1900;
28my $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime);
e3ac0d70 29
8a6aec16 30
31print <<EOF
49b35ff9 32#include "proxmark3.h"
8a6aec16 33/* Generated file, do not edit */
b7913d8f 34const struct version_information __attribute__((section(".version_information"))) version_information = {
8a6aec16 35 VERSION_INFORMATION_MAGIC,
36 1,
69135e1c 37 1,
8a6aec16 38 $clean,
e3ac0d70 39 "$fullgitinfo",
8a6aec16 40 "$ctime",
41};
42EOF
Impressum, Datenschutz