added some code & compiler information to cmd_netinfo
[NeonServV5.git] / version.sh
1 #! /bin/sh
2 echo "Extracting version.c ..."
3
4 if test -r version.c
5 then
6    compilation=`sed -n 's/^const char \*compilation = \"\(.*\)\";/\1/p' < version.c`
7    if test ! "$compilation" ; then compilation=0; fi
8 else
9    compilation=0
10 fi
11
12 compilation=`expr $compilation + 1`
13
14 creation=`date | \
15 awk '{if (NF == 6) \
16          { print $1 " " $2 " " $3 " " $6 " at " $4 " " $5 } \
17 else \
18          { print $1 " " $2 " " $3 " " $7 " at " $4 " " $5 " " $6 }}'`
19
20 codelines=`find . -type f -regex '\./.*\.h' -or -regex '\./.*\.c' |xargs cat|wc -l`
21
22 svn_revision=`svn info | grep Revision | grep -o -E '[0-9]+'`
23 if test "x$svn_revision" = "x" ; then
24   svn_revision=`git log -n 1 --pretty="format:%h"`
25   if test "x$svn_revision" = "x" ; then
26     svn_revision="0"
27   else
28     git_commitcount=`git rev-list --all | wc -l | sed "s/[ \t]//g"`
29     svn_revision="git-$git_commitcount-$svn_revision"
30   fi
31 else
32   svn_revision="svn-$svn_revision"
33 fi
34
35
36 /bin/cat >version.c <<!SUB!THIS!
37 //Auto generated file!
38
39 #include "version.h"
40
41 const char *compilation = "$compilation";
42 const char *creation = "$creation";
43 const char *revision = "$svn_revision";
44 const char *codelines = "$codelines";
45
46 !SUB!THIS!
47