* Assorted tweaks to activate the translations...
[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=6.21
8 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
9 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
10 AC_SUBST(PACKAGE)
11 AC_SUBST(VERSION)
12
13 AC_CANONICAL_HOST
14 AC_PROG_INSTALL
15 AC_PREFIX_DEFAULT(/usr/local/webcit)
16
17 AC_ARG_WITH(with_libical, [  --with-libical      use libical calendaring library])
18 AC_ARG_WITH(with_zlib,    [  --with-zlib         use zlib compression if present])
19 AC_ARG_WITH(with_newt,    [  --with-newt         use newt window library])
20 AC_ARG_WITH(ssl,
21         [  --with-ssl=PATH     Specify path to OpenSSL installation ],
22         [
23                 if test "x$withval" != "xno" ; then
24                         tryssldir=$withval
25                 fi
26         ]
27 )
28 dnl Set some system-specific variables which are OK to set before compiler
29 dnl checks:
30 PTHREAD_DEFS=-D_REENTRANT
31 case "$host" in
32         dnl Tru64 Unix requires we use -pthread instead of linking the threads
33         dnl libraries directly, and we can't build threaded programs with gcc
34         dnl due to header file problems.
35         alpha*-dec-osf*)
36                 test -z "$CC" && CC=cc
37                 LIBS=-pthread
38         ;;
39         dnl FreeBSD is similar:
40         *-*-freebsd*)
41                 LIBS=-pthread
42                 PTHREAD_DEFS=-D_THREAD_SAFE
43         ;;
44         *-*-solaris*)
45                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
46         ;;
47 esac
48 AC_SUBST(PTHREAD_DEFS)
49
50 dnl Checks for programs.
51 AC_PROG_CC
52
53 dnl Configure compiler flags for GCC
54 if test "$GCC" = yes; then
55         case "$host" in
56                 *-*-solaris*)
57                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
58                 ;;
59                 *)
60                         CFLAGS="$CFLAGS -Wall"
61                 ;;
62         esac
63 fi
64
65 missing_dir=`cd $ac_aux_dir && pwd`
66 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
67
68 dnl Checks for libraries.
69 if test "$LIBS" != -pthread; then
70         AC_CHECK_LIB(pthread, pthread_create)
71         AC_CHECK_LIB(pthreads, pthread_create)
72 fi
73 AC_SEARCH_LIBS(gethostbyname, nsl)
74 AC_SEARCH_LIBS(connect, socket)
75
76 dnl Checks for header files.
77 AC_HEADER_STDC
78 dnl AC_HEADER_SYS_WAIT
79 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
80
81
82
83
84 dnl Checks for typedefs, structures, and compiler characteristics.
85 AC_C_CONST
86 AC_TYPE_OFF_T
87 AC_TYPE_SIZE_T
88 dnl AC_HEADER_TIME
89
90 dnl Checks for library functions.
91 AC_TYPE_SIGNAL
92 dnl AC_FUNC_VPRINTF
93 dnl AC_CHECK_FUNCS(strerror)
94 AC_REPLACE_FUNCS(snprintf)
95
96 dnl Checks for the libical calendaring library.
97 if test "x$with_libical" != xno ; then
98         AC_CHECK_HEADERS(ical.h,
99                 [AC_CHECK_LIB(ical, icalcomponent_new,
100                         [ok_libical=yes],,
101         )])
102 fi
103
104 if test "x$ok_libical" = xyes ; then
105
106         AC_TRY_RUN(
107                 [
108 #include <ical.h>
109 main() {
110         int major, minor, v;
111         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
112         v = 100*major + minor;
113         printf("libical version: %i\n", v);
114         if (v >= 24) {
115                 printf("This version is ok.\n");
116                 return(0);
117         }
118         printf("libical 0.24 or newer required.\n");
119         printf("Citadel will be built without calendar support.\n");
120         return(1);
121 }
122                 ], 
123                 [
124                         LIBS="-lical $LIBS"
125                         AC_DEFINE(HAVE_LIBICAL)
126                 ]
127         )
128 fi
129
130
131
132 dnl Checks for the zlib compression library.
133 if test "x$with_zlib" != xno ; then
134         AC_CHECK_HEADERS(zlib.h,
135                 [AC_CHECK_LIB(z, zlibVersion,
136                         [ok_zlib=yes],,
137         )])
138 fi
139
140 if test "x$ok_zlib" = xyes ; then
141         LIBS="-lz $LIBS"
142         AC_DEFINE(HAVE_ZLIB)
143 fi
144
145 dnl Checks for the newt window library.
146 if test "x$with_newt" != xno ; then
147         AC_CHECK_HEADERS(newt.h,
148                 [AC_CHECK_LIB(newt, newtInit,
149                         [ok_newt=yes],,
150         )])
151 fi
152
153 if test "x$ok_newt" = xyes ; then
154         SETUP_LIBS="-lnewt $SETUP_LIBS"
155         AC_DEFINE(HAVE_NEWT)
156 fi
157
158 # The big search for OpenSSL
159 if test "$with_ssl" != "no"; then
160         saved_LIBS="$LIBS"
161         saved_LDFLAGS="$LDFLAGS"
162         saved_CFLAGS="$CFLAGS"
163         if test "x$prefix" != "xNONE"; then
164                 tryssldir="$tryssldir $prefix"
165         fi
166         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
167                 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
168                         CFLAGS="$saved_CFLAGS"
169                         LDFLAGS="$saved_LDFLAGS"
170                         LIBS="$saved_LIBS -lssl -lcrypto"
171         
172                         # Skip directories if they don't exist
173                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
174                                 continue;
175                         fi
176                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
177                                 # Try to use $ssldir/lib if it exists, otherwise
178                                 # $ssldir
179                                 if test -d "$ssldir/lib" ; then
180                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
181                                         if test ! -z "$need_dash_r" ; then
182                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
183                                         fi
184                                 else
185                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
186                                         if test ! -z "$need_dash_r" ; then
187                                                 LDFLAGS="-R$ssldir $LDFLAGS"
188                                         fi
189                                 fi
190                                 # Try to use $ssldir/include if it exists, otherwise
191                                 # $ssldir
192                                 if test -d "$ssldir/include" ; then
193                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
194                                 else
195                                         CFLAGS="-I$ssldir $saved_CFLAGS"
196                                 fi
197                         fi
198         
199                         # Basic test to check for compatible version and correct linking
200                         # *does not* test for RSA - that comes later.
201                         AC_TRY_RUN(
202                                 [
203         #include <string.h>
204         #include <openssl/rand.h>
205         int main(void)
206         {
207                 char a[2048];
208                 memset(a, 0, sizeof(a));
209                 RAND_add(a, sizeof(a), sizeof(a));
210                 return(RAND_status() <= 0);
211         }
212                                 ],
213                                 [
214                                         found_crypto=1
215                                         break;
216                                 ], []
217                         )
218         
219                         if test ! -z "$found_crypto" ; then
220                                 break;
221                         fi
222                 done
223         
224                 if test -z "$ssldir" ; then
225                         ssldir="(system)"
226                 fi
227         
228                 if test ! -z "$found_crypto" ; then
229                         ac_cv_openssldir=$ssldir
230                 else
231                         ac_cv_openssldir="no"
232                 fi
233         ])
234         LIBS="$saved_LIBS"
235         LDFLAGS="$saved_LDFLAGS"
236         CFLAGS="$saved_CFLAGS"
237         
238         if test "x$ac_cv_openssldir" != "xno" ; then
239                 AC_DEFINE(HAVE_OPENSSL)
240                 LIBS="-lssl -lcrypto $LIBS"
241                 dnl Need to recover ssldir - test above runs in subshell
242                 ssldir=$ac_cv_openssldir
243                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
244                         # Try to use $ssldir/lib if it exists, otherwise
245                         # $ssldir
246                         if test -d "$ssldir/lib" ; then
247                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
248                                 if test ! -z "$need_dash_r" ; then
249                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
250                                 fi
251                         else
252                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
253                                 if test ! -z "$need_dash_r" ; then
254                                         LDFLAGS="-R$ssldir $LDFLAGS"
255                                 fi
256                         fi
257                         # Try to use $ssldir/include if it exists, otherwise
258                         # $ssldir
259                         if test -d "$ssldir/include" ; then
260                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
261                         else
262                                 CFLAGS="-I$ssldir $saved_CFLAGS"
263                         fi
264                 fi
265         fi
266 fi
267
268 AM_GNU_GETTEXT
269
270 AC_SUBST(SETUP_LIBS)
271
272 AC_OUTPUT(Makefile intl/Makefile po/Makefile.in )
273