f7720f4e46b2d81648900443b49ade3fd2188521
[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 AC_CANONICAL_HOST
6
7 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
8 AC_ARG_WITH(with_newt, [  --with-newt          use newt window library])
9
10 dnl Set some system-specific variables which are OK to set before compiler
11 dnl checks:
12 PTHREAD_DEFS=-D_REENTRANT
13 case "$host" in
14         dnl Tru64 Unix requires we use -pthread instead of linking the threads
15         dnl libraries directly, and we can't build threaded programs with gcc
16         dnl due to header file problems.
17         alpha*-dec-osf*)
18                 test -z "$CC" && CC=cc
19                 LIBS=-pthread
20         ;;
21         dnl FreeBSD is similar:
22         *-*-freebsd*)
23                 LIBS=-pthread
24                 PTHREAD_DEFS=-D_THREAD_SAFE
25         ;;
26         *-*-solaris*)
27                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
28         ;;
29 esac
30 AC_SUBST(PTHREAD_DEFS)
31
32 dnl Checks for programs.
33 AC_PROG_CC
34
35 dnl Configure compiler flags for GCC
36 if test "$GCC" = yes; then
37         case "$host" in
38                 *-*-solaris*)
39                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
40                 ;;
41                 *)
42                         CFLAGS="$CFLAGS -Wall"
43                 ;;
44         esac
45 fi
46
47 missing_dir=`cd $ac_aux_dir && pwd`
48 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
49
50 dnl Checks for libraries.
51 if test "$LIBS" != -pthread; then
52         AC_CHECK_LIB(pthread, pthread_create)
53         AC_CHECK_LIB(pthreads, pthread_create)
54 fi
55 AC_SEARCH_LIBS(gethostbyname, nsl)
56 AC_SEARCH_LIBS(connect, socket)
57
58 dnl Checks for header files.
59 AC_HEADER_STDC
60 dnl AC_HEADER_SYS_WAIT
61 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
62
63 dnl Checks for typedefs, structures, and compiler characteristics.
64 AC_C_CONST
65 AC_TYPE_OFF_T
66 AC_TYPE_SIZE_T
67 dnl AC_HEADER_TIME
68
69 dnl Checks for library functions.
70 AC_TYPE_SIGNAL
71 dnl AC_FUNC_VPRINTF
72 dnl AC_CHECK_FUNCS(strerror)
73 AC_REPLACE_FUNCS(snprintf)
74
75 dnl Checks for the libical calendaring library.
76 if test "x$with_libical" != xno ; then
77         AC_CHECK_HEADERS(ical.h,
78                 [AC_CHECK_LIB(ical, icalcomponent_new,
79                         [ok_libical=yes],,
80         )])
81 fi
82
83 if test "x$ok_libical" = xyes ; then
84
85         AC_TRY_RUN(
86                 [
87 #include <ical.h>
88 main() {
89         float v;
90         int i;
91         sscanf(ICAL_VERSION, "%f", &v);
92         printf("libical version: %0.2f\n", v);
93         v = v * 100.0;
94         i = (int) v;
95         if (i >= 24) {
96                 printf("This version is ok.\n");
97                 printf("WebCit will be built with calendar support.\n");
98                 return(0);
99         }
100         printf("libical 0.24 or newer is required.\n");
101         printf("WebCit will be built without calendar support.\n");
102         return(1);
103 }
104                 ], 
105                 [
106                         LIBS="-lical $LIBS"
107                         AC_DEFINE(HAVE_LIBICAL)
108                 ]
109         )
110 fi
111
112 dnl Checks for the newt window library.
113 if test "x$with_newt" != xno ; then
114         AC_CHECK_HEADERS(newt.h,
115                 [AC_CHECK_LIB(newt, newtInit,
116                         [ok_newt=yes],,
117         )])
118 fi
119
120 if test "x$ok_newt" = xyes ; then
121         SETUP_LIBS="-lnewt $SETUP_LIBS"
122         AC_DEFINE(HAVE_NEWT)
123 fi
124
125
126
127 AC_SUBST(SETUP_LIBS)
128
129 AC_OUTPUT(Makefile)
130