sync with 0.7.4cvs21
[claws.git] / ac / pspell.m4
1 dnl Autoconf macros for libpspell
2 dnl $Id$
3
4 # Configure paths for PSPELL
5 # Shamelessly stolen from the one of GPGME by Werner Koch 
6 # Melvin Hadasht  2001-09-17
7
8 dnl AM_PATH_PSPELL([MINIMUM-VERSION,
9 dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
10 dnl Test for pspell, and define PSPELL_CFLAGS and PSPELL_LIBS
11 dnl
12 AC_DEFUN(AM_PATH_PSPELL,
13 [dnl
14 dnl Get the cflags and libraries from the pspell-config script
15 dnl
16   AC_ARG_WITH(pspell-prefix,
17    [  --with-pspell-prefix=PFX           Prefix where pspell-config is installed (optional)],
18           pspell_config_prefix="$withval", pspell_config_prefix="")
19   AC_ARG_ENABLE(pspelltest,
20    [  --disable-pspelltest               Do not try to compile and run a test pspell program],
21           , enable_pspelltest=yes)
22   AC_ARG_WITH(pspelllibs,
23    [  --with-pspell-libs=LIBS            Where pspell library reside (/usr/local/lib)],
24           pspell_libs=$pspelllibs, pspell_libs='/usr/local/lib')
25   AC_ARG_WITH(pspellincludes,
26    [  --with-pspell-includes=INCLUDES    Where pspell headers reside (/usr/local/include)],
27           pspell_includes=$pspelllibs, pspell_includes='/usr/local/include')
28
29
30   if test x$pspell_config_prefix != x ; then
31      if test x${PSPELL_CONFIG+set} != xset ; then
32         PSPELL_CONFIG=$pspell_config_prefix/bin/pspell-config
33      fi
34   fi
35
36   AC_PATH_PROG(PSPELL_CONFIG, pspell-config, no)
37   min_pspell_version=ifelse([$1], ,.12.2,$1)
38   AC_MSG_CHECKING(for pspell - version >= $min_pspell_version)
39   no_pspell=""
40   if test "$PSPELL_CONFIG" = "no" ; then
41     no_pspell=yes
42   else
43     PSPELL_CFLAGS="-I$pspell_includes"
44     PSPELL_LIBS="-L$pspell_libs -lpspell"
45     pspell_config_version=`$PSPELL_CONFIG version`
46     if test "x$enable_pspelltest" = "xyes" ; then
47       ac_save_CFLAGS="$CFLAGS"
48       ac_save_LIBS="$LIBS"
49       CFLAGS="$CFLAGS $PSPELL_CFLAGS"
50       LIBS="$LIBS $PSPELL_LIBS"
51 dnl
52 dnl 
53 dnl
54       rm -f conf.pspelltest
55       AC_TRY_RUN([
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 #include <pspell/pspell.h>
60
61 int
62 main ()
63 {
64  system ("touch conf.pspelltest");
65  if(strcmp("$pspell_config_version","$min_pspell_version")<0){
66    printf("no\n");
67    return 1;
68    }
69  return 0;
70 }
71 ],, no_pspell=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
72        CFLAGS="$ac_save_CFLAGS"
73        LIBS="$ac_save_LIBS"
74      fi
75   fi
76   if test "x$no_pspell" = x ; then
77      AC_MSG_RESULT(yes)
78      ifelse([$2], , :, [$2])
79   else
80      if test -f conf.pspelltest ; then
81         :
82      else
83         AC_MSG_RESULT(no)
84      fi
85      if test "$PSPELL_CONFIG" = "no" ; then
86        echo "*** The pspell-config script installed by pspell could not be found"
87        echo "*** If pspell was installed in PREFIX, make sure PREFIX/bin is in"
88        echo "*** your path, or set the PSPELL_CONFIG environment variable to the"
89        echo "*** full path to pspell-config."
90      else
91        if test -f conf.pspelltest ; then
92         :
93        else
94           echo "*** Could not run pspell test program, checking why..."
95           CFLAGS="$CFLAGS $PSPELL_CFLAGS"
96           LIBS="$LIBS $PSPELL_LIBS"
97           AC_TRY_LINK([
98 #include <stdio.h>
99 #include <stdlib.h>
100 #include <string.h>
101 #include <pspell/pspell.h>
102 ],      [ PspellConfig * pspellconfig= new_pspell_config(); return 0 ],
103         [ 
104 echo "*** The test program compiled, but did not run. This usually means"
105 echo "*** that the run-time linker is not finding pspell or finding the wrong"
106 echo "*** version of pspell. If it is not finding pspell, you'll need to set your"
107 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
108 echo "*** to the installed location  Also, make sure you have run ldconfig if"
109 echo "*** that is required on your system"
110 echo "***"
111 echo "*** If you have an old version installed, it is best to remove it,"
112 echo "*** although you may also be able to get things to work by"
113 echo "*** modifying LD_LIBRARY_PATH"
114 echo "***"
115         ],
116         [
117 echo "*** The test program failed to compile or link. See the file config.log"
118 echo "*** for the exact error that occured. This usually means pspell was"
119 echo "*** incorrectly installed or that you have moved pspell since it was"
120 echo "*** installed. In the latter case, you may want to edit the"
121 echo "*** pspell-config script: $PSPELL_CONFIG" 
122         ])
123           CFLAGS="$ac_save_CFLAGS"
124           LIBS="$ac_save_LIBS"
125        fi
126      fi
127      PSPELL_CFLAGS=""
128      PSPELL_LIBS=""
129      ifelse([$3], , :, [$3])
130   fi
131   AC_SUBST(PSPELL_CFLAGS)
132   AC_SUBST(PSPELL_LIBS)
133   rm -f conf.pspelltest
134 ])
135