]> git.lyx.org Git - lyx.git/blob - config/spell.m4
ctest update: we now work around a problem with Czech or Slovak text in some tables.
[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="$ENCHANT_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         AC_MSG_CHECKING([whether to use hunspell])
90         if $lyx_use_hunspell ; then
91                 AC_MSG_RESULT(yes)
92                 AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
93                 lyx_flags="$lyx_flags use-hunspell"
94         else
95                 AC_MSG_RESULT(no)
96         fi
97     fi
98         LYX_HAVE_HUNSPELL_CXXABI
99         if test $enable_stdlib_debug = "yes" -a -n "$have_hunspell_cxx_abi" ; then
100                 LYX_WARNING([Compiling LyX with stdlib-debug and system hunspell libraries may lead to
101    crashes. Consider using --disable-stdlib-debug or --with-included-hunspell.])
102               fi
103
104     ])
105
106 dnl Usage: LYX_USE_INCLUDED_HUNSPELL : select if the included hunspell should
107 dnl        be used.
108 AC_DEFUN([LYX_USE_INCLUDED_HUNSPELL],[
109         AC_MSG_CHECKING([whether to use included hunspell library])
110         AC_ARG_WITH(included-hunspell,
111                 [AS_HELP_STRING([--with-included-hunspell], [use the hunspell lib supplied with LyX instead of the system one])],
112                 [lyx_cv_with_included_hunspell=$withval],
113                 [lyx_cv_with_included_hunspell=no])
114         AM_CONDITIONAL(USE_INCLUDED_HUNSPELL, test x$lyx_cv_with_included_hunspell = xyes)
115         AC_MSG_RESULT([$lyx_cv_with_included_hunspell])
116         if test x$lyx_cv_with_included_hunspell = xyes ; then
117                 lyx_included_libs="$lyx_included_libs hunspell"
118                 HUNSPELL_CFLAGS='-I$(top_srcdir)/3rdparty/hunspell/1.7.0/src'
119                 HUNSPELL_LIBS='$(top_builddir)/3rdparty/hunspell/liblyxhunspell.a'
120                 AC_SUBST(HUNSPELL_CFLAGS)
121                 AC_SUBST(HUNSPELL_LIBS)
122         fi
123         ])
124
125
126 ### Check if we want spell libraries, prefer new aspell or hunspell
127 AC_DEFUN([LYX_CHECK_SPELL_ENGINES],
128 [
129         LYX_USE_INCLUDED_HUNSPELL
130         if test x$lyx_cv_with_included_hunspell = xyes ; then
131 dnl the user wanted to use the included hunspell, so do not check for external hunspell
132                 lyx_use_hunspell=true
133                 AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
134                 AC_DEFINE(HAVE_HUNSPELL_CXXABI, 1, [Define to 1 if hunspell C++ (rather than C) ABI is detected])
135                 lyx_flags="$lyx_flags use-hunspell"
136         else
137                 CHECK_WITH_HUNSPELL
138         fi
139         CHECK_WITH_ASPELL
140         CHECK_WITH_ENCHANT
141
142         AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
143         AM_CONDITIONAL(USE_ENCHANT, $lyx_use_enchant)
144         AM_CONDITIONAL(USE_HUNSPELL, $lyx_use_hunspell)
145         ])
146