* Updated internal version number of citadel and webcit to 7.23
[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.23], [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 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
88
89
90
91
92 dnl Checks for typedefs, structures, and compiler characteristics.
93 AC_C_CONST
94 AC_TYPE_OFF_T
95 AC_TYPE_SIZE_T
96 dnl AC_HEADER_TIME
97
98 dnl Checks for library functions.
99 AC_TYPE_SIGNAL
100 dnl AC_FUNC_VPRINTF
101 AC_REPLACE_FUNCS(snprintf)
102
103 webcit_with_calendar_service=no
104 dnl Checks for the libical calendaring library.
105 if test "x$with_libical" != xno ; then
106         AC_CHECK_HEADERS(ical.h,
107                 [AC_CHECK_LIB(ical, icalcomponent_new,
108                         [ok_libical=yes],,
109         )])
110 fi
111
112 if test "x$ok_libical" = xyes ; then
113
114         AC_TRY_RUN(
115                 [
116 #include <ical.h>
117 main() {
118         int major, minor, v;
119         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
120         v = 100*major + minor;
121         printf("libical version: %i\n", v);
122         if (v >= 24) {
123                 printf("This version is ok.\n");
124                 return(0);
125         }
126         printf("libical 0.24 or newer required.\n");
127         printf("Citadel will be built without calendar support.\n");
128         return(1);
129 }
130                 ], 
131                 [
132                         LIBS="-lical $LIBS"
133                         AC_DEFINE(HAVE_LIBICAL,[],[whether we have libical available])
134                         webcit_with_calendar_service=yes
135                 ]
136         )
137 fi
138
139 if test "$webcit_with_calendar_service" == "yes"; then
140                         AC_DEFINE(WEBCIT_WITH_CALENDAR_SERVICE,[],[whether we can do with calendar.])
141 fi
142
143 dnl Checks for the zlib compression library.
144 if test "x$with_zlib" != xno ; then
145         AC_CHECK_HEADERS(zlib.h,
146                 [AC_CHECK_LIB(z, zlibVersion,
147                         [ok_zlib=yes],,
148         )])
149 fi
150
151 if test "x$ok_zlib" = xyes ; then
152         LIBS="-lz $LIBS"
153         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
154 fi
155
156
157 # The big search for OpenSSL
158 if test "$with_ssl" != "no"; then
159         saved_LIBS="$LIBS"
160         saved_LDFLAGS="$LDFLAGS"
161         saved_CFLAGS="$CFLAGS"
162         if test "x$prefix" != "xNONE"; then
163                 tryssldir="$tryssldir $prefix"
164         fi
165         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
166                 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
167                         CFLAGS="$saved_CFLAGS"
168                         LDFLAGS="$saved_LDFLAGS"
169                         LIBS="$saved_LIBS -lssl -lcrypto"
170         
171                         # Skip directories if they don't exist
172                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
173                                 continue;
174                         fi
175                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
176                                 # Try to use $ssldir/lib if it exists, otherwise
177                                 # $ssldir
178                                 if test -d "$ssldir/lib" ; then
179                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
180                                         if test ! -z "$need_dash_r" ; then
181                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
182                                         fi
183                                 else
184                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
185                                         if test ! -z "$need_dash_r" ; then
186                                                 LDFLAGS="-R$ssldir $LDFLAGS"
187                                         fi
188                                 fi
189                                 # Try to use $ssldir/include if it exists, otherwise
190                                 # $ssldir
191                                 if test -d "$ssldir/include" ; then
192                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
193                                 else
194                                         CFLAGS="-I$ssldir $saved_CFLAGS"
195                                 fi
196                         fi
197         
198                         # Basic test to check for compatible version and correct linking
199                         # *does not* test for RSA - that comes later.
200                         AC_TRY_RUN(
201                                 [
202         #include <string.h>
203         #include <openssl/rand.h>
204         int main(void)
205         {
206                 char a[2048];
207                 memset(a, 0, sizeof(a));
208                 RAND_add(a, sizeof(a), sizeof(a));
209                 return(RAND_status() <= 0);
210         }
211                                 ],
212                                 [
213                                         found_crypto=1
214                                         break;
215                                 ], []
216                         )
217         
218                         if test ! -z "$found_crypto" ; then
219                                 break;
220                         fi
221                 done
222         
223                 if test -z "$ssldir" ; then
224                         ssldir="(system)"
225                 fi
226         
227                 if test ! -z "$found_crypto" ; then
228                         ac_cv_openssldir=$ssldir
229                 else
230                         ac_cv_openssldir="no"
231                 fi
232         ])
233         LIBS="$saved_LIBS"
234         LDFLAGS="$saved_LDFLAGS"
235         CFLAGS="$saved_CFLAGS"
236         
237         if test "x$ac_cv_openssldir" != "xno" ; then
238                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
239                 LIBS="-lssl -lcrypto $LIBS"
240                 dnl Need to recover ssldir - test above runs in subshell
241                 ssldir=$ac_cv_openssldir
242                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
243                         # Try to use $ssldir/lib if it exists, otherwise
244                         # $ssldir
245                         if test -d "$ssldir/lib" ; then
246                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
247                                 if test ! -z "$need_dash_r" ; then
248                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
249                                 fi
250                         else
251                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
252                                 if test ! -z "$need_dash_r" ; then
253                                         LDFLAGS="-R$ssldir $LDFLAGS"
254                                 fi
255                         fi
256                         # Try to use $ssldir/include if it exists, otherwise
257                         # $ssldir
258                         if test -d "$ssldir/include" ; then
259                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
260                         else
261                                 CFLAGS="-I$ssldir $saved_CFLAGS"
262                         fi
263                 fi
264         fi
265 fi
266 dnl Checks for the SSLdir
267 dnl this is a bit different than the rest, 
268 dnl because of the citadel used to have a keys/ subdir.
269 AC_ARG_WITH(ssldir, 
270                     [  --with-ssldir          directory to store the ssl certificates under],
271                         [ if test "x$withval" != "xno" ; then
272                                               
273                                                   ssl_dir="$withval"
274                           fi
275                         AC_SUBST(MAKE_SSL_DIR)
276                         ]
277 )
278 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
279
280 dnl Here is the check for a usable iconv
281
282 AC_ARG_ENABLE(iconv,
283         [  --disable-iconv         do not use iconv charset conversion],
284         ok_iconv=no, ok_iconv=yes)
285
286 if test "$ok_nls" != "no"; then
287         AC_MSG_RESULT(Checking to see if your system supports iconv...)
288         AC_TRY_RUN([
289                 #include <iconv.h>
290                 main() {
291                         iconv_t ic = (iconv_t)(-1) ;
292                         ic = iconv_open("UTF-8", "us-ascii");
293                         iconv_close(ic);
294                         exit(0);
295                 }
296         ],
297                 ok_iconv=yes,
298                 ok_iconv=no
299         )
300 fi
301
302 if test "$ok_iconv" != "no"; then
303         AC_MSG_RESULT(WebCit will be built with character set conversion.)
304         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
305 else
306         AC_MSG_RESULT(WebCit will be built without character set conversion.)
307 fi
308
309
310
311 dnl Here is the check for libintl etc.
312
313 AC_ARG_ENABLE(nls,
314         [  --disable-nls           do not use Native Language Support],
315         ok_nls=no, ok_nls=yes)
316
317 if test "$ok_nls" != "no"; then
318         AC_MSG_RESULT(Checking for per-thread NLS support...)
319         AC_TRY_RUN([
320                 #define _GNU_SOURCE
321                 #include <libintl.h>
322                 #include <locale.h>
323                 #include <time.h>
324                 main() {
325                         char *foo = NULL;
326                         char baz[32];
327                         struct tm *tm;
328                         uselocale(LC_GLOBAL_LOCALE);
329                         foo = gettext("bar");
330                         if (0) {
331                                 strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
332                         }
333                         exit(0);
334                 }
335         ],
336                 ok_uselocale=yes,
337                 ok_uselocale=no
338         )
339         ok_nls=$ok_uselocale
340 fi
341
342 if test "$ok_nls" != "no"; then
343         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
344         ok_nls=$ok_xgettext
345 fi
346
347 if test "$ok_nls" != "no"; then
348         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
349         ok_nls=$ok_msgmerge
350 fi
351
352 if test "$ok_nls" != "no"; then
353         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
354         ok_nls=$ok_msgfmt
355 fi
356
357 if test "$ok_nls" != "no"; then
358         AC_MSG_RESULT(WebCit will be built with national language support.)
359         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
360         PROG_SUBDIRS="$PROG_SUBDIRS po"
361 else
362         AC_MSG_RESULT(WebCit will be built without national language support.)
363 fi
364
365 AC_SUBST(SETUP_LIBS)
366
367 dnl disable backtrace if we don't want it.
368 AC_ARG_WITH(gprof, 
369                     [  --with-gprof          enable profiling],
370                         [ if test "x$withval" != "xno" ; then
371                              CFLAGS="$CFLAGS  -pg "
372                              LDFLAGS="$LDFLAGS  -pg "
373                           fi
374                         ]
375 )
376
377 dnl disable backtrace if we don't want it.
378 AC_ARG_WITH(backtrace, 
379                     [  --with-backtrace          enable backtrace dumps in the syslog],
380                         [ if test "x$withval" != "xno" ; then
381                              CFLAGS="$CFLAGS  -rdynamic "
382                              LDFLAGS="$LDFLAGS  -rdynamic "
383                              AC_CHECK_FUNCS(backtrace)
384                           fi
385                         ]
386 )
387
388 if test "$prefix" = NONE; then
389         datadir=$ac_default_prefix
390         localedir=$ac_default_prefix
391         wwwdir=$ac_default_prefix
392         rundir=$ac_default_prefix
393         editordir=$ac_default_prefix/tiny_mce
394 else
395         localedir=$prefix
396         wwwdir=$prefix
397         datadir=$prefix
398         rundir=$prefix
399         editordir=$prefix/tiny_mce
400 fi
401
402 dnl where to put the locale files
403 AC_ARG_WITH(localedir, 
404                     [  --with-localedir          directory to put the locale files to],
405                         [ if test "x$withval" != "xno" ; then
406                             localedir=$withval
407                           fi
408                         ]
409 )
410 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
411 LOCALEDIR=$localedir
412 AC_SUBST(LOCALEDIR)
413
414 dnl Checks where to put our templates
415 AC_ARG_WITH(wwwdir, 
416                     [  --with-wwwdir             directory to put our templates],
417                         [ if test "x$withval" != "xno" ; then
418                                 wwwdir=$withval
419                           fi
420                         ]
421 )
422 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
423 WWWDIR=$wwwdir
424 AC_SUBST(WWWDIR)
425
426
427 dnl Checks for the run-dir for the sockets
428 AC_ARG_WITH(rundir, 
429                         [  --with-rundir           directory to place runtime files (UDS) to?],
430                         [ if test "x$withval" != "xno" ; then
431                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
432                                                 
433                                                 rundir=$withval
434                                                 AC_SUBST(MAKE_RUN_DIR)
435                           fi
436                         ]
437 )
438 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
439
440 dnl Checks for the Datadir
441 AC_ARG_WITH(datadir, 
442                     [  --with-datadir          directory to store the databases under],
443                         [ if test "x$withval" != "xno" ; then
444                                               datadir=$withval
445                           fi
446                         ]
447 )
448 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
449
450 dnl Checks where to put our editor
451 AC_ARG_WITH(editordir, 
452                     [  --with-editordir             directory to put our editor],
453                         [ if test "x$withval" != "xno" ; then
454                                 editordir=$withval
455                           fi
456                         ]
457 )
458 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
459
460 AC_CONFIG_HEADER(sysdep.h)
461 AC_OUTPUT(Makefile po/Makefile )
462
463 echo ------------------------------------------------------------------------
464 echo 'zlib compression:                ' $ok_zlib
465 echo 'Calendar support:                ' $ok_libical
466 echo 'Character set conversion support:' $ok_iconv
467 echo 'National language support:       ' $ok_nls
468 echo