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)
137 dnl m4_warn([obsolete],
138 [Update your code to rely only on HAVE_SYS_TIME_H,
139 then remove this warning and the obsolete code below it.
140 All current systems provide time.h; it need not be checked for.
141 Not all systems provide sys/time.h, but those that do, all allow
142 you to include it and time.h simultaneously.])dnl
143 AC_CHECK_HEADERS_ONCE([sys/time.h])
144 # Obsolete code to be removed.
145 if test $ac_cv_header_sys_time_h = yes; then
146 AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h>
147 and <time.h>. This macro is obsolete.])
149 # End of obsolete code.
152 dnl Checks for library functions.
154 [your code may safely assume C89 semantics that RETSIGTYPE is void.
155 Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl
156 AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
157 [AC_LANG_PROGRAM([#include <sys/types.h>
160 [return *(signal (0, 0)) (0) == 1;])],
161 [ac_cv_type_signal=int],
162 [ac_cv_type_signal=void])])
163 AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
167 AC_REPLACE_FUNCS(snprintf)
168 AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should compile the test-suite])])
170 AC_CHECK_HEADERS(fcntl.h limits.h unistd.h iconv.h xlocale.h)
172 dnl Checks for the zlib compression library.
173 saved_CFLAGS="$CFLAGS"
174 CFLAGS="$CFLAGS $SERVER_LIBS"
175 AC_CHECK_HEADER(zlib.h,
176 [AC_CHECK_LIB(z, zlibVersion,
178 LIBS="-lz $LIBS $SERVER_LIBS"
181 AC_MSG_ERROR(zlib was not found or is not usable. Please install zlib.)
186 AC_MSG_ERROR(zlib.h was not found or is not usable. Please install zlib.)
189 CFLAGS="$saved_CFLAGS"
191 dnl Here is the check for a libc integrated iconv
193 [ --disable-iconv do not use iconv charset conversion],
194 ok_iconv=no, ok_iconv=yes)
196 AC_MSG_CHECKING(Checking to see if your system supports iconv)
197 AC_RUN_IFELSE([AC_LANG_SOURCE([[
200 iconv_t ic = (iconv_t)(-1) ;
201 ic = iconv_open("UTF-8", "us-ascii");
214 dnl Check for iconv in external libiconv
215 if test "$ok_iconv" = no; then
216 AC_MSG_CHECKING(Checking for an external libiconv)
217 OLD_LDFLAGS="$LDFLAGS"
218 LDFLAGS="$LDFLAGS -liconv"
219 AC_RUN_IFELSE([AC_LANG_SOURCE([[
222 iconv_t ic = (iconv_t)(-1) ;
223 ic = iconv_open("UTF-8", "us-ascii");
231 LDFLAGS="$OLD_LDFLAGS"
236 if test "$ok_iconv" != "no"; then
237 AC_MSG_RESULT(webcit will be built with character set conversion.)
238 AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
240 AC_MSG_RESULT(webcit will be built without character set conversion.)
243 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
246 dnl Checks for the libical iCalendar library.
247 AC_CHECK_HEADER(libical/ical.h,
248 [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
253 AC_MSG_ERROR(libical was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
258 AC_MSG_ERROR(libical/ical.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
262 dnl Checks for the discount markdown library.
263 AC_CHECK_LIB(markdown,
266 LIBS="$LIBS -lmarkdown"
267 AC_DEFINE(HAVE_MARKDOWN,[],[whether we have markdown message rendering])
270 dnl Check for libcitadel
271 AC_CHECK_HEADER(libcitadel.h,
272 [AC_CHECK_LIB(citadel, libcitadel_version_string,
274 LIBS="-lcitadel $LIBS"
275 SETUP_LIBS="-lcitadel $SETUP_LIBS"
278 AC_MSG_ERROR(libcitadel was not found or is not usable. Please install libcitadel.)
283 AC_MSG_ERROR(libcitadel.h was not found or is not usable. Please install libcitadel.)
287 AC_MSG_CHECKING([whether your system likes memcpy + HKEY])
288 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
296 #include <sys/select.h>
298 #include <sys/types.h>
300 #include "lib/libcitadel.h"
303 memcpy(foo, HKEY("foo"));
309 AC_DEFINE(UNDEF_MEMCPY, [], [whether we need to undefine memcpy])
314 dnl Checks for the Expat XML parser.
315 AC_CHECK_HEADER(expat.h,
316 [AC_CHECK_LIB(expat, XML_ParserCreateNS,
321 AC_MSG_ERROR(The Expat XML parser was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
326 AC_MSG_ERROR(expat.h was not found and is required. More info: http://www.citadel.org/doku.php/installation:start)
333 # The big search for OpenSSL
334 if test "$with_ssl" != "no"; then
336 saved_LDFLAGS="$LDFLAGS"
337 saved_CFLAGS="$CFLAGS"
338 if test "x$prefix" != "xNONE"; then
339 tryssldir="$tryssldir $prefix"
341 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
342 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
343 CFLAGS="$saved_CFLAGS"
344 LDFLAGS="$saved_LDFLAGS"
345 LIBS="$saved_LIBS -lssl -lcrypto"
347 # Skip directories if they don't exist
348 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
351 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
352 # Try to use $ssldir/lib if it exists, otherwise
354 if test -d "$ssldir/lib" ; then
355 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
356 if test ! -z "$need_dash_r" ; then
357 LDFLAGS="-R$ssldir/lib $LDFLAGS"
360 LDFLAGS="-L$ssldir $saved_LDFLAGS"
361 if test ! -z "$need_dash_r" ; then
362 LDFLAGS="-R$ssldir $LDFLAGS"
365 # Try to use $ssldir/include if it exists, otherwise
367 if test -d "$ssldir/include" ; then
368 CFLAGS="-I$ssldir/include $saved_CFLAGS"
370 CFLAGS="-I$ssldir $saved_CFLAGS"
374 # Basic test to check for compatible version and correct linking
375 # *does not* test for RSA - that comes later.
376 AC_RUN_IFELSE([AC_LANG_SOURCE([[
378 #include <openssl/rand.h>
382 memset(a, 0, sizeof(a));
383 RAND_add(a, sizeof(a), sizeof(a));
384 return(RAND_status() <= 0);
392 if test ! -z "$found_crypto" ; then
397 if test -z "$ssldir" ; then
401 if test ! -z "$found_crypto" ; then
402 ac_cv_openssldir=$ssldir
404 ac_cv_openssldir="no"
408 LDFLAGS="$saved_LDFLAGS"
409 CFLAGS="$saved_CFLAGS"
411 if test "x$ac_cv_openssldir" != "xno" ; then
412 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
414 LIBS="-lssl -lcrypto $LIBS"
415 dnl Need to recover ssldir - test above runs in subshell
416 ssldir=$ac_cv_openssldir
417 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
418 # Try to use $ssldir/lib if it exists, otherwise
420 if test -d "$ssldir/lib" ; then
421 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
422 if test ! -z "$need_dash_r" ; then
423 LDFLAGS="-R$ssldir/lib $LDFLAGS"
426 LDFLAGS="-L$ssldir $saved_LDFLAGS"
427 if test ! -z "$need_dash_r" ; then
428 LDFLAGS="-R$ssldir $LDFLAGS"
431 # Try to use $ssldir/include if it exists, otherwise
433 if test -d "$ssldir/include" ; then
434 CFLAGS="-I$ssldir/include $saved_CFLAGS"
436 CFLAGS="-I$ssldir $saved_CFLAGS"
441 dnl Checks for the SSLdir
442 dnl this is a bit different than the rest,
443 dnl because of the citadel used to have a keys/ subdir.
445 [ --with-ssldir directory to store the ssl certificates under],
446 [ if test "x$withval" != "xno" ; then
449 if test "$found_ssl" = "no"; then
450 echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
454 AC_SUBST(MAKE_SSL_DIR)
457 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
462 AC_CHECK_FUNCS(strftime_l uselocale gettext)
464 if test "$ok_nls" != "no"; then
465 AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
469 if test "$ok_nls" != "no"; then
470 AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
474 if test "$ok_nls" != "no"; then
475 AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
479 if test "$ok_nls" != "no"; then
480 AC_MSG_RESULT(WebCit will be built with national language support.)
481 AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
482 PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
484 AC_MSG_RESULT(WebCit will be built without national language support.)
489 dnl disable backtrace if we don't want it.
491 [ --with-gprof enable profiling],
492 [ if test "x$withval" != "xno" ; then
493 CFLAGS="$CFLAGS -pg "
494 LDFLAGS="$LDFLAGS -pg "
499 dnl disable backtrace if we don't want it.
500 AC_ARG_WITH(backtrace,
501 [ --with-backtrace enable backtrace dumps in the syslog],
502 [ if test "x$withval" != "xno" ; then
503 CFLAGS="$CFLAGS -rdynamic "
504 LDFLAGS="$LDFLAGS -rdynamic "
505 AC_CHECK_FUNCS(backtrace)
510 if test "$prefix" = NONE; then
511 datadir=$ac_default_prefix
512 localedir=$ac_default_prefix
513 wwwdir=$ac_default_prefix
514 rundir=$ac_default_prefix
515 editordir=$ac_default_prefix/tiny_mce
516 etcdir=$ac_default_prefix
522 editordir=$prefix/tiny_mce
526 dnl where to put the locale files
527 AC_ARG_WITH(localedir,
528 [ --with-localedir directory to put the locale files to],
529 [ if test "x$withval" != "xno" ; then
534 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
538 dnl Checks where to put our templates
540 [ --with-wwwdir directory to put our templates],
541 [ if test "x$withval" != "xno" ; then
546 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
551 dnl Checks for the run-dir for the sockets
553 [ --with-rundir directory to place runtime files (UDS) to?],
554 [ if test "x$withval" != "xno" ; then
555 AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
558 AC_SUBST(MAKE_RUN_DIR)
562 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
564 dnl Checks for the Datadir
566 [ --with-datadir directory to store the databases under],
567 [ if test "x$withval" != "xno" ; then
572 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
574 dnl Checks where to put our editor
575 AC_ARG_WITH(editordir,
576 [ --with-editordir directory to put our editor],
577 [ if test "x$withval" != "xno" ; then
583 dnl Checks where to find our configs
585 [ --with-etcdir directory to read our configs],
586 [ if test "x$withval" != "xno" ; then
591 AC_DEFINE_UNQUOTED(ETCDIR, "$etcdir", [where to find our configs])
595 abs_srcdir="`cd $srcdir && pwd`"
597 if test "$abs_srcdir" != "$abs_builddir"; then
598 CFLAGS="$CFLAGS -I $abs_builddir"
600 AC_CONFIG_HEADERS([sysdep.h])
601 AC_CONFIG_FILES([Makefile po/webcit/Makefile])
604 if test "$abs_srcdir" != "$abs_builddir"; then
605 ln -s $abs_srcdir/static $abs_builddir
606 ln -s $abs_srcdir/tiny_mce $abs_builddir
607 ln -s $abs_srcdir/*.h $abs_builddir
611 dnl just run it on devel systems and if non vdir build.
612 if test -d .svn; then
617 if test -n "$srcdir"; then
622 echo ------------------------------------------------------------------------
623 echo 'Character set conversion support:' $ok_iconv
624 echo 'National language support: ' $ok_nls