1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([WebCit],m4_esyscmd_s([grep CLIENT_VERSION webcit.h | sed 's/[^0-9]*//g']),[http://uncensored.citadel.org])
6 AC_DEFINE(PROG_SUBDIRS, [], [Program dirs])
9 missing_dir=`cd $ac_aux_dir && pwd`
10 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
11 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
13 dnl Make sure we see all GNU and Solaris extensions.
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"
22 AC_DEFINE_UNQUOTED(WEBCITDIR, "$prefix", [define this to the Citadel home directory])
23 ssl_dir="$prefix/keys"
27 [ --with-ssl=PATH Specify path to OpenSSL installation ],
29 if test "x$withval" != "xno" ; then
34 dnl Set some system-specific variables which are OK to set before compiler
36 PTHREAD_DEFS=-D_REENTRANT
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.
42 test -z "$CC" && CC=cc
45 dnl FreeBSD is similar:
48 PTHREAD_DEFS=-D_THREAD_SAFE
51 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
56 AC_SUBST(PTHREAD_DEFS)
58 dnl Checks for programs.
61 dnl Configure compiler flags for GCC
62 if test "$GCC" = yes; then
65 dnl CFLAGS="$CFLAGS -Wall -Wno-char-subscripts --pedantic"
66 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
69 dnl CFLAGS="$CFLAGS -Wall --pedantic"
70 CFLAGS="$CFLAGS -Wall"
75 # missing_dir=`cd $ac_aux_dir && pwd`
76 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
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)
83 AC_SEARCH_LIBS(gethostbyname, nsl)
84 AC_SEARCH_LIBS(connect, socket)
86 dnl Checks for header files.
88 dnl AC_HEADER_SYS_WAIT
90 AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r getloadavg)
92 [for call semantics from getpwuid_r],
93 ac_cv_call_getpwuid_r,
94 [AC_TRY_COMPILE([#include <sys/types.h>
97 struct passwd pw, *pwp;
101 getpwuid_r(uid, &pw, pwbuf, sizeof(pwbuf), &pwp);
103 ac_cv_call_getpwuid_r=yes,
104 ac_cv_call_getpwuid_r=no)
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?])
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?])
121 dnl Checks for typedefs, structures, and compiler characteristics.
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)
134 dnl Checks for library functions.
137 AC_REPLACE_FUNCS(snprintf)
138 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
140 AC_CHECK_HEADERS(fcntl.h limits.h unistd.h iconv.h xlocale.h)
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,
148 LIBS="-lz $LIBS $SERVER_LIBS"
151 AC_MSG_ERROR(zlib was not found or is not usable. Please install zlib.)
156 AC_MSG_ERROR(zlib.h was not found or is not usable. Please install zlib.)
159 CFLAGS="$saved_CFLAGS"
161 dnl Here is the check for a libc integrated iconv
163 [ --disable-iconv do not use iconv charset conversion],
164 ok_iconv=no, ok_iconv=yes)
166 AC_MSG_CHECKING(Checking to see if your system supports iconv)
170 iconv_t ic = (iconv_t)(-1) ;
171 ic = iconv_open("UTF-8", "us-ascii");
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"
194 iconv_t ic = (iconv_t)(-1) ;
195 ic = iconv_open("UTF-8", "us-ascii");
205 LDFLAGS="$OLD_LDFLAGS"
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])
214 AC_MSG_RESULT(webcit will be built without character set conversion.)
217 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
220 dnl Checks for the libical iCalendar library.
221 AC_CHECK_HEADER(libical/ical.h,
222 [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
227 AC_MSG_ERROR(libical was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
232 AC_MSG_ERROR(libical/ical.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
236 dnl Checks for the discount markdown library.
237 AC_CHECK_LIB(markdown,
240 LIBS="$LIBS -lmarkdown"
241 AC_DEFINE(HAVE_MARKDOWN,[],[whether we have markdown message rendering])
244 dnl Check for libcitadel
245 AC_CHECK_HEADER(libcitadel.h,
246 [AC_CHECK_LIB(citadel, libcitadel_version_string,
248 LIBS="-lcitadel $LIBS"
249 SETUP_LIBS="-lcitadel $SETUP_LIBS"
252 AC_MSG_ERROR(libcitadel was not found or is not usable. Please install libcitadel.)
257 AC_MSG_ERROR(libcitadel.h was not found or is not usable. Please install libcitadel.)
261 AC_MSG_CHECKING([whether your system likes memcpy + HKEY])
270 #include <sys/select.h>
272 #include <sys/types.h>
274 #include "lib/libcitadel.h"
278 memcpy(foo, HKEY("foo"));
286 AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
291 dnl Checks for the Expat XML parser.
292 AC_CHECK_HEADER(expat.h,
293 [AC_CHECK_LIB(expat, XML_ParserCreateNS,
298 AC_MSG_ERROR(The Expat XML parser was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
303 AC_MSG_ERROR(expat.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
310 # The big search for OpenSSL
311 if test "$with_ssl" != "no"; then
313 saved_LDFLAGS="$LDFLAGS"
314 saved_CFLAGS="$CFLAGS"
315 if test "x$prefix" != "xNONE"; then
316 tryssldir="$tryssldir $prefix"
318 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
319 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
320 CFLAGS="$saved_CFLAGS"
321 LDFLAGS="$saved_LDFLAGS"
322 LIBS="$saved_LIBS -lssl -lcrypto"
324 # Skip directories if they don't exist
325 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
328 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
329 # Try to use $ssldir/lib if it exists, otherwise
331 if test -d "$ssldir/lib" ; then
332 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
333 if test ! -z "$need_dash_r" ; then
334 LDFLAGS="-R$ssldir/lib $LDFLAGS"
337 LDFLAGS="-L$ssldir $saved_LDFLAGS"
338 if test ! -z "$need_dash_r" ; then
339 LDFLAGS="-R$ssldir $LDFLAGS"
342 # Try to use $ssldir/include if it exists, otherwise
344 if test -d "$ssldir/include" ; then
345 CFLAGS="-I$ssldir/include $saved_CFLAGS"
347 CFLAGS="-I$ssldir $saved_CFLAGS"
351 # Basic test to check for compatible version and correct linking
352 # *does not* test for RSA - that comes later.
356 #include <openssl/rand.h>
360 memset(a, 0, sizeof(a));
361 RAND_add(a, sizeof(a), sizeof(a));
362 return(RAND_status() <= 0);
371 if test ! -z "$found_crypto" ; then
376 if test -z "$ssldir" ; then
380 if test ! -z "$found_crypto" ; then
381 ac_cv_openssldir=$ssldir
383 ac_cv_openssldir="no"
387 LDFLAGS="$saved_LDFLAGS"
388 CFLAGS="$saved_CFLAGS"
390 if test "x$ac_cv_openssldir" != "xno" ; then
391 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
393 LIBS="-lssl -lcrypto $LIBS"
394 dnl Need to recover ssldir - test above runs in subshell
395 ssldir=$ac_cv_openssldir
396 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
397 # Try to use $ssldir/lib if it exists, otherwise
399 if test -d "$ssldir/lib" ; then
400 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
401 if test ! -z "$need_dash_r" ; then
402 LDFLAGS="-R$ssldir/lib $LDFLAGS"
405 LDFLAGS="-L$ssldir $saved_LDFLAGS"
406 if test ! -z "$need_dash_r" ; then
407 LDFLAGS="-R$ssldir $LDFLAGS"
410 # Try to use $ssldir/include if it exists, otherwise
412 if test -d "$ssldir/include" ; then
413 CFLAGS="-I$ssldir/include $saved_CFLAGS"
415 CFLAGS="-I$ssldir $saved_CFLAGS"
420 dnl Checks for the SSLdir
421 dnl this is a bit different than the rest,
422 dnl because of the citadel used to have a keys/ subdir.
424 [ --with-ssldir directory to store the ssl certificates under],
425 [ if test "x$withval" != "xno" ; then
428 if test "$found_ssl" = "no"; then
429 echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
433 AC_SUBST(MAKE_SSL_DIR)
436 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
441 AC_CHECK_FUNCS(strftime_l uselocale gettext)
443 if test "$ok_nls" != "no"; then
444 AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
448 if test "$ok_nls" != "no"; then
449 AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
453 if test "$ok_nls" != "no"; then
454 AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
458 if test "$ok_nls" != "no"; then
459 AC_MSG_RESULT(WebCit will be built with national language support.)
460 AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
461 PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
463 AC_MSG_RESULT(WebCit will be built without national language support.)
468 dnl disable backtrace if we don't want it.
470 [ --with-gprof enable profiling],
471 [ if test "x$withval" != "xno" ; then
472 CFLAGS="$CFLAGS -pg "
473 LDFLAGS="$LDFLAGS -pg "
478 dnl disable backtrace if we don't want it.
479 AC_ARG_WITH(backtrace,
480 [ --with-backtrace enable backtrace dumps in the syslog],
481 [ if test "x$withval" != "xno" ; then
482 CFLAGS="$CFLAGS -rdynamic "
483 LDFLAGS="$LDFLAGS -rdynamic "
484 AC_CHECK_FUNCS(backtrace)
489 if test "$prefix" = NONE; then
490 datadir=$ac_default_prefix
491 localedir=$ac_default_prefix
492 wwwdir=$ac_default_prefix
493 rundir=$ac_default_prefix
494 editordir=$ac_default_prefix/tiny_mce
495 markdowneditordir=$ac_default_prefix/epic
496 etcdir=$ac_default_prefix
502 editordir=$prefix/tiny_mce
503 markdowneditordir=$prefix/epic
507 dnl where to put the locale files
508 AC_ARG_WITH(localedir,
509 [ --with-localedir directory to put the locale files to],
510 [ if test "x$withval" != "xno" ; then
515 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
519 dnl Checks where to put our templates
521 [ --with-wwwdir directory to put our templates],
522 [ if test "x$withval" != "xno" ; then
527 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
532 dnl Checks for the run-dir for the sockets
534 [ --with-rundir directory to place runtime files (UDS) to?],
535 [ if test "x$withval" != "xno" ; then
536 AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
539 AC_SUBST(MAKE_RUN_DIR)
543 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
545 dnl Checks for the Datadir
547 [ --with-datadir directory to store the databases under],
548 [ if test "x$withval" != "xno" ; then
553 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
555 dnl Checks where to put our editor
556 AC_ARG_WITH(editordir,
557 [ --with-editordir directory to put our editor],
558 [ if test "x$withval" != "xno" ; then
563 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
565 AC_ARG_WITH(markdowneditordir,
566 [ --with-markdowneditordir directory to put our markdown editor],
567 [ if test "x$withval" != "xno" ; then
568 markdowneditordir=$withval
572 AC_DEFINE_UNQUOTED(MARKDOWNEDITORDIR, "$markdowneditordir", [where to find our markdown editor])
574 dnl Checks where to find our configs
576 [ --with-etcdir directory to read our configs],
577 [ if test "x$withval" != "xno" ; then
582 AC_DEFINE_UNQUOTED(ETCDIR, "$etcdir", [where to find our configs])
586 abs_srcdir="`cd $srcdir && pwd`"
588 if test "$abs_srcdir" != "$abs_builddir"; then
589 CFLAGS="$CFLAGS -I $abs_builddir"
591 AC_CONFIG_HEADER(sysdep.h)
592 AC_OUTPUT(Makefile po/webcit/Makefile tests/Makefile)
594 if test "$abs_srcdir" != "$abs_builddir"; then
595 ln -s $abs_srcdir/static $abs_builddir
596 ln -s $abs_srcdir/tiny_mce $abs_builddir
597 ln -s $abs_srcdir/epic $abs_builddir
598 ln -s $abs_srcdir/*.h $abs_builddir
602 dnl just run it on devel systems and if non vdir build.
603 if test -d .svn; then
608 if test -n "$srcdir"; then
613 echo ------------------------------------------------------------------------
614 echo 'Character set conversion support:' $ok_iconv
615 echo 'National language support: ' $ok_nls