aboutsummaryrefslogtreecommitdiffstats
path: root/version.pl
blob: 3b1d403e3dbb68eeef176ba24432fa46724e83cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl

use strict;
use warnings;

my $version = '';

# git repository
if (system('which git >/dev/null 2>&1') == 0
and system('git ls-files colorize.c --error-unmatch >/dev/null 2>&1') == 0) {
    $version = `git describe --tags --dirty`;
    $version =~ s/\n$//g;
}

if (length $version) {
    print <<"EOT";
const char *const version = "$version";
EOT
}
else {
    print <<'EOT';
const char *const version = NULL;
EOT
}