aboutsummaryrefslogtreecommitdiffstats
path: root/generate_version_h.sh
blob: cbf1a0aa5bfb3c879f4bffc4a5f8ded3b86202ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
#   This file is part of cputemp2maxfreq.
#
#   Copyright (C) 2023-2024 pa4wdh
#
#   cputemp2maxfreq is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   cputemp2maxfreq is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with cputemp2maxfreq.  If not, see <https://www.gnu.org/licenses/>.
#
if [ -d ".git" ]
then
# If we have a git directory use that as an information source
 VERSION=`git describe --tags --abbrev=0`
 HASH=`git show --format="%h" --no-patch master`
 BRANCH=`git rev-parse --abbrev-ref HEAD`
elif [ "$#" = "3" ]
then
# If we have 3 commandline arguments use them
 VERSION="$1"
 HASH="$2"
 BRANCH="$3"
else
# We don't know our version
 VERSION="Unknown"
 HASH="none"
 BRANCH="Unknown"
fi

# Generate a GPL license header
head -n 17 cputemp2maxfreq.c
echo ""
echo "    This file is generated by $0,"
echo "    do not edit."
echo "*/"

echo "#ifndef HAVE_VERSION_H"
echo "#define HAVE_VERSION_H"
echo ""
echo "#define VERSION \"$VERSION\""
echo "#define HASH \"$HASH\""
echo "#define BRANCH \"$BRANCH\""
echo "#define VERSION_FULL VERSION\"-\"HASH\" (\"BRANCH\")\""
echo "char* version();"
echo ""
echo "#endif"