]> git.lyx.org Git - lyx.git/blob - config/spell.m4
Set buffer_ correctly when inseting a math macro over a selection
[lyx.git] / config / spell.m4
1 # Macro to add for using aspell spellchecker libraries!     -*- sh -*-
2 # Only checks for "new" aspell, > 0.50
3 AC_DEFUN([CHECK_WITH_ASPELL],
4 [
5         lyx_use_aspell=true
6         AC_ARG_WITH(aspell, AS_HELP_STRING([--without-aspell],[do not check for ASpell library]))
7         test "$with_aspell" = "no" && lyx_use_aspell=false
8
9         if $lyx_use_aspell ; then
10                 AC_CHECK_HEADERS(aspell.h,
11                         [lyx_use_aspell=true; break;],
12                         [lyx_use_aspell=false])
13                 AC_CHECK_LIB(aspell, new_aspell_config, LIBS="-laspell $LIBS", lyx_use_aspell=false)
14
15                 AC_MSG_CHECKING([whether to use aspell])
16                 if $lyx_use_aspell ; then
17                         AC_MSG_RESULT(yes)
18                         AC_DEFINE(USE_ASPELL, 1, [Define as 1 to use the aspell library])
19                         lyx_flags="$lyx_flags use-aspell"
20                 else
21                         AC_MSG_RESULT(no)
22                 fi
23         fi
24         ])
25
26 AC_DEFUN([LYX_HAVE_ENCHANT2],
27 [
28   AC_MSG_CHECKING([whether enchant is version 2.x at least])
29   save_CXXFLAGS=$CXXFLAGS
30   CXXFLAGS="$ENCHANT_CFLAGS $AM_CXXFLAGS $CXXFLAGS"
31
32   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <enchant++.h>]], [[enchant::Broker broker;]])],[AC_MSG_RESULT(yes)
33        AC_DEFINE(HAVE_ENCHANT2, 1, [Define to 1 if enchant 2.x is detected])
34       ],[AC_MSG_RESULT(no)])
35   CXXFLAGS=$save_CXXFLAGS
36 ])
37
38 AC_DEFUN([CHECK_WITH_ENCHANT],
39 [
40         lyx_use_enchant=true
41         AC_ARG_WITH(enchant, AS_HELP_STRING([--without-enchant],[do not check for Enchant library]))
42         test "$with_enchant" = "no" && lyx_use_enchant=false
43
44         if $lyx_use_enchant; then
45                 PKG_CHECK_MODULES([ENCHANT], [enchant-2], [],
46                     [PKG_CHECK_MODULES([ENCHANT], [enchant], [],
47                         [lyx_use_enchant=false])])
48                 AC_MSG_CHECKING([whether to use enchant])
49                 if $lyx_use_enchant ; then
50                     AC_MSG_RESULT(yes)
51                     AC_DEFINE(USE_ENCHANT, 1, [Define as 1 to use the enchant library])
52                     LYX_HAVE_ENCHANT2
53                     lyx_flags="$lyx_flags use-enchant"
54                 else
55                     AC_MSG_RESULT(no)
56                 fi
57         fi
58     ])
59
60 AC_DEFUN([LYX_HAVE_HUNSPELL_CXXABI],
61 [
62   AC_MSG_CHECKING([whether hunspell C++ (rather than C) ABI is provided])
63   save_CXXFLAGS=$CXXFLAGS
64   CXXFLAGS="$HUNSPELL_CFLAGS $AM_CXXFLAGS $CXXFLAGS"
65
66 # in the C++ ABI, stem() returns a vector, in the C ABI, it returns an int
67   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <hunspell/hunspell.hxx>]], [[Hunspell sp("foo", "bar");
68        int i = sp.stem("test").size();]])],[AC_MSG_RESULT(yes)
69        AC_DEFINE(HAVE_HUNSPELL_CXXABI, 1, [Define to 1 if hunspell C++ (rather than C) ABI is detected])
70        have_hunspell_cxx_abi=yes
71       ],[AC_MSG_RESULT(no)])
72   CXXFLAGS=$save_CXXFLAGS
73 ])
74
75 # Macro to add for using hunspell spellchecker libraries!     -*- sh -*-
76 AC_DEFUN([CHECK_WITH_HUNSPELL],
77 [
78         lyx_use_hunspell=true
79         AC_ARG_WITH(hunspell, AS_HELP_STRING([--without-hunspell],[do not check for Hunspell library]))
80         test "$with_hunspell" = "no" && lyx_use_hunspell=false
81
82         if $lyx_use_hunspell ; then
83         PKG_CHECK_MODULES([HUNSPELL], [hunspell], [], [
84                   AC_CHECK_HEADERS(hunspell/hunspell.hxx,
85                     [lyx_use_hunspell=true; break;],
86                          [lyx_use_hunspell=false])
87                          AC_CHECK_LIB(hunspell, main, LIBS="-lhunspell $LIBS", lyx_use_hunspell=false)
88                 ])
89         fi
90         AC_MSG_CHECKING([whether to use hunspell])
91         if $lyx_use_hunspell ; then
92                 AC_MSG_RESULT(yes)
93                 AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
94                 lyx_flags="$lyx_flags use-hunspell"
95                 LYX_HAVE_HUNSPELL_CXXABI
96                 if test $enable_stdlib_debug = "yes" -a -n "$have_hunspell_cxx_abi" ; then
97                     LYX_WARNING([Compiling LyX with stdlib-debug and system hunspell libraries may lead to
98    crashes. Consider using --disable-stdlib-debug or --with-included-hunspell.])
99                 fi
100         else
101                 AC_MSG_RESULT(no)
102         fi
103     ])
104
105 dnl Usage: LYX_USE_INCLUDED_HUNSPELL : select if the included hunspell should
106 dnl        be used.
107 AC_DEFUN([LYX_USE_INCLUDED_HUNSPELL],[
108         AC_MSG_CHECKING([whether to use included hunspell library])
109         AC_ARG_WITH(included-hunspell,
110                 [AS_HELP_STRING([--with-included-hunspell], [use the hunspell lib supplied with LyX instead of the system one])],
111                 [lyx_cv_with_included_hunspell=$withval],
112                 [lyx_cv_with_included_hunspell=no])
113         AM_CONDITIONAL(USE_INCLUDED_HUNSPELL, test x$lyx_cv_with_included_hunspell = xyes)
114         AC_MSG_RESULT([$lyx_cv_with_included_hunspell])
115         if test x$lyx_cv_with_included_hunspell = xyes ; then
116                 lyx_included_libs="$lyx_included_libs hunspell"
117                 HUNSPELL_CFLAGS='-I$(top_srcdir)/3rdparty/hunspell/1.7.0/src'
118                 HUNSPELL_LIBS='$(top_builddir)/3rdparty/hunspell/liblyxhunspell.a'
119                 AC_SUBST(HUNSPELL_CFLAGS)
120                 AC_SUBST(HUNSPELL_LIBS)
121         fi
122         ])
123
124
125 ### Check if we want spell libraries, prefer new aspell or hunspell
126 AC_DEFUN([LYX_CHECK_SPELL_ENGINES],
127 [
128         LYX_USE_INCLUDED_HUNSPELL
129         if test x$lyx_cv_with_included_hunspell = xyes ; then
130 dnl the user wanted to use the included hunspell, so do not check for external hunspell
131                 lyx_use_hunspell=true
132                 AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
133                 AC_DEFINE(HAVE_HUNSPELL_CXXABI, 1, [Define to 1 if hunspell C++ (rather than C) ABI is detected])
134                 lyx_flags="$lyx_flags use-hunspell"
135         else
136                 CHECK_WITH_HUNSPELL
137         fi
138         CHECK_WITH_ASPELL
139         CHECK_WITH_ENCHANT
140
141         AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
142         AM_CONDITIONAL(USE_ENCHANT, $lyx_use_enchant)
143         AM_CONDITIONAL(USE_HUNSPELL, $lyx_use_hunspell)
144         ])
145