aboutsummaryrefslogtreecommitdiffstats
path: root/version.pl
blob: 850902eeddad409af4f7d7e0810ec6651a15f0f7 (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 *version = "$version";
EOT
}
else {
    print <<'EOT';
const char *version = NULL;
EOT
}