* -d to daemonize, -D to daemonize with specifying
[citadel.git] / webcit / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT(webserver.c)
4
5
6 PACKAGE=webcit
7 VERSION=7.02
8 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
9 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
10 AC_SUBST(PACKAGE)
11 AC_SUBST(VERSION)
12
13 AC_SUBST(PROG_SUBDIRS)
14 AC_CANONICAL_HOST
15 AC_PROG_INSTALL
16 AC_CHECK_PROG(AUTOCONF, autoconf)
17 AC_CHECK_PROG(SED, sed, sed, no)
18 AC_PREFIX_DEFAULT(/usr/local/webcit)
19
20 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
21 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
22 AC_ARG_WITH(ssl,
23         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
24         [
25                 if test "x$withval" != "xno" ; then
26                         tryssldir=$withval
27                 fi
28         ]
29 )
30 dnl Set some system-specific variables which are OK to set before compiler
31 dnl checks:
32 PTHREAD_DEFS=-D_REENTRANT
33 case "$host" in
34         dnl Tru64 Unix requires we use -pthread instead of linking the threads
35         dnl libraries directly, and we can't build threaded programs with gcc
36         dnl due to header file problems.
37         alpha*-dec-osf*)
38                 test -z "$CC" && CC=cc
39                 LIBS=-pthread
40         ;;
41         dnl FreeBSD is similar:
42         *-*-freebsd*)
43                 LIBS=-pthread
44                 PTHREAD_DEFS=-D_THREAD_SAFE
45         ;;
46         *-*-solaris*)
47                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
48         ;;
49 esac
50 AC_SUBST(PTHREAD_DEFS)
51
52 dnl Checks for programs.
53 AC_PROG_CC
54
55 dnl Configure compiler flags for GCC
56 if test "$GCC" = yes; then
57         case "$host" in
58                 *-*-solaris*)
59                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
60                 ;;
61                 *)
62                         CFLAGS="$CFLAGS -Wall"
63                 ;;
64         esac
65 fi
66
67 # missing_dir=`cd $ac_aux_dir && pwd`
68 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
69
70 dnl Checks for libraries.
71 if test "$LIBS" != -pthread; then
72         AC_CHECK_LIB(pthread, pthread_create)
73         AC_CHECK_LIB(pthreads, pthread_create)
74 fi
75 AC_SEARCH_LIBS(gethostbyname, nsl)
76 AC_SEARCH_LIBS(connect, socket)
77
78 dnl Checks for header files.
79 AC_HEADER_STDC
80 dnl AC_HEADER_SYS_WAIT
81 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
82
83
84
85
86 dnl Checks for typedefs, structures, and compiler characteristics.
87 AC_C_CONST
88 AC_TYPE_OFF_T
89 AC_TYPE_SIZE_T
90 dnl AC_HEADER_TIME
91
92 dnl Checks for library functions.
93 AC_TYPE_SIGNAL
94 dnl AC_FUNC_VPRINTF
95 dnl AC_CHECK_FUNCS(strerror)
96 AC_REPLACE_FUNCS(snprintf)
97
98 dnl Checks for the libical calendaring library.
99 if test "x$with_libical" != xno ; then
100         AC_CHECK_HEADERS(ical.h,
101                 [AC_CHECK_LIB(ical, icalcomponent_new,
102                         [ok_libical=yes],,
103         )])
104 fi
105
106 if test "x$ok_libical" = xyes ; then
107
108         AC_TRY_RUN(
109                 [
110 #include <ical.h>
111 main() {
112         int major, minor, v;
113         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
114         v = 100*major + minor;
115         printf("libical version: %i\n", v);
116         if (v >= 24) {
117                 printf("This version is ok.\n");
118                 return(0);
119         }
120         printf("libical 0.24 or newer required.\n");
121         printf("Citadel will be built without calendar support.\n");
122         return(1);
123 }
124                 ], 
125                 [
126                         LIBS="-lical $LIBS"
127                         AC_DEFINE(HAVE_LIBICAL)
128                 ]
129         )
130 fi
131
132
133
134 dnl Checks for the zlib compression library.
135 if test "x$with_zlib" != xno ; then
136         AC_CHECK_HEADERS(zlib.h,
137                 [AC_CHECK_LIB(z, zlibVersion,
138                         [ok_zlib=yes],,
139         )])
140 fi
141
142 if test "x$ok_zlib" = xyes ; then
143         LIBS="-lz $LIBS"
144         AC_DEFINE(HAVE_ZLIB)
145 fi
146
147 # The big search for OpenSSL
148 if test "$with_ssl" != "no"; then
149         saved_LIBS="$LIBS"
150         saved_LDFLAGS="$LDFLAGS"
151         saved_CFLAGS="$CFLAGS"
152         if test "x$prefix" != "xNONE"; then
153                 tryssldir="$tryssldir $prefix"
154         fi
155         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
156                 for ssldir in $tryssldir "" /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
157                         CFLAGS="$saved_CFLAGS"
158                         LDFLAGS="$saved_LDFLAGS"
159                         LIBS="$saved_LIBS -lssl -lcrypto"
160         
161                         # Skip directories if they don't exist
162                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
163                                 continue;
164                         fi
165                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
166                                 # Try to use $ssldir/lib if it exists, otherwise
167                                 # $ssldir
168                                 if test -d "$ssldir/lib" ; then
169                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
170                                         if test ! -z "$need_dash_r" ; then
171                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
172                                         fi
173                                 else
174                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
175                                         if test ! -z "$need_dash_r" ; then
176                                                 LDFLAGS="-R$ssldir $LDFLAGS"
177                                         fi
178                                 fi
179                                 # Try to use $ssldir/include if it exists, otherwise
180                                 # $ssldir
181                                 if test -d "$ssldir/include" ; then
182                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
183                                 else
184                                         CFLAGS="-I$ssldir $saved_CFLAGS"
185                                 fi
186                         fi
187         
188                         # Basic test to check for compatible version and correct linking
189                         # *does not* test for RSA - that comes later.
190                         AC_TRY_RUN(
191                                 [
192         #include <string.h>
193         #include <openssl/rand.h>
194         int main(void)
195         {
196                 char a[2048];
197                 memset(a, 0, sizeof(a));
198                 RAND_add(a, sizeof(a), sizeof(a));
199                 return(RAND_status() <= 0);
200         }
201                                 ],
202                                 [
203                                         found_crypto=1
204                                         break;
205                                 ], []
206                         )
207         
208                         if test ! -z "$found_crypto" ; then
209                                 break;
210                         fi
211                 done
212         
213                 if test -z "$ssldir" ; then
214                         ssldir="(system)"
215                 fi
216         
217                 if test ! -z "$found_crypto" ; then
218                         ac_cv_openssldir=$ssldir
219                 else
220                         ac_cv_openssldir="no"
221                 fi
222         ])
223         LIBS="$saved_LIBS"
224         LDFLAGS="$saved_LDFLAGS"
225         CFLAGS="$saved_CFLAGS"
226         
227         if test "x$ac_cv_openssldir" != "xno" ; then
228                 AC_DEFINE(HAVE_OPENSSL)
229                 LIBS="-lssl -lcrypto $LIBS"
230                 dnl Need to recover ssldir - test above runs in subshell
231                 ssldir=$ac_cv_openssldir
232                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
233                         # Try to use $ssldir/lib if it exists, otherwise
234                         # $ssldir
235                         if test -d "$ssldir/lib" ; then
236                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
237                                 if test ! -z "$need_dash_r" ; then
238                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
239                                 fi
240                         else
241                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
242                                 if test ! -z "$need_dash_r" ; then
243                                         LDFLAGS="-R$ssldir $LDFLAGS"
244                                 fi
245                         fi
246                         # Try to use $ssldir/include if it exists, otherwise
247                         # $ssldir
248                         if test -d "$ssldir/include" ; then
249                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
250                         else
251                                 CFLAGS="-I$ssldir $saved_CFLAGS"
252                         fi
253                 fi
254         fi
255 fi
256
257 dnl Here is the check for a usable iconv
258
259 AC_ARG_ENABLE(iconv,
260         [  --disable-iconv         do not use iconv charset conversion],
261         ok_iconv=no, ok_iconv=yes)
262
263 if test "$ok_nls" != "no"; then
264         AC_MSG_RESULT(Checking to see if your system supports iconv...)
265         AC_TRY_RUN([
266                 #include <iconv.h>
267                 main() {
268                         iconv_t ic = (iconv_t)(-1) ;
269                         ic = iconv_open("UTF-8", "us-ascii");
270                         iconv_close(ic);
271                         exit(0);
272                 }
273         ],
274                 ok_iconv=yes,
275                 ok_iconv=no
276         )
277 fi
278
279 if test "$ok_iconv" != "no"; then
280         AC_MSG_RESULT(WebCit will be built with character set conversion.)
281         AC_DEFINE(HAVE_ICONV)
282 else
283         AC_MSG_RESULT(WebCit will be built without character set conversion.)
284 fi
285
286
287
288 dnl Here is the check for libintl etc.
289
290 AC_ARG_ENABLE(nls,
291         [  --disable-nls           do not use Native Language Support],
292         ok_nls=no, ok_nls=yes)
293
294 if test "$ok_nls" != "no"; then
295         AC_MSG_RESULT(Checking for per-thread NLS support...)
296         AC_TRY_RUN([
297                 #define _GNU_SOURCE
298                 #include <libintl.h>
299                 #include <locale.h>
300                 #include <time.h>
301                 main() {
302                         char *foo = NULL;
303                         char baz[32];
304                         struct tm *tm;
305                         uselocale(LC_GLOBAL_LOCALE);
306                         foo = gettext("bar");
307                         if (0) {
308                                 strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
309                         }
310                         exit(0);
311                 }
312         ],
313                 ok_uselocale=yes,
314                 ok_uselocale=no
315         )
316         ok_nls=$ok_uselocale
317 fi
318
319 if test "$ok_nls" != "no"; then
320         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
321         ok_nls=$ok_xgettext
322 fi
323
324 if test "$ok_nls" != "no"; then
325         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
326         ok_nls=$ok_msgmerge
327 fi
328
329 if test "$ok_nls" != "no"; then
330         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
331         ok_nls=$ok_msgfmt
332 fi
333
334 if test "$ok_nls" != "no"; then
335         AC_MSG_RESULT(WebCit will be built with national language support.)
336         AC_DEFINE(ENABLE_NLS)
337         PROG_SUBDIRS="$PROG_SUBDIRS po"
338 else
339         AC_MSG_RESULT(WebCit will be built without national language support.)
340 fi
341
342 AC_SUBST(SETUP_LIBS)
343
344 AC_OUTPUT(Makefile po/Makefile )
345
346 echo ------------------------------------------------------------------------
347 echo 'zlib compression:                ' $ok_zlib
348 echo 'Calendar support:                ' $ok_libical
349 echo 'Character set conversion support:' $ok_iconv
350 echo 'National language support:       ' $ok_nls
351 echo