forked from c-koi/gmic-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_versions.sh
executable file
·85 lines (71 loc) · 1.92 KB
/
check_versions.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
set -o errexit
function usage()
{
echo " Usage:"
echo
echo " check_version.sh GMIC_PATH [gmic|CImg|stdlib]"
echo
exit 0
}
function die()
{
local message="$1"
>&2 echo "Error: $*"
exit 1
}
(( $# == 0 )) && usage
[[ -d "$1" ]] || die "$1 is not an existing directory"
# @param folder
function gmic_version()
{
local folder="$1"
[[ -e "${folder}/gmic.h" ]] || die "File not found: ${folder}/gmic.h"
local version=$(grep -F "#define gmic_version " ${folder}/gmic.h)
echo ${version//* }
}
# @param folder
function cimg_version()
{
local folder="$1"
[[ -e "${folder}/CImg.h" ]] || die "File not found: ${folder}/CImg.h"
local version=$(grep -F "#define cimg_version " ${folder}/CImg.h)
echo ${version//* }
}
# @param folder
function stdlib_version()
{
local folder="$1"
[[ -e "${folder}/gmic_stdlib_community.h" ]] || die "File not found: ${folder}/gmic_stdlib_community.h"
local version=$(grep -E "File.*gmic_stdlib_community.h.*\(v." ${folder}/gmic_stdlib_community.h)
version=${version#*v.}
version=${version%)}
version=${version//.}
echo ${version}
}
if [[ "$2" == gmic ]]; then
gmic_version "$1"
exit 0
fi
if [[ "$2" == CImg ]]; then
cimg_version "$1"
exit 0
fi
if [[ "$2" == stdlib ]]; then
stdlib_version "$1"
exit 0
fi
echo "Checking G'MIC and CImg versions..."
GMIC_VERSION=$(gmic_version "$1")
CIMG_VERSION=$(cimg_version "$1")
STDLIB_VERSION=$(stdlib_version "$1")
echo "G'MIC version is .................... $GMIC_VERSION"
echo "gmic_stdlib_community.h version is .. $STDLIB_VERSION"
echo "CImg version is ..................... $CIMG_VERSION"
if [[ $GMIC_VERSION != $CIMG_VERSION ]]; then
die "Version numbers of files 'gmic.h' (${GMIC_VERSION}) and 'CImg.h' (${CIMG_VERSION}) mismatch"
fi
if [[ $GMIC_VERSION != $STDLIB_VERSION ]]; then
die "Version numbers of files 'gmic.h' (${GMIC_VERSION}) and 'gmic_stdlib_community.h' (${STDLIB_VERSION}) mismatch"
fi
exit 0