Fix utf8-non-encoding in xml-escape
[citadel] / 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
8 AC_INIT(libcitadel, 4.8.29, http://uncensored.citadel.org)
9
10 AC_CONFIG_SRCDIR(Makefile.in)
11 AC_CONFIG_AUX_DIR(conftools)
12 AC_CONFIG_SRCDIR(tests/Makefile.in)
13
14 dnl
15 dnl Increment LIBREVISION if source code has changed at all
16 dnl
17 dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
18 dnl
19 dnl If the API changes compatibly (i.e. simply adding a new function
20 dnl without changing or removing earlier interfaces), then increment LIBAGE.
21 dnl 
22 dnl If the API changes incompatibly set LIBAGE back to 0
23 dnl
24
25 LIBCURRENT=4
26 LIBREVISION=829
27 LIBAGE=0
28
29 sinclude(conftools/libtool.m4)
30 sinclude(conftools/ac_c_bigendian_cross.m4)
31
32 AC_PROG_LIBTOOL
33
34 AC_SUBST(LIBCURRENT)
35 AC_SUBST(LIBREVISION)
36 AC_SUBST(LIBAGE)
37
38 dnl Checks for programs.
39 AC_PROG_CC
40 AC_PROG_INSTALL
41
42 if test "$GCC" = yes ; then
43     dnl
44     dnl Be careful about adding the -fexceptions option; some versions of
45     dnl GCC don't support it and it causes extra warnings that are only
46     dnl distracting; avoid.
47     dnl
48     OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
49     CFLAGS="$OLDCFLAGS -fexceptions"
50     AC_MSG_CHECKING(whether $CC accepts -fexceptions)
51     AC_TRY_LINK( , ,
52                    AC_MSG_RESULT(yes),
53                    AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
54     CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
55 fi
56
57 dnl Checks for header files.
58 AC_HEADER_STDC
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_TRY_COMPILE([
83 #define _GNU_SOURCE
84 #include <unistd.h>
85 #include <fcntl.h>
86 ],
87 [
88         ssize_t sent, pipesize;
89         int fd, SplicePipe[2];
90         pipesize = splice(fd, NULL, 
91                           SplicePipe[1], NULL, 
92                           1, 
93                           SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
94 ],
95                 [
96                   ok_splice=yes
97                   AC_DEFINE(LINUX_SPLICE, [], [whether we have the linux splice api])
98                   AC_MSG_RESULT([yes])
99                 ],
100                 [ 
101                   ok_splice=no
102                   AC_MSG_RESULT([no])
103                 ]
104 )
105
106 AC_MSG_CHECKING([whether your system likes memcpy + HKEY]) 
107 AC_TRY_COMPILE([
108 #define _GNU_SOURCE
109 #include <ctype.h>
110 #include <errno.h>
111 #include <string.h>
112 #include <unistd.h>
113 #include <string.h>
114 #include <stdio.h>
115 #include <sys/select.h>
116 #include <fcntl.h>
117 #include <sys/types.h>
118
119 #include "lib/libcitadel.h"
120 ],
121 [
122         char foo[22];
123         memcpy(foo, HKEY("foo"));
124         
125 ],
126                 [
127
128                   AC_MSG_RESULT([yes])
129                 ],
130                 [ 
131                   AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
132                   AC_MSG_RESULT([no])
133                 ]
134 )
135
136
137 AC_CHECK_HEADERS(iconv.h)
138
139
140 dnl Here is the check for a libc integrated iconv
141 AC_ARG_ENABLE(iconv,
142         [  --disable-iconv         do not use iconv charset conversion],
143         ok_iconv=no, ok_iconv=yes)
144
145 AC_MSG_CHECKING(Checking to see if your system supports iconv)
146 AC_TRY_RUN([
147         #include <iconv.h>
148         main() {
149                 iconv_t ic = (iconv_t)(-1) ;
150                 ic = iconv_open("UTF-8", "us-ascii");
151                 iconv_close(ic);
152                 exit(0);
153         }
154  ],
155                 [
156                   ok_iconv=yes
157                   AC_MSG_RESULT([yes])
158                 ],
159                 [ 
160                   ok_iconv=no
161                   AC_MSG_RESULT([no])
162                 ]
163 )
164
165 dnl Check for iconv in external libiconv
166 if test "$ok_iconv" = no; then
167         AC_MSG_CHECKING(Checking for an external libiconv)
168         OLD_LDFLAGS="$LDFLAGS"
169         LDFLAGS="$LDFLAGS -liconv"
170         AC_TRY_RUN([
171                         #include <iconv.h>
172                         main() {
173                                 iconv_t ic = (iconv_t)(-1) ;
174                                 ic = iconv_open("UTF-8", "us-ascii");
175                                 iconv_close(ic);
176                         }
177                 ],
178                         [
179                           ok_iconv=yes
180                           AC_MSG_RESULT([yes])
181                         ],
182                         [ 
183                           ok_iconv=no
184                           LDFLAGS="$OLD_LDFLAGS"
185                           AC_MSG_RESULT([no])
186                         ]
187                 )
188 fi      
189 if test "$ok_iconv" != "no"; then
190         AC_MSG_RESULT(libcitadel will be built with character set conversion.)
191         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
192 else
193         AC_MSG_RESULT(libcitadel will be built without character set conversion.)
194 fi
195
196 dnl disable backtrace if we don't want it.
197 AC_ARG_WITH(backtrace, 
198                     [  --with-backtrace          enable backtrace dumps in the syslog],
199                         [ if test "x$withval" != "xno" ; then
200                              CFLAGS="$CFLAGS  -rdynamic "
201                              LDFLAGS="$LDFLAGS  -rdynamic "
202                              AC_CHECK_FUNCS(backtrace)
203                           fi
204                         ]
205 )
206
207
208 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
209 dnl Checks for the zlib compression library.
210 if test "x$with_zlib" != xno ; then
211         AC_CHECK_HEADERS(zlib.h,
212                 [AC_CHECK_LIB(z, zlibVersion,
213                         [ok_zlib=yes],,
214         )])
215 fi
216
217 if test "x$ok_zlib" = xyes ; then
218         LIBS="-lz $LIBS"
219         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
220 fi
221
222
223 dnl Checks for typedefs, structures, and compiler characteristics.
224
225 AC_SUBST(LIBS)
226 AC_C_CONST
227 AC_TYPE_SIZE_T
228 AC_CHECK_FUNCS(memmove bcopy)
229
230 AC_CONFIG_FILES(Makefile libcitadel.pc tests/Makefile)
231 AC_CONFIG_HEADER(sysdep.h)
232 AC_OUTPUT
233
234 abs_srcdir="`cd $srcdir && pwd`"
235 abs_builddir="`pwd`"
236 if test "$abs_srcdir" != "$abs_builddir"; then
237   make mkdir-init
238 fi
239 echo 'zlib compression:                ' $ok_zlib
240 echo 'Character set conversion support:' $ok_iconv