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