Fix a memory leak in rssyl_update_comments().
[claws.git] / m4 / aspell.m4
1 dnl Autoconf macros for libaspell
2 dnl Copyright (C) 2003 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 # Configure paths for ASPELL
8 # Shamelessly stolen from the one of GPGME by Werner Koch 
9 # Melvin Hadasht  2001-09-17, 2002
10
11 dnl AM_PATH_ASPELL([MINIMUM-VERSION,
12 dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
13 dnl Test for aspell, and define ASPELL_CFLAGS, ASPELL_LIBS and ASPELL_PATH
14 dnl
15 AC_DEFUN([AM_PATH_ASPELL],
16 [dnl
17 dnl Get the cflags and libraries from the aspell-config script
18 dnl
19    AC_ARG_WITH(aspell-prefix,
20       [  --with-aspell-prefix=PFX           Prefix where aspell is installed (optional)],
21       aspell_prefix="$withval", aspell_prefix="")
22    AC_ARG_ENABLE(aspell-test,
23       [  --disable-aspell-test   Do not try to compile and run a test GNU/aspell program],
24       , enable_aspelltest=yes)
25    AC_ARG_WITH(aspell-libs,
26       [  --with-aspell-libs=LIBS            Where GNU/aspell library reside (/usr/local/lib)],
27       aspell_libs="$withval", aspell_libs="")
28    AC_ARG_WITH(aspell-includes,
29       [  --with-aspell-includes=INCLUDES    Where GNU/aspell headers reside (/usr/local/include)],
30       aspell_includes="$withval", aspell_includes="")
31
32   if test x$aspell_prefix != x ; then
33      if test x${ASPELL+set} != xset ; then
34         ASPELL=$aspell_prefix/bin/aspell
35      fi
36      if test x$aspell_includes = x ; then
37         aspell_includes=$aspell_prefix/include
38      fi
39      if test x$aspell_libs = x ; then
40         aspell_libs=$aspell_prefix/lib
41      fi
42      aspell_path=$aspell_prefix/lib/aspell
43   fi
44   if test x$aspell_includes = x ; then
45      aspell_includes=/usr/local/include
46   fi
47   if test x$aspell_libs = x ; then
48      aspell_libs=/usr/local/lib
49   fi
50   if test x$aspell_path = x ; then
51      aspell_path=/usr/local/lib/aspell
52   fi
53   if test "x$enable_aspelltest" != "xyes" ; then
54      echo "*** Disabling GNU/aspell tests upon user request" 
55      ASPELL_CFLAGS="-I$aspell_includes"
56      ASPELL_LIBS="-L$aspell_libs -laspell"
57      AC_DEFINE_UNQUOTED(ASPELL_PATH, "${aspell_path}/", Define ASPELL's default directory)
58      ifelse([$2], , :, [$2])
59   else   
60      AC_PATH_PROG(ASPELL, aspell, no)
61      min_aspell_version=ifelse([$1], ,.50,$1)
62      AC_MSG_CHECKING(for GNU/aspell - version >= $min_aspell_version)
63      no_aspell=""
64      if test "$ASPELL" = "no" ; then
65         echo "*** The aspell executable could not be found"
66         echo "*** If aspell was installed in PREFIX, make sure PREFIX/bin is in"
67         echo "*** your path, or set the ASPELL environment variable to the"
68         echo "*** full path to aspell or configure with --with-aspell-prefix=PREFIX."
69         ASPELL_CFLAGS=""
70         ASPELL_LIBS=""
71         ASPELL_PATH=""
72         no_aspell=yes
73         ifelse([$3], , :, [$3])
74      else
75         ASPELL_CFLAGS="-I$aspell_includes"
76         ASPELL_LIBS="-L$aspell_libs -laspell"
77         aspell_version=`$ASPELL version|sed -e "s/\(@(#) International Ispell Version 3.1.20 (but really Aspell \)\(.*\))/\2/"`
78         rm -f conf.aspelltest
79         AC_TRY_RUN([
80 #include <stdio.h>
81 #include <stdlib.h>
82 #include <string.h>
83
84 int
85 main ()
86 {
87  system ("touch conf.aspelltest");
88  if(strcmp("$aspell_version","$min_aspell_version")<0){
89    return 1;
90    }
91  return 0;
92 }
93         ],, no_aspell=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
94         rm -f conf.aspelltest
95         if test "x$no_aspell" = x ; then
96            AC_MSG_RESULT(yes)
97            AC_MSG_CHECKING(for GNU/aspell dictionaries location)
98            aspell_path="`$ASPELL config dict-dir`"
99            AC_DEFINE_UNQUOTED(ASPELL_PATH, "${aspell_path}/", Define ASPELL's default directory)
100            AC_MSG_RESULT($aspell_path)
101            AC_MSG_CHECKING(if GNU/aspell is correctly installed)
102            ac_save_CFLAGS="$CFLAGS"
103            ac_save_LIBS="$LIBS"
104            CFLAGS="$CFLAGS $ASPELL_CFLAGS"
105            LIBS="$LIBS $ASPELL_LIBS"
106            AC_TRY_RUN([
107 #include <stdio.h>
108 #include <stdlib.h>
109 #include <string.h>
110 #include <aspell.h>
111
112 int
113 main()
114 {
115  AspellConfig * aspellconfig = new_aspell_config();
116  return 0;
117 }
118            ],, aspell_failure=yes,)
119            rm -f conftest.c
120            CFLAGS="$ac_save_CFLAGS"
121            LIBS="$ac_save_LIBS"
122            if test "x$aspell_failure" = x ; then     
123               AC_MSG_RESULT(yes)
124               ifelse([$2], , :, [$2])
125            else
126               AC_MSG_RESULT(no)
127               echo "*** The GNU/aspell test program did not succeed. This usually means that "
128               echo "*** the headers and the libraries could not be found. Check config.log"
129               echo "*** for detailed error message and add the relevant options"
130               echo "*** --with-aspell-prefix, --with-aspell-includes or --with-aspell-libs"
131               echo "*** to the configure command."
132               echo "*** This can also mean that the library was not found at runtime. In that case"
133               echo "*** add its path to LD_LIBRARY_PATH environment variable or in /etc/ld.so.conf"
134               ASPELL_CFLAGS=""
135               ASPELL_LIBS=""
136               ASPELL_PATH=""
137               ifelse([$3], , :, [$3])
138            fi
139         else
140            AC_MSG_RESULT(no)
141            ASPELL_CFLAGS=""
142            ASPELL_LIBS=""
143            ASPELL_PATH=""
144            ifelse([$3], , :, [$3])
145         fi   
146      fi 
147   fi
148   AC_SUBST(ASPELL_CFLAGS)
149   AC_SUBST(ASPELL_LIBS)
150   AC_SUBST(ASPELL_PATH)
151 ])
152