blob: 38627bd07498024318e49129f9d353f85fee8cc9 (
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
|
#!/bin/sh
# Simple script to extract the version number parts from src/gd.h. If
# called with the middle word of the version macro, it prints the
# value of that macro. If called with no argument, it outputs a
# human-readable version string. This must be run in the project
# root. It is used by configure.ac and docs/naturaldocs/run_docs.sh.
TOPDIR="${0%/*}/.."
HEADER="${TOPDIR}/src/gd.h"
SENTINEL="/*version605b5d1778*/"
getpart() {
awk -vfield="GD_${1}_VERSION" -vsentinel="${SENTINEL}" '
$1 == "#define" && $2 == field && $NF == sentinel {
gsub(/^"/, "", $3)
gsub(/"$/, "", $3)
print $3
}
' "${HEADER}"
}
case $# in
0)
printf '%s.%s.%s%s\n' \
"$(getpart MAJOR)" \
"$(getpart MINOR)" \
"$(getpart RELEASE)" \
"$(getpart EXTRA)"
;;
1)
case $1 in
MAJOR|MINOR|RELEASE|EXTRA)
part=$(getpart "$1")
if [ -n "${part}" ]; then
printf '%s' "${part}"
fi
;;
*)
exit 1
;;
esac
;;
*)
echo "$0: error: script takes at most 1 arg"
exit 1
;;
esac
|