autoconf: Number processing Macros
1
1 8.3.8 Arithmetic computation in M4
1 ----------------------------------
1
1 The following macros facilitate integer arithmetic operations. Where a
1 parameter is documented as taking an arithmetic expression, you can use
1 anything that can be parsed by `m4_eval'.
1
1 -- Macro: m4_cmp (EXPR-1, EXPR-2)
1 Compare the arithmetic expressions EXPR-1 and EXPR-2, and expand
1 to `-1' if EXPR-1 is smaller, `0' if they are equal, and `1' if
1 EXPR-1 is larger.
1
1 -- Macro: m4_list_cmp (LIST-1, LIST-2)
1 Compare the two M4 lists consisting of comma-separated arithmetic
1 expressions, left to right. Expand to `-1' for the first element
1 pairing where the value from LIST-1 is smaller, `1' where the
1 value from LIST-2 is smaller, or `0' if both lists have the same
1 values. If one list is shorter than the other, the remaining
1 elements of the longer list are compared against zero.
1 m4_list_cmp([1, 0], [1])
1 =>0
1 m4_list_cmp([1, [1 * 0]], [1, 0])
1 =>0
1 m4_list_cmp([1, 2], [1, 0])
1 =>1
1 m4_list_cmp([1, [1+1], 3],[1, 2])
1 =>1
1 m4_list_cmp([1, 2, -3], [1, 2])
1 =>-1
1 m4_list_cmp([1, 0], [1, 2])
1 =>-1
1 m4_list_cmp([1], [1, 2])
1 =>-1
1
1 -- Macro: m4_max (ARG, ...)
1 This macro was introduced in Autoconf 2.62. Expand to the decimal
1 value of the maximum arithmetic expression among all the arguments.
1
1 -- Macro: m4_min (ARG, ...)
1 This macro was introduced in Autoconf 2.62. Expand to the decimal
1 value of the minimum arithmetic expression among all the arguments.
1
1 -- Macro: m4_sign (EXPR)
1 Expand to `-1' if the arithmetic expression EXPR is negative, `1'
1 if it is positive, and `0' if it is zero.
1
1 -- Macro: m4_version_compare (VERSION-1, VERSION-2)
1 This macro was introduced in Autoconf 2.53, but had a number of
1 usability limitations that were not lifted until Autoconf 2.62.
1 Compare the version strings VERSION-1 and VERSION-2, and expand to
1 `-1' if VERSION-1 is smaller, `0' if they are the same, or `1'
1 VERSION-2 is smaller. Version strings must be a list of elements
1 separated by `.', `,' or `-', where each element is a number along
1 with optional case-insensitive letters designating beta releases.
1 The comparison stops at the leftmost element that contains a
1 difference, although a 0 element compares equal to a missing
1 element.
1
1 It is permissible to include commit identifiers in VERSION, such
1 as an abbreviated SHA1 of the commit, provided there is still a
1 monotonically increasing prefix to allow for accurate version-based
1 comparisons. For example, this paragraph was written when the
1 development snapshot of autoconf claimed to be at version
1 `2.61a-248-dc51', or 248 commits after the 2.61a release, with an
1 abbreviated commit identification of `dc51'.
1
1 m4_version_compare([1.1], [2.0])
1 =>-1
1 m4_version_compare([2.0b], [2.0a])
1 =>1
1 m4_version_compare([1.1.1], [1.1.1a])
1 =>-1
1 m4_version_compare([1.2], [1.1.1a])
1 =>1
1 m4_version_compare([1.0], [1])
1 =>0
1 m4_version_compare([1.1pre], [1.1PRE])
1 =>0
1 m4_version_compare([1.1a], [1,10])
1 =>-1
1 m4_version_compare([2.61a], [2.61a-248-dc51])
1 =>-1
1 m4_version_compare([2.61b], [2.61a-248-dc51])
1 =>1
1
1 -- Macro: m4_version_prereq (VERSION, [IF-NEW-ENOUGH], [IF-OLD =
1 `m4_fatal'])
1 Compares VERSION against the version of Autoconf currently
1 running. If the running version is at VERSION or newer, expand
1 IF-NEW-ENOUGH, but if VERSION is larger than the version currently
1 executing, expand IF-OLD, which defaults to printing an error
1 message and exiting m4sugar with status 63. When given only one
1 argument, this behaves like `AC_PREREQ' (⇒Versioning).
1 Remember that the autoconf philosophy favors feature checks over
1 version checks.
1