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