* prefer the actual session id
[citadel.git] / webcit / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT([WebCit], [7.31], [http://www.citadel.org/])
4
5 AC_SUBST(PROG_SUBDIRS)
6 AC_DEFINE(PROG_SUBDIRS, [], [Program dirs])
7 AC_CANONICAL_HOST
8 AC_PROG_INSTALL
9 missing_dir=`cd $ac_aux_dir && pwd`
10 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
11 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
12
13 dnl Make sure we see all GNU and Solaris extensions.
14 AC_GNU_SOURCE
15
16 AC_CHECK_PROG(SED, sed, sed, no)
17 AC_PREFIX_DEFAULT(/usr/local/webcit)
18 if test "$prefix" = NONE; then
19         AC_DEFINE_UNQUOTED(WEBCITDIR, "$ac_default_prefix", [define this to the Citadel home directory])
20         ssl_dir="$ac_default_prefix/keys"
21 else
22         AC_DEFINE_UNQUOTED(WEBCITDIR, "$prefix", [define this to the Citadel home directory])
23         ssl_dir="$prefix/keys"
24 fi
25
26 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
27 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
28 AC_ARG_WITH(ssl,
29         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
30         [
31                 if test "x$withval" != "xno" ; then
32                         tryssldir=$withval
33                 fi
34         ]
35 )
36 dnl Set some system-specific variables which are OK to set before compiler
37 dnl checks:
38 PTHREAD_DEFS=-D_REENTRANT
39 case "$host" in
40         dnl Tru64 Unix requires we use -pthread instead of linking the threads
41         dnl libraries directly, and we can't build threaded programs with gcc
42         dnl due to header file problems.
43         alpha*-dec-osf*)
44                 test -z "$CC" && CC=cc
45                 LIBS=-pthread
46         ;;
47         dnl FreeBSD is similar:
48         *-*-freebsd*)
49                 LIBS=-pthread
50                 PTHREAD_DEFS=-D_THREAD_SAFE
51         ;;
52         *-*-solaris*)
53                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
54         ;;
55 esac
56 AC_SUBST(PTHREAD_DEFS)
57
58 dnl Checks for programs.
59 AC_PROG_CC
60
61 dnl Configure compiler flags for GCC
62 if test "$GCC" = yes; then
63         case "$host" in
64                 *-*-solaris*)
65                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
66                 ;;
67                 *)
68                         CFLAGS="$CFLAGS -Wall"
69                 ;;
70         esac
71 fi
72
73 # missing_dir=`cd $ac_aux_dir && pwd`
74 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
75
76 dnl Checks for libraries.
77 if test "$LIBS" != -pthread; then
78         AC_CHECK_LIB(pthread, pthread_create)
79         AC_CHECK_LIB(pthreads, pthread_create)
80 fi
81 AC_SEARCH_LIBS(gethostbyname, nsl)
82 AC_SEARCH_LIBS(connect, socket)
83
84 dnl Checks for header files.
85 AC_HEADER_STDC
86 dnl AC_HEADER_SYS_WAIT
87
88
89
90
91 dnl Checks for typedefs, structures, and compiler characteristics.
92 AC_C_CONST
93 AC_TYPE_OFF_T
94 AC_TYPE_SIZE_T
95 dnl AC_HEADER_TIME
96
97 dnl Checks for library functions.
98 AC_TYPE_SIGNAL
99 dnl AC_FUNC_VPRINTF
100 AC_REPLACE_FUNCS(snprintf)
101 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h iconv.h)
102
103
104 dnl Here is the check for a libc integrated iconv
105 AC_ARG_ENABLE(iconv,
106         [  --disable-iconv         do not use iconv charset conversion],
107         ok_iconv=no, ok_iconv=yes)
108
109 AC_MSG_CHECKING(Checking to see if your system supports iconv)
110 AC_TRY_RUN([
111         #include <iconv.h>
112         main() {
113                 iconv_t ic = (iconv_t)(-1) ;
114                 ic = iconv_open("UTF-8", "us-ascii");
115                 iconv_close(ic);
116                 exit(0);
117         }
118  ],
119                 [
120                   ok_iconv=yes
121                   AC_MSG_RESULT([yes])
122                 ],
123                 [ 
124                   ok_iconv=no
125                   AC_MSG_RESULT([no])
126                 ]
127 )
128
129 dnl Check for iconv in external libiconv
130 if test "$ok_iconv" = no; then
131         AC_MSG_CHECKING(Checking for an external libiconv)
132         OLD_LDFLAGS=$LDFLAGS
133         LDFLAGS="$LDFLAGS -liconv"
134         AC_TRY_RUN([
135                         #include <iconv.h>
136                         main() {
137                                 iconv_t ic = (iconv_t)(-1) ;
138                                 ic = iconv_open("UTF-8", "us-ascii");
139                                 iconv_close(ic);
140                         }
141                 ],
142                         [
143                           ok_iconv=yes
144                           AC_MSG_RESULT([yes])
145                         ],
146                         [ 
147                           ok_iconv=no
148                           LDFLAGS=$OLDLDFLAGS
149                           AC_MSG_RESULT([no])
150                         ]
151                 )
152 fi      
153 if test "$ok_iconv" != "no"; then
154         AC_MSG_RESULT(WebCit will be built with character set conversion.)
155         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
156 else
157         AC_MSG_RESULT(WebCit will be built without character set conversion.)
158 fi
159
160 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
161
162
163
164 dnl Check for libcitadel
165 AC_CHECK_HEADER(libcitadel.h,
166         [AC_CHECK_LIB(citadel, libcitadel_version_string,
167                 [
168                         LIBS="-lcitadel $LIBS"
169                 ],
170                 [
171                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
172                 ]
173         ,
174         )],
175         [
176                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
177         ]
178 )
179
180
181 webcit_with_calendar_service=no
182 dnl Checks for the libical calendaring library.
183 if test "x$with_libical" != xno ; then
184         AC_CHECK_HEADERS(ical.h,
185                 [AC_CHECK_LIB(ical, icalcomponent_new,
186                         [ok_libical=yes],,
187         )])
188 fi
189
190 if test "x$ok_libical" = xyes ; then
191
192         AC_TRY_RUN(
193                 [
194 #include <ical.h>
195 main() {
196         int major, minor, v;
197         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
198         v = 100*major + minor;
199         printf("libical version: %i\n", v);
200         if (v >= 30) {
201                 printf("This version is ok.\n");
202                 return(0);
203         }
204         printf("libical 0.30 or newer required.\n");
205         printf("Citadel will be built without calendar support.\n");
206         return(1);
207 }
208                 ], 
209                 [
210                         LIBS="-lical $LIBS"
211                         AC_DEFINE(HAVE_LIBICAL,[],[whether we have libical available])
212                         webcit_with_calendar_service=yes
213                 ]
214         )
215 fi
216 ok_libical=$webcit_with_calendar_service
217
218
219 if test "$webcit_with_calendar_service" == "yes"; then
220                         AC_DEFINE(WEBCIT_WITH_CALENDAR_SERVICE,[],[whether we can do with calendar.])
221 fi
222
223 dnl Checks for the zlib compression library.
224 if test "x$with_zlib" != xno ; then
225         AC_CHECK_HEADERS(zlib.h,
226                 [AC_CHECK_LIB(z, zlibVersion,
227                         [ok_zlib=yes],,
228         )])
229 fi
230
231 if test "x$ok_zlib" = xyes ; then
232         LIBS="-lz $LIBS"
233         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
234 fi
235
236
237 # The big search for OpenSSL
238 if test "$with_ssl" != "no"; then
239         saved_LIBS="$LIBS"
240         saved_LDFLAGS="$LDFLAGS"
241         saved_CFLAGS="$CFLAGS"
242         if test "x$prefix" != "xNONE"; then
243                 tryssldir="$tryssldir $prefix"
244         fi
245         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
246                 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
247                         CFLAGS="$saved_CFLAGS"
248                         LDFLAGS="$saved_LDFLAGS"
249                         LIBS="$saved_LIBS -lssl -lcrypto"
250         
251                         # Skip directories if they don't exist
252                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
253                                 continue;
254                         fi
255                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
256                                 # Try to use $ssldir/lib if it exists, otherwise
257                                 # $ssldir
258                                 if test -d "$ssldir/lib" ; then
259                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
260                                         if test ! -z "$need_dash_r" ; then
261                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
262                                         fi
263                                 else
264                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
265                                         if test ! -z "$need_dash_r" ; then
266                                                 LDFLAGS="-R$ssldir $LDFLAGS"
267                                         fi
268                                 fi
269                                 # Try to use $ssldir/include if it exists, otherwise
270                                 # $ssldir
271                                 if test -d "$ssldir/include" ; then
272                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
273                                 else
274                                         CFLAGS="-I$ssldir $saved_CFLAGS"
275                                 fi
276                         fi
277         
278                         # Basic test to check for compatible version and correct linking
279                         # *does not* test for RSA - that comes later.
280                         AC_TRY_RUN(
281                                 [
282         #include <string.h>
283         #include <openssl/rand.h>
284         int main(void)
285         {
286                 char a[2048];
287                 memset(a, 0, sizeof(a));
288                 RAND_add(a, sizeof(a), sizeof(a));
289                 return(RAND_status() <= 0);
290         }
291                                 ],
292                                 [
293                                         found_crypto=1
294                                         break;
295                                 ], []
296                         )
297         
298                         if test ! -z "$found_crypto" ; then
299                                 break;
300                         fi
301                 done
302         
303                 if test -z "$ssldir" ; then
304                         ssldir="(system)"
305                 fi
306         
307                 if test ! -z "$found_crypto" ; then
308                         ac_cv_openssldir=$ssldir
309                 else
310                         ac_cv_openssldir="no"
311                 fi
312         ])
313         LIBS="$saved_LIBS"
314         LDFLAGS="$saved_LDFLAGS"
315         CFLAGS="$saved_CFLAGS"
316         
317         if test "x$ac_cv_openssldir" != "xno" ; then
318                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
319                 LIBS="-lssl -lcrypto $LIBS"
320                 dnl Need to recover ssldir - test above runs in subshell
321                 ssldir=$ac_cv_openssldir
322                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
323                         # Try to use $ssldir/lib if it exists, otherwise
324                         # $ssldir
325                         if test -d "$ssldir/lib" ; then
326                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
327                                 if test ! -z "$need_dash_r" ; then
328                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
329                                 fi
330                         else
331                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
332                                 if test ! -z "$need_dash_r" ; then
333                                         LDFLAGS="-R$ssldir $LDFLAGS"
334                                 fi
335                         fi
336                         # Try to use $ssldir/include if it exists, otherwise
337                         # $ssldir
338                         if test -d "$ssldir/include" ; then
339                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
340                         else
341                                 CFLAGS="-I$ssldir $saved_CFLAGS"
342                         fi
343                 fi
344         fi
345 fi
346 dnl Checks for the SSLdir
347 dnl this is a bit different than the rest, 
348 dnl because of the citadel used to have a keys/ subdir.
349 AC_ARG_WITH(ssldir, 
350                     [  --with-ssldir          directory to store the ssl certificates under],
351                         [ if test "x$withval" != "xno" ; then
352                                               
353                                                   ssl_dir="$withval"
354                           fi
355                         AC_SUBST(MAKE_SSL_DIR)
356                         ]
357 )
358 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
359
360
361
362
363 AC_CHECK_FUNCS(strftime_l uselocale gettext)
364
365 if test "$ok_nls" != "no"; then
366         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
367         ok_nls=$ok_xgettext
368 fi
369
370 if test "$ok_nls" != "no"; then
371         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
372         ok_nls=$ok_msgmerge
373 fi
374
375 if test "$ok_nls" != "no"; then
376         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
377         ok_nls=$ok_msgfmt
378 fi
379
380 if test "$ok_nls" != "no"; then
381         AC_MSG_RESULT(WebCit will be built with national language support.)
382         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
383         PROG_SUBDIRS="$PROG_SUBDIRS po"
384 else
385         AC_MSG_RESULT(WebCit will be built without national language support.)
386 fi
387
388 AC_SUBST(SETUP_LIBS)
389
390 dnl disable backtrace if we don't want it.
391 AC_ARG_WITH(gprof, 
392                     [  --with-gprof          enable profiling],
393                         [ if test "x$withval" != "xno" ; then
394                              CFLAGS="$CFLAGS  -pg "
395                              LDFLAGS="$LDFLAGS  -pg "
396                           fi
397                         ]
398 )
399
400 dnl disable backtrace if we don't want it.
401 AC_ARG_WITH(backtrace, 
402                     [  --with-backtrace          enable backtrace dumps in the syslog],
403                         [ if test "x$withval" != "xno" ; then
404                              CFLAGS="$CFLAGS  -rdynamic "
405                              LDFLAGS="$LDFLAGS  -rdynamic "
406                              AC_CHECK_FUNCS(backtrace)
407                           fi
408                         ]
409 )
410
411 if test "$prefix" = NONE; then
412         datadir=$ac_default_prefix
413         localedir=$ac_default_prefix
414         wwwdir=$ac_default_prefix
415         rundir=$ac_default_prefix
416         editordir=$ac_default_prefix/tiny_mce
417 else
418         localedir=$prefix
419         wwwdir=$prefix
420         datadir=$prefix
421         rundir=$prefix
422         editordir=$prefix/tiny_mce
423 fi
424
425 dnl where to put the locale files
426 AC_ARG_WITH(localedir, 
427                     [  --with-localedir          directory to put the locale files to],
428                         [ if test "x$withval" != "xno" ; then
429                             localedir=$withval
430                           fi
431                         ]
432 )
433 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
434 LOCALEDIR=$localedir
435 AC_SUBST(LOCALEDIR)
436
437 dnl Checks where to put our templates
438 AC_ARG_WITH(wwwdir, 
439                     [  --with-wwwdir             directory to put our templates],
440                         [ if test "x$withval" != "xno" ; then
441                                 wwwdir=$withval
442                           fi
443                         ]
444 )
445 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
446 WWWDIR=$wwwdir
447 AC_SUBST(WWWDIR)
448
449
450 dnl Checks for the run-dir for the sockets
451 AC_ARG_WITH(rundir, 
452                         [  --with-rundir           directory to place runtime files (UDS) to?],
453                         [ if test "x$withval" != "xno" ; then
454                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
455                                                 
456                                                 rundir=$withval
457                                                 AC_SUBST(MAKE_RUN_DIR)
458                           fi
459                         ]
460 )
461 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
462
463 dnl Checks for the Datadir
464 AC_ARG_WITH(datadir, 
465                     [  --with-datadir          directory to store the databases under],
466                         [ if test "x$withval" != "xno" ; then
467                                               datadir=$withval
468                           fi
469                         ]
470 )
471 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
472
473 dnl Checks where to put our editor
474 AC_ARG_WITH(editordir, 
475                     [  --with-editordir             directory to put our editor],
476                         [ if test "x$withval" != "xno" ; then
477                                 editordir=$withval
478                           fi
479                         ]
480 )
481 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
482
483 AC_CONFIG_HEADER(sysdep.h)
484 AC_OUTPUT(Makefile po/Makefile )
485
486 echo ------------------------------------------------------------------------
487 echo 'zlib compression:                ' $ok_zlib
488 echo 'Calendar support:                ' $ok_libical
489 echo 'Character set conversion support:' $ok_iconv
490 echo 'National language support:       ' $ok_nls
491 echo