summaryrefslogtreecommitdiff
path: root/m4/ax_prog_robot.m4
blob: 7dfd728934d5350bff53922971bb0c7af113e9ae (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
56
57
58
59
60
61
62
63
# ===========================================================================
#      https://www.gnu.org/software/autoconf-archive/ax_prog_robot.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_ROBOT([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])
#
# DESCRIPTION
#
#   This macro searches for the "robot" command from the Robot Framework and
#   sets the variable "ROBOT" to the name of the application and the
#   "ROBOT_VERSION" variable to the version of the Robot Framework. When
#   robot is found sets the "HAS_ROBOT" to "yes", otherwise to "no".
#
#   Example:
#
#     AX_PROG_ROBOT([3.1.0], [], [])
#
# LICENSE
#
#   Copyright (c) 2020, Adam Chyla <adam@chyla.org>
#
#   Distributed under the terms of the BSD 3-Clause License.

#serial 5

AC_DEFUN([AX_PROG_ROBOT],
[
    AC_REQUIRE([AC_PROG_SED])

    ax_robot_version="$1"

    AC_CHECK_PROGS(ROBOT,[robot])
    AS_IF([test "x$ROBOT" = "x"],
        [
            AC_SUBST([HAS_ROBOT],[no])
            AC_SUBST([ROBOT_VERSION],[])
            $3
        ],
        [
            AC_MSG_CHECKING([for robot version])
            changequote(<<,>>)
            robot_version=`$ROBOT --version | $SED -e 's/^[^0-9]* \([0-9.]*\) .*/\1/'`
            changequote([,])
            AC_MSG_RESULT($robot_version)

            AX_COMPARE_VERSION([$ax_robot_version],[le],[$robot_version],
                [
                    AC_SUBST([HAS_ROBOT],[yes])
                    AC_SUBST([ROBOT_VERSION],[$robot_version])
                    $2
                ],
                [
                    AC_SUBST([HAS_ROBOT],[no])
                    AC_SUBST([ROBOT],[])
                    AC_SUBST([ROBOT_VERSION],[])
                    $3
                ]
            )
        ]
    )
])