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