Blame acinclude.m4

rpm-build c487f7
# Checks the location of the XML Catalog
rpm-build c487f7
# Usage:
rpm-build c487f7
#   JH_PATH_XML_CATALOG([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
rpm-build c487f7
# Defines XMLCATALOG and XML_CATALOG_FILE substitutions
rpm-build c487f7
AC_DEFUN([JH_PATH_XML_CATALOG],
rpm-build c487f7
[
rpm-build c487f7
  # check for the presence of the XML catalog
rpm-build c487f7
  AC_ARG_WITH([xml-catalog],
rpm-build c487f7
              AC_HELP_STRING([--with-xml-catalog=CATALOG],
rpm-build c487f7
                             [path to xml catalog to use]),,
rpm-build c487f7
              [with_xml_catalog=/etc/xml/catalog])
rpm-build c487f7
  jh_found_xmlcatalog=true
rpm-build c487f7
  XML_CATALOG_FILE="$with_xml_catalog"
rpm-build c487f7
  AC_SUBST([XML_CATALOG_FILE])
rpm-build c487f7
  AC_MSG_CHECKING([for XML catalog ($XML_CATALOG_FILE)])
rpm-build c487f7
  if test -f "$XML_CATALOG_FILE"; then
rpm-build c487f7
    AC_MSG_RESULT([found])
rpm-build c487f7
  else
rpm-build c487f7
    jh_found_xmlcatalog=false
rpm-build c487f7
    AC_MSG_RESULT([not found])
rpm-build c487f7
  fi
rpm-build c487f7
rpm-build c487f7
  # check for the xmlcatalog program
rpm-build c487f7
  AC_PATH_PROG(XMLCATALOG, xmlcatalog, no)
rpm-build c487f7
  if test "x$XMLCATALOG" = xno; then
rpm-build c487f7
    jh_found_xmlcatalog=false
rpm-build c487f7
  fi
rpm-build c487f7
rpm-build c487f7
  if $jh_found_xmlcatalog; then
rpm-build c487f7
    ifelse([$1],,[:],[$1])
rpm-build c487f7
  else
rpm-build c487f7
    ifelse([$2],,[AC_MSG_ERROR([could not find XML catalog])],[$2])
rpm-build c487f7
  fi
rpm-build c487f7
])
rpm-build c487f7
rpm-build c487f7
# Checks if a particular URI appears in the XML catalog
rpm-build c487f7
# Usage:
rpm-build c487f7
#   JH_CHECK_XML_CATALOG(URI, [FRIENDLY-NAME], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
rpm-build c487f7
AC_DEFUN([JH_CHECK_XML_CATALOG],
rpm-build c487f7
[
rpm-build c487f7
  AC_REQUIRE([JH_PATH_XML_CATALOG],[JH_PATH_XML_CATALOG(,[:])])dnl
rpm-build c487f7
  AC_MSG_CHECKING([for ifelse([$2],,[$1],[$2]) in XML catalog])
rpm-build c487f7
  if $jh_found_xmlcatalog && \
rpm-build c487f7
     AC_RUN_LOG([$XMLCATALOG --noout "$XML_CATALOG_FILE" "$1" >&2]); then
rpm-build c487f7
    AC_MSG_RESULT([found])
rpm-build c487f7
    ifelse([$3],,,[$3
rpm-build c487f7
])dnl
rpm-build c487f7
  else
rpm-build c487f7
    AC_MSG_RESULT([not found])
rpm-build c487f7
    ifelse([$4],,
rpm-build c487f7
       [AC_MSG_ERROR([could not find ifelse([$2],,[$1],[$2]) in XML catalog])],
rpm-build c487f7
       [$4])
rpm-build c487f7
  fi
rpm-build c487f7
])
rpm-build c487f7
rpm-build c487f7
# ===========================================================================
rpm-build c487f7
#     http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
rpm-build c487f7
# ===========================================================================
rpm-build c487f7
#
rpm-build c487f7
# SYNOPSIS
rpm-build c487f7
#
rpm-build c487f7
#   AX_VALGRIND_CHECK()
rpm-build c487f7
#
rpm-build c487f7
# DESCRIPTION
rpm-build c487f7
#
rpm-build c487f7
#   Checks whether Valgrind is present and, if so, allows running `make
rpm-build c487f7
#   check` under a variety of Valgrind tools to check for memory and
rpm-build c487f7
#   threading errors.
rpm-build c487f7
#
rpm-build c487f7
#   Defines VALGRIND_CHECK_RULES which should be substituted in your
rpm-build c487f7
#   Makefile; and $enable_valgrind which can be used in subsequent configure
rpm-build c487f7
#   output. VALGRIND_ENABLED is defined and substituted, and corresponds to
rpm-build c487f7
#   the value of the --enable-valgrind option, which defaults to being
rpm-build c487f7
#   enabled if Valgrind is installed and disabled otherwise.
rpm-build c487f7
#
rpm-build c487f7
#   If unit tests are written using a shell script and automake's
rpm-build c487f7
#   LOG_COMPILER system, the $(VALGRIND) variable can be used within the
rpm-build c487f7
#   shell scripts to enable Valgrind, as described here:
rpm-build c487f7
#
rpm-build c487f7
#     https://www.gnu.org/software/gnulib/manual/html_node/Running-self_002dtests-under-valgrind.html
rpm-build c487f7
#
rpm-build c487f7
#   Usage example:
rpm-build c487f7
#
rpm-build c487f7
#   configure.ac:
rpm-build c487f7
#
rpm-build c487f7
#     AX_VALGRIND_CHECK
rpm-build c487f7
#
rpm-build c487f7
#   Makefile.am:
rpm-build c487f7
#
rpm-build c487f7
#     @VALGRIND_CHECK_RULES@
rpm-build c487f7
#     VALGRIND_SUPPRESSIONS_FILES = my-project.supp
rpm-build c487f7
#     EXTRA_DIST = my-project.supp
rpm-build c487f7
#
rpm-build c487f7
#   This results in a "check-valgrind" rule being added to any Makefile.am
rpm-build c487f7
#   which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been
rpm-build c487f7
#   configured with --enable-valgrind). Running `make check-valgrind` in
rpm-build c487f7
#   that directory will run the module's test suite (`make check`) once for
rpm-build c487f7
#   each of the available Valgrind tools (out of memcheck, helgrind, drd and
rpm-build c487f7
#   sgcheck), and will output results to test-suite-$toolname.log for each.
rpm-build c487f7
#   The target will succeed if there are zero errors and fail otherwise.
rpm-build c487f7
#
rpm-build c487f7
#   The macro supports running with and without libtool.
rpm-build c487f7
#
rpm-build c487f7
# LICENSE
rpm-build c487f7
#
rpm-build c487f7
#   Copyright (c) 2014, 2015 Philip Withnall <philip.withnall@collabora.co.uk>
rpm-build c487f7
#
rpm-build c487f7
#   Copying and distribution of this file, with or without modification, are
rpm-build c487f7
#   permitted in any medium without royalty provided the copyright notice
rpm-build c487f7
#   and this notice are preserved.  This file is offered as-is, without any
rpm-build c487f7
#   warranty.
rpm-build c487f7
rpm-build c487f7
#serial 4
rpm-build c487f7
rpm-build c487f7
AC_DEFUN([AX_VALGRIND_CHECK],[
rpm-build c487f7
	dnl Check for --enable-valgrind
rpm-build c487f7
	AC_MSG_CHECKING([whether to enable Valgrind on the unit tests])
rpm-build c487f7
	AC_ARG_ENABLE([valgrind],
rpm-build c487f7
	              [AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests])],
rpm-build c487f7
	              [enable_valgrind=$enableval],[enable_valgrind=])
rpm-build c487f7
rpm-build c487f7
	# Check for Valgrind.
rpm-build c487f7
	AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind])
rpm-build c487f7
rpm-build c487f7
	AS_IF([test "$enable_valgrind" = "yes" -a "$VALGRIND" = ""],[
rpm-build c487f7
		AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind])
rpm-build c487f7
	])
rpm-build c487f7
	AS_IF([test "$enable_valgrind" != "no"],[enable_valgrind=yes])
rpm-build c487f7
rpm-build c487f7
	AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"])
rpm-build c487f7
	AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind])
rpm-build c487f7
	AC_MSG_RESULT([$enable_valgrind])
rpm-build c487f7
rpm-build c487f7
	# Check for Valgrind tools we care about.
rpm-build c487f7
        #m4_define([valgrind_tool_list],[[memcheck], [helgrind], [drd], [exp-sgcheck]])
rpm-build c487f7
        # I trimmed this, because we fail on all the thread stuff
rpm-build c487f7
        m4_define([valgrind_tool_list],[[memcheck]])
rpm-build c487f7
rpm-build c487f7
	AS_IF([test "$VALGRIND" != ""],[
rpm-build c487f7
		m4_foreach([vgtool],[valgrind_tool_list],[
rpm-build c487f7
			m4_define([vgtooln],AS_TR_SH(vgtool))
rpm-build c487f7
			m4_define([ax_cv_var],[ax_cv_valgrind_tool_]vgtooln)
rpm-build c487f7
			AC_CACHE_CHECK([for Valgrind tool ]vgtool,ax_cv_var,[
rpm-build c487f7
				ax_cv_var=
rpm-build c487f7
				AS_IF([`$VALGRIND --tool=vgtool --help >/dev/null 2>&1`],[
rpm-build c487f7
					ax_cv_var="vgtool"
rpm-build c487f7
				])
rpm-build c487f7
			])
rpm-build c487f7
rpm-build c487f7
			AC_SUBST([VALGRIND_HAVE_TOOL_]vgtooln,[$ax_cv_var])
rpm-build c487f7
		])
rpm-build c487f7
	])
rpm-build c487f7
rpm-build c487f7
VALGRIND_CHECK_RULES='
rpm-build c487f7
# Valgrind check
rpm-build c487f7
#
rpm-build c487f7
# Optional:
rpm-build c487f7
#  - VALGRIND_SUPPRESSIONS_FILES: Space-separated list of Valgrind suppressions
rpm-build c487f7
#    files to load. (Default: empty)
rpm-build c487f7
#  - VALGRIND_FLAGS: General flags to pass to all Valgrind tools.
rpm-build c487f7
#    (Default: --num-callers=30)
rpm-build c487f7
#  - VALGRIND_$toolname_FLAGS: Flags to pass to Valgrind $toolname (one of:
rpm-build c487f7
#    memcheck, helgrind, drd, sgcheck). (Default: various)
rpm-build c487f7
rpm-build c487f7
# Optional variables
rpm-build c487f7
VALGRIND_SUPPRESSIONS ?= $(addprefix --suppressions=,$(VALGRIND_SUPPRESSIONS_FILES))
rpm-build c487f7
VALGRIND_FLAGS ?= --num-callers=30
rpm-build c487f7
VALGRIND_memcheck_FLAGS ?= --leak-check=full --show-reachable=no
rpm-build c487f7
VALGRIND_helgrind_FLAGS ?= --history-level=approx
rpm-build c487f7
VALGRIND_drd_FLAGS ?=
rpm-build c487f7
VALGRIND_sgcheck_FLAGS ?=
rpm-build c487f7
rpm-build c487f7
# Internal use
rpm-build c487f7
valgrind_tools = memcheck helgrind drd sgcheck
rpm-build c487f7
valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools)))
rpm-build c487f7
rpm-build c487f7
valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS)
rpm-build c487f7
valgrind_helgrind_flags = --tool=helgrind $(VALGRIND_helgrind_FLAGS)
rpm-build c487f7
valgrind_drd_flags = --tool=drd $(VALGRIND_drd_FLAGS)
rpm-build c487f7
valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS)
rpm-build c487f7
rpm-build c487f7
valgrind_quiet = $(valgrind_quiet_$(V))
rpm-build c487f7
valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY))
rpm-build c487f7
valgrind_quiet_0 = --quiet
rpm-build c487f7
rpm-build c487f7
# Support running with and without libtool.
rpm-build c487f7
ifneq ($(LIBTOOL),)
rpm-build c487f7
valgrind_lt = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=execute
rpm-build c487f7
else
rpm-build c487f7
valgrind_lt =
rpm-build c487f7
endif
rpm-build c487f7
rpm-build c487f7
# Use recursive makes in order to ignore errors during check
rpm-build c487f7
check-valgrind:
rpm-build c487f7
ifeq ($(VALGRIND_ENABLED),yes)
rpm-build c487f7
	-$(foreach tool,$(valgrind_tools), \
rpm-build c487f7
		$(if $(VALGRIND_HAVE_TOOL_$(tool))$(VALGRIND_HAVE_TOOL_exp_$(tool)), \
rpm-build c487f7
			$(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-tool VALGRIND_TOOL=$(tool); \
rpm-build c487f7
		) \
rpm-build c487f7
	)
rpm-build c487f7
else
rpm-build c487f7
	@echo "Need to reconfigure with --enable-valgrind"
rpm-build c487f7
endif
rpm-build c487f7
rpm-build c487f7
# Valgrind running
rpm-build c487f7
VALGRIND_TESTS_ENVIRONMENT = \
rpm-build c487f7
	$(TESTS_ENVIRONMENT) \
rpm-build c487f7
	env VALGRIND=$(VALGRIND) \
rpm-build c487f7
	G_SLICE=always-malloc,debug-blocks \
rpm-build c487f7
	G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly
rpm-build c487f7
rpm-build c487f7
VALGRIND_LOG_COMPILER = \
rpm-build c487f7
	$(valgrind_lt) \
rpm-build c487f7
	$(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS)
rpm-build c487f7
rpm-build c487f7
check-valgrind-tool:
rpm-build c487f7
ifeq ($(VALGRIND_ENABLED),yes)
rpm-build c487f7
	$(MAKE) check-TESTS \
rpm-build c487f7
		TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \
rpm-build c487f7
		LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \
rpm-build c487f7
		LOG_FLAGS="$(valgrind_$(VALGRIND_TOOL)_flags)" \
rpm-build c487f7
		TEST_SUITE_LOG=test-suite-$(VALGRIND_TOOL).log
rpm-build c487f7
else
rpm-build c487f7
	@echo "Need to reconfigure with --enable-valgrind"
rpm-build c487f7
endif
rpm-build c487f7
rpm-build c487f7
DISTCHECK_CONFIGURE_FLAGS ?=
rpm-build c487f7
DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind
rpm-build c487f7
rpm-build c487f7
MOSTLYCLEANFILES ?=
rpm-build c487f7
MOSTLYCLEANFILES += $(valgrind_log_files)
rpm-build c487f7
rpm-build c487f7
.PHONY: check-valgrind check-valgrind-tool
rpm-build c487f7
'
rpm-build c487f7
rpm-build c487f7
	AC_SUBST([VALGRIND_CHECK_RULES])
rpm-build c487f7
	m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])])
rpm-build c487f7
])
rpm-build c487f7
rpm-build c487f7
# ===========================================================================
rpm-build c487f7
#    http://www.gnu.org/software/autoconf-archive/ax_compare_version.html
rpm-build c487f7
# ===========================================================================
rpm-build c487f7
#
rpm-build c487f7
# SYNOPSIS
rpm-build c487f7
#
rpm-build c487f7
#   AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
rpm-build c487f7
#
rpm-build c487f7
# DESCRIPTION
rpm-build c487f7
#
rpm-build c487f7
#   This macro compares two version strings. Due to the various number of
rpm-build c487f7
#   minor-version numbers that can exist, and the fact that string
rpm-build c487f7
#   comparisons are not compatible with numeric comparisons, this is not
rpm-build c487f7
#   necessarily trivial to do in a autoconf script. This macro makes doing
rpm-build c487f7
#   these comparisons easy.
rpm-build c487f7
#
rpm-build c487f7
#   The six basic comparisons are available, as well as checking equality
rpm-build c487f7
#   limited to a certain number of minor-version levels.
rpm-build c487f7
#
rpm-build c487f7
#   The operator OP determines what type of comparison to do, and can be one
rpm-build c487f7
#   of:
rpm-build c487f7
#
rpm-build c487f7
#    eq  - equal (test A == B)
rpm-build c487f7
#    ne  - not equal (test A != B)
rpm-build c487f7
#    le  - less than or equal (test A <= B)
rpm-build c487f7
#    ge  - greater than or equal (test A >= B)
rpm-build c487f7
#    lt  - less than (test A < B)
rpm-build c487f7
#    gt  - greater than (test A > B)
rpm-build c487f7
#
rpm-build c487f7
#   Additionally, the eq and ne operator can have a number after it to limit
rpm-build c487f7
#   the test to that number of minor versions.
rpm-build c487f7
#
rpm-build c487f7
#    eq0 - equal up to the length of the shorter version
rpm-build c487f7
#    ne0 - not equal up to the length of the shorter version
rpm-build c487f7
#    eqN - equal up to N sub-version levels
rpm-build c487f7
#    neN - not equal up to N sub-version levels
rpm-build c487f7
#
rpm-build c487f7
#   When the condition is true, shell commands ACTION-IF-TRUE are run,
rpm-build c487f7
#   otherwise shell commands ACTION-IF-FALSE are run. The environment
rpm-build c487f7
#   variable 'ax_compare_version' is always set to either 'true' or 'false'
rpm-build c487f7
#   as well.
rpm-build c487f7
#
rpm-build c487f7
#   Examples:
rpm-build c487f7
#
rpm-build c487f7
#     AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
rpm-build c487f7
#     AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
rpm-build c487f7
#
rpm-build c487f7
#   would both be true.
rpm-build c487f7
#
rpm-build c487f7
#     AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
rpm-build c487f7
#     AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
rpm-build c487f7
#
rpm-build c487f7
#   would both be false.
rpm-build c487f7
#
rpm-build c487f7
#     AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
rpm-build c487f7
#
rpm-build c487f7
#   would be true because it is only comparing two minor versions.
rpm-build c487f7
#
rpm-build c487f7
#     AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
rpm-build c487f7
#
rpm-build c487f7
#   would be true because it is only comparing the lesser number of minor
rpm-build c487f7
#   versions of the two values.
rpm-build c487f7
#
rpm-build c487f7
#   Note: The characters that separate the version numbers do not matter. An
rpm-build c487f7
#   empty string is the same as version 0. OP is evaluated by autoconf, not
rpm-build c487f7
#   configure, so must be a string, not a variable.
rpm-build c487f7
#
rpm-build c487f7
#   The author would like to acknowledge Guido Draheim whose advice about
rpm-build c487f7
#   the m4_case and m4_ifvaln functions make this macro only include the
rpm-build c487f7
#   portions necessary to perform the specific comparison specified by the
rpm-build c487f7
#   OP argument in the final configure script.
rpm-build c487f7
#
rpm-build c487f7
# LICENSE
rpm-build c487f7
#
rpm-build c487f7
#   Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
rpm-build c487f7
#
rpm-build c487f7
#   Copying and distribution of this file, with or without modification, are
rpm-build c487f7
#   permitted in any medium without royalty provided the copyright notice
rpm-build c487f7
#   and this notice are preserved. This file is offered as-is, without any
rpm-build c487f7
#   warranty.
rpm-build c487f7
rpm-build c487f7
#serial 11
rpm-build c487f7
rpm-build c487f7
dnl #########################################################################
rpm-build c487f7
AC_DEFUN([AX_COMPARE_VERSION], [
rpm-build c487f7
  AC_REQUIRE([AC_PROG_AWK])
rpm-build c487f7
rpm-build c487f7
  # Used to indicate true or false condition
rpm-build c487f7
  ax_compare_version=false
rpm-build c487f7
rpm-build c487f7
  # Convert the two version strings to be compared into a format that
rpm-build c487f7
  # allows a simple string comparison.  The end result is that a version
rpm-build c487f7
  # string of the form 1.12.5-r617 will be converted to the form
rpm-build c487f7
  # 0001001200050617.  In other words, each number is zero padded to four
rpm-build c487f7
  # digits, and non digits are removed.
rpm-build c487f7
  AS_VAR_PUSHDEF([A],[ax_compare_version_A])
rpm-build c487f7
  A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
rpm-build c487f7
                     -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
rpm-build c487f7
                     -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
rpm-build c487f7
                     -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
rpm-build c487f7
                     -e 's/[[^0-9]]//g'`
rpm-build c487f7
rpm-build c487f7
  AS_VAR_PUSHDEF([B],[ax_compare_version_B])
rpm-build c487f7
  B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
rpm-build c487f7
                     -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
rpm-build c487f7
                     -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
rpm-build c487f7
                     -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
rpm-build c487f7
                     -e 's/[[^0-9]]//g'`
rpm-build c487f7
rpm-build c487f7
  dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
rpm-build c487f7
  dnl # then the first line is used to determine if the condition is true.
rpm-build c487f7
  dnl # The sed right after the echo is to remove any indented white space.
rpm-build c487f7
  m4_case(m4_tolower($2),
rpm-build c487f7
  [lt],[
rpm-build c487f7
    ax_compare_version=`echo "x$A
rpm-build c487f7
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
rpm-build c487f7
  ],
rpm-build c487f7
  [gt],[
rpm-build c487f7
    ax_compare_version=`echo "x$A
rpm-build c487f7
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
rpm-build c487f7
  ],
rpm-build c487f7
  [le],[
rpm-build c487f7
    ax_compare_version=`echo "x$A
rpm-build c487f7
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
rpm-build c487f7
  ],
rpm-build c487f7
  [ge],[
rpm-build c487f7
    ax_compare_version=`echo "x$A
rpm-build c487f7
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
rpm-build c487f7
  ],[
rpm-build c487f7
    dnl Split the operator from the subversion count if present.
rpm-build c487f7
    m4_bmatch(m4_substr($2,2),
rpm-build c487f7
    [0],[
rpm-build c487f7
      # A count of zero means use the length of the shorter version.
rpm-build c487f7
      # Determine the number of characters in A and B.
rpm-build c487f7
      ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
rpm-build c487f7
      ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
rpm-build c487f7
rpm-build c487f7
      # Set A to no more than B's length and B to no more than A's length.
rpm-build c487f7
      A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
rpm-build c487f7
      B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
rpm-build c487f7
    ],
rpm-build c487f7
    [[0-9]+],[
rpm-build c487f7
      # A count greater than zero means use only that many subversions
rpm-build c487f7
      A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
rpm-build c487f7
      B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
rpm-build c487f7
    ],
rpm-build c487f7
    [.+],[
rpm-build c487f7
      AC_WARNING(
rpm-build c487f7
        [illegal OP numeric parameter: $2])
rpm-build c487f7
    ],[])
rpm-build c487f7
rpm-build c487f7
    # Pad zeros at end of numbers to make same length.
rpm-build c487f7
    ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
rpm-build c487f7
    B="$B`echo $A | sed 's/./0/g'`"
rpm-build c487f7
    A="$ax_compare_version_tmp_A"
rpm-build c487f7
rpm-build c487f7
    # Check for equality or inequality as necessary.
rpm-build c487f7
    m4_case(m4_tolower(m4_substr($2,0,2)),
rpm-build c487f7
    [eq],[
rpm-build c487f7
      test "x$A" = "x$B" && ax_compare_version=true
rpm-build c487f7
    ],
rpm-build c487f7
    [ne],[
rpm-build c487f7
      test "x$A" != "x$B" && ax_compare_version=true
rpm-build c487f7
    ],[
rpm-build c487f7
      AC_WARNING([illegal OP parameter: $2])
rpm-build c487f7
    ])
rpm-build c487f7
  ])
rpm-build c487f7
rpm-build c487f7
  AS_VAR_POPDEF([A])dnl
rpm-build c487f7
  AS_VAR_POPDEF([B])dnl
rpm-build c487f7
rpm-build c487f7
  dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
rpm-build c487f7
  if test "$ax_compare_version" = "true" ; then
rpm-build c487f7
    m4_ifvaln([$4],[$4],[:])dnl
rpm-build c487f7
    m4_ifvaln([$5],[else $5])dnl
rpm-build c487f7
  fi
rpm-build c487f7
]) dnl AX_COMPARE_VERSION