1 # Get XAPIANLETOR_CXXFLAGS, XAPIANLETOR_LIBS, and XAPIANLETOR_VERSION from xapianletor-config and
6 # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
7 # -----------------------------------------------------------
8 # If this macro is not defined by Autoconf, define it here.
9 m4_ifdef([AC_PROVIDE_IFELSE],
11 [m4_define([AC_PROVIDE_IFELSE],
12 [m4_ifdef([AC_PROVIDE_$1],
15 # XO_LIB_XAPIANLETOR([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND[ ,XAPIANLETOR-CONFIG]]])
16 # --------------------------------------------------------
17 # AC_SUBST-s XAPIANLETOR_CXXFLAGS, XAPIANLETOR_LIBS, and XAPIANLETOR_VERSION for use in
20 # If ACTION-IF-FOUND and ACTION-IF-NOT-FOUND are both unset, then an
21 # appropriate AC_MSG_ERROR is used as a default ACTION-IF-NOT-FOUND.
22 # This allows XO_LIB_XAPIANLETOR to be used without any arguments in the
23 # common case where Xapian is a requirement (rather than optional).
25 # XAPIANLETOR-CONFIG provides the default name for the xapianletor-config script
26 # (which the user can override with "./configure XAPIANLETOR_CONFIG=/path/to/it").
27 # If unset, the default is xapianletor-config.
28 AC_DEFUN([XO_LIB_XAPIANLETOR],
30 AC_ARG_VAR(XAPIANLETOR_CONFIG, [Location of xapianletor-config (default:] ifelse([$3], [], xapianletor-config, [$3]) [on PATH)])
31 dnl AC_PATH_PROG ignores an existing user setting of XAPIANLETOR_CONFIG unless it
32 dnl has a full path, so add special handling for such cases.
33 config_script_to_check_for="ifelse([$3], [], xapianletor-config, [$3])"
34 case $XAPIANLETOR_CONFIG in
37 AC_MSG_ERROR([XAPIANLETOR_CONFIG should point to a xapianletor-config script, not a configure script.])
40 # XAPIANLETOR_CONFIG has an absolute path, so AC_PATH_PROG can handle it.
43 # Convert a relative path to an absolute one.
44 XAPIANLETOR_CONFIG=`pwd`/$XAPIANLETOR_CONFIG
47 # If there's no path on XAPIANLETOR_CONFIG, use it as the name of the tool to
48 # search PATH for, so that things like this work:
49 # ./configure XAPIANLETOR_CONFIG=xapianletor-config-1.3
50 config_script_to_check_for=$XAPIANLETOR_CONFIG
54 AC_PATH_PROG(XAPIANLETOR_CONFIG, "$config_script_to_check_for")
55 AC_MSG_CHECKING([$XAPIANLETOR_CONFIG works])
56 dnl check for --ltlibs but not --libs as "xapianletor-config --libs" will
57 dnl fail if xapian isn't installed...
59 dnl run with exec to avoid leaking output on "real" bourne shells
60 if (exec >&5 2>&5 ; $XAPIANLETOR_CONFIG --ltlibs --cxxflags; exit $?) then
65 AC_MSG_ERROR(['$XAPIANLETOR_CONFIG' not found, aborting])
68 if test -d "$XAPIANLETOR_CONFIG" ; then
69 AC_MSG_ERROR(['$XAPIANLETOR_CONFIG' is a directory; it should be the filename of the xapianletor-config script])
71 AC_MSG_ERROR(['$XAPIANLETOR_CONFIG' not executable, aborting])
74 AC_MSG_ERROR(['$XAPIANLETOR_CONFIG --ltlibs --cxxflags' doesn't work, aborting])
77 dnl If LT_INIT, AC_PROG_LIBTOOL or the deprecated older version
78 dnl AM_PROG_LIBTOOL has already been expanded, enable libtool support now.
79 dnl Otherwise add hooks to the end of LT_INIT, AC_PROG_LIBTOOL and
80 dnl AM_PROG_LIBTOOL to enable it if one of these is expanded later.
81 XAPIANLETOR_VERSION=`$XAPIANLETOR_CONFIG --version|sed 's/.* //;s/_.*$//'`
82 XAPIANLETOR_CXXFLAGS=`$XAPIANLETOR_CONFIG --cxxflags`
83 AC_PROVIDE_IFELSE([LT_INIT],
84 [XAPIANLETOR_LIBS=`$XAPIANLETOR_CONFIG --ltlibs`],
85 [AC_PROVIDE_IFELSE([AC_PROG_LIBTOOL],
86 [XAPIANLETOR_LIBS=`$XAPIANLETOR_CONFIG --ltlibs`],
87 [AC_PROVIDE_IFELSE([AM_PROG_LIBTOOL],
88 [XAPIANLETOR_LIBS=`$XAPIANLETOR_CONFIG --ltlibs`],
89 dnl Pass magic option so xapianletor-config knows we called it (so it
90 dnl can choose a more appropriate error message if asked to link
91 dnl with an uninstalled libxapian). Also pass ac_top_srcdir
92 dnl so the error message can correctly say "configure.ac" or
93 dnl "configure.in" according to which is in use.
94 [XAPIANLETOR_LIBS=`ac_top_srcdir="$ac_top_srcdir" $XAPIANLETOR_CONFIG --from-xo-lib-xapianletor --libs`
96 [m4_define([LT_INIT], m4_defn([LT_INIT])
97 [XAPIANLETOR_LIBS=`$XAPIANLETOR_CONFIG --ltlibs`])])
98 m4_ifdef([AC_PROG_LIBTOOL],
99 [m4_define([AC_PROG_LIBTOOL], m4_defn([AC_PROG_LIBTOOL])
100 [XAPIANLETOR_LIBS=`$XAPIANLETOR_CONFIG --ltlibs`])])
101 m4_ifdef([AM_PROG_LIBTOOL],
102 [m4_define([AM_PROG_LIBTOOL], m4_defn([AM_PROG_LIBTOOL])
103 [XAPIANLETOR_LIBS=`$XAPIANLETOR_CONFIG --ltlibs`])])])])])
104 ifelse([$1], , :, [$1])
105 AC_SUBST(XAPIANLETOR_CXXFLAGS)
106 AC_SUBST(XAPIANLETOR_LIBS)
107 AC_SUBST(XAPIANLETOR_VERSION)
108 m4_define([XO_LIB_XAPIANLETOR_EXPANDED_], [])
111 # XO_LETOR_REQUIRE(VERSION[, ACTION-IF-LESS-THAN[, ACTION-IF-GREATHER-THAN-OR-EQUAL]])
112 # --------------------------------------------------------
113 # Check if $XAPIANLETOR_VERSION is at least VERSION. This macro should
114 # be used after XO_LIB_XAPIANLETOR.
116 # If ACTION-IF-LESS-THAN is unset, it defaults to an
117 # appropriate AC_MSG_ERROR saying that Xapian >= VERSION is needed.
119 # If ACTION-IF-GREATHER-THAN-OR-EQUAL is unset, the default is no
121 AC_DEFUN([XO_LETOR_REQUIRE],
123 m4_ifndef([XO_LIB_XAPIANLETOR_EXPANDED_],
124 [m4_fatal([XO_LETOR_REQUIRE can only be used after XO_LIB_XAPIANLETOR])])
125 dnl [Version component '$v' is not a number]
126 AC_MSG_CHECKING([if $XAPIANLETOR_CONFIG version >= $1])
129 set x `echo "$XAPIANLETOR_VERSION"|sed 's/_.*//'`
132 m4_foreach([min_component], m4_split([$1], [\.]), [
133 ifelse(regexp(min_component, [^[0-9][0-9]*$]), [-1], [m4_fatal(Component `min_component' not numeric)])dnl
134 if test -z "$res" ; then
136 if test "$[]1" -gt 'min_component' ; then
138 elif test "$[]1" -lt 'min_component' ; then
142 if test "$res" = 0 ; then
143 AC_MSG_RESULT([no ($XAPIANLETOR_VERSION)])
144 m4_default([$2], [AC_MSG_ERROR([XAPIANLETOR_VERSION is $XAPIANLETOR_VERSION, but >= $1 required])])
146 AC_MSG_RESULT([yes ($XAPIANLETOR_VERSION)])