Mailing list header changes (fuck you Google)
[citadel.git] / webcit / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT([WebCit],m4_esyscmd_s([grep CLIENT_VERSION webcit.h | sed 's/[^0-9]*//g']),[http://uncensored.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(ssl,
27         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
28         [
29                 if test "x$withval" != "xno" ; then
30                         tryssldir=$withval
31                 fi
32         ]
33 )
34 dnl Set some system-specific variables which are OK to set before compiler
35 dnl checks:
36 PTHREAD_DEFS=-D_REENTRANT
37 case "$host" in
38         dnl Tru64 Unix requires we use -pthread instead of linking the threads
39         dnl libraries directly, and we can't build threaded programs with gcc
40         dnl due to header file problems.
41         alpha*-dec-osf*)
42                 test -z "$CC" && CC=cc
43                 LIBS=-pthread
44         ;;
45         dnl FreeBSD is similar:
46         *-*-freebsd*)
47                 LIBS=-pthread
48                 PTHREAD_DEFS=-D_THREAD_SAFE
49         ;;
50         *-*-solaris*)
51                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
52         ;;
53         *-*-darwin*)
54                 LIBS=-lintl
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 dnl                     CFLAGS="$CFLAGS -Wall -Wno-char-subscripts --pedantic"
66                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
67                 ;;
68                 *)
69 dnl                     CFLAGS="$CFLAGS -Wall --pedantic"
70                         CFLAGS="$CFLAGS -Wall"
71                 ;;
72         esac
73 fi
74
75 # missing_dir=`cd $ac_aux_dir && pwd`
76 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
77
78 dnl Checks for libraries.
79 if test "$LIBS" != -pthread; then
80         AC_CHECK_LIB(pthread, pthread_create)
81         AC_CHECK_LIB(pthreads, pthread_create)
82 fi
83 AC_SEARCH_LIBS(gethostbyname, nsl)
84 AC_SEARCH_LIBS(connect, socket)
85
86 dnl Checks for header files.
87 AC_HEADER_STDC
88 dnl AC_HEADER_SYS_WAIT
89
90 AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r getloadavg)
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 unistd.h iconv.h xlocale.h)
141
142 dnl Checks for the zlib compression library.
143 saved_CFLAGS="$CFLAGS"
144 CFLAGS="$CFLAGS $SERVER_LIBS"
145 AC_CHECK_HEADER(zlib.h,
146         [AC_CHECK_LIB(z, zlibVersion,
147                 [
148                         LIBS="-lz $LIBS $SERVER_LIBS"
149                 ],
150                 [
151                         AC_MSG_ERROR(zlib was not found or is not usable.  Please install zlib.)
152                 ]
153         ,
154         )],
155         [
156                 AC_MSG_ERROR(zlib.h was not found or is not usable.  Please install zlib.)
157         ]
158 )
159 CFLAGS="$saved_CFLAGS"
160
161 dnl Here is the check for a libc integrated iconv
162 AC_ARG_ENABLE(iconv,
163         [  --disable-iconv         do not use iconv charset conversion],
164         ok_iconv=no, ok_iconv=yes)
165
166 AC_MSG_CHECKING(Checking to see if your system supports iconv)
167 AC_TRY_RUN([
168         #include <iconv.h>
169         main() {
170                 iconv_t ic = (iconv_t)(-1) ;
171                 ic = iconv_open("UTF-8", "us-ascii");
172                 iconv_close(ic);
173                 exit(0);
174         }
175  ],
176                 [
177                   ok_iconv=yes
178                   AC_MSG_RESULT([yes])
179                 ],
180                 [ 
181                   ok_iconv=no
182                   AC_MSG_RESULT([no])
183                 ]
184 )
185
186 dnl Check for iconv in external libiconv
187 if test "$ok_iconv" = no; then
188         AC_MSG_CHECKING(Checking for an external libiconv)
189         OLD_LDFLAGS="$LDFLAGS"
190         LDFLAGS="$LDFLAGS -liconv"
191         AC_TRY_RUN([
192                         #include <iconv.h>
193                         main() {
194                                 iconv_t ic = (iconv_t)(-1) ;
195                                 ic = iconv_open("UTF-8", "us-ascii");
196                                 iconv_close(ic);
197                         }
198                 ],
199                         [
200                           ok_iconv=yes
201                           AC_MSG_RESULT([yes])
202                         ],
203                         [ 
204                           ok_iconv=no
205                           LDFLAGS="$OLD_LDFLAGS"
206                           AC_MSG_RESULT([no])
207                         ]
208                 )
209 fi      
210 if test "$ok_iconv" != "no"; then
211         AC_MSG_RESULT(webcit will be built with character set conversion.)
212         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
213 else
214         AC_MSG_RESULT(webcit will be built without character set conversion.)
215 fi
216
217
218 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
219
220
221 dnl Checks for the libical iCalendar library.
222 AC_CHECK_HEADER(libical/ical.h,
223         [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
224                 [
225                         LIBS="-lical $LIBS"
226                 ],
227                 [
228                         AC_MSG_ERROR(libical was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
229                 ]
230         ,
231         )],
232         [
233                 AC_MSG_ERROR(libical/ical.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
234         ]
235 )
236
237 dnl Checks for the discount markdown library.
238 AC_CHECK_LIB(markdown,
239          markdown,
240          [
241          LIBS="$LIBS -lmarkdown"
242          AC_DEFINE(HAVE_MARKDOWN,[],[whether we have markdown message rendering])
243 ])
244
245 dnl Check for libcitadel
246 AC_CHECK_HEADER(libcitadel.h,
247         [AC_CHECK_LIB(citadel, libcitadel_version_string,
248                 [
249                         LIBS="-lcitadel $LIBS"
250                         SETUP_LIBS="-lcitadel $SETUP_LIBS"
251                 ],
252                 [
253                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
254                 ]
255         ,
256         )],
257         [
258                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
259         ]
260 )
261
262 AC_MSG_CHECKING([whether your system likes memcpy + HKEY]) 
263 AC_TRY_COMPILE([
264 #define _GNU_SOURCE
265 #include <ctype.h>
266 #include <errno.h>
267 #include <string.h>
268 #include <unistd.h>
269 #include <string.h>
270 #include <stdio.h>
271 #include <sys/select.h>
272 #include <fcntl.h>
273 #include <sys/types.h>
274
275 #include "lib/libcitadel.h"
276 ],
277 [
278         char foo[22];
279         memcpy(foo, HKEY("foo"));
280         
281 ],
282                 [
283
284                   AC_MSG_RESULT([yes])
285                 ],
286                 [ 
287                   AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
288                   AC_MSG_RESULT([no])
289                 ]
290 )
291
292 dnl Checks for the Expat XML parser.
293 AC_CHECK_HEADER(expat.h,
294         [AC_CHECK_LIB(expat, XML_ParserCreateNS,
295                 [
296                         LIBS="-lexpat $LIBS"
297                 ],
298                 [
299                         AC_MSG_ERROR(The Expat XML parser was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
300                 ]
301         ,
302         )],
303         [
304                 AC_MSG_ERROR(expat.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
305         ]
306 )
307
308
309
310 found_ssl=no
311 # The big search for OpenSSL
312 if test "$with_ssl" != "no"; then
313         saved_LIBS="$LIBS"
314         saved_LDFLAGS="$LDFLAGS"
315         saved_CFLAGS="$CFLAGS"
316         if test "x$prefix" != "xNONE"; then
317                 tryssldir="$tryssldir $prefix"
318         fi
319         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
320                 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
321                         CFLAGS="$saved_CFLAGS"
322                         LDFLAGS="$saved_LDFLAGS"
323                         LIBS="$saved_LIBS -lssl -lcrypto"
324         
325                         # Skip directories if they don't exist
326                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
327                                 continue;
328                         fi
329                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
330                                 # Try to use $ssldir/lib if it exists, otherwise
331                                 # $ssldir
332                                 if test -d "$ssldir/lib" ; then
333                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
334                                         if test ! -z "$need_dash_r" ; then
335                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
336                                         fi
337                                 else
338                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
339                                         if test ! -z "$need_dash_r" ; then
340                                                 LDFLAGS="-R$ssldir $LDFLAGS"
341                                         fi
342                                 fi
343                                 # Try to use $ssldir/include if it exists, otherwise
344                                 # $ssldir
345                                 if test -d "$ssldir/include" ; then
346                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
347                                 else
348                                         CFLAGS="-I$ssldir $saved_CFLAGS"
349                                 fi
350                         fi
351         
352                         # Basic test to check for compatible version and correct linking
353                         # *does not* test for RSA - that comes later.
354                         AC_TRY_RUN(
355                                 [
356         #include <string.h>
357         #include <openssl/rand.h>
358         int main(void)
359         {
360                 char a[2048];
361                 memset(a, 0, sizeof(a));
362                 RAND_add(a, sizeof(a), sizeof(a));
363                 return(RAND_status() <= 0);
364         }
365                                 ],
366                                 [
367                                         found_crypto=1
368                                         break;
369                                 ], []
370                         )
371         
372                         if test ! -z "$found_crypto" ; then
373                                 break;
374                         fi
375                 done
376         
377                 if test -z "$ssldir" ; then
378                         ssldir="(system)"
379                 fi
380         
381                 if test ! -z "$found_crypto" ; then
382                         ac_cv_openssldir=$ssldir
383                 else
384                         ac_cv_openssldir="no"
385                 fi
386         ])
387         LIBS="$saved_LIBS"
388         LDFLAGS="$saved_LDFLAGS"
389         CFLAGS="$saved_CFLAGS"
390         
391         if test "x$ac_cv_openssldir" != "xno" ; then
392                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
393                 found_ssl=yes
394                 LIBS="-lssl -lcrypto $LIBS"
395                 dnl Need to recover ssldir - test above runs in subshell
396                 ssldir=$ac_cv_openssldir
397                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
398                         # Try to use $ssldir/lib if it exists, otherwise
399                         # $ssldir
400                         if test -d "$ssldir/lib" ; then
401                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
402                                 if test ! -z "$need_dash_r" ; then
403                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
404                                 fi
405                         else
406                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
407                                 if test ! -z "$need_dash_r" ; then
408                                         LDFLAGS="-R$ssldir $LDFLAGS"
409                                 fi
410                         fi
411                         # Try to use $ssldir/include if it exists, otherwise
412                         # $ssldir
413                         if test -d "$ssldir/include" ; then
414                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
415                         else
416                                 CFLAGS="-I$ssldir $saved_CFLAGS"
417                         fi
418                 fi
419         fi
420 fi
421 dnl Checks for the SSLdir
422 dnl this is a bit different than the rest, 
423 dnl because of the citadel used to have a keys/ subdir.
424 AC_ARG_WITH(ssldir, 
425                     [  --with-ssldir          directory to store the ssl certificates under],
426                         [ if test "x$withval" != "xno" ; then
427                                               
428                                                   ssl_dir="$withval"
429                                                   if test "$found_ssl" = "no"; then
430                                                      echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
431                                                      exit
432                                                   fi
433                           fi
434                         AC_SUBST(MAKE_SSL_DIR)
435                         ]
436 )
437 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
438
439
440
441
442 AC_CHECK_FUNCS(strftime_l uselocale gettext)
443
444 if test "$ok_nls" != "no"; then
445         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
446         ok_nls=$ok_xgettext
447 fi
448
449 if test "$ok_nls" != "no"; then
450         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
451         ok_nls=$ok_msgmerge
452 fi
453
454 if test "$ok_nls" != "no"; then
455         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
456         ok_nls=$ok_msgfmt
457 fi
458
459 if test "$ok_nls" != "no"; then
460         AC_MSG_RESULT(WebCit will be built with national language support.)
461         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
462         PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
463 else
464         AC_MSG_RESULT(WebCit will be built without national language support.)
465 fi
466
467 AC_SUBST(SETUP_LIBS)
468
469 dnl disable backtrace if we don't want it.
470 AC_ARG_WITH(gprof, 
471                     [  --with-gprof          enable profiling],
472                         [ if test "x$withval" != "xno" ; then
473                              CFLAGS="$CFLAGS  -pg "
474                              LDFLAGS="$LDFLAGS  -pg "
475                           fi
476                         ]
477 )
478
479 dnl disable backtrace if we don't want it.
480 AC_ARG_WITH(backtrace, 
481                     [  --with-backtrace          enable backtrace dumps in the syslog],
482                         [ if test "x$withval" != "xno" ; then
483                              CFLAGS="$CFLAGS  -rdynamic "
484                              LDFLAGS="$LDFLAGS  -rdynamic "
485                              AC_CHECK_FUNCS(backtrace)
486                           fi
487                         ]
488 )
489
490 if test "$prefix" = NONE; then
491         datadir=$ac_default_prefix
492         localedir=$ac_default_prefix
493         wwwdir=$ac_default_prefix
494         rundir=$ac_default_prefix
495         editordir=$ac_default_prefix/tiny_mce
496         markdowneditordir=$ac_default_prefix/epic
497         etcdir=$ac_default_prefix
498 else
499         localedir=$prefix
500         wwwdir=$prefix
501         datadir=$prefix
502         rundir=$prefix
503         editordir=$prefix/tiny_mce
504         markdowneditordir=$prefix/epic
505         etcdir=$prefix
506 fi
507
508 dnl where to put the locale files
509 AC_ARG_WITH(localedir, 
510                     [  --with-localedir          directory to put the locale files to],
511                         [ if test "x$withval" != "xno" ; then
512                             localedir=$withval
513                           fi
514                         ]
515 )
516 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
517 LOCALEDIR=$localedir
518 AC_SUBST(LOCALEDIR)
519
520 dnl Checks where to put our templates
521 AC_ARG_WITH(wwwdir, 
522                     [  --with-wwwdir             directory to put our templates],
523                         [ if test "x$withval" != "xno" ; then
524                                 wwwdir=$withval
525                           fi
526                         ]
527 )
528 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
529 WWWDIR=$wwwdir
530 AC_SUBST(WWWDIR)
531
532
533 dnl Checks for the run-dir for the sockets
534 AC_ARG_WITH(rundir, 
535                         [  --with-rundir           directory to place runtime files (UDS) to?],
536                         [ if test "x$withval" != "xno" ; then
537                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
538                                                 
539                                                 rundir=$withval
540                                                 AC_SUBST(MAKE_RUN_DIR)
541                           fi
542                         ]
543 )
544 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
545
546 dnl Checks for the Datadir
547 AC_ARG_WITH(datadir, 
548                     [  --with-datadir          directory to store the databases under],
549                         [ if test "x$withval" != "xno" ; then
550                                               datadir=$withval
551                           fi
552                         ]
553 )
554 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
555
556 dnl Checks where to put our editor
557 AC_ARG_WITH(editordir, 
558                     [  --with-editordir             directory to put our editor],
559                         [ if test "x$withval" != "xno" ; then
560                                 editordir=$withval
561                           fi
562                         ]
563 )
564 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
565
566 AC_ARG_WITH(markdowneditordir, 
567                     [  --with-markdowneditordir             directory to put our markdown editor],
568                         [ if test "x$withval" != "xno" ; then
569                                 markdowneditordir=$withval
570                           fi
571                         ]
572 )
573 AC_DEFINE_UNQUOTED(MARKDOWNEDITORDIR, "$markdowneditordir", [where to find our markdown editor])
574
575 dnl Checks where to find our configs
576 AC_ARG_WITH(etcdir, 
577                     [  --with-etcdir             directory to read our configs],
578                         [ if test "x$withval" != "xno" ; then
579                                 etcdir=$withval
580                           fi
581                         ]
582 )
583 AC_DEFINE_UNQUOTED(ETCDIR, "$etcdir", [where to find our configs])
584 ETCDIR=$etcdir
585 AC_SUBST(ETCDIR)
586
587 abs_srcdir="`cd $srcdir && pwd`"
588 abs_builddir="`pwd`"
589 if test "$abs_srcdir" != "$abs_builddir"; then
590    CFLAGS="$CFLAGS -I $abs_builddir"
591 fi
592 AC_CONFIG_HEADER(sysdep.h)
593 AC_OUTPUT(Makefile po/webcit/Makefile tests/Makefile)
594
595 if test "$abs_srcdir" != "$abs_builddir"; then
596    ln -s $abs_srcdir/static $abs_builddir
597    ln -s $abs_srcdir/tiny_mce $abs_builddir
598    ln -s $abs_srcdir/epic $abs_builddir
599    ln -s $abs_srcdir/*.h $abs_builddir
600    make mkdir-init
601    
602 else
603 dnl just run it on devel systems and if non vdir build.
604    if test -d .svn; then
605       ./mk_module_init.sh
606    fi
607 fi
608
609 if test -n "$srcdir"; then 
610    export srcdir=.
611 fi
612
613
614 echo ------------------------------------------------------------------------
615 echo 'Character set conversion support:' $ok_iconv
616 echo 'National language support:       ' $ok_nls
617 echo