1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([WebCit], [912], [http://www.citadel.org/])
7 AC_DEFINE(PROG_SUBDIRS, [], [Program dirs])
10 missing_dir=`cd $ac_aux_dir && pwd`
11 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
12 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
14 dnl Make sure we see all GNU and Solaris extensions.
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"
23 AC_DEFINE_UNQUOTED(WEBCITDIR, "$prefix", [define this to the Citadel home directory])
24 ssl_dir="$prefix/keys"
28 [ --with-ssl=PATH Specify path to OpenSSL installation ],
30 if test "x$withval" != "xno" ; then
35 dnl Set some system-specific variables which are OK to set before compiler
37 PTHREAD_DEFS=-D_REENTRANT
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.
43 test -z "$CC" && CC=cc
46 dnl FreeBSD is similar:
49 PTHREAD_DEFS=-D_THREAD_SAFE
52 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
57 AC_SUBST(PTHREAD_DEFS)
59 dnl Checks for programs.
62 dnl Configure compiler flags for GCC
63 if test "$GCC" = yes; then
66 dnl CFLAGS="$CFLAGS -Wall -Wno-char-subscripts --pedantic"
67 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
70 dnl CFLAGS="$CFLAGS -Wall --pedantic"
71 CFLAGS="$CFLAGS -Wall"
76 # missing_dir=`cd $ac_aux_dir && pwd`
77 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
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)
84 AC_SEARCH_LIBS(gethostbyname, nsl)
85 AC_SEARCH_LIBS(connect, socket)
87 dnl Checks for header files.
89 dnl AC_HEADER_SYS_WAIT
91 AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r getloadavg)
93 [for call semantics from getpwuid_r],
94 ac_cv_call_getpwuid_r,
95 [AC_TRY_COMPILE([#include <sys/types.h>
98 struct passwd pw, *pwp;
102 getpwuid_r(uid, &pw, pwbuf, sizeof(pwbuf), &pwp);
104 ac_cv_call_getpwuid_r=yes,
105 ac_cv_call_getpwuid_r=no)
108 if test $ac_cv_call_getpwuid_r = no; then
109 AC_DEFINE(SOLARIS_GETPWUID,[],[do we need to use solaris call syntax?])
110 AC_DEFINE(SOLARIS_LOCALTIME_R,[], [do we need to use soralis call syntax?])
111 AC_DEFINE(F_UID_T, "%ld", [whats the matching format string for uid_t?])
112 AC_DEFINE(F_PID_T, "%ld", [whats the matching format string for pid_t?])
113 AC_DEFINE(F_XPID_T, "%lx", [whats the matching format string for xpid_t?])
115 AC_DEFINE(F_UID_T, "%d", [whats the matching format string for uid_t?])
116 AC_DEFINE(F_PID_T, "%d", [whats the matching format string for pid_t?])
117 AC_DEFINE(F_XPID_T, "%x", [whats the matching format string for xpid_t?])
122 dnl Checks for typedefs, structures, and compiler characteristics.
126 dnl Check the size of various builtin types; see typesize.h (error)
127 AC_CHECK_SIZEOF(char, 0)
128 AC_CHECK_SIZEOF(short, 0)
129 AC_CHECK_SIZEOF(int, 0)
130 AC_CHECK_SIZEOF(long, 0)
131 AC_CHECK_SIZEOF(long unsigned int, 0)
132 AC_CHECK_SIZEOF(size_t, 0)
135 dnl Checks for library functions.
138 AC_REPLACE_FUNCS(snprintf)
139 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
141 AC_CHECK_HEADERS(fcntl.h limits.h unistd.h iconv.h xlocale.h)
143 dnl Checks for the zlib compression library.
144 saved_CFLAGS="$CFLAGS"
145 CFLAGS="$CFLAGS $SERVER_LIBS"
146 AC_CHECK_HEADER(zlib.h,
147 [AC_CHECK_LIB(z, zlibVersion,
149 LIBS="-lz $LIBS $SERVER_LIBS"
152 AC_MSG_ERROR(zlib was not found or is not usable. Please install zlib.)
157 AC_MSG_ERROR(zlib.h was not found or is not usable. Please install zlib.)
160 CFLAGS="$saved_CFLAGS"
162 dnl Here is the check for a libc integrated iconv
164 [ --disable-iconv do not use iconv charset conversion],
165 ok_iconv=no, ok_iconv=yes)
167 AC_MSG_CHECKING(Checking to see if your system supports iconv)
171 iconv_t ic = (iconv_t)(-1) ;
172 ic = iconv_open("UTF-8", "us-ascii");
187 dnl Check for iconv in external libiconv
188 if test "$ok_iconv" = no; then
189 AC_MSG_CHECKING(Checking for an external libiconv)
190 OLD_LDFLAGS="$LDFLAGS"
191 LDFLAGS="$LDFLAGS -liconv"
195 iconv_t ic = (iconv_t)(-1) ;
196 ic = iconv_open("UTF-8", "us-ascii");
206 LDFLAGS="$OLD_LDFLAGS"
211 if test "$ok_iconv" != "no"; then
212 AC_MSG_RESULT(webcit will be built with character set conversion.)
213 AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
215 AC_MSG_RESULT(webcit will be built without character set conversion.)
219 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
222 dnl Checks for the libical iCalendar library.
223 AC_CHECK_HEADER(libical/ical.h,
224 [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
229 AC_MSG_ERROR(libical was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
234 AC_MSG_ERROR(libical/ical.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
238 dnl Checks for the discount markdown library.
239 AC_CHECK_LIB(markdown,
242 LIBS="$LIBS -lmarkdown"
243 AC_DEFINE(HAVE_MARKDOWN,[],[whether we have markdown message rendering])
246 dnl Check for libcitadel
247 AC_CHECK_HEADER(libcitadel.h,
248 [AC_CHECK_LIB(citadel, libcitadel_version_string,
250 LIBS="-lcitadel $LIBS"
251 SETUP_LIBS="-lcitadel $SETUP_LIBS"
254 AC_MSG_ERROR(libcitadel was not found or is not usable. Please install libcitadel.)
259 AC_MSG_ERROR(libcitadel.h was not found or is not usable. Please install libcitadel.)
263 AC_MSG_CHECKING([whether your system likes memcpy + HKEY])
272 #include <sys/select.h>
274 #include <sys/types.h>
276 #include "lib/libcitadel.h"
280 memcpy(foo, HKEY("foo"));
288 AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
293 dnl Checks for the Expat XML parser.
294 AC_CHECK_HEADER(expat.h,
295 [AC_CHECK_LIB(expat, XML_ParserCreateNS,
300 AC_MSG_ERROR(The Expat XML parser was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
305 AC_MSG_ERROR(expat.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
312 # The big search for OpenSSL
313 if test "$with_ssl" != "no"; then
315 saved_LDFLAGS="$LDFLAGS"
316 saved_CFLAGS="$CFLAGS"
317 if test "x$prefix" != "xNONE"; then
318 tryssldir="$tryssldir $prefix"
320 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
321 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
322 CFLAGS="$saved_CFLAGS"
323 LDFLAGS="$saved_LDFLAGS"
324 LIBS="$saved_LIBS -lssl -lcrypto"
326 # Skip directories if they don't exist
327 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
330 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
331 # Try to use $ssldir/lib if it exists, otherwise
333 if test -d "$ssldir/lib" ; then
334 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
335 if test ! -z "$need_dash_r" ; then
336 LDFLAGS="-R$ssldir/lib $LDFLAGS"
339 LDFLAGS="-L$ssldir $saved_LDFLAGS"
340 if test ! -z "$need_dash_r" ; then
341 LDFLAGS="-R$ssldir $LDFLAGS"
344 # Try to use $ssldir/include if it exists, otherwise
346 if test -d "$ssldir/include" ; then
347 CFLAGS="-I$ssldir/include $saved_CFLAGS"
349 CFLAGS="-I$ssldir $saved_CFLAGS"
353 # Basic test to check for compatible version and correct linking
354 # *does not* test for RSA - that comes later.
358 #include <openssl/rand.h>
362 memset(a, 0, sizeof(a));
363 RAND_add(a, sizeof(a), sizeof(a));
364 return(RAND_status() <= 0);
373 if test ! -z "$found_crypto" ; then
378 if test -z "$ssldir" ; then
382 if test ! -z "$found_crypto" ; then
383 ac_cv_openssldir=$ssldir
385 ac_cv_openssldir="no"
389 LDFLAGS="$saved_LDFLAGS"
390 CFLAGS="$saved_CFLAGS"
392 if test "x$ac_cv_openssldir" != "xno" ; then
393 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
395 LIBS="-lssl -lcrypto $LIBS"
396 dnl Need to recover ssldir - test above runs in subshell
397 ssldir=$ac_cv_openssldir
398 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
399 # Try to use $ssldir/lib if it exists, otherwise
401 if test -d "$ssldir/lib" ; then
402 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
403 if test ! -z "$need_dash_r" ; then
404 LDFLAGS="-R$ssldir/lib $LDFLAGS"
407 LDFLAGS="-L$ssldir $saved_LDFLAGS"
408 if test ! -z "$need_dash_r" ; then
409 LDFLAGS="-R$ssldir $LDFLAGS"
412 # Try to use $ssldir/include if it exists, otherwise
414 if test -d "$ssldir/include" ; then
415 CFLAGS="-I$ssldir/include $saved_CFLAGS"
417 CFLAGS="-I$ssldir $saved_CFLAGS"
422 dnl Checks for the SSLdir
423 dnl this is a bit different than the rest,
424 dnl because of the citadel used to have a keys/ subdir.
426 [ --with-ssldir directory to store the ssl certificates under],
427 [ if test "x$withval" != "xno" ; then
430 if test "$found_ssl" = "no"; then
431 echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
435 AC_SUBST(MAKE_SSL_DIR)
438 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
443 AC_CHECK_FUNCS(strftime_l uselocale gettext)
445 if test "$ok_nls" != "no"; then
446 AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
450 if test "$ok_nls" != "no"; then
451 AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
455 if test "$ok_nls" != "no"; then
456 AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
460 if test "$ok_nls" != "no"; then
461 AC_MSG_RESULT(WebCit will be built with national language support.)
462 AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
463 PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
465 AC_MSG_RESULT(WebCit will be built without national language support.)
470 dnl disable backtrace if we don't want it.
472 [ --with-gprof enable profiling],
473 [ if test "x$withval" != "xno" ; then
474 CFLAGS="$CFLAGS -pg "
475 LDFLAGS="$LDFLAGS -pg "
480 dnl disable backtrace if we don't want it.
481 AC_ARG_WITH(backtrace,
482 [ --with-backtrace enable backtrace dumps in the syslog],
483 [ if test "x$withval" != "xno" ; then
484 CFLAGS="$CFLAGS -rdynamic "
485 LDFLAGS="$LDFLAGS -rdynamic "
486 AC_CHECK_FUNCS(backtrace)
491 if test "$prefix" = NONE; then
492 datadir=$ac_default_prefix
493 localedir=$ac_default_prefix
494 wwwdir=$ac_default_prefix
495 rundir=$ac_default_prefix
496 editordir=$ac_default_prefix/tiny_mce
497 markdowneditordir=$ac_default_prefix/epic
498 etcdir=$ac_default_prefix
504 editordir=$prefix/tiny_mce
505 markdowneditordir=$prefix/epic
509 dnl where to put the locale files
510 AC_ARG_WITH(localedir,
511 [ --with-localedir directory to put the locale files to],
512 [ if test "x$withval" != "xno" ; then
517 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
521 dnl Checks where to put our templates
523 [ --with-wwwdir directory to put our templates],
524 [ if test "x$withval" != "xno" ; then
529 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
534 dnl Checks for the run-dir for the sockets
536 [ --with-rundir directory to place runtime files (UDS) to?],
537 [ if test "x$withval" != "xno" ; then
538 AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
541 AC_SUBST(MAKE_RUN_DIR)
545 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
547 dnl Checks for the Datadir
549 [ --with-datadir directory to store the databases under],
550 [ if test "x$withval" != "xno" ; then
555 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
557 dnl Checks where to put our editor
558 AC_ARG_WITH(editordir,
559 [ --with-editordir directory to put our editor],
560 [ if test "x$withval" != "xno" ; then
565 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
567 AC_ARG_WITH(markdowneditordir,
568 [ --with-markdowneditordir directory to put our markdown editor],
569 [ if test "x$withval" != "xno" ; then
570 markdowneditordir=$withval
574 AC_DEFINE_UNQUOTED(MARKDOWNEDITORDIR, "$markdowneditordir", [where to find our markdown editor])
576 dnl Checks where to find our configs
578 [ --with-etcdir directory to read our configs],
579 [ if test "x$withval" != "xno" ; then
584 AC_DEFINE_UNQUOTED(ETCDIR, "$etcdir", [where to find our configs])
588 abs_srcdir="`cd $srcdir && pwd`"
590 if test "$abs_srcdir" != "$abs_builddir"; then
591 CFLAGS="$CFLAGS -I $abs_builddir"
593 AC_CONFIG_HEADER(sysdep.h)
594 AC_OUTPUT(Makefile po/webcit/Makefile tests/Makefile)
596 if test "$abs_srcdir" != "$abs_builddir"; then
597 ln -s $abs_srcdir/static $abs_builddir
598 ln -s $abs_srcdir/tiny_mce $abs_builddir
599 ln -s $abs_srcdir/epic $abs_builddir
600 ln -s $abs_srcdir/*.h $abs_builddir
604 dnl just run it on devel systems and if non vdir build.
605 if test -d .svn; then
610 if test -n "$srcdir"; then
615 echo ------------------------------------------------------------------------
616 echo 'Character set conversion support:' $ok_iconv
617 echo 'National language support: ' $ok_nls