Rewrote our local implementation of a Base64 encoder/decoder as specified
[citadel.git] / libcitadel / configure.in
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.52)
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_TRY_LINK( , ,
46                    AC_MSG_RESULT(yes),
47                    AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
48     CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
49 fi
50
51 dnl Checks for header files.
52 AC_HEADER_STDC
53
54 AC_CHECK_HEADER(sys/mman.h, [CFLAGS="$CFLAGS -D HAVE_MMAP"])
55 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
56 dnl Checks for the zlib compression library.
57 if test "x$with_zlib" != xno ; then
58         AC_CHECK_HEADERS(zlib.h,
59                 [AC_CHECK_LIB(z, zlibVersion,
60                         [ok_zlib=yes],,
61         )])
62 fi
63
64 if test "x$ok_zlib" = xyes ; then
65         LIBS="-lz $LIBS"
66         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
67 fi
68
69 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
70
71 AC_CHECK_HEADER(sys/sendfile.h, [AC_DEFINE(LINUX_SENDFILE, [], [whether we have the linux sendfile api])])
72 dnl TODO: we might need to check for the actual syntax....  
73
74
75 AC_MSG_CHECKING([whether your system knows about splice()]) 
76 AC_TRY_COMPILE([
77 #define _GNU_SOURCE
78 #include <unistd.h>
79 #include <fcntl.h>
80 ],
81 [
82         ssize_t sent, pipesize;
83         int fd, SplicePipe[2];
84         pipesize = splice(fd, NULL, 
85                           SplicePipe[1], NULL, 
86                           1, 
87                           SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
88 ],
89                 [
90                   ok_splice=yes
91                   AC_DEFINE(LINUX_SPLICE, [], [whether we have the linux splice api])
92                   AC_MSG_RESULT([yes])
93                 ],
94                 [ 
95                   ok_splice=no
96                   AC_MSG_RESULT([no])
97                 ]
98 )
99
100 AC_MSG_CHECKING([whether your system likes memcpy + HKEY]) 
101 AC_TRY_COMPILE([
102 #define _GNU_SOURCE
103 #include <ctype.h>
104 #include <errno.h>
105 #include <string.h>
106 #include <unistd.h>
107 #include <string.h>
108 #include <stdio.h>
109 #include <sys/select.h>
110 #include <fcntl.h>
111 #include <sys/types.h>
112
113 #include "lib/libcitadel.h"
114 ],
115 [
116         char foo[22];
117         memcpy(foo, HKEY("foo"));
118         
119 ],
120                 [
121
122                   AC_MSG_RESULT([yes])
123                 ],
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_TRY_RUN([
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                 [
150                   ok_iconv=yes
151                   AC_MSG_RESULT([yes])
152                 ],
153                 [ 
154                   ok_iconv=no
155                   AC_MSG_RESULT([no])
156                 ]
157 )
158
159 dnl Check for iconv in external libiconv
160 if test "$ok_iconv" = no; then
161         AC_MSG_CHECKING(Checking for an external libiconv)
162         OLD_LDFLAGS="$LDFLAGS"
163         LDFLAGS="$LDFLAGS -liconv"
164         AC_TRY_RUN([
165                         #include <iconv.h>
166                         main() {
167                                 iconv_t ic = (iconv_t)(-1) ;
168                                 ic = iconv_open("UTF-8", "us-ascii");
169                                 iconv_close(ic);
170                         }
171                 ],
172                         [
173                           ok_iconv=yes
174                           AC_MSG_RESULT([yes])
175                         ],
176                         [ 
177                           ok_iconv=no
178                           LDFLAGS="$OLD_LDFLAGS"
179                           AC_MSG_RESULT([no])
180                         ]
181                 )
182 fi      
183 if test "$ok_iconv" != "no"; then
184         AC_MSG_RESULT(libcitadel will be built with character set conversion.)
185         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
186 else
187         AC_MSG_RESULT(libcitadel will be built without character set conversion.)
188 fi
189
190 dnl disable backtrace if we don't want it.
191 AC_ARG_WITH(backtrace, 
192                     [  --with-backtrace          enable backtrace dumps in the syslog],
193                         [ if test "x$withval" != "xno" ; then
194                              CFLAGS="$CFLAGS  -rdynamic "
195                              LDFLAGS="$LDFLAGS  -rdynamic "
196                              AC_CHECK_FUNCS(backtrace)
197                           fi
198                         ]
199 )
200
201
202 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
203 dnl Checks for the zlib compression library.
204 if test "x$with_zlib" != xno ; then
205         AC_CHECK_HEADERS(zlib.h,
206                 [AC_CHECK_LIB(z, zlibVersion,
207                         [ok_zlib=yes],,
208         )])
209 fi
210
211 if test "x$ok_zlib" = xyes ; then
212         LIBS="-lz $LIBS"
213         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
214 fi
215
216
217 dnl Checks for typedefs, structures, and compiler characteristics.
218
219 AC_SUBST(LIBS)
220 AC_C_CONST
221 AC_TYPE_SIZE_T
222 AC_CHECK_FUNCS(memmove bcopy)
223
224 AC_CONFIG_FILES(Makefile libcitadel.pc)
225 AC_CONFIG_HEADER(sysdep.h)
226 AC_OUTPUT
227
228 abs_srcdir="`cd $srcdir && pwd`"
229 abs_builddir="`pwd`"
230 if test "$abs_srcdir" != "$abs_builddir"; then
231   make mkdir-init
232 fi
233 echo 'zlib compression:                ' $ok_zlib
234 echo 'Character set conversion support:' $ok_iconv