added config parser & incoming connection handler
[NextIRCd.git] / src / 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
23 git_revision_id=`git rev-list -n 1 --pretty="format:%h" --header refs/heads/master | grep '^[0-9a-f]*$'`
24 if test "x$git_revision_id" = "x" ; then
25   git_revision="0"
26   git_commitcount="0"
27   git_is_stable="1"
28   git_dev_rev=""
29 else
30   git_commitcount=`git rev-list --oneline --first-parent refs/heads/master | wc -l | sed "s/[ \t]//g"`
31   git_revision="git-$git_revision_id"
32   
33   git_real_revision_id=`git rev-list -n 1 --pretty="format:%h" --header HEAD | grep '^[0-9a-f]*$'`
34   if test "$git_revision_id" = "$git_real_revision_id" ; then
35     git_is_stable="1"
36     git_dev_rev=""
37   else
38     git_is_stable="0"
39     git_dev_rev="git-$git_real_revision_id"
40   fi
41 fi
42
43
44 /bin/cat > version.c <<!SUB!THIS!
45 /* version.c - NextIRCd
46  * Copyright (C) 2012-2013  Philipp Kreil (pk910)
47  * 
48  * This program is free software: you can redistribute it and/or modify
49  * it under the terms of the GNU General Public License as published by
50  * the Free Software Foundation, either version 3 of the License, or
51  * (at your option) any later version.
52  * 
53  * This program is distributed in the hope that it will be useful,
54  * but WITHOUT ANY WARRANTY; without even the implied warranty of
55  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
56  * GNU General Public License for more details.
57  * 
58  * You should have received a copy of the GNU General Public License 
59  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
60  */
61 //Auto generated file!
62
63 #include "version.h"
64
65 const char *compilation = "$compilation";
66 const char *creation = "$creation";
67 const char *revision = "$git_revision";
68 const char *codelines = "$codelines";
69 const int revision_master = $git_is_stable;
70 const char *dev_revision = "$git_dev_rev";
71
72 const int patchlevel = ($git_commitcount ? ($git_commitcount - VERSION_PATCHLEVEL) : 0);
73
74 !SUB!THIS!
75