+sub describe {
+ my ($basename) = @_;
+
+ # get a git tag if we can
+ my $tag = `git describe --dirty 2>/dev/null`;
+ chomp $tag;
+ if ($? != 0 or $tag !~ /^xnu-([^\s\n]+)$/) {
+ return $basename;
+ }
+
+ # If basename is just 'xnu' then replace it with the tag. Otherwise add
+ # the tag in brackets.
+ if ($basename eq 'xnu') {
+ return $tag
+ } else {
+ return "${basename}[$tag]"
+ }
+}
+