Integrated the DKIM signer into serv_smtpclient, but disabled it
[citadel.git] / libcitadel / configure.ac
1 dnl   configuration script for libcitadel
2 dnl   Process this file with autoconf to produce a configure script.
3 dnl
4
5 dnl Ensure that libcitadel is configured with autoconf 2.52 or newer
6 AC_PREREQ([2.69])
7 AC_INIT([libcitadel],[m4_esyscmd_s(grep LIBCITADEL_VERSION lib/libcitadel.h | sed 's/[^0-9]*//g' )],[http://uncensored.citadel.org])
8 AC_CONFIG_SRCDIR(Makefile.in)
9 AC_CONFIG_AUX_DIR(conftools)
10
11 dnl
12 dnl Set LIBREVISION to the ever-ascending libcitadel version number.
13 dnl
14 dnl If the API has changed, increment LIBCURRENT.
15 dnl
16 dnl Set LIBAGE to 0.
17 dnl
18
19 LIBCURRENT=4
20 LIBREVISION=m4_esyscmd_s([grep LIBCITADEL_VERSION lib/libcitadel.h | sed 's/[^0-9]*//g' ])
21 LIBAGE=0
22
23 sinclude(conftools/libtool.m4)
24 sinclude(conftools/ac_c_bigendian_cross.m4)
25
26 AC_PROG_LIBTOOL
27
28 AC_SUBST(LIBCURRENT)
29 AC_SUBST(LIBREVISION)
30 AC_SUBST(LIBAGE)
31
32 dnl Checks for programs.
33 AC_PROG_CC
34 AC_PROG_INSTALL
35
36 if test "$GCC" = yes ; then
37     dnl
38     dnl Be careful about adding the -fexceptions option; some versions of
39     dnl GCC don't support it and it causes extra warnings that are only
40     dnl distracting; avoid.
41     dnl
42     OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
43     CFLAGS="$OLDCFLAGS -fexceptions"
44     AC_MSG_CHECKING(whether $CC accepts -fexceptions)
45     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS"])
46     CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
47 fi
48
49 dnl Checks for header files.
50 m4_warn([obsolete],
51 [The preprocessor macro `STDC_HEADERS' is obsolete.
52   Except in unusual embedded environments, you can safely include all
53   ISO C90 headers unconditionally.])dnl
54 # Autoupdate added the next two lines to ensure that your configure
55 # script's behavior did not change.  They are probably safe to remove.
56 AC_CHECK_INCLUDES_DEFAULT
57 AC_PROG_EGREP
58
59
60 AC_CHECK_HEADER(sys/mman.h, [CFLAGS="$CFLAGS -D HAVE_MMAP"])
61 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
62 dnl Checks for the zlib compression library.
63 if test "x$with_zlib" != xno ; then
64         AC_CHECK_HEADERS(zlib.h,
65                 [AC_CHECK_LIB(z, zlibVersion,
66                         [ok_zlib=yes],,
67         )])
68 fi
69
70 if test "x$ok_zlib" = xyes ; then
71         LIBS="-lz $LIBS"
72         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
73 fi
74
75 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
76
77 AC_CHECK_HEADER(sys/sendfile.h, [AC_DEFINE(LINUX_SENDFILE, [], [whether we have the linux sendfile api])])
78 dnl TODO: we might need to check for the actual syntax....  
79
80
81 AC_MSG_CHECKING([whether your system knows about splice()]) 
82 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
83 #define _GNU_SOURCE
84 #include <unistd.h>
85 #include <fcntl.h>
86 ]], [[
87         ssize_t sent, pipesize;
88         int fd, SplicePipe[2];
89         pipesize = splice(fd, NULL, 
90                           SplicePipe[1], NULL, 
91                           1, 
92                           SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
93 ]])],[
94                   ok_splice=yes
95                   AC_DEFINE(LINUX_SPLICE, [], [whether we have the linux splice api])
96                   AC_MSG_RESULT([yes])
97                 ],[ 
98                   ok_splice=no
99                   AC_MSG_RESULT([no])
100                 
101 ])
102
103 AC_MSG_CHECKING([whether your system likes memcpy + HKEY]) 
104 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
105 #define _GNU_SOURCE
106 #include <ctype.h>
107 #include <errno.h>
108 #include <string.h>
109 #include <unistd.h>
110 #include <string.h>
111 #include <stdio.h>
112 #include <sys/select.h>
113 #include <fcntl.h>
114 #include <sys/types.h>
115
116 #include "lib/libcitadel.h"
117 ]], [[
118         char foo[22];
119         memcpy(foo, HKEY("foo"));
120         
121 ]])],[
122
123                   AC_MSG_RESULT([yes])
124                 ],[ 
125                   AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
126                   AC_MSG_RESULT([no])
127                 
128 ])
129
130
131 AC_CHECK_HEADERS(iconv.h)
132
133
134 dnl Here is the check for a libc integrated iconv
135 AC_ARG_ENABLE(iconv,
136         [  --disable-iconv         do not use iconv charset conversion],
137         ok_iconv=no, ok_iconv=yes)
138
139 AC_MSG_CHECKING(Checking to see if your system supports iconv)
140 AC_RUN_IFELSE([AC_LANG_SOURCE([[
141         #include <iconv.h>
142         main() {
143                 iconv_t ic = (iconv_t)(-1) ;
144                 ic = iconv_open("UTF-8", "us-ascii");
145                 iconv_close(ic);
146                 exit(0);
147         }
148  ]])],[
149                   ok_iconv=yes
150                   AC_MSG_RESULT([yes])
151                 ],[ 
152                   ok_iconv=no
153                   AC_MSG_RESULT([no])
154                 
155 ],[])
156
157 dnl Check for iconv in external libiconv
158 if test "$ok_iconv" = no; then
159         AC_MSG_CHECKING(Checking for an external libiconv)
160         OLD_LDFLAGS="$LDFLAGS"
161         LDFLAGS="$LDFLAGS -liconv"
162         AC_RUN_IFELSE([AC_LANG_SOURCE([[
163                         #include <iconv.h>
164                         main() {
165                                 iconv_t ic = (iconv_t)(-1) ;
166                                 ic = iconv_open("UTF-8", "us-ascii");
167                                 iconv_close(ic);
168                         }
169                 ]])],[
170                           ok_iconv=yes
171                           AC_MSG_RESULT([yes])
172                         ],[ 
173                           ok_iconv=no
174                           LDFLAGS="$OLD_LDFLAGS"
175                           AC_MSG_RESULT([no])
176                         
177                 ],[])
178 fi      
179 if test "$ok_iconv" != "no"; then
180         AC_MSG_RESULT(libcitadel will be built with character set conversion.)
181         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
182 else
183         AC_MSG_RESULT(libcitadel will be built without character set conversion.)
184 fi
185
186 dnl disable backtrace if we don't want it.
187 AC_ARG_WITH(backtrace, 
188                     [  --with-backtrace          enable backtrace dumps in the syslog],
189                         [ if test "x$withval" != "xno" ; then
190                              CFLAGS="$CFLAGS  -rdynamic "
191                              LDFLAGS="$LDFLAGS  -rdynamic "
192                              AC_CHECK_FUNCS(backtrace)
193                           fi
194                         ]
195 )
196
197
198 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
199 dnl Checks for the zlib compression library.
200 if test "x$with_zlib" != xno ; then
201         AC_CHECK_HEADERS(zlib.h,
202                 [AC_CHECK_LIB(z, zlibVersion,
203                         [ok_zlib=yes],,
204         )])
205 fi
206
207 if test "x$ok_zlib" = xyes ; then
208         LIBS="-lz $LIBS"
209         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
210 fi
211
212
213 dnl Checks for typedefs, structures, and compiler characteristics.
214
215 AC_SUBST(LIBS)
216 AC_C_CONST
217 AC_TYPE_SIZE_T
218 AC_CHECK_FUNCS(memmove bcopy)
219
220 AC_CONFIG_FILES(Makefile libcitadel.pc)
221 AC_CONFIG_HEADERS([sysdep.h])
222 AC_OUTPUT
223
224 abs_srcdir="`cd $srcdir && pwd`"
225 abs_builddir="`pwd`"
226 if test "$abs_srcdir" != "$abs_builddir"; then
227   make mkdir-init
228 fi
229 echo 'zlib compression:                ' $ok_zlib
230 echo 'Character set conversion support:' $ok_iconv