diff options
-rw-r--r-- | configure.ac | 50 | ||||
-rw-r--r-- | providers/Makefile.am | 10 | ||||
-rw-r--r-- | providers/applespell_checker.h | 49 | ||||
-rw-r--r-- | providers/applespell_checker.mm | 30 | ||||
-rw-r--r-- | src/Makefile.am | 6 |
5 files changed, 54 insertions, 91 deletions
diff --git a/configure.ac b/configure.ac index 1049cbf..0f2a292 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,7 @@ AC_PROG_CC gl_EARLY AC_PROG_CXX AX_CXX_COMPILE_STDCXX(11) -AC_PROG_OBJC +AC_PROG_OBJCXX AC_PROG_INSTALL AC_PROG_LN_S AC_HEADER_STDC @@ -162,6 +162,7 @@ dnl Very hackish. dnl Ubuntu / Debian ship older version of unittest++ with their own pkg-config dnl and include dnl =========================================================================== +AC_LANG_PUSH([C++]) PKG_CHECK_EXISTS([UnitTest++], [PKG_CHECK_MODULES(UNITTESTPP, [UnitTest++]) dnl and because of the above, we need to tweak the include until we stop @@ -195,6 +196,7 @@ dnl supporting this old version. ) AC_SUBST(UNITTESTPP_CFLAGS) AC_SUBST(UNITTESTPP_LIBS) +AC_LANG_POP([C++]) dnl Provider detection @@ -228,10 +230,14 @@ AC_DEFUN([ENCHANT_CHECK_PKG_CONFIG_PROVIDER], AC_DEFUN([ENCHANT_CHECK_LIB_PROVIDER], [ENCHANT_CHECK_PROVIDER_SETUP([$1], [$4]) AS_IF([test "x$with_[]$1" != xno], - [AC_CHECK_HEADERS([$1[].h]) - AC_CHECK_LIB([$1], [$3],,, [$5]) - - if test "x$ac_cv_header_[]$1_h" != xyes -o "x$ac_cv_lib_[]$1[]_[]$3" != xyes; then + [_enchant_header=m4_default([$6], [$1[].h]) + AC_CHECK_HEADERS([$_enchant_header], [_header_found=yes], [_header_found=no], []) + if test "$3" != NOLIB; then + AC_CHECK_LIB([$1], [$3],,, [$5]) + else + ac_cv_lib_[]$1[]_[]$3=yes + fi + if test "x$_header_found" != xyes -o "x$ac_cv_lib_[]$1[]_[]$3" != xyes; then if test "x$with_[]$1" != xcheck; then AC_MSG_FAILURE([--with-[]$1 was given, but tests for $1 failed]) fi @@ -252,38 +258,18 @@ ENCHANT_CHECK_PKG_CONFIG_PROVIDER([hunspell], [HUNSPELL]) ENCHANT_CHECK_LIB_PROVIDER([aspell], [ASPELL], [get_aspell_dict_info_list]) ENCHANT_CHECK_LIB_PROVIDER([hspell], [HSPELL], [hspell_get_dictionary_path],, [-lz]) ENCHANT_CHECK_PKG_CONFIG_PROVIDER([voikko], [VOIKKO], [libvoikko]) +if test "$ac_cv_env_OBJCXX_value" != ""; then + AC_LANG_PUSH([Objective C++]) + ENCHANT_CHECK_LIB_PROVIDER([applespell], [APPLESPELL], [NOLIB],, [-framework Cocoa], [Cocoa/Cocoa.h]) + AC_LANG_POP([Objective C++]) +fi +dnl Must call AM_CONDITIONAL outside conditional +AM_CONDITIONAL(WITH_APPLESPELL, test "x$with_applespell" = xyes) dnl Experimental/deprecated providers ENCHANT_CHECK_PKG_CONFIG_PROVIDER([uspell], [USPELL], , [no]) ENCHANT_CHECK_PKG_CONFIG_PROVIDER([zemberek], [ZEMBEREK], [dbus-glib-1 >= 0.62], [no]) -dnl Apple Spell -ENCHANT_CHECK_PROVIDER_SETUP([applespell]) -AS_IF([test "x$with_applespell" != xno], - [AC_MSG_CHECKING([for applespell]) - case ${host_os} in - *darwin*) - APPLESPELL_CFLAGS=" -xobjective-c" - APPLESPELL_LIBS=" -lobjc" - APPLESPELL_LDFLAGS=" -framework Cocoa" - with_applespell=yes - build_providers+=" applespell" - ;; - *) - if test "x$with_applespell" != xcheck; then - AC_MSG_FAILURE([--with-applespell was given, but not building for macOS]) - fi - with_applespell=no - ;; - esac - AC_MSG_RESULT([$with_applespell]) - ]) -AC_SUBST(APPLESPELL_CFLAGS) -AC_SUBST(APPLESPELL_LIBS) -AC_SUBST(APPLESPELL_LDFLAGS) - -AM_CONDITIONAL(WITH_APPLESPELL, test "x$with_applespell" = xyes) - dnl ======================================================================================= AC_CONFIG_HEADERS([config.h]) diff --git a/providers/Makefile.am b/providers/Makefile.am index bb5bc99..b4ea39d 100644 --- a/providers/Makefile.am +++ b/providers/Makefile.am @@ -1,7 +1,4 @@ -# FIXME: Build and test AppleSpell back-end EXTRA_DIST = \ - applespell_checker.h \ - applespell_checker.mm \ AppleSpell.config \ libenchant_hunspell.rc @@ -47,3 +44,10 @@ endif enchant_zemberek_la_CXXFLAGS = $(AM_CXXFLAGS) $(ZEMBEREK_CFLAGS) enchant_zemberek_la_LIBADD = $(ZEMBEREK_LIBS) enchant_zemberek_la_SOURCES = enchant_zemberek.cpp + +if WITH_APPLESPELL +provider_LTLIBRARIES += enchant_applespell.la +endif +enchant_applespell_la_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag=CXX +enchant_applespell_la_OBJCXXFLAGS = $(AM_OBJCXXFLAGS) +enchant_applespell_la_SOURCES = applespell_checker.mm diff --git a/providers/applespell_checker.h b/providers/applespell_checker.h deleted file mode 100644 index 98dbdf7..0000000 --- a/providers/applespell_checker.h +++ /dev/null @@ -1,49 +0,0 @@ -/* enchant - * Copyright (C) 2004 Remi Payette - * Copyright (C) 2004 Francis James Franklin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02110-1301, USA. - */ - -#import <Cocoa/Cocoa.h> - -#include "enchant-provider.h" - -class AppleSpellChecker -{ - public: - AppleSpellChecker(); - - ~AppleSpellChecker(); - - void parseConfigFile (const char * configFile); - - bool checkWord (const char * word, size_t len, NSString * lang); - char ** suggestWord (const char * const word, size_t len, size_t * nsug, NSString * lang); - - NSString * requestDictionary (const char * const code); - private: - NSString * dictionaryForCode (NSString * code); - - NSSpellChecker * m_checker; - NSMutableDictionary * m_languages; -}; - -typedef struct -{ - AppleSpellChecker * AppleSpell; - NSString * DictionaryName; -} AppleSpellDictionary; diff --git a/providers/applespell_checker.mm b/providers/applespell_checker.mm index 67688a4..e21efcc 100644 --- a/providers/applespell_checker.mm +++ b/providers/applespell_checker.mm @@ -22,7 +22,35 @@ #include <glib.h> #include <gmodule.h> -#include "applespell_checker.h" +#import <Cocoa/Cocoa.h> + +#include "enchant-provider.h" + +class AppleSpellChecker +{ + public: + AppleSpellChecker(); + + ~AppleSpellChecker(); + + void parseConfigFile (const char * configFile); + + bool checkWord (const char * word, size_t len, NSString * lang); + char ** suggestWord (const char * const word, size_t len, size_t * nsug, NSString * lang); + + NSString * requestDictionary (const char * const code); + private: + NSString * dictionaryForCode (NSString * code); + + NSSpellChecker * m_checker; + NSMutableDictionary * m_languages; +}; + +typedef struct +{ + AppleSpellChecker * AppleSpell; + NSString * DictionaryName; +} AppleSpellDictionary; AppleSpellChecker::AppleSpellChecker() { diff --git a/src/Makefile.am b/src/Makefile.am index b55c032..f21fb8a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,12 +20,6 @@ endif libenchant_includedir = $(includedir)/enchant libenchant_include_HEADERS = enchant.h enchant-provider.h enchant++.h -if WITH_APPLESPELL -libenchant_la_CPPFLAGS += @APPLESPELL_CFLAGS@ -libenchant_la_LIBADD += @APPLESPELL_LIBS@ -libenchant_la_LDFLAGS += @APPLESPELL_LDFLAGS@ -endif - orderingdir=$(datadir)/enchant ordering_DATA = enchant.ordering |