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