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