1AC_INIT(src/enchant.h)
2AC_CANONICAL_HOST
3
4dnl Set release number
5dnl This is derived from "Versioning" chapter of info libtool documentation.
6PACKAGE=enchant
7dnl     4a) Increment when removing or changing interfaces.
8ENCHANT_MAJOR_VERSION=1
9dnl     4a) 5) Increment when adding interfaces.
10dnl     6) Set to zero when removing or changing interfaces.
11ENCHANT_MINOR_VERSION=6
12dnl     3) Increment when interfaces not changed at all,
13dnl               only bug fixes or internal changes made.
14dnl     4b) Set to zero when adding, removing or changing interfaces.
15ENCHANT_MICRO_VERSION=0
16dnl
17dnl     Set this too
18MAJOR_VERSION_PLUS_MINOR_VERSION=`expr $ENCHANT_MAJOR_VERSION + $ENCHANT_MINOR_VERSION`
19dnl
20VERSION=$ENCHANT_MAJOR_VERSION.$ENCHANT_MINOR_VERSION.$ENCHANT_MICRO_VERSION
21dnl Version info for libraries = CURRENT:REVISION:AGE
22VERSION_INFO=$MAJOR_VERSION_PLUS_MINOR_VERSION:$ENCHANT_MICRO_VERSION:$ENCHANT_MINOR_VERSION
23AC_SUBST(VERSION_INFO)
24AC_SUBST(ENCHANT_MAJOR_VERSION)
25AC_SUBST(ENCHANT_MINOR_VERSION)
26AC_SUBST(ENCHANT_MICRO_VERSION)
27
28AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
29AM_MAINTAINER_MODE
30
31dnl Checks for programs.
32AC_ISC_POSIX
33AC_PROG_CC
34AC_PROG_CPP
35AC_PROG_INSTALL
36AC_PROG_LN_S
37AC_PROG_MAKE_SET
38AC_STDC_HEADERS
39AC_LIBTOOL_WIN32_DLL
40AM_PROG_LIBTOOL
41gt_TYPE_SSIZE_T
42
43AC_C_CONST
44
45AC_CHECK_FUNCS(flock lockf)
46
47have_cxx=yes
48AC_PROG_CXX(,have_cxx=no)
49AM_CONDITIONAL(WITH_CXX, test "x$have_cxx" = "xyes")
50
51AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
52
53PKG_CHECK_MODULES(ENCHANT, [glib-2.0 >= 2.6 gmodule-2.0])
54
55dnl ===========================================================================
56dnl check compiler flags
57AC_DEFUN([ENCHANT_CC_TRY_FLAG], [
58  AC_MSG_CHECKING([whether $CC supports $1])
59
60  enchant_save_CFLAGS="$CFLAGS"
61  CFLAGS="$CFLAGS $1"
62
63  AC_COMPILE_IFELSE([ ], [enchant_cc_flag=yes], [enchant_cc_flag=no])
64  CFLAGS="$enchant_save_CFLAGS"
65
66  if test "x$enchant_cc_flag" = "xyes"; then
67    ifelse([$2], , :, [$2])
68  else
69    ifelse([$3], , :, [$3])
70  fi
71  AC_MSG_RESULT([$enchant_cc_flag])
72])
73
74dnl check compiler flags
75AC_DEFUN([ENCHANT_CXX_TRY_FLAG], [
76  AC_MSG_CHECKING([whether $CXX supports $1])
77
78  AC_LANG_PUSH(C++)
79  enchant_save_CXXFLAGS="$CXXFLAGS"
80  CXXFLAGS="$CXXFLAGS $1"
81
82  AC_COMPILE_IFELSE([ ], [enchant_cxx_flag=yes], [enchant_cxx_flag=no])
83  CXXFLAGS="$enchant_save_CXXFLAGS"
84
85  if test "x$enchant_cxx_flag" = "xyes"; then
86    ifelse([$2], , :, [$2])
87  else
88    ifelse([$3], , :, [$3])
89  fi
90  AC_MSG_RESULT([$enchant_cxx_flag])
91  AC_LANG_POP(C++)
92])
93
94dnl Use lots of warning flags with gcc and compatible compilers
95
96dnl Note: if you change the following variable, the cache is automatically
97dnl skipped and all flags rechecked.  So there's no need to do anything
98dnl else.  If for any reason you need to force a recheck, just change
99dnl MAYBE_WARN in an ignorable way (like adding whitespace)
100
101CC_MAYBE_WARN="-Wall -Wextra \
102-Wsign-compare -Werror-implicit-function-declaration \
103-Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
104-Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
105-Wpacked -Wswitch-enum -Wmissing-format-attribute \
106-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
107-Wdeclaration-after-statement -Wold-style-definition \
108-Wno-missing-field-initializers -Wno-unused-parameter \
109-Wno-attributes -Wno-long-long -Winline -fno-strict-aliasing"
110
111# invalidate cached value if MAYBE_WARN has changed
112if test "x$enchant_cv_warn_maybe" != "x$CC_MAYBE_WARN"; then
113	unset enchant_cv_warn_cflags
114fi
115AC_CACHE_CHECK([for supported C warning flags], enchant_cv_warn_cflags, [
116	echo
117	CC_WARN_CFLAGS=""
118
119	# Some warning options are not supported by all versions of
120	# gcc, so test all desired options against the current
121	# compiler.
122	#
123	# Note that there are some order dependencies
124	# here. Specifically, an option that disables a warning will
125	# have no net effect if a later option then enables that
126	# warnings, (perhaps implicitly). So we put some grouped
127	# options (-Wall and -Wextra) up front and the -Wno options
128	# last.
129
130	for W in $CC_MAYBE_WARN; do
131		ENCHANT_CC_TRY_FLAG([$W], [CC_WARN_CFLAGS="$CC_WARN_CFLAGS $W"])
132	done
133
134	enchant_cv_warn_cflags=$CC_WARN_CFLAGS
135	enchant_cv_warn_maybe=$CC_MAYBE_WARN
136
137	AC_MSG_CHECKING([which C warning flags were supported])])
138CC_WARN_CFLAGS="$enchant_cv_warn_cflags"
139AC_SUBST(CC_WARN_CFLAGS)
140
141CXX_MAYBE_WARN="-Wall -Wextra \
142-Wsign-compare \
143-Wpointer-arith -Wwrite-strings \
144-Wpacked -Wswitch-enum -Wmissing-format-attribute \
145-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
146-Wno-missing-field-initializers -Wno-unused-parameter \
147-Wno-attributes -Wno-long-long -Winline -fno-strict-aliasing"
148
149# invalidate cached value if MAYBE_WARN has changed
150if test "x$enchant_cxx_cv_warn_maybe" != "x$CXX_MAYBE_WARN"; then
151	unset enchant_cxx_cv_warn_cflags
152fi
153AC_CACHE_CHECK([for supported C++ warning flags], enchant_cxx_cv_warn_cflags, [
154	echo
155	CXX_WARN_CFLAGS=""
156
157	# Some warning options are not supported by all versions of
158	# gcc, so test all desired options against the current
159	# compiler.
160	#
161	# Note that there are some order dependencies
162	# here. Specifically, an option that disables a warning will
163	# have no net effect if a later option then enables that
164	# warnings, (perhaps implicitly). So we put some grouped
165	# options (-Wall and -Wextra) up front and the -Wno options
166	# last.
167
168	for W in $CXX_MAYBE_WARN; do
169		ENCHANT_CXX_TRY_FLAG([$W], [CXX_WARN_CFLAGS="$CXX_WARN_CFLAGS $W"])
170	done
171
172	enchant_cxx_cv_warn_cflags=$CXX_WARN_CFLAGS
173	enchant_cxx_cv_warn_maybe=$CXX_MAYBE_WARN
174
175	AC_MSG_CHECKING([which C++ warning flags were supported])])
176CXX_WARN_CFLAGS="$enchant_cxx_cv_warn_cflags"
177AC_SUBST(CXX_WARN_CFLAGS)
178
179ENCHANT_CFLAGS="$ENCHANT_CFLAGS -DENCHANT_PREFIX_DIR='\"$prefix\"'"
180
181AC_SUBST(ENCHANT_CFLAGS)
182AC_SUBST(ENCHANT_LIBS)
183
184AC_MSG_CHECKING([for native Win32])
185case "$target" in
186  *-*-mingw*)
187    native_win32=yes
188    SOCKET_LIBS='-lws2_32 -ldnsapi'
189    ENCHANT_WIN32_RESOURCE=enchant-win32res.lo
190    ;;
191  *)
192    native_win32=no
193    SOCKET_LIBS=''
194    ENCHANT_WIN32_RESOURCE=
195    ;;
196esac
197AC_MSG_RESULT([$native_win32])
198AM_CONDITIONAL(OS_WIN32, test "x$native_win32" = "xyes")
199AC_SUBST([ENCHANT_WIN32_RESOURCE])
200
201AC_SUBST(SOCKET_LIBS)
202
203# Courtesy of Glib: Ensure MSVC-compatible struct packing convention
204# is used when compiling for Win32 with gcc.
205# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
206# gcc2 uses "-fnative-struct".
207if test x"$native_win32" = xyes; then
208  if test x"$GCC" = xyes; then
209    msnative_struct=''
210    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
211    if test -z "$ac_cv_prog_CC"; then
212      our_gcc="$CC"
213    else
214      our_gcc="$ac_cv_prog_CC"
215    fi
216    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
217      2.)
218	if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
219	  msnative_struct='-fnative-struct'
220	fi
221	;;
222      *)
223	if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
224	  msnative_struct='-mms-bitfields'
225	fi
226	;;
227    esac
228    if test x"$msnative_struct" = x ; then
229      AC_MSG_RESULT([no way])
230      AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
231    else
232      CFLAGS="$CFLAGS $msnative_struct"
233      CXXFLAGS="$CXXFLAGS $msnative_struct"
234      AC_MSG_RESULT([${msnative_struct}])
235    fi
236  fi
237fi
238
239dnl ===========================================================================
240
241m4_copy([AC_DEFUN],[glib_DEFUN])
242glib_DEFUN([GLIB_LC_MESSAGES],
243  [AC_CHECK_HEADERS([locale.h])
244    if test $ac_cv_header_locale_h = yes; then
245    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
246      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
247       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
248    if test $am_cv_val_LC_MESSAGES = yes; then
249      AC_DEFINE(HAVE_LC_MESSAGES, 1,
250        [Define if your <locale.h> file defines LC_MESSAGES.])
251    fi
252  fi])
253
254GLIB_LC_MESSAGES
255
256dnl ===========================================================================
257
258dnl binreloc
259dnl AM_BINRELOC
260AM_CONDITIONAL(WITH_BINRELOC, test "x$br_cv_binreloc" = "xyes")
261
262build_ispell=yes
263
264AC_ARG_ENABLE(ispell, AS_HELP_STRING([--disable-ispell],[enable the ispell backend @<:@default=auto@:>@]), build_ispell="$enableval", build_ispell=yes)
265
266if test "x$have_cxx" = "xno"; then
267   build_ispell=no
268fi
269AM_CONDITIONAL(WITH_ISPELL, test "x$build_ispell" = "xyes")
270
271ispell_dir=${datadir}/enchant/ispell
272AC_ARG_WITH(ispell-dir, AS_HELP_STRING([--with-ispell-dir=PATH],[path to installed ispell dicts]))
273
274if test "x$with_ispell_dir" != "x" ; then
275   ispell_dir=$with_ispell_dir
276fi
277
278ISPELL_CFLAGS="-DENCHANT_ISPELL_DICT_DIR='\"$ispell_dir\"'"
279AC_SUBST(ISPELL_CFLAGS)
280
281build_myspell=yes
282
283AC_ARG_ENABLE(myspell, AS_HELP_STRING([--disable-myspell],[enable the myspell backend @<:@default=auto@:>@]), build_myspell="$enableval", build_myspell=yes)
284
285if test "x$have_cxx" = "xno"; then
286   build_myspell=no
287fi
288AM_CONDITIONAL(WITH_MYSPELL, test "x$build_myspell" = "xyes")
289
290myspell_dir=${datadir}/myspell/dicts
291AC_ARG_WITH(myspell-dir, AS_HELP_STRING([--with-myspell-dir=PATH],[path to installed myspell dicts]))
292
293if test "x$with_myspell_dir" != "x" ; then
294   myspell_dir=$with_myspell_dir
295fi
296
297MYSPELL_CFLAGS="$MYSPELL_CFLAGS -DENCHANT_MYSPELL_DICT_DIR='\"$myspell_dir\"'"
298
299AC_ARG_WITH(system-myspell, AS_HELP_STRING([--with-system-myspell=yes/no],[use the system myspell/hunspell @<:@default=auto@:>@]))
300if test "x$with_system_myspell" != "xno"; then
301	PKG_CHECK_MODULES(MYSPELL, [hunspell], have_system_myspell=true, have_system_myspell=false)
302	AC_SUBST(MYSPELL_CFLAGS)
303	AC_SUBST(MYSPELL_LIBS)
304else
305	have_system_myspell=false;
306fi
307AM_CONDITIONAL(WITH_SYSTEM_MYSPELL, test "x$have_system_myspell" = "xtrue")
308
309check_aspell=yes
310build_aspell=no
311
312AC_ARG_ENABLE(aspell, AS_HELP_STRING([--disable-aspell],[enable the aspell backend @<:@default=auto@:>@]), check_aspell="$enableval", check_aspell=yes)
313
314AC_ARG_WITH(aspell-prefix, AS_HELP_STRING([--with-aspell-prefix=DIR],[specify under which prefix aspell is installed]), aspell_prefix="$withval", )
315
316if test "x$check_aspell" != "xno"; then
317   saved_LDFLAGS=$LDFLAGS
318
319   ASPELL_CFLAGS=
320   if test "x$aspell_prefix" != "x"; then
321       LDFLAGS="-L$aspell_prefix/lib "$LDFLAGS
322       ASPELL_INC="-I$aspell_prefix/include"
323       ASPELL_LIBS="-L$aspell_prefix/lib -laspell"
324   else
325       aspell_prefix=${prefix}
326       if test "x$prefix" = "xNONE"; then
327	  aspell_prefix="/usr/local"
328       fi
329
330       AC_CHECK_PROG(HAVE_ASPELL, aspell, yes, no)
331       if test "x$HAVE_ASPELL" = "xyes"; then
332	  AC_MSG_CHECKING([For Aspell >= 0.50.0])
333	  aspell_major=`aspell -v | awk -F. '{print $4;}' | awk -F")" '{print $1;}'`
334	  if test "$aspell_major" -ge "50"; then
335	      aspell_prefix=`aspell config prefix`
336              LDFLAGS="-L${aspell_prefix}/lib "$LDFLAGS
337	      ASPELL_INC="-I${aspell_prefix}/include"
338	      ASPELL_LIBS="-L${aspell_prefix}/lib -laspell"
339	      AC_MSG_RESULT([yes])
340	  else
341	      AC_MSG_RESULT([unknown])
342	  fi
343      fi
344
345      if test "x$HAVE_ASPELL" != "xyes"; then
346	      AC_MSG_WARN([Didn't find aspell >= 0.50.0 and no explicit path aspell specified. Guessing at $aspell_prefix])
347	      ASPELL_LIBS="-L$aspell_prefix/lib -laspell"
348      fi
349   fi
350
351   AC_MSG_CHECKING([For aspell headers in $aspell_prefix/include])
352   if test -f "$aspell_prefix/include/pspell/pspell.h"; then
353       AC_MSG_RESULT([yes (pspell)])
354
355       AC_CHECK_LIB(aspell,new_aspell_config,build_aspell=yes,
356          [AC_CHECK_LIB(pspell, new_pspell_config, build_aspell=yes, AC_MSG_WARN([Enchant building without the aspell library]))]
357         ,)
358       AC_CHECK_LIB(aspell,get_aspell_dict_info_list,ASPELL_CFLAGS="-DASPELL_0_50_0=1",)
359
360       ASPELL_CFLAGS+=" -DHAVE_PSPELL_H"
361   elif test -f "$aspell_prefix/include/aspell.h"; then
362       AC_MSG_RESULT([yes (aspell)])
363
364       AC_CHECK_LIB(aspell,new_aspell_config,build_aspell=yes,
365          [AC_CHECK_LIB(pspell, new_pspell_config, build_aspell=yes, AC_MSG_WARN([Enchant building without the aspell library]))]
366         ,)
367       AC_CHECK_LIB(aspell,get_aspell_dict_info_list,ASPELL_CFLAGS="-DASPELL_0_50_0=1",)
368   else
369       AC_MSG_RESULT([no])
370       if test "x$HAVE_ASPELL" = "xyes"; then
371           AC_MSG_WARN([Didn't find pspell (aspell) headers])
372       fi
373   fi
374   LDFLAGS=$saved_LDFLAGS
375
376   AC_SUBST(ASPELL_INC)
377   AC_SUBST(ASPELL_LIBS)
378   AC_SUBST(ASPELL_CFLAGS)
379fi
380
381AM_CONDITIONAL(WITH_ASPELL, test "$build_aspell" = yes)
382
383check_voikko=yes
384build_voikko=no
385
386AC_ARG_ENABLE(voikko, AS_HELP_STRING([--disable-voikko],[enable the voikko backend @<:@default=auto@:>@]), check_voikko="$enableval", check_voikko=yes)
387
388AC_ARG_WITH(voikko-prefix, AS_HELP_STRING([--with-voikko-prefix=DIR],[specify under which prefix voikko is installed]), voikko_prefix="$withval", )
389
390if test "x$check_voikko" != "xno"; then
391   saved_LDFLAGS=$LDFLAGS
392
393   VOIKKO_INC=
394   VOIKKO_LIBS="-lvoikko"
395   if test "x$voikko_prefix" != "x"; then
396       LDFLAGS="-L$voikko_prefix/lib "$LDFLAGS
397       VOIKKO_INC="-I$voikko_prefix/include"
398       VOIKKO_LIBS="-L$voikko_prefix/lib "$VOIKKO_LIBS
399   fi
400
401   AC_CHECK_LIB(voikko,voikko_init,build_voikko=yes)
402
403   LDFLAGS=$saved_LDFLAGS
404
405   AC_SUBST(VOIKKO_INC)
406   AC_SUBST(VOIKKO_LIBS)
407fi
408
409AM_CONDITIONAL(WITH_VOIKKO, test "$build_voikko" = yes)
410
411build_uspell=no
412
413check_uspell=yes
414AC_ARG_ENABLE(uspell, AS_HELP_STRING([--disable-uspell],[enable the uspell backend @<:@default=auto@:>@]), check_uspell="$enableval", check_uspell=yes)
415
416if test "x$have_cxx" = "xno"; then
417   check_uspell=no
418fi
419
420if test "x$check_uspell" != "xno"; then
421   PKG_CHECK_MODULES(USPELL, [libuspell >= 1.1.0], build_uspell=yes, build_uspell=no)
422fi
423
424uspell_dir=${datadir}/uspell
425AC_ARG_WITH(uspell-dir, AS_HELP_STRING([--with-uspell-dir=PATH],[path to installed uspell dicts]))
426
427if test "x$with_uspell_dir" != "x" ; then
428   uspell_dir=$with_uspell_dir
429fi
430
431USPELL_CFLAGS="$USPELL_CFLAGS -DENCHANT_USPELL_DICT_DIR='\"$uspell_dir\"'"
432AC_SUBST(USPELL_CFLAGS)
433AC_SUBST(USPELL_LIBS)
434
435AM_CONDITIONAL(WITH_USPELL, test "$build_uspell" = yes)
436
437build_hspell=no
438check_hspell=yes
439AC_ARG_ENABLE(hspell, AS_HELP_STRING([--disable-hspell],[enable the hspell backend @<:@default=auto@:>@]), check_hspell="$enableval", check_hspell=yes)
440
441AC_ARG_WITH(hspell-prefix, AS_HELP_STRING([--with-hspell-prefix=DIR],[specify under which prefix hspell is installed]), hspell_prefix="$withval", )
442
443dnl change to pkg-config when hspell provides a hspell.pc file
444
445if test "x$check_hspell" != "xno"; then
446   saved_LDFLAGS=$LDFLAGS
447
448   HSPELL_CFLAGS=
449   HSPELL_LIBS=" -lhspell -lz"
450
451   if test "x$hspell_prefix" != "x"; then
452       LDFLAGS="-L$hspell_prefix/lib "$LDFLAGS
453       HSPELL_CFLAGS="-I$hspell_prefix/include"
454       HSPELL_LIBS="-L$hspell_prefix/lib "$HSPELL_LIBS
455   fi
456
457   AC_CHECK_LIB(hspell, hspell_get_dictionary_path, build_hspell=yes, build_hspell=no, -lz)
458   LDFLAGS=$saved_LDFLAGS
459
460   AC_SUBST(HSPELL_CFLAGS)
461   AC_SUBST(HSPELL_LIBS)
462fi
463
464AM_CONDITIONAL(WITH_HSPELL, test "$build_hspell" = yes)
465
466build_zemberek=no
467
468AC_ARG_ENABLE(zemberek, AS_HELP_STRING([--disable-zemberek],[enable the experimental zemberek (turkish) backend @<:@default=auto@:>@]), build_zemberek="$enableval", build_zemberek=no)
469
470if test "x$have_cxx" = "xno"; then
471   build_zemberek=no
472fi
473AC_MSG_CHECKING([For DBus-Glib >= 0.62])
474if pkg-config --atleast-version=0.62 dbus-glib-1; then
475	ZEMBEREK_CFLAGS=`pkg-config --cflags dbus-glib-1`
476	ZEMBEREK_LIBS=`pkg-config --libs dbus-glib-1`
477else
478	build_zemberek=no
479fi
480
481AC_SUBST(ZEMBEREK_CFLAGS)
482AC_SUBST(ZEMBEREK_LIBS)
483
484AM_CONDITIONAL(WITH_ZEMBEREK, test "x$build_zemberek" = "xyes")
485
486zemberek_dir=${datadir}/enchant/zemberek
487
488dnl =======================================================================================
489
490AC_OUTPUT([
491Makefile
492enchant.pc
493enchant-uninstalled.pc
494enchant.spec
495src/libenchant.rc
496src/Makefile
497src/aspell/Makefile
498src/ispell/Makefile
499src/uspell/Makefile
500src/myspell/Makefile
501src/hspell/Makefile
502src/applespell/Makefile
503src/voikko/Makefile
504src/zemberek/Makefile
505tests/Makefile
506tests/ispell
507doc/Makefile
508data/Makefile
509autopackage/default.apspec
510])
511
512dnl ===========================================================================================
513
514relocatable_library="no"
515if test "x$native_win32" = "xyes" || test "x$br_cv_binreloc" = "xyes"; then
516   relocatable_library="yes"
517fi
518
519echo "
520$PACKAGE-$VERSION
521
522	prefix:                         ${prefix}
523	compiler:                       ${CC}
524
525	Build Aspell backend:           ${build_aspell}
526	Build Ispell backend:           ${build_ispell}
527	Build Uspell backend:           ${build_uspell}
528	Build Hspell backend:           ${build_hspell}
529	Build Myspell/Hunspell backend: ${build_myspell}
530	Build Voikko backend:           ${build_voikko}
531	Build Zemberek backend:         ${build_zemberek}
532	Build a relocatable library:	${relocatable_library}"
533
534if test "x$build_zemberek" = "xyes"; then
535   echo "
536The Zemberek Turkish spell-checking plugin is enabled. It is known
537to cause crashes with WebKit. Use at your own discretion."
538fi
539