xref: /freebsd/contrib/ntp/scripts/build/mkver.in (revision a466cc55373fc3cf86837f09da729535b57e69a1)
1#!@CONFIG_SHELL@
2PROG=${1-UNKNOWN}
3
4ConfStr="$PROG"
5
6ConfStr="$ConfStr @VERSION@"
7
8case "$CSET" in
9 '') ;;
10 *) ConfStr="$ConfStr@$CSET" ;;
11esac
12
13case "@VER_SUFFIX@" in
14 '') ;;
15 *) ConfStr="${ConfStr}-@VER_SUFFIX@" ;;
16esac
17
18if [ -n "$SOURCE_DATE_EPOCH" ]; then
19   ConfStr="$ConfStr `LC_TIME=C TZ=UTC date -d@$SOURCE_DATE_EPOCH 2>/dev/null`" ||
20   ConfStr="$ConfStr `LC_TIME=C TZ=UTC date -r $SOURCE_DATE_EPOCH`"
21else
22   ConfStr="$ConfStr `LC_TIME=C TZ=UTC date`"
23fi
24
25if [ ! -f .version ]; then
26  echo 0 > .version
27fi
28RUN="`cat .version`"
29RUN="`expr $RUN + 1`"
30echo $RUN > .version
31
32ConfStr="$ConfStr (${RUN})"
33
34echo "Version <${ConfStr}>";
35
36rm -f version.c
37cat > version.c << -EoF-
38/*
39 * version file for $PROG
40 */
41#include <config.h>
42const char * Version = "${ConfStr}";
43-EoF-
44