]> git.lyx.org Git - lyx.git/blob - config/spell.m4
tex2lyx: normalize bib and bst paths
[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], [], [lyx_use_enchant=false])
49                 AC_MSG_CHECKING([whether to use enchant])
50                 if $lyx_use_enchant ; then
51                     AC_MSG_RESULT(yes)
52                     AC_DEFINE(USE_ENCHANT, 1, [Define as 1 to use the enchant library])
53                     LYX_HAVE_ENCHANT2
54                     lyx_flags="$lyx_flags use-enchant"
55                 else
56                     AC_MSG_RESULT(no)
57                 fi
58         fi
59     ])
60
61 # Macro to add for using hunspell spellchecker libraries!     -*- sh -*-
62 AC_DEFUN([CHECK_WITH_HUNSPELL],
63 [
64         lyx_use_hunspell=true
65         AC_ARG_WITH(hunspell, AC_HELP_STRING([--without-hunspell],[do not check for Hunspell library]))
66         test "$with_hunspell" = "no" && lyx_use_hunspell=false
67
68         if $lyx_use_hunspell ; then
69         PKG_CHECK_MODULES([HUNSPELL], [hunspell], [], [
70                   AC_CHECK_HEADERS(hunspell/hunspell.hxx,
71                     [lyx_use_hunspell=true; break;],
72                          [lyx_use_hunspell=false])
73                          AC_CHECK_LIB(hunspell, main, LIBS="-lhunspell $LIBS", lyx_use_hunspell=false)
74                 ])
75         AC_MSG_CHECKING([whether to use hunspell])
76         if $lyx_use_hunspell ; then
77                 AC_MSG_RESULT(yes)
78                 AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
79                 lyx_flags="$lyx_flags use-hunspell"
80         else
81                 AC_MSG_RESULT(no)
82         fi
83     fi
84     ])
85
86 dnl Usage: LYX_USE_INCLUDED_HUNSPELL : select if the included hunspell should
87 dnl        be used.
88 AC_DEFUN([LYX_USE_INCLUDED_HUNSPELL],[
89         AC_MSG_CHECKING([whether to use included hunspell library])
90         AC_ARG_WITH(included-hunspell,
91                 [AC_HELP_STRING([--with-included-hunspell], [use the hunspell lib supplied with LyX instead of the system one])],
92                 [lyx_cv_with_included_hunspell=$withval],
93                 [lyx_cv_with_included_hunspell=no])
94         AM_CONDITIONAL(USE_INCLUDED_HUNSPELL, test x$lyx_cv_with_included_hunspell = xyes)
95         AC_MSG_RESULT([$lyx_cv_with_included_hunspell])
96         if test x$lyx_cv_with_included_hunspell = xyes ; then
97                 lyx_included_libs="$lyx_included_libs hunspell"
98                 HUNSPELL_CFLAGS='-I$(top_srcdir)/3rdparty/hunspell/1.6.2/src'
99                 HUNSPELL_LIBS='$(top_builddir)/3rdparty/hunspell/liblyxhunspell.a'
100                 AC_SUBST(HUNSPELL_CFLAGS)
101                 AC_SUBST(HUNSPELL_LIBS)
102         fi
103         ])
104
105
106 ### Check if we want spell libraries, prefer new aspell or hunspell
107 AC_DEFUN([LYX_CHECK_SPELL_ENGINES],
108 [
109         LYX_USE_INCLUDED_HUNSPELL
110         if test x$lyx_cv_with_included_hunspell = xyes ; then
111 dnl the user wanted to use the included hunspell, so do not check for external hunspell
112                 lyx_use_hunspell=true
113                 AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
114                 lyx_flags="$lyx_flags use-hunspell"
115         else
116                 CHECK_WITH_HUNSPELL
117         fi
118         CHECK_WITH_ASPELL
119         CHECK_WITH_ENCHANT
120
121         AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
122         AM_CONDITIONAL(USE_ENCHANT, $lyx_use_enchant)
123         AM_CONDITIONAL(USE_HUNSPELL, $lyx_use_hunspell)
124         ])
125