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.
14 AC_USE_SYSTEM_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 [The preprocessor macro `STDC_HEADERS' is obsolete.
89 Except in unusual embedded environments, you can safely include all
90 ISO C90 headers unconditionally.])dnl
91 # Autoupdate added the next two lines to ensure that your configure
92 # script's behavior did not change. They are probably safe to remove.
93 AC_CHECK_INCLUDES_DEFAULT
96 dnl AC_HEADER_SYS_WAIT
98 AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r getloadavg)
100 [for call semantics from getpwuid_r],
101 ac_cv_call_getpwuid_r,
102 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
103 #include <pwd.h>]], [[
104 struct passwd pw, *pwp;
108 getpwuid_r(uid, &pw, pwbuf, sizeof(pwbuf), &pwp);
109 ]])],[ac_cv_call_getpwuid_r=yes],[ac_cv_call_getpwuid_r=no])
112 if test $ac_cv_call_getpwuid_r = no; then
113 AC_DEFINE(SOLARIS_GETPWUID,[],[do we need to use solaris call syntax?])
114 AC_DEFINE(SOLARIS_LOCALTIME_R,[], [do we need to use soralis call syntax?])
115 AC_DEFINE(F_UID_T, "%ld", [whats the matching format string for uid_t?])
116 AC_DEFINE(F_PID_T, "%ld", [whats the matching format string for pid_t?])
117 AC_DEFINE(F_XPID_T, "%lx", [whats the matching format string for xpid_t?])
119 AC_DEFINE(F_UID_T, "%d", [whats the matching format string for uid_t?])
120 AC_DEFINE(F_PID_T, "%d", [whats the matching format string for pid_t?])
121 AC_DEFINE(F_XPID_T, "%x", [whats the matching format string for xpid_t?])
126 dnl Checks for typedefs, structures, and compiler characteristics.
130 dnl Check the size of various builtin types; see typesize.h (error)
131 AC_CHECK_SIZEOF(char, 0)
132 AC_CHECK_SIZEOF(short, 0)
133 AC_CHECK_SIZEOF(int, 0)
134 AC_CHECK_SIZEOF(long, 0)
135 AC_CHECK_SIZEOF(long unsigned int, 0)
136 AC_CHECK_SIZEOF(size_t, 0)
138 dnl Checks for library functions.
140 [your code may safely assume C89 semantics that RETSIGTYPE is void.
141 Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl
142 AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
143 [AC_LANG_PROGRAM([#include <sys/types.h>
146 [return *(signal (0, 0)) (0) == 1;])],
147 [ac_cv_type_signal=int],
148 [ac_cv_type_signal=void])])
149 AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
153 AC_REPLACE_FUNCS(snprintf)
154 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
156 AC_CHECK_HEADERS(fcntl.h limits.h unistd.h iconv.h xlocale.h)
158 dnl Checks for the zlib compression library.
159 saved_CFLAGS="$CFLAGS"
160 CFLAGS="$CFLAGS $SERVER_LIBS"
161 AC_CHECK_HEADER(zlib.h,
162 [AC_CHECK_LIB(z, zlibVersion,
164 LIBS="-lz $LIBS $SERVER_LIBS"
167 AC_MSG_ERROR(zlib was not found or is not usable. Please install zlib.)
172 AC_MSG_ERROR(zlib.h was not found or is not usable. Please install zlib.)
175 CFLAGS="$saved_CFLAGS"
177 dnl Here is the check for a libc integrated iconv
179 [ --disable-iconv do not use iconv charset conversion],
180 ok_iconv=no, ok_iconv=yes)
182 AC_MSG_CHECKING(Checking to see if your system supports iconv)
183 AC_RUN_IFELSE([AC_LANG_SOURCE([[
186 iconv_t ic = (iconv_t)(-1) ;
187 ic = iconv_open("UTF-8", "us-ascii");
200 dnl Check for iconv in external libiconv
201 if test "$ok_iconv" = no; then
202 AC_MSG_CHECKING(Checking for an external libiconv)
203 OLD_LDFLAGS="$LDFLAGS"
204 LDFLAGS="$LDFLAGS -liconv"
205 AC_RUN_IFELSE([AC_LANG_SOURCE([[
208 iconv_t ic = (iconv_t)(-1) ;
209 ic = iconv_open("UTF-8", "us-ascii");
217 LDFLAGS="$OLD_LDFLAGS"
222 if test "$ok_iconv" != "no"; then
223 AC_MSG_RESULT(webcit will be built with character set conversion.)
224 AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
226 AC_MSG_RESULT(webcit will be built without character set conversion.)
229 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
232 dnl Checks for the libical iCalendar library.
233 AC_CHECK_HEADER(libical/ical.h,
234 [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
239 AC_MSG_ERROR(libical was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
244 AC_MSG_ERROR(libical/ical.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
248 dnl Checks for the discount markdown library.
249 AC_CHECK_LIB(markdown,
252 LIBS="$LIBS -lmarkdown"
253 AC_DEFINE(HAVE_MARKDOWN,[],[whether we have markdown message rendering])
256 dnl Check for libcitadel
257 AC_CHECK_HEADER(libcitadel.h,
258 [AC_CHECK_LIB(citadel, libcitadel_version_string,
260 LIBS="-lcitadel $LIBS"
261 SETUP_LIBS="-lcitadel $SETUP_LIBS"
264 AC_MSG_ERROR(libcitadel was not found or is not usable. Please install libcitadel.)
269 AC_MSG_ERROR(libcitadel.h was not found or is not usable. Please install libcitadel.)
273 AC_MSG_CHECKING([whether your system likes memcpy + HKEY])
274 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
282 #include <sys/select.h>
284 #include <sys/types.h>
286 #include "lib/libcitadel.h"
289 memcpy(foo, HKEY("foo"));
295 AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
300 dnl Checks for the Expat XML parser.
301 AC_CHECK_HEADER(expat.h,
302 [AC_CHECK_LIB(expat, XML_ParserCreateNS,
307 AC_MSG_ERROR(The Expat XML parser was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
312 AC_MSG_ERROR(expat.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
319 # The big search for OpenSSL
320 if test "$with_ssl" != "no"; then
322 saved_LDFLAGS="$LDFLAGS"
323 saved_CFLAGS="$CFLAGS"
324 if test "x$prefix" != "xNONE"; then
325 tryssldir="$tryssldir $prefix"
327 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
328 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
329 CFLAGS="$saved_CFLAGS"
330 LDFLAGS="$saved_LDFLAGS"
331 LIBS="$saved_LIBS -lssl -lcrypto"
333 # Skip directories if they don't exist
334 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
337 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
338 # Try to use $ssldir/lib if it exists, otherwise
340 if test -d "$ssldir/lib" ; then
341 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
342 if test ! -z "$need_dash_r" ; then
343 LDFLAGS="-R$ssldir/lib $LDFLAGS"
346 LDFLAGS="-L$ssldir $saved_LDFLAGS"
347 if test ! -z "$need_dash_r" ; then
348 LDFLAGS="-R$ssldir $LDFLAGS"
351 # Try to use $ssldir/include if it exists, otherwise
353 if test -d "$ssldir/include" ; then
354 CFLAGS="-I$ssldir/include $saved_CFLAGS"
356 CFLAGS="-I$ssldir $saved_CFLAGS"
360 # Basic test to check for compatible version and correct linking
361 # *does not* test for RSA - that comes later.
362 AC_RUN_IFELSE([AC_LANG_SOURCE([[
364 #include <openssl/rand.h>
368 memset(a, 0, sizeof(a));
369 RAND_add(a, sizeof(a), sizeof(a));
370 return(RAND_status() <= 0);
378 if test ! -z "$found_crypto" ; then
383 if test -z "$ssldir" ; then
387 if test ! -z "$found_crypto" ; then
388 ac_cv_openssldir=$ssldir
390 ac_cv_openssldir="no"
394 LDFLAGS="$saved_LDFLAGS"
395 CFLAGS="$saved_CFLAGS"
397 if test "x$ac_cv_openssldir" != "xno" ; then
398 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
400 LIBS="-lssl -lcrypto $LIBS"
401 dnl Need to recover ssldir - test above runs in subshell
402 ssldir=$ac_cv_openssldir
403 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
404 # Try to use $ssldir/lib if it exists, otherwise
406 if test -d "$ssldir/lib" ; then
407 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
408 if test ! -z "$need_dash_r" ; then
409 LDFLAGS="-R$ssldir/lib $LDFLAGS"
412 LDFLAGS="-L$ssldir $saved_LDFLAGS"
413 if test ! -z "$need_dash_r" ; then
414 LDFLAGS="-R$ssldir $LDFLAGS"
417 # Try to use $ssldir/include if it exists, otherwise
419 if test -d "$ssldir/include" ; then
420 CFLAGS="-I$ssldir/include $saved_CFLAGS"
422 CFLAGS="-I$ssldir $saved_CFLAGS"
427 dnl Checks for the SSLdir
428 dnl this is a bit different than the rest,
429 dnl because of the citadel used to have a keys/ subdir.
431 [ --with-ssldir directory to store the ssl certificates under],
432 [ if test "x$withval" != "xno" ; then
435 if test "$found_ssl" = "no"; then
436 echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
440 AC_SUBST(MAKE_SSL_DIR)
443 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
448 AC_CHECK_FUNCS(strftime_l uselocale gettext)
450 if test "$ok_nls" != "no"; then
451 AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
455 if test "$ok_nls" != "no"; then
456 AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
460 if test "$ok_nls" != "no"; then
461 AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
465 if test "$ok_nls" != "no"; then
466 AC_MSG_RESULT(WebCit will be built with national language support.)
467 AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
468 PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
470 AC_MSG_RESULT(WebCit will be built without national language support.)
475 dnl disable backtrace if we don't want it.
477 [ --with-gprof enable profiling],
478 [ if test "x$withval" != "xno" ; then
479 CFLAGS="$CFLAGS -pg "
480 LDFLAGS="$LDFLAGS -pg "
485 dnl disable backtrace if we don't want it.
486 AC_ARG_WITH(backtrace,
487 [ --with-backtrace enable backtrace dumps in the syslog],
488 [ if test "x$withval" != "xno" ; then
489 CFLAGS="$CFLAGS -rdynamic "
490 LDFLAGS="$LDFLAGS -rdynamic "
491 AC_CHECK_FUNCS(backtrace)
496 if test "$prefix" = NONE; then
497 datadir=$ac_default_prefix
498 localedir=$ac_default_prefix
499 wwwdir=$ac_default_prefix
500 rundir=$ac_default_prefix
501 editordir=$ac_default_prefix/tiny_mce
502 etcdir=$ac_default_prefix
508 editordir=$prefix/tiny_mce
512 dnl where to put the locale files
513 AC_ARG_WITH(localedir,
514 [ --with-localedir directory to put the locale files to],
515 [ if test "x$withval" != "xno" ; then
520 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
524 dnl Checks where to put our templates
526 [ --with-wwwdir directory to put our templates],
527 [ if test "x$withval" != "xno" ; then
532 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
537 dnl Checks for the run-dir for the sockets
539 [ --with-rundir directory to place runtime files (UDS) to?],
540 [ if test "x$withval" != "xno" ; then
541 AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
544 AC_SUBST(MAKE_RUN_DIR)
548 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
550 dnl Checks for the Datadir
552 [ --with-datadir directory to store the databases under],
553 [ if test "x$withval" != "xno" ; then
558 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
560 dnl Checks where to put our editor
561 AC_ARG_WITH(editordir,
562 [ --with-editordir directory to put our editor],
563 [ if test "x$withval" != "xno" ; then
569 dnl Checks where to find our configs
571 [ --with-etcdir directory to read our configs],
572 [ if test "x$withval" != "xno" ; then
577 AC_DEFINE_UNQUOTED(ETCDIR, "$etcdir", [where to find our configs])
581 abs_srcdir="`cd $srcdir && pwd`"
583 if test "$abs_srcdir" != "$abs_builddir"; then
584 CFLAGS="$CFLAGS -I $abs_builddir"
586 AC_CONFIG_HEADERS([sysdep.h])
587 AC_CONFIG_FILES([Makefile po/webcit/Makefile])
590 if test "$abs_srcdir" != "$abs_builddir"; then
591 ln -s $abs_srcdir/static $abs_builddir
592 ln -s $abs_srcdir/tiny_mce $abs_builddir
593 ln -s $abs_srcdir/*.h $abs_builddir
597 dnl just run it on devel systems and if non vdir build.
598 if test -d .svn; then
603 if test -n "$srcdir"; then
608 echo ------------------------------------------------------------------------
609 echo 'Character set conversion support:' $ok_iconv
610 echo 'National language support: ' $ok_nls