@node ax_compare_version @unnumberedsec ax_compare_version @majorheading Synopsis @smallexample AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) @end smallexample @majorheading Description This macro compares two version strings. Due to the various number of minor-version numbers that can exist, and the fact that string comparisons are not compatible with numeric comparisons, this is not necessarily trivial to do in a autoconf script. This macro makes doing these comparisons easy. The six basic comparisons are available, as well as checking equality limited to a certain number of minor-version levels. The operator OP determines what type of comparison to do, and can be one of: @smallexample eq - equal (test A == B) ne - not equal (test A != B) le - less than or equal (test A <= B) ge - greater than or equal (test A >= B) lt - less than (test A < B) gt - greater than (test A > B) @end smallexample Additionally, the eq and ne operator can have a number after it to limit the test to that number of minor versions. @smallexample eq0 - equal up to the length of the shorter version ne0 - not equal up to the length of the shorter version eqN - equal up to N sub-version levels neN - not equal up to N sub-version levels @end smallexample When the condition is true, shell commands ACTION-IF-TRUE are run, otherwise shell commands ACTION-IF-FALSE are run. The environment variable 'ax_compare_version' is always set to either 'true' or 'false' as well. Examples: @smallexample AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) @end smallexample would both be true. @smallexample AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) @end smallexample would both be false. @smallexample AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) @end smallexample would be true because it is only comparing two minor versions. @smallexample AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) @end smallexample would be true because it is only comparing the lesser number of minor versions of the two values. Note: The characters that separate the version numbers do not matter. An empty string is the same as version 0. OP is evaluated by autoconf, not configure, so must be a string, not a variable. The author would like to acknowledge Guido Draheim whose advice about the m4_case and m4_ifvaln functions make this macro only include the portions necessary to perform the specific comparison specified by the OP argument in the final configure script. @majorheading Source Code Download the @uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_compare_version.m4,latest version of @file{ax_compare_version.m4}} or browse @uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=m4/ax_compare_version.m4,the macro's revision history}. @majorheading License @w{Copyright @copyright{} 2008 Tim Toolan @email{toolan@@ele.uri.edu}} Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.