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