Revert "Remove ENABLE_NLS definition. Either we HAVE_USELOCALE or we don't translate...
[citadel.git] / webcit / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT([WebCit], [8.10], [http://www.citadel.org/])
4
5
6 AC_SUBST(PROG_SUBDIRS)
7 AC_DEFINE(PROG_SUBDIRS, [], [Program dirs])
8 AC_CANONICAL_HOST
9 AC_PROG_INSTALL
10 missing_dir=`cd $ac_aux_dir && pwd`
11 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
12 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
13
14 dnl Make sure we see all GNU and Solaris extensions.
15 AC_GNU_SOURCE
16
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"
22 else
23         AC_DEFINE_UNQUOTED(WEBCITDIR, "$prefix", [define this to the Citadel home directory])
24         ssl_dir="$prefix/keys"
25 fi
26
27 AC_ARG_WITH(ssl,
28         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
29         [
30                 if test "x$withval" != "xno" ; then
31                         tryssldir=$withval
32                 fi
33         ]
34 )
35 dnl Set some system-specific variables which are OK to set before compiler
36 dnl checks:
37 PTHREAD_DEFS=-D_REENTRANT
38 case "$host" in
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.
42         alpha*-dec-osf*)
43                 test -z "$CC" && CC=cc
44                 LIBS=-pthread
45         ;;
46         dnl FreeBSD is similar:
47         *-*-freebsd*)
48                 LIBS=-pthread
49                 PTHREAD_DEFS=-D_THREAD_SAFE
50         ;;
51         *-*-solaris*)
52                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
53         ;;
54         *-*-darwin*)
55                 LIBS=-lintl
56 esac
57 AC_SUBST(PTHREAD_DEFS)
58
59 dnl Checks for programs.
60 AC_PROG_CC
61
62 dnl Configure compiler flags for GCC
63 if test "$GCC" = yes; then
64         case "$host" in
65                 *-*-solaris*)
66 dnl                     CFLAGS="$CFLAGS -Wall -Wno-char-subscripts --pedantic"
67                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
68                 ;;
69                 *)
70 dnl                     CFLAGS="$CFLAGS -Wall --pedantic"
71                         CFLAGS="$CFLAGS -Wall"
72                 ;;
73         esac
74 fi
75
76 # missing_dir=`cd $ac_aux_dir && pwd`
77 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
78
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)
83 fi
84 AC_SEARCH_LIBS(gethostbyname, nsl)
85 AC_SEARCH_LIBS(connect, socket)
86
87 dnl Checks for header files.
88 AC_HEADER_STDC
89 dnl AC_HEADER_SYS_WAIT
90
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 sys/time.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
238 dnl Check for libcitadel
239 AC_CHECK_HEADER(libcitadel.h,
240         [AC_CHECK_LIB(citadel, libcitadel_version_string,
241                 [
242                         LIBS="-lcitadel $LIBS"
243                         SETUP_LIBS="-lcitadel $SETUP_LIBS"
244                 ],
245                 [
246                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
247                 ]
248         ,
249         )],
250         [
251                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
252         ]
253 )
254
255
256 dnl Checks for the Expat XML parser.
257 AC_CHECK_HEADER(expat.h,
258         [AC_CHECK_LIB(expat, XML_ParserCreateNS,
259                 [
260                         LIBS="-lexpat $LIBS"
261                 ],
262                 [
263                         AC_MSG_ERROR(The Expat XML parser was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
264                 ]
265         ,
266         )],
267         [
268                 AC_MSG_ERROR(expat.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
269         ]
270 )
271
272
273
274 found_ssl=no
275 # The big search for OpenSSL
276 if test "$with_ssl" != "no"; then
277         saved_LIBS="$LIBS"
278         saved_LDFLAGS="$LDFLAGS"
279         saved_CFLAGS="$CFLAGS"
280         if test "x$prefix" != "xNONE"; then
281                 tryssldir="$tryssldir $prefix"
282         fi
283         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
284                 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
285                         CFLAGS="$saved_CFLAGS"
286                         LDFLAGS="$saved_LDFLAGS"
287                         LIBS="$saved_LIBS -lssl -lcrypto"
288         
289                         # Skip directories if they don't exist
290                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
291                                 continue;
292                         fi
293                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
294                                 # Try to use $ssldir/lib if it exists, otherwise
295                                 # $ssldir
296                                 if test -d "$ssldir/lib" ; then
297                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
298                                         if test ! -z "$need_dash_r" ; then
299                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
300                                         fi
301                                 else
302                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
303                                         if test ! -z "$need_dash_r" ; then
304                                                 LDFLAGS="-R$ssldir $LDFLAGS"
305                                         fi
306                                 fi
307                                 # Try to use $ssldir/include if it exists, otherwise
308                                 # $ssldir
309                                 if test -d "$ssldir/include" ; then
310                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
311                                 else
312                                         CFLAGS="-I$ssldir $saved_CFLAGS"
313                                 fi
314                         fi
315         
316                         # Basic test to check for compatible version and correct linking
317                         # *does not* test for RSA - that comes later.
318                         AC_TRY_RUN(
319                                 [
320         #include <string.h>
321         #include <openssl/rand.h>
322         int main(void)
323         {
324                 char a[2048];
325                 memset(a, 0, sizeof(a));
326                 RAND_add(a, sizeof(a), sizeof(a));
327                 return(RAND_status() <= 0);
328         }
329                                 ],
330                                 [
331                                         found_crypto=1
332                                         break;
333                                 ], []
334                         )
335         
336                         if test ! -z "$found_crypto" ; then
337                                 break;
338                         fi
339                 done
340         
341                 if test -z "$ssldir" ; then
342                         ssldir="(system)"
343                 fi
344         
345                 if test ! -z "$found_crypto" ; then
346                         ac_cv_openssldir=$ssldir
347                 else
348                         ac_cv_openssldir="no"
349                 fi
350         ])
351         LIBS="$saved_LIBS"
352         LDFLAGS="$saved_LDFLAGS"
353         CFLAGS="$saved_CFLAGS"
354         
355         if test "x$ac_cv_openssldir" != "xno" ; then
356                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
357                 found_ssl=yes
358                 LIBS="-lssl -lcrypto $LIBS"
359                 dnl Need to recover ssldir - test above runs in subshell
360                 ssldir=$ac_cv_openssldir
361                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
362                         # Try to use $ssldir/lib if it exists, otherwise
363                         # $ssldir
364                         if test -d "$ssldir/lib" ; then
365                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
366                                 if test ! -z "$need_dash_r" ; then
367                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
368                                 fi
369                         else
370                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
371                                 if test ! -z "$need_dash_r" ; then
372                                         LDFLAGS="-R$ssldir $LDFLAGS"
373                                 fi
374                         fi
375                         # Try to use $ssldir/include if it exists, otherwise
376                         # $ssldir
377                         if test -d "$ssldir/include" ; then
378                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
379                         else
380                                 CFLAGS="-I$ssldir $saved_CFLAGS"
381                         fi
382                 fi
383         fi
384 fi
385 dnl Checks for the SSLdir
386 dnl this is a bit different than the rest, 
387 dnl because of the citadel used to have a keys/ subdir.
388 AC_ARG_WITH(ssldir, 
389                     [  --with-ssldir          directory to store the ssl certificates under],
390                         [ if test "x$withval" != "xno" ; then
391                                               
392                                                   ssl_dir="$withval"
393                                                   if test "$found_ssl" = "no"; then
394                                                      echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
395                                                      exit
396                                                   fi
397                           fi
398                         AC_SUBST(MAKE_SSL_DIR)
399                         ]
400 )
401 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
402
403
404
405
406 AC_CHECK_FUNCS(strftime_l uselocale gettext)
407
408 if test "$ok_nls" != "no"; then
409         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
410         ok_nls=$ok_xgettext
411 fi
412
413 if test "$ok_nls" != "no"; then
414         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
415         ok_nls=$ok_msgmerge
416 fi
417
418 if test "$ok_nls" != "no"; then
419         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
420         ok_nls=$ok_msgfmt
421 fi
422
423 if test "$ok_nls" != "no"; then
424         AC_MSG_RESULT(WebCit will be built with national language support.)
425         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
426         PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
427 else
428         AC_MSG_RESULT(WebCit will be built without national language support.)
429 fi
430
431 AC_SUBST(SETUP_LIBS)
432
433 dnl disable backtrace if we don't want it.
434 AC_ARG_WITH(gprof, 
435                     [  --with-gprof          enable profiling],
436                         [ if test "x$withval" != "xno" ; then
437                              CFLAGS="$CFLAGS  -pg "
438                              LDFLAGS="$LDFLAGS  -pg "
439                           fi
440                         ]
441 )
442
443 dnl disable backtrace if we don't want it.
444 AC_ARG_WITH(backtrace, 
445                     [  --with-backtrace          enable backtrace dumps in the syslog],
446                         [ if test "x$withval" != "xno" ; then
447                              CFLAGS="$CFLAGS  -rdynamic "
448                              LDFLAGS="$LDFLAGS  -rdynamic "
449                              AC_CHECK_FUNCS(backtrace)
450                           fi
451                         ]
452 )
453
454 if test "$prefix" = NONE; then
455         datadir=$ac_default_prefix
456         localedir=$ac_default_prefix
457         wwwdir=$ac_default_prefix
458         rundir=$ac_default_prefix
459         editordir=$ac_default_prefix/tiny_mce
460 else
461         localedir=$prefix
462         wwwdir=$prefix
463         datadir=$prefix
464         rundir=$prefix
465         editordir=$prefix/tiny_mce
466 fi
467
468 dnl where to put the locale files
469 AC_ARG_WITH(localedir, 
470                     [  --with-localedir          directory to put the locale files to],
471                         [ if test "x$withval" != "xno" ; then
472                             localedir=$withval
473                           fi
474                         ]
475 )
476 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
477 LOCALEDIR=$localedir
478 AC_SUBST(LOCALEDIR)
479
480 dnl Checks where to put our templates
481 AC_ARG_WITH(wwwdir, 
482                     [  --with-wwwdir             directory to put our templates],
483                         [ if test "x$withval" != "xno" ; then
484                                 wwwdir=$withval
485                           fi
486                         ]
487 )
488 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
489 WWWDIR=$wwwdir
490 AC_SUBST(WWWDIR)
491
492
493 dnl Checks for the run-dir for the sockets
494 AC_ARG_WITH(rundir, 
495                         [  --with-rundir           directory to place runtime files (UDS) to?],
496                         [ if test "x$withval" != "xno" ; then
497                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
498                                                 
499                                                 rundir=$withval
500                                                 AC_SUBST(MAKE_RUN_DIR)
501                           fi
502                         ]
503 )
504 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
505
506 dnl Checks for the Datadir
507 AC_ARG_WITH(datadir, 
508                     [  --with-datadir          directory to store the databases under],
509                         [ if test "x$withval" != "xno" ; then
510                                               datadir=$withval
511                           fi
512                         ]
513 )
514 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
515
516 dnl Checks where to put our editor
517 AC_ARG_WITH(editordir, 
518                     [  --with-editordir             directory to put our editor],
519                         [ if test "x$withval" != "xno" ; then
520                                 editordir=$withval
521                           fi
522                         ]
523 )
524 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
525
526 abs_srcdir="`cd $srcdir && pwd`"
527 abs_builddir="`pwd`"
528 if test "$abs_srcdir" != "$abs_builddir"; then
529    CFLAGS="$CFLAGS -I $abs_builddir"
530 fi
531 AC_CONFIG_HEADER(sysdep.h)
532 AC_OUTPUT(Makefile po/webcit/Makefile tests/Makefile)
533
534 if test "$abs_srcdir" != "$abs_builddir"; then
535    ln -s $abs_srcdir/static $abs_builddir
536    ln -s $abs_srcdir/tiny_mce $abs_builddir
537    ln -s $abs_srcdir/*.h $abs_builddir
538    make mkdir-init
539    
540 else
541 dnl just run it on devel systems and if non vdir build.
542    if test -d .svn; then
543       ./mk_module_init.sh
544    fi
545 fi
546
547 if test -n "$srcdir"; then 
548    export srcdir=.
549 fi
550
551
552 echo ------------------------------------------------------------------------
553 echo 'Character set conversion support:' $ok_iconv
554 echo 'National language support:       ' $ok_nls
555 echo