Began some of the PROPFIND mods needed for CalDAV. Mike Shaver is a self-righteous...
[citadel.git] / webcit / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT([WebCit], [8.03], [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 dnl                     CFLAGS="$CFLAGS -Wall -Wno-char-subscripts --pedantic"
67                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
68                 ;;
69                 *)
70 dnl                     CFLAGS="$CFLAGS -Wall --pedantic"
71                         CFLAGS="$CFLAGS -Wall"
72                 ;;
73         esac
74 fi
75
76 # missing_dir=`cd $ac_aux_dir && pwd`
77 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
78
79 dnl Checks for libraries.
80 if test "$LIBS" != -pthread; then
81         AC_CHECK_LIB(pthread, pthread_create)
82         AC_CHECK_LIB(pthreads, pthread_create)
83 fi
84 AC_SEARCH_LIBS(gethostbyname, nsl)
85 AC_SEARCH_LIBS(connect, socket)
86
87 dnl Checks for header files.
88 AC_HEADER_STDC
89 dnl AC_HEADER_SYS_WAIT
90
91 AC_CACHE_CHECK(
92         [for call semantics from getpwuid_r], 
93         ac_cv_call_getpwuid_r,
94         [AC_TRY_COMPILE([#include <sys/types.h>
95 #include <pwd.h>], 
96                          [
97                                 struct passwd pw, *pwp;
98                                 char pwbuf[64];
99                                 uid_t uid;
100
101                                 getpwuid_r(uid, &pw, pwbuf, sizeof(pwbuf), &pwp);
102                         ],
103                         ac_cv_call_getpwuid_r=yes, 
104                         ac_cv_call_getpwuid_r=no)
105         ])
106
107 if test $ac_cv_call_getpwuid_r = no; then
108         AC_DEFINE(SOLARIS_GETPWUID,[],[do we need to use solaris call syntax?])
109         AC_DEFINE(SOLARIS_LOCALTIME_R,[], [do we need to use soralis call syntax?])
110         AC_DEFINE(F_UID_T, "%ld", [whats the matching format string for uid_t?])
111         AC_DEFINE(F_PID_T, "%ld",  [whats the matching format string for pid_t?])
112         AC_DEFINE(F_XPID_T, "%lx",  [whats the matching format string for xpid_t?])
113 else
114         AC_DEFINE(F_UID_T, "%d",  [whats the matching format string for uid_t?])
115         AC_DEFINE(F_PID_T, "%d",  [whats the matching format string for pid_t?])
116         AC_DEFINE(F_XPID_T, "%x",  [whats the matching format string for xpid_t?])
117 fi
118
119
120
121 dnl Checks for typedefs, structures, and compiler characteristics.
122 AC_C_CONST
123 AC_TYPE_OFF_T
124 AC_TYPE_SIZE_T
125 dnl Check the size of various builtin types; see typesize.h (error)
126 AC_CHECK_SIZEOF(char, 0)
127 AC_CHECK_SIZEOF(short, 0)
128 AC_CHECK_SIZEOF(int, 0)
129 AC_CHECK_SIZEOF(long, 0)
130 AC_CHECK_SIZEOF(long unsigned int, 0)
131 AC_CHECK_SIZEOF(size_t, 0)
132 dnl AC_HEADER_TIME
133
134 dnl Checks for library functions.
135 AC_TYPE_SIGNAL
136 dnl AC_FUNC_VPRINTF
137 AC_REPLACE_FUNCS(snprintf)
138 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
139
140 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h iconv.h xlocale.h)
141
142 dnl Checks for the zlib compression library.
143 if test "x$with_zlib" != xno ; then
144        AC_CHECK_HEADERS(zlib.h,
145                [AC_CHECK_LIB(z, zlibVersion,
146                        [ok_zlib=yes],,
147        )])
148 fi
149
150 if test "x$ok_zlib" = xyes ; then
151 dnl  libcitadel will bring libz, so we don't need it here.     LDFLAGS="-lz $LDFLAGS" 
152        AC_DEFINE(HAVE_ZLIB, [], [define this if you have zlib compression available])
153 fi
154
155
156 dnl Here is the check for a libc integrated iconv
157 AC_ARG_ENABLE(iconv,
158         [  --disable-iconv         do not use iconv charset conversion],
159         ok_iconv=no, ok_iconv=yes)
160
161 AC_MSG_CHECKING(Checking to see if your system supports iconv)
162 AC_TRY_RUN([
163         #include <iconv.h>
164         main() {
165                 iconv_t ic = (iconv_t)(-1) ;
166                 ic = iconv_open("UTF-8", "us-ascii");
167                 iconv_close(ic);
168                 exit(0);
169         }
170  ],
171                 [
172                   ok_iconv=yes
173                   AC_MSG_RESULT([yes])
174                 ],
175                 [ 
176                   ok_iconv=no
177                   AC_MSG_RESULT([no])
178                 ]
179 )
180
181 dnl Check for iconv in external libiconv
182 if test "$ok_iconv" = no; then
183         AC_MSG_CHECKING(Checking for an external libiconv)
184         OLD_LDFLAGS="$LDFLAGS"
185         LDFLAGS="$LDFLAGS -liconv"
186         AC_TRY_RUN([
187                         #include <iconv.h>
188                         main() {
189                                 iconv_t ic = (iconv_t)(-1) ;
190                                 ic = iconv_open("UTF-8", "us-ascii");
191                                 iconv_close(ic);
192                         }
193                 ],
194                         [
195                           ok_iconv=yes
196                           AC_MSG_RESULT([yes])
197                         ],
198                         [ 
199                           ok_iconv=no
200                           LDFLAGS="$OLD_LDFLAGS"
201                           AC_MSG_RESULT([no])
202                         ]
203                 )
204 fi      
205 if test "$ok_iconv" != "no"; then
206         AC_MSG_RESULT(webcit will be built with character set conversion.)
207         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
208 else
209         AC_MSG_RESULT(webcit will be built without character set conversion.)
210 fi
211
212
213 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
214
215
216 dnl Checks for the libical iCalendar library.
217 AC_CHECK_HEADER(libical/ical.h,
218         [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
219                 [
220                         LIBS="-lical $LIBS"
221                 ],
222                 [
223                         AC_MSG_ERROR(libical was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
224                 ]
225         ,
226         )],
227         [
228                 AC_MSG_ERROR(libical/ical.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
229         ]
230 )
231
232
233 dnl Check for libcitadel
234 AC_CHECK_HEADER(libcitadel.h,
235         [AC_CHECK_LIB(citadel, libcitadel_version_string,
236                 [
237                         LIBS="-lcitadel $LIBS"
238                         SETUP_LIBS="-lcitadel $SETUP_LIBS"
239                 ],
240                 [
241                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
242                 ]
243         ,
244         )],
245         [
246                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
247         ]
248 )
249
250
251 dnl Checks for the Expat XML parser.
252 AC_CHECK_HEADER(expat.h,
253         [AC_CHECK_LIB(expat, XML_ParserCreateNS,
254                 [
255                         LIBS="-lexpat $LIBS"
256                 ],
257                 [
258                         AC_MSG_ERROR(The Expat XML parser was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
259                 ]
260         ,
261         )],
262         [
263                 AC_MSG_ERROR(expat.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
264         ]
265 )
266
267
268
269 found_ssl=no
270 # The big search for OpenSSL
271 if test "$with_ssl" != "no"; then
272         saved_LIBS="$LIBS"
273         saved_LDFLAGS="$LDFLAGS"
274         saved_CFLAGS="$CFLAGS"
275         if test "x$prefix" != "xNONE"; then
276                 tryssldir="$tryssldir $prefix"
277         fi
278         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
279                 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
280                         CFLAGS="$saved_CFLAGS"
281                         LDFLAGS="$saved_LDFLAGS"
282                         LIBS="$saved_LIBS -lssl -lcrypto"
283         
284                         # Skip directories if they don't exist
285                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
286                                 continue;
287                         fi
288                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
289                                 # Try to use $ssldir/lib if it exists, otherwise
290                                 # $ssldir
291                                 if test -d "$ssldir/lib" ; then
292                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
293                                         if test ! -z "$need_dash_r" ; then
294                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
295                                         fi
296                                 else
297                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
298                                         if test ! -z "$need_dash_r" ; then
299                                                 LDFLAGS="-R$ssldir $LDFLAGS"
300                                         fi
301                                 fi
302                                 # Try to use $ssldir/include if it exists, otherwise
303                                 # $ssldir
304                                 if test -d "$ssldir/include" ; then
305                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
306                                 else
307                                         CFLAGS="-I$ssldir $saved_CFLAGS"
308                                 fi
309                         fi
310         
311                         # Basic test to check for compatible version and correct linking
312                         # *does not* test for RSA - that comes later.
313                         AC_TRY_RUN(
314                                 [
315         #include <string.h>
316         #include <openssl/rand.h>
317         int main(void)
318         {
319                 char a[2048];
320                 memset(a, 0, sizeof(a));
321                 RAND_add(a, sizeof(a), sizeof(a));
322                 return(RAND_status() <= 0);
323         }
324                                 ],
325                                 [
326                                         found_crypto=1
327                                         break;
328                                 ], []
329                         )
330         
331                         if test ! -z "$found_crypto" ; then
332                                 break;
333                         fi
334                 done
335         
336                 if test -z "$ssldir" ; then
337                         ssldir="(system)"
338                 fi
339         
340                 if test ! -z "$found_crypto" ; then
341                         ac_cv_openssldir=$ssldir
342                 else
343                         ac_cv_openssldir="no"
344                 fi
345         ])
346         LIBS="$saved_LIBS"
347         LDFLAGS="$saved_LDFLAGS"
348         CFLAGS="$saved_CFLAGS"
349         
350         if test "x$ac_cv_openssldir" != "xno" ; then
351                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
352                 found_ssl=yes
353                 LIBS="-lssl -lcrypto $LIBS"
354                 dnl Need to recover ssldir - test above runs in subshell
355                 ssldir=$ac_cv_openssldir
356                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
357                         # Try to use $ssldir/lib if it exists, otherwise
358                         # $ssldir
359                         if test -d "$ssldir/lib" ; then
360                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
361                                 if test ! -z "$need_dash_r" ; then
362                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
363                                 fi
364                         else
365                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
366                                 if test ! -z "$need_dash_r" ; then
367                                         LDFLAGS="-R$ssldir $LDFLAGS"
368                                 fi
369                         fi
370                         # Try to use $ssldir/include if it exists, otherwise
371                         # $ssldir
372                         if test -d "$ssldir/include" ; then
373                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
374                         else
375                                 CFLAGS="-I$ssldir $saved_CFLAGS"
376                         fi
377                 fi
378         fi
379 fi
380 dnl Checks for the SSLdir
381 dnl this is a bit different than the rest, 
382 dnl because of the citadel used to have a keys/ subdir.
383 AC_ARG_WITH(ssldir, 
384                     [  --with-ssldir          directory to store the ssl certificates under],
385                         [ if test "x$withval" != "xno" ; then
386                                               
387                                                   ssl_dir="$withval"
388                                                   if test "$found_ssl" = "no"; then
389                                                      echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
390                                                      exit
391                                                   fi
392                           fi
393                         AC_SUBST(MAKE_SSL_DIR)
394                         ]
395 )
396 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
397
398
399
400
401 AC_CHECK_FUNCS(strftime_l uselocale gettext)
402
403 if test "$ok_nls" != "no"; then
404         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
405         ok_nls=$ok_xgettext
406 fi
407
408 if test "$ok_nls" != "no"; then
409         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
410         ok_nls=$ok_msgmerge
411 fi
412
413 if test "$ok_nls" != "no"; then
414         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
415         ok_nls=$ok_msgfmt
416 fi
417
418 if test "$ok_nls" != "no"; then
419         AC_MSG_RESULT(WebCit will be built with national language support.)
420         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
421         PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
422 else
423         AC_MSG_RESULT(WebCit will be built without national language support.)
424 fi
425
426 AC_SUBST(SETUP_LIBS)
427
428 dnl disable backtrace if we don't want it.
429 AC_ARG_WITH(gprof, 
430                     [  --with-gprof          enable profiling],
431                         [ if test "x$withval" != "xno" ; then
432                              CFLAGS="$CFLAGS  -pg "
433                              LDFLAGS="$LDFLAGS  -pg "
434                           fi
435                         ]
436 )
437
438 dnl disable backtrace if we don't want it.
439 AC_ARG_WITH(backtrace, 
440                     [  --with-backtrace          enable backtrace dumps in the syslog],
441                         [ if test "x$withval" != "xno" ; then
442                              CFLAGS="$CFLAGS  -rdynamic "
443                              LDFLAGS="$LDFLAGS  -rdynamic "
444                              AC_CHECK_FUNCS(backtrace)
445                           fi
446                         ]
447 )
448
449 if test "$prefix" = NONE; then
450         datadir=$ac_default_prefix
451         localedir=$ac_default_prefix
452         wwwdir=$ac_default_prefix
453         rundir=$ac_default_prefix
454         editordir=$ac_default_prefix/tiny_mce
455 else
456         localedir=$prefix
457         wwwdir=$prefix
458         datadir=$prefix
459         rundir=$prefix
460         editordir=$prefix/tiny_mce
461 fi
462
463 dnl where to put the locale files
464 AC_ARG_WITH(localedir, 
465                     [  --with-localedir          directory to put the locale files to],
466                         [ if test "x$withval" != "xno" ; then
467                             localedir=$withval
468                           fi
469                         ]
470 )
471 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
472 LOCALEDIR=$localedir
473 AC_SUBST(LOCALEDIR)
474
475 dnl Checks where to put our templates
476 AC_ARG_WITH(wwwdir, 
477                     [  --with-wwwdir             directory to put our templates],
478                         [ if test "x$withval" != "xno" ; then
479                                 wwwdir=$withval
480                           fi
481                         ]
482 )
483 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
484 WWWDIR=$wwwdir
485 AC_SUBST(WWWDIR)
486
487
488 dnl Checks for the run-dir for the sockets
489 AC_ARG_WITH(rundir, 
490                         [  --with-rundir           directory to place runtime files (UDS) to?],
491                         [ if test "x$withval" != "xno" ; then
492                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
493                                                 
494                                                 rundir=$withval
495                                                 AC_SUBST(MAKE_RUN_DIR)
496                           fi
497                         ]
498 )
499 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
500
501 dnl Checks for the Datadir
502 AC_ARG_WITH(datadir, 
503                     [  --with-datadir          directory to store the databases under],
504                         [ if test "x$withval" != "xno" ; then
505                                               datadir=$withval
506                           fi
507                         ]
508 )
509 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
510
511 dnl Checks where to put our editor
512 AC_ARG_WITH(editordir, 
513                     [  --with-editordir             directory to put our editor],
514                         [ if test "x$withval" != "xno" ; then
515                                 editordir=$withval
516                           fi
517                         ]
518 )
519 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
520
521 abs_srcdir="`cd $srcdir && pwd`"
522 abs_builddir="`pwd`"
523 if test "$abs_srcdir" != "$abs_builddir"; then
524    CFLAGS="$CFLAGS -I $abs_builddir"
525 fi
526 AC_CONFIG_HEADER(sysdep.h)
527 AC_OUTPUT(Makefile po/webcit/Makefile tests/Makefile)
528
529 if test "$abs_srcdir" != "$abs_builddir"; then
530    ln -s $abs_srcdir/static $abs_builddir
531    ln -s $abs_srcdir/tiny_mce $abs_builddir
532    ln -s $abs_srcdir/*.h $abs_builddir
533    make mkdir-init
534    
535 else
536 dnl just run it on devel systems and if non vdir build.
537    if test -d .svn; then
538       ./mk_module_init.sh
539    fi
540 fi
541
542 if test -n "$srcdir"; then 
543    export srcdir=.
544 fi
545
546
547 echo ------------------------------------------------------------------------
548 echo 'Character set conversion support:' $ok_iconv
549 echo 'National language support:       ' $ok_nls
550 echo 'Compression support:             ' $ok_zlib
551 echo