]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/dependencies/check-host-cmake.sh
core: reverse the argument order in check-host-cmake
[coffee/buildroot.git] / support / dependencies / check-host-cmake.sh
1 #!/bin/sh
2
3 version_min="${1}"
4 candidate="${2}"
5
6 major_min="${version_min%.*}"
7 minor_min="${version_min#*.}"
8
9 cmake=`which ${candidate}`
10 if [ ! -x "${cmake}" ]; then
11     # echo nothing: no suitable cmake found
12     exit 1
13 fi
14
15 # Extract version X.Y from versions in the form X.Y or X.Y.Z
16 # with X, Y and Z numbers with one or more digits each, e.g.
17 #   3.2     -> 3.2
18 #   3.2.3   -> 3.2
19 #   3.2.42  -> 3.2
20 #   3.10    -> 3.10
21 #   3.10.4  -> 3.10
22 #   3.10.42 -> 3.10
23 version="$(${cmake} --version \
24            |sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' \
25                    -e 's//\1/'
26           )"
27 major="${version%.*}"
28 minor="${version#*.}"
29
30 if [ ${major} -gt ${major_min} ]; then
31     echo "${cmake}"
32 else
33     if [ ${major} -eq ${major_min} -a ${minor} -ge ${minor_min} ]; then
34         echo "${cmake}"
35     else
36         # echo nothing: no suitable cmake found
37         exit 1
38     fi
39 fi